platform_def.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  1. /*
  2. * Copyright (c) 2019-2024, Arm Limited. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef PLATFORM_DEF_H
  7. #define PLATFORM_DEF_H
  8. #include <common/tbbr/tbbr_img_def.h>
  9. #include <lib/utils_def.h>
  10. #include <lib/xlat_tables/xlat_tables_defs.h>
  11. #include <plat/arm/board/common/v2m_def.h>
  12. #include <plat/arm/common/smccc_def.h>
  13. #include <plat/common/common_def.h>
  14. /* Memory location options for TSP */
  15. #define ARM_DRAM_ID 2
  16. #define ARM_DRAM1_BASE UL(0x80000000)
  17. #define ARM_DRAM1_SIZE UL(0x80000000)
  18. #define ARM_DRAM1_END (ARM_DRAM1_BASE + \
  19. ARM_DRAM1_SIZE - 1)
  20. #define SRAM_BASE 0x2000000
  21. #define SRAM_SIZE 0x200000
  22. /* The first 4KB of NS DRAM1 are used as shared memory */
  23. #define A5DS_SHARED_RAM_BASE SRAM_BASE
  24. #define A5DS_SHARED_RAM_SIZE UL(0x00001000) /* 4 KB */
  25. /* The next 252 kB of NS DRAM is used to load the BL images */
  26. #define ARM_BL_RAM_BASE (A5DS_SHARED_RAM_BASE + \
  27. A5DS_SHARED_RAM_SIZE)
  28. #define ARM_BL_RAM_SIZE (PLAT_ARM_BL_PLUS_SHARED_RAM_SIZE - \
  29. A5DS_SHARED_RAM_SIZE)
  30. #define PERIPHBASE 0x1a000000
  31. #define PERIPH_SIZE 0x00240000
  32. #define A5_PERIPHERALS_BASE 0x1c000000
  33. #define A5_PERIPHERALS_SIZE 0x10000
  34. #define ARM_CACHE_WRITEBACK_SHIFT 5
  35. #define ARM_IRQ_SEC_PHY_TIMER 29
  36. #define ARM_IRQ_SEC_SGI_0 8
  37. #define ARM_IRQ_SEC_SGI_1 9
  38. #define ARM_IRQ_SEC_SGI_2 10
  39. #define ARM_IRQ_SEC_SGI_3 11
  40. #define ARM_IRQ_SEC_SGI_4 12
  41. #define ARM_IRQ_SEC_SGI_5 13
  42. #define ARM_IRQ_SEC_SGI_6 14
  43. #define ARM_IRQ_SEC_SGI_7 15
  44. /*
  45. * Define a list of Group 1 Secure and Group 0 interrupt properties as per GICv3
  46. * terminology. On a GICv2 system or mode, the lists will be merged and treated
  47. * as Group 0 interrupts.
  48. */
  49. #define ARM_G1S_IRQ_PROPS(grp) \
  50. INTR_PROP_DESC(ARM_IRQ_SEC_PHY_TIMER, GIC_HIGHEST_SEC_PRIORITY, (grp), \
  51. GIC_INTR_CFG_LEVEL), \
  52. INTR_PROP_DESC(ARM_IRQ_SEC_SGI_1, GIC_HIGHEST_SEC_PRIORITY, (grp), \
  53. GIC_INTR_CFG_EDGE), \
  54. INTR_PROP_DESC(ARM_IRQ_SEC_SGI_2, GIC_HIGHEST_SEC_PRIORITY, (grp), \
  55. GIC_INTR_CFG_EDGE), \
  56. INTR_PROP_DESC(ARM_IRQ_SEC_SGI_3, GIC_HIGHEST_SEC_PRIORITY, (grp), \
  57. GIC_INTR_CFG_EDGE), \
  58. INTR_PROP_DESC(ARM_IRQ_SEC_SGI_4, GIC_HIGHEST_SEC_PRIORITY, (grp), \
  59. GIC_INTR_CFG_EDGE), \
  60. INTR_PROP_DESC(ARM_IRQ_SEC_SGI_5, GIC_HIGHEST_SEC_PRIORITY, (grp), \
  61. GIC_INTR_CFG_EDGE), \
  62. INTR_PROP_DESC(ARM_IRQ_SEC_SGI_7, GIC_HIGHEST_SEC_PRIORITY, (grp), \
  63. GIC_INTR_CFG_EDGE)
  64. #define ARM_G0_IRQ_PROPS(grp) \
  65. INTR_PROP_DESC(ARM_IRQ_SEC_SGI_6, GIC_HIGHEST_SEC_PRIORITY, (grp), \
  66. GIC_INTR_CFG_EDGE)
  67. #define A5DS_IRQ_TZ_WDOG 56
  68. #define A5DS_IRQ_SEC_SYS_TIMER 57
  69. /* Default cluster count for A5DS */
  70. #define A5DS_CLUSTER_COUNT U(1)
  71. /* Default number of CPUs per cluster on A5DS */
  72. #define A5DS_MAX_CPUS_PER_CLUSTER U(4)
  73. /* Default number of threads per CPU on A5DS */
  74. #define A5DS_MAX_PE_PER_CPU U(1)
  75. #define A5DS_CORE_COUNT U(4)
  76. #define A5DS_PRIMARY_CPU 0x0
  77. #define BOOT_BASE ARM_DRAM1_BASE
  78. #define BOOT_SIZE UL(0x2800000)
  79. #define ARM_NS_DRAM1_BASE (ARM_DRAM1_BASE + BOOT_SIZE)
  80. /*
  81. * The last 2MB is meant to be NOLOAD and will not be zero
  82. * initialized.
  83. */
  84. #define ARM_NS_DRAM1_SIZE (ARM_DRAM1_SIZE - \
  85. BOOT_SIZE - \
  86. 0x00200000)
  87. #define MAP_BOOT_RW MAP_REGION_FLAT( \
  88. BOOT_BASE, \
  89. BOOT_SIZE, \
  90. MT_DEVICE | MT_RW | MT_SECURE)
  91. #define ARM_MAP_SHARED_RAM MAP_REGION_FLAT( \
  92. A5DS_SHARED_RAM_BASE, \
  93. A5DS_SHARED_RAM_SIZE, \
  94. MT_MEMORY | MT_RW | MT_SECURE)
  95. #define ARM_MAP_NS_DRAM1 MAP_REGION_FLAT( \
  96. ARM_NS_DRAM1_BASE, \
  97. ARM_NS_DRAM1_SIZE, \
  98. MT_MEMORY | MT_RW | MT_NS)
  99. #define ARM_MAP_SRAM MAP_REGION_FLAT( \
  100. SRAM_BASE, \
  101. SRAM_SIZE, \
  102. MT_MEMORY | MT_RW | MT_NS)
  103. /*
  104. * Mapping for the BL1 RW region. This mapping is needed by BL2 in order to
  105. * share the Mbed TLS heap. Since the heap is allocated inside BL1, it resides
  106. * in the BL1 RW region. Hence, BL2 needs access to the BL1 RW region in order
  107. * to be able to access the heap.
  108. */
  109. #define ARM_MAP_BL_RO MAP_REGION_FLAT(\
  110. BL_CODE_BASE,\
  111. BL_CODE_END - BL_CODE_BASE,\
  112. MT_CODE | MT_SECURE),\
  113. MAP_REGION_FLAT(\
  114. BL_RO_DATA_BASE,\
  115. BL_RO_DATA_END\
  116. - BL_RO_DATA_BASE, \
  117. MT_RO_DATA | MT_SECURE)
  118. #if USE_COHERENT_MEM
  119. #define ARM_MAP_BL_COHERENT_RAM MAP_REGION_FLAT(\
  120. BL_COHERENT_RAM_BASE,\
  121. BL_COHERENT_RAM_END \
  122. - BL_COHERENT_RAM_BASE, \
  123. MT_DEVICE | MT_RW | MT_SECURE)
  124. #endif
  125. /*
  126. * Map the region for device tree configuration with read and write permissions
  127. */
  128. #define ARM_MAP_BL_CONFIG_REGION MAP_REGION_FLAT(ARM_BL_RAM_BASE, \
  129. (ARM_FW_CONFIGS_LIMIT \
  130. - ARM_BL_RAM_BASE), \
  131. MT_MEMORY | MT_RW | MT_SECURE)
  132. /*
  133. * The max number of regions like RO(code), coherent and data required by
  134. * different BL stages which need to be mapped in the MMU.
  135. */
  136. #define ARM_BL_REGIONS 6
  137. #define MAX_MMAP_REGIONS (PLAT_ARM_MMAP_ENTRIES + \
  138. ARM_BL_REGIONS)
  139. /* Memory mapped Generic timer interfaces */
  140. #define A5DS_TIMER_BASE_FREQUENCY UL(7500000)
  141. #define ARM_CONSOLE_BAUDRATE 115200
  142. #define PLAT_PHY_ADDR_SPACE_SIZE (1ULL << 32)
  143. #define PLAT_VIRT_ADDR_SPACE_SIZE (1ULL << 32)
  144. /*
  145. * This macro defines the deepest retention state possible. A higher state
  146. * id will represent an invalid or a power down state.
  147. */
  148. #define PLAT_MAX_RET_STATE 1
  149. /*
  150. * This macro defines the deepest power down states possible. Any state ID
  151. * higher than this is invalid.
  152. */
  153. #define PLAT_MAX_OFF_STATE 2
  154. /*
  155. * Some data must be aligned on the biggest cache line size in the platform.
  156. * This is known only to the platform as it might have a combination of
  157. * integrated and external caches.
  158. */
  159. #define CACHE_WRITEBACK_GRANULE (U(1) << ARM_CACHE_WRITEBACK_SHIFT)
  160. /*
  161. * To enable FW_CONFIG to be loaded by BL1, define the corresponding base
  162. * and limit. Leave enough space of BL2 meminfo.
  163. */
  164. #define ARM_FW_CONFIG_BASE (ARM_BL_RAM_BASE + sizeof(meminfo_t))
  165. #define ARM_FW_CONFIG_LIMIT (ARM_BL_RAM_BASE + PAGE_SIZE)
  166. /*
  167. * Define limit of firmware configuration memory:
  168. * ARM_FW_CONFIG + ARM_BL2_MEM_DESC memory
  169. */
  170. #define ARM_FW_CONFIGS_LIMIT (ARM_BL_RAM_BASE + (PAGE_SIZE * 2))
  171. /* Define memory configuration for device tree files. */
  172. #define PLAT_ARM_HW_CONFIG_SIZE U(0x01000000)
  173. /*******************************************************************************
  174. * BL1 specific defines.
  175. * BL1 RW data is relocated from ROM to RAM at runtime so we need 2 sets of
  176. * addresses.
  177. ******************************************************************************/
  178. #define BL1_RO_BASE 0x00000000
  179. #define BL1_RO_LIMIT PLAT_ARM_TRUSTED_ROM_SIZE
  180. /*
  181. * Put BL1 RW at the top of the memory allocated for BL images in NS DRAM.
  182. */
  183. #define BL1_RW_BASE (ARM_BL_RAM_BASE + \
  184. ARM_BL_RAM_SIZE - \
  185. (PLAT_ARM_MAX_BL1_RW_SIZE))
  186. #define BL1_RW_LIMIT (ARM_BL_RAM_BASE + \
  187. (ARM_BL_RAM_SIZE))
  188. /*******************************************************************************
  189. * BL2 specific defines.
  190. ******************************************************************************/
  191. /*
  192. * Put BL2 just below BL1.
  193. */
  194. #define BL2_BASE (BL1_RW_BASE - A5DS_MAX_BL2_SIZE)
  195. #define BL2_LIMIT BL1_RW_BASE
  196. /* Put BL32 below BL2 in NS DRAM.*/
  197. #define ARM_BL2_MEM_DESC_BASE ARM_FW_CONFIG_LIMIT
  198. #define ARM_BL2_MEM_DESC_LIMIT (ARM_BL2_MEM_DESC_BASE \
  199. + (PAGE_SIZE / 2U))
  200. #define BL32_BASE ((ARM_BL_RAM_BASE + ARM_BL_RAM_SIZE)\
  201. - PLAT_ARM_MAX_BL32_SIZE)
  202. #define BL32_PROGBITS_LIMIT BL2_BASE
  203. #define BL32_LIMIT (ARM_BL_RAM_BASE + ARM_BL_RAM_SIZE)
  204. /* Required platform porting definitions */
  205. #define PLATFORM_CORE_COUNT A5DS_CORE_COUNT
  206. #define PLAT_NUM_PWR_DOMAINS (A5DS_CLUSTER_COUNT + \
  207. PLATFORM_CORE_COUNT) + U(1)
  208. #define PLAT_MAX_PWR_LVL 2
  209. /*
  210. * Other platform porting definitions are provided by included headers
  211. */
  212. /*
  213. * Required ARM standard platform porting definitions
  214. */
  215. #define PLAT_ARM_BL_PLUS_SHARED_RAM_SIZE 0x00040000 /* 256 KB */
  216. #define PLAT_ARM_TRUSTED_ROM_BASE 0x00000000
  217. #define PLAT_ARM_TRUSTED_ROM_SIZE 0x10000 /* 64KB */
  218. #define PLAT_ARM_DRAM2_SIZE ULL(0x80000000)
  219. /*
  220. * Load address of BL33 for this platform port
  221. */
  222. #define PLAT_ARM_NS_IMAGE_BASE (ARM_DRAM1_BASE + U(0x8000000))
  223. /*
  224. * PLAT_ARM_MMAP_ENTRIES depends on the number of entries in the
  225. * plat_arm_mmap array defined for each BL stage.
  226. */
  227. #if defined(IMAGE_BL32)
  228. # define PLAT_ARM_MMAP_ENTRIES 8
  229. # define MAX_XLAT_TABLES 6
  230. #else
  231. # define PLAT_ARM_MMAP_ENTRIES 12
  232. # define MAX_XLAT_TABLES 6
  233. #endif
  234. /*
  235. * PLAT_ARM_MAX_BL1_RW_SIZE is calculated using the current BL1 RW debug size
  236. * plus a little space for growth.
  237. */
  238. #define PLAT_ARM_MAX_BL1_RW_SIZE 0xB000
  239. /*
  240. * A5DS_MAX_BL2_SIZE is calculated using the current BL2 debug size plus a
  241. * little space for growth.
  242. */
  243. #define A5DS_MAX_BL2_SIZE 0x11000
  244. /*
  245. * Since BL32 NOBITS overlays BL2 and BL1-RW, PLAT_ARM_MAX_BL32_SIZE is
  246. * calculated using the current SP_MIN PROGBITS debug size plus the sizes of
  247. * BL2 and BL1-RW
  248. */
  249. #define PLAT_ARM_MAX_BL32_SIZE 0x3B000
  250. /*
  251. * Size of cacheable stacks
  252. */
  253. #if defined(IMAGE_BL1)
  254. # define PLATFORM_STACK_SIZE 0x440
  255. #elif defined(IMAGE_BL2)
  256. # define PLATFORM_STACK_SIZE 0x400
  257. #elif defined(IMAGE_BL32)
  258. # define PLATFORM_STACK_SIZE 0x440
  259. #endif
  260. #define MAX_IO_DEVICES 3
  261. #define MAX_IO_HANDLES 4
  262. /* Reserve the last block of flash for PSCI MEM PROTECT flag */
  263. #define PLAT_ARM_FLASH_IMAGE_BASE BOOT_BASE
  264. #define PLAT_ARM_FLASH_IMAGE_MAX_SIZE (BOOT_SIZE - V2M_FLASH_BLOCK_SIZE)
  265. #define PLAT_ARM_NVM_BASE BOOT_BASE
  266. #define PLAT_ARM_NVM_SIZE (BOOT_SIZE - V2M_FLASH_BLOCK_SIZE)
  267. /*
  268. * PL011 related constants
  269. */
  270. #define PLAT_ARM_BOOT_UART_BASE 0x1A200000
  271. #define PLAT_ARM_BOOT_UART_CLK_IN_HZ UL(7500000)
  272. #define PLAT_ARM_RUN_UART_BASE 0x1A210000
  273. #define PLAT_ARM_RUN_UART_CLK_IN_HZ UL(7500000)
  274. #define PLAT_ARM_CRASH_UART_BASE PLAT_ARM_RUN_UART_BASE
  275. #define PLAT_ARM_CRASH_UART_CLK_IN_HZ PLAT_ARM_RUN_UART_CLK_IN_HZ
  276. #define A5DS_TIMER_BASE_FREQUENCY UL(7500000)
  277. /* System timer related constants */
  278. #define PLAT_ARM_NSTIMER_FRAME_ID 1
  279. /* Mailbox base address */
  280. #define A5DS_TRUSTED_MAILBOX_BASE A5DS_SHARED_RAM_BASE
  281. #define A5DS_TRUSTED_MAILBOX_SIZE (8 + A5DS_HOLD_SIZE)
  282. #define A5DS_HOLD_BASE (A5DS_TRUSTED_MAILBOX_BASE + 8)
  283. #define A5DS_HOLD_SIZE (PLATFORM_CORE_COUNT * \
  284. A5DS_HOLD_ENTRY_SIZE)
  285. #define A5DS_HOLD_ENTRY_SHIFT 3
  286. #define A5DS_HOLD_ENTRY_SIZE (1 << A5DS_HOLD_ENTRY_SHIFT)
  287. #define A5DS_HOLD_STATE_WAIT 0
  288. #define A5DS_HOLD_STATE_GO 1
  289. /* Snoop Control Unit base address */
  290. #define A5DS_SCU_BASE 0x1C000000
  291. /*
  292. * GIC related constants to cater for GICv2
  293. */
  294. #define PLAT_ARM_GICD_BASE 0x1C001000
  295. #define PLAT_ARM_GICC_BASE 0x1C000100
  296. /*
  297. * Define a list of Group 1 Secure and Group 0 interrupts as per GICv3
  298. * terminology. On a GICv2 system or mode, the lists will be merged and treated
  299. * as Group 0 interrupts.
  300. */
  301. #define PLAT_ARM_G1S_IRQ_PROPS(grp) \
  302. ARM_G1S_IRQ_PROPS(grp), \
  303. INTR_PROP_DESC(A5DS_IRQ_TZ_WDOG, GIC_HIGHEST_SEC_PRIORITY, (grp), \
  304. GIC_INTR_CFG_LEVEL), \
  305. INTR_PROP_DESC(A5DS_IRQ_SEC_SYS_TIMER,\
  306. GIC_HIGHEST_SEC_PRIORITY, (grp), \
  307. GIC_INTR_CFG_LEVEL)
  308. #define PLAT_ARM_G0_IRQ_PROPS(grp) ARM_G0_IRQ_PROPS(grp)
  309. #endif /* PLATFORM_DEF_H */