platform_def.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. /*
  2. * Copyright (c) 2015-2020, Broadcom
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef PLATFORM_DEF_H
  7. #define PLATFORM_DEF_H
  8. #include <arch.h>
  9. #include <common/tbbr/tbbr_img_def.h>
  10. #include <plat/common/common_def.h>
  11. #include <brcm_def.h>
  12. #include "sr_def.h"
  13. #include <cmn_plat_def.h>
  14. /*
  15. * Most platform porting definitions provided by included headers
  16. */
  17. #define PLAT_BRCM_SCP_TZC_DRAM1_SIZE ULL(0x0)
  18. /*
  19. * Required by standard platform porting definitions
  20. */
  21. #define PLATFORM_CLUSTER0_CORE_COUNT 2
  22. #define PLATFORM_CLUSTER1_CORE_COUNT 2
  23. #define PLATFORM_CLUSTER2_CORE_COUNT 2
  24. #define PLATFORM_CLUSTER3_CORE_COUNT 2
  25. #define BRCM_SYSTEM_COUNT 1
  26. #define BRCM_CLUSTER_COUNT 4
  27. #define PLATFORM_CORE_COUNT (PLATFORM_CLUSTER0_CORE_COUNT + \
  28. PLATFORM_CLUSTER1_CORE_COUNT+ \
  29. PLATFORM_CLUSTER2_CORE_COUNT+ \
  30. PLATFORM_CLUSTER3_CORE_COUNT)
  31. #define PLAT_NUM_PWR_DOMAINS (BRCM_SYSTEM_COUNT + \
  32. BRCM_CLUSTER_COUNT + \
  33. PLATFORM_CORE_COUNT)
  34. #define PLAT_MAX_PWR_LVL MPIDR_AFFLVL2
  35. /* TBD-STINGRAY */
  36. #define CACHE_WRITEBACK_SHIFT 6
  37. /*
  38. * Some data must be aligned on the biggest cache line size in the platform.
  39. * This is known only to the platform as it might have a combination of
  40. * integrated and external caches.
  41. */
  42. #define CACHE_WRITEBACK_GRANULE (1 << CACHE_WRITEBACK_SHIFT)
  43. /* TBD-STINGRAY */
  44. #define PLATFORM_MAX_AFFLVL MPIDR_AFFLVL1
  45. #define BL1_PLATFORM_STACK_SIZE 0x3300
  46. #define BL2_PLATFORM_STACK_SIZE 0xc000
  47. #define BL11_PLATFORM_STACK_SIZE 0x2b00
  48. #define DEFAULT_PLATFORM_STACK_SIZE 0x400
  49. #if IMAGE_BL1
  50. # define PLATFORM_STACK_SIZE BL1_PLATFORM_STACK_SIZE
  51. #else
  52. #if IMAGE_BL2
  53. #ifdef USE_BL1_RW
  54. # define PLATFORM_STACK_SIZE BL2_PLATFORM_STACK_SIZE
  55. #else
  56. # define PLATFORM_STACK_SIZE BL1_PLATFORM_STACK_SIZE
  57. #endif
  58. #else
  59. #if IMAGE_BL11
  60. # define PLATFORM_STACK_SIZE BL11_PLATFORM_STACK_SIZE
  61. #else
  62. # define PLATFORM_STACK_SIZE DEFAULT_PLATFORM_STACK_SIZE
  63. #endif
  64. #endif
  65. #endif
  66. #define PLAT_BRCM_TRUSTED_SRAM_BASE 0x66D00000
  67. #define PLAT_BRCM_TRUSTED_SRAM_SIZE 0x00040000
  68. #ifdef RUN_BL1_FROM_QSPI /* BL1 XIP from QSPI */
  69. # define PLAT_BRCM_TRUSTED_ROM_BASE QSPI_BASE_ADDR
  70. #elif RUN_BL1_FROM_NAND /* BL1 XIP from NAND */
  71. # define PLAT_BRCM_TRUSTED_ROM_BASE NAND_BASE_ADDR
  72. #else /* BL1 executed in ROM */
  73. # define PLAT_BRCM_TRUSTED_ROM_BASE ROM_BASE_ADDR
  74. #endif
  75. #define PLAT_BRCM_TRUSTED_ROM_SIZE 0x00040000
  76. /*******************************************************************************
  77. * BL1 specific defines.
  78. ******************************************************************************/
  79. #define BL1_RO_BASE PLAT_BRCM_TRUSTED_ROM_BASE
  80. #define BL1_RO_LIMIT (PLAT_BRCM_TRUSTED_ROM_BASE \
  81. + PLAT_BRCM_TRUSTED_ROM_SIZE)
  82. /*
  83. * Put BL1 RW at the beginning of the Trusted SRAM.
  84. */
  85. #define BL1_RW_BASE (BRCM_BL_RAM_BASE)
  86. #define BL1_RW_LIMIT (BL1_RW_BASE + 0x12000)
  87. #define BL11_RW_BASE BL1_RW_LIMIT
  88. #define BL11_RW_LIMIT (PLAT_BRCM_TRUSTED_SRAM_BASE + \
  89. PLAT_BRCM_TRUSTED_SRAM_SIZE)
  90. /*******************************************************************************
  91. * BL2 specific defines.
  92. ******************************************************************************/
  93. #if RUN_BL2_FROM_QSPI /* BL2 XIP from QSPI */
  94. #define BL2_BASE QSPI_BASE_ADDR
  95. #define BL2_LIMIT (BL2_BASE + 0x40000)
  96. #define BL2_RW_BASE BL1_RW_LIMIT
  97. #define BL2_RW_LIMIT (PLAT_BRCM_TRUSTED_SRAM_BASE + \
  98. PLAT_BRCM_TRUSTED_SRAM_SIZE)
  99. #elif RUN_BL2_FROM_NAND /* BL2 XIP from NAND */
  100. #define BL2_BASE NAND_BASE_ADDR
  101. #define BL2_LIMIT (BL2_BASE + 0x40000)
  102. #define BL2_RW_BASE BL1_RW_LIMIT
  103. #define BL2_RW_LIMIT (PLAT_BRCM_TRUSTED_SRAM_BASE + \
  104. PLAT_BRCM_TRUSTED_SRAM_SIZE)
  105. #else
  106. #define BL2_BASE (BL1_RW_LIMIT + PAGE_SIZE)
  107. #define BL2_LIMIT (BRCM_BL_RAM_BASE + BRCM_BL_RAM_SIZE)
  108. #endif
  109. /*
  110. * BL1 persistent area in internal SRAM
  111. * This area will increase as more features gets into BL1
  112. */
  113. #define BL1_PERSISTENT_DATA_SIZE 0x2000
  114. /* To reduce BL2 runtime footprint, we can re-use some BL1_RW area */
  115. #define BL1_RW_RECLAIM_BASE (PLAT_BRCM_TRUSTED_SRAM_BASE + \
  116. BL1_PERSISTENT_DATA_SIZE)
  117. /*******************************************************************************
  118. * BL3-1 specific defines.
  119. ******************************************************************************/
  120. /* Max Size of BL31 (in DRAM) */
  121. #define PLAT_BRCM_MAX_BL31_SIZE 0x30000
  122. #ifdef USE_DDR
  123. #define BL31_BASE BRCM_AP_TZC_DRAM1_BASE
  124. #define BL31_LIMIT (BRCM_AP_TZC_DRAM1_BASE + \
  125. PLAT_BRCM_MAX_BL31_SIZE)
  126. #else
  127. /* Put BL3-1 at the end of external on-board SRAM connected as NOR flash */
  128. #define BL31_BASE (NOR_BASE_ADDR + NOR_SIZE - \
  129. PLAT_BRCM_MAX_BL31_SIZE)
  130. #define BL31_LIMIT (NOR_BASE_ADDR + NOR_SIZE)
  131. #endif
  132. #define SECURE_DDR_END_ADDRESS BL31_LIMIT
  133. #ifdef NEED_SCP_BL2
  134. #define SCP_BL2_BASE BL31_BASE
  135. #define PLAT_MAX_SCP_BL2_SIZE 0x9000
  136. #define PLAT_SCP_COM_SHARED_MEM_BASE (CRMU_SHARED_SRAM_BASE)
  137. /* dummy defined */
  138. #define PLAT_BRCM_MHU_BASE 0x0
  139. #endif
  140. #define SECONDARY_CPU_SPIN_BASE_ADDR BRCM_SHARED_RAM_BASE
  141. /* Generic system timer counter frequency */
  142. #ifndef SYSCNT_FREQ
  143. #define SYSCNT_FREQ (125 * 1000 * 1000)
  144. #endif
  145. /*
  146. * Enable the BL32 definitions, only when optee os is selected as secure
  147. * payload (BL32).
  148. */
  149. #ifdef SPD_opteed
  150. /*
  151. * Reserved Memory Map : SHMEM & TZDRAM.
  152. *
  153. * +--------+----------+ 0x8D000000
  154. * | SHMEM (NS) | 16MB
  155. * +-------------------+ 0x8E000000
  156. * | | TEE_RAM(S)| 4MB
  157. * + TZDRAM +----------+ 0x8E400000
  158. * | | TA_RAM(S) | 12MB
  159. * +-------------------+ 0x8F000000
  160. * | BL31 Binary (S) | 192KB
  161. * +-------------------+ 0x8F030000
  162. */
  163. #define BL32_VA_SIZE (4 * 1024 * 1024)
  164. #define BL32_BASE (0x8E000000)
  165. #define BL32_LIMIT (BL32_BASE + BL32_VA_SIZE)
  166. #define TSP_SEC_MEM_BASE BL32_BASE
  167. #define TSP_SEC_MEM_SIZE BL32_VA_SIZE
  168. #endif
  169. #ifdef SPD_opteed
  170. #define SECURE_DDR_BASE_ADDRESS BL32_BASE
  171. #else
  172. #define SECURE_DDR_BASE_ADDRESS BL31_BASE
  173. #endif
  174. /*******************************************************************************
  175. * Platform specific page table and MMU setup constants
  176. ******************************************************************************/
  177. #define MAX_XLAT_TABLES 7
  178. #define PLAT_BRCM_MMAP_ENTRIES 10
  179. #define MAX_MMAP_REGIONS (PLAT_BRCM_MMAP_ENTRIES + \
  180. BRCM_BL_REGIONS)
  181. #ifdef USE_DDR
  182. #ifdef BL33_OVERRIDE_LOAD_ADDR
  183. #define PLAT_BRCM_NS_IMAGE_OFFSET BL33_OVERRIDE_LOAD_ADDR
  184. #else
  185. /*
  186. * BL3-3 image starting offset.
  187. * Putting start of DRAM as of now.
  188. */
  189. #define PLAT_BRCM_NS_IMAGE_OFFSET 0x80000000
  190. #endif /* BL33_OVERRIDE_LOAD_ADDR */
  191. #else
  192. /*
  193. * BL3-3 image starting offset.
  194. * Putting start of external on-board SRAM as of now.
  195. */
  196. #define PLAT_BRCM_NS_IMAGE_OFFSET NOR_BASE_ADDR
  197. #endif /* USE_DDR */
  198. /******************************************************************************
  199. * Required platform porting definitions common to all BRCM platforms
  200. *****************************************************************************/
  201. #define MAX_IO_DEVICES 5
  202. #define MAX_IO_HANDLES 6
  203. #define PRIMARY_CPU 0
  204. /* GIC Parameter */
  205. #define PLAT_BRCM_GICD_BASE GIC500_BASE
  206. #define PLAT_BRCM_GICR_BASE (GIC500_BASE + 0x200000)
  207. /* Define secure interrupt as per Group here */
  208. #define PLAT_BRCM_G1S_IRQ_PROPS(grp) \
  209. INTR_PROP_DESC(BRCM_IRQ_SEC_SGI_1, GIC_HIGHEST_SEC_PRIORITY, (grp), \
  210. GIC_INTR_CFG_EDGE), \
  211. INTR_PROP_DESC(BRCM_IRQ_SEC_SPI_0, GIC_HIGHEST_SEC_PRIORITY, (grp), \
  212. GIC_INTR_CFG_EDGE)
  213. #define PLAT_BRCM_G0_IRQ_PROPS(grp) \
  214. INTR_PROP_DESC(BRCM_IRQ_SEC_SGI_0, PLAT_SDEI_NORMAL_PRI, (grp), \
  215. GIC_INTR_CFG_EDGE), \
  216. /*
  217. *CCN 502 related constants.
  218. */
  219. #define PLAT_BRCM_CLUSTER_COUNT 4 /* Number of RN-F Masters */
  220. #define PLAT_BRCM_CLUSTER_TO_CCN_ID_MAP CLUSTER0_NODE_ID, CLUSTER1_NODE_ID, CLUSTER2_NODE_ID, CLUSTER3_NODE_ID
  221. #define CCN_SIZE 0x1000000
  222. #define CLUSTER0_NODE_ID 1
  223. #define CLUSTER1_NODE_ID 7
  224. #define CLUSTER2_NODE_ID 9
  225. #define CLUSTER3_NODE_ID 15
  226. #endif