platform_def.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*
  2. * Copyright (c) 2015-2024, Arm Limited and Contributors. All rights reserved.
  3. * Copyright (c) 2024, Mario Bălănică <mariobalanica02@gmail.com>
  4. *
  5. * SPDX-License-Identifier: BSD-3-Clause
  6. */
  7. #ifndef PLATFORM_DEF_H
  8. #define PLATFORM_DEF_H
  9. #include <arch.h>
  10. #include <common/tbbr/tbbr_img_def.h>
  11. #include <lib/utils_def.h>
  12. #include <plat/common/common_def.h>
  13. #include "rpi_hw.h"
  14. /* Special value used to verify platform parameters from BL2 to BL31 */
  15. #define RPI3_BL31_PLAT_PARAM_VAL ULL(0x0F1E2D3C4B5A6978)
  16. #define PLATFORM_STACK_SIZE ULL(0x1000)
  17. #define PLATFORM_MAX_CPUS_PER_CLUSTER U(4)
  18. #define PLATFORM_CLUSTER_COUNT U(1)
  19. #define PLATFORM_CLUSTER0_CORE_COUNT PLATFORM_MAX_CPUS_PER_CLUSTER
  20. #define PLATFORM_CORE_COUNT PLATFORM_CLUSTER0_CORE_COUNT
  21. #define RPI_PRIMARY_CPU U(0)
  22. #define PLAT_MAX_PWR_LVL MPIDR_AFFLVL1
  23. #define PLAT_NUM_PWR_DOMAINS (PLATFORM_CLUSTER_COUNT + \
  24. PLATFORM_CORE_COUNT)
  25. #define PLAT_MAX_RET_STATE U(1)
  26. #define PLAT_MAX_OFF_STATE U(2)
  27. /* Local power state for power domains in Run state. */
  28. #define PLAT_LOCAL_STATE_RUN U(0)
  29. /* Local power state for retention. Valid only for CPU power domains */
  30. #define PLAT_LOCAL_STATE_RET U(1)
  31. /*
  32. * Local power state for OFF/power-down. Valid for CPU and cluster power
  33. * domains.
  34. */
  35. #define PLAT_LOCAL_STATE_OFF U(2)
  36. /*
  37. * Macros used to parse state information from State-ID if it is using the
  38. * recommended encoding for State-ID.
  39. */
  40. #define PLAT_LOCAL_PSTATE_WIDTH U(4)
  41. #define PLAT_LOCAL_PSTATE_MASK ((U(1) << PLAT_LOCAL_PSTATE_WIDTH) - 1)
  42. /*
  43. * Some data must be aligned on the biggest cache line size in the platform.
  44. * This is known only to the platform as it might have a combination of
  45. * integrated and external caches.
  46. */
  47. #define CACHE_WRITEBACK_SHIFT U(6)
  48. #define CACHE_WRITEBACK_GRANULE (U(1) << CACHE_WRITEBACK_SHIFT)
  49. /*
  50. * I/O registers.
  51. */
  52. #define DEVICE0_BASE RPI_IO_BASE
  53. #define DEVICE0_SIZE RPI_IO_SIZE
  54. /*
  55. * Mailbox to control the secondary cores. All secondary cores are held in a
  56. * wait loop in cold boot. To release them perform the following steps (plus
  57. * any additional barriers that may be needed):
  58. *
  59. * uint64_t *entrypoint = (uint64_t *)PLAT_RPI3_TM_ENTRYPOINT;
  60. * *entrypoint = ADDRESS_TO_JUMP_TO;
  61. *
  62. * uint64_t *mbox_entry = (uint64_t *)PLAT_RPI3_TM_HOLD_BASE;
  63. * mbox_entry[cpu_id] = PLAT_RPI3_TM_HOLD_STATE_GO;
  64. *
  65. * sev();
  66. */
  67. /* The secure entry point to be used on warm reset by all CPUs. */
  68. #define PLAT_RPI3_TM_ENTRYPOINT 0x100
  69. #define PLAT_RPI3_TM_ENTRYPOINT_SIZE ULL(8)
  70. /* Hold entries for each CPU. */
  71. #define PLAT_RPI3_TM_HOLD_BASE (PLAT_RPI3_TM_ENTRYPOINT + \
  72. PLAT_RPI3_TM_ENTRYPOINT_SIZE)
  73. #define PLAT_RPI3_TM_HOLD_ENTRY_SIZE ULL(8)
  74. #define PLAT_RPI3_TM_HOLD_SIZE (PLAT_RPI3_TM_HOLD_ENTRY_SIZE * \
  75. PLATFORM_CORE_COUNT)
  76. #define PLAT_RPI3_TRUSTED_MAILBOX_SIZE (PLAT_RPI3_TM_ENTRYPOINT_SIZE + \
  77. PLAT_RPI3_TM_HOLD_SIZE)
  78. #define PLAT_RPI3_TM_HOLD_STATE_WAIT ULL(0)
  79. #define PLAT_RPI3_TM_HOLD_STATE_GO ULL(1)
  80. #define PLAT_RPI3_TM_HOLD_STATE_BSP_OFF ULL(2)
  81. /*
  82. * BL31 specific defines.
  83. *
  84. * Put BL31 at the top of the Trusted SRAM. BL31_BASE is calculated using the
  85. * current BL31 debug size plus a little space for growth.
  86. */
  87. #define PLAT_MAX_BL31_SIZE ULL(0x80000)
  88. #define BL31_BASE ULL(0x1000)
  89. #define BL31_LIMIT ULL(0x80000)
  90. #define BL31_PROGBITS_LIMIT ULL(0x80000)
  91. #define SEC_SRAM_ID 0
  92. #define SEC_DRAM_ID 1
  93. /*
  94. * Other memory-related defines.
  95. */
  96. #define PLAT_PHY_ADDR_SPACE_SIZE (ULL(1) << 40)
  97. #define PLAT_VIRT_ADDR_SPACE_SIZE (ULL(1) << 40)
  98. #define MAX_MMAP_REGIONS 8
  99. #define MAX_XLAT_TABLES 4
  100. #define MAX_IO_DEVICES U(3)
  101. #define MAX_IO_HANDLES U(4)
  102. #define MAX_IO_BLOCK_DEVICES U(1)
  103. /*
  104. * Serial-related constants.
  105. */
  106. #define PLAT_RPI_PL011_UART_BASE RPI4_PL011_UART_BASE
  107. #define PLAT_RPI_PL011_UART_CLOCK RPI4_PL011_UART_CLOCK
  108. #define PLAT_RPI_UART_BAUDRATE ULL(115200)
  109. #define PLAT_RPI_CRASH_UART_BASE PLAT_RPI_PL011_UART_BASE
  110. /*
  111. * System counter
  112. */
  113. #define SYS_COUNTER_FREQ_IN_TICKS ULL(54000000)
  114. #endif /* PLATFORM_DEF_H */