platform_def.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. /*
  2. * Copyright (C) 2016-2021 Marvell International Ltd.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. * https://spdx.org/licenses
  6. */
  7. #ifndef PLATFORM_DEF_H
  8. #define PLATFORM_DEF_H
  9. #ifndef __ASSEMBLER__
  10. #include <stdio.h>
  11. #endif /* __ASSEMBLER__ */
  12. #include <board_marvell_def.h>
  13. #include <mvebu_def.h>
  14. /*
  15. * Most platform porting definitions provided by included headers
  16. */
  17. /*
  18. * DRAM Memory layout:
  19. * +-----------------------+
  20. * : :
  21. * : Linux :
  22. * 0x04X00000-->+-----------------------+
  23. * | BL3-3(u-boot) |>>}>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  24. * |-----------------------| } |
  25. * | BL3-[0,1, 2] | }---------------------------------> |
  26. * |-----------------------| } || |
  27. * | BL2 | }->FIP (loaded by || |
  28. * |-----------------------| } BootROM to DRAM) || |
  29. * | FIP_TOC | } || |
  30. * 0x04120000-->|-----------------------| || |
  31. * | BL1 (RO) | || |
  32. * 0x04100000-->+-----------------------+ || |
  33. * : : || |
  34. * : Trusted SRAM section : \/ |
  35. * 0x04040000-->+-----------------------+ Replaced by BL2 +----------------+ |
  36. * | BL1 (RW) | <<<<<<<<<<<<<<<< | BL3-1 NOBITS | |
  37. * 0x04037000-->|-----------------------| <<<<<<<<<<<<<<<< |----------------| |
  38. * | | <<<<<<<<<<<<<<<< | BL3-1 PROGBITS | |
  39. * 0x04023000-->|-----------------------| +----------------+ |
  40. * | BL2 | |
  41. * |-----------------------| |
  42. * | | |
  43. * 0x04001000-->|-----------------------| |
  44. * | Shared | |
  45. * 0x04000000-->+-----------------------+ |
  46. * : : |
  47. * : Linux : |
  48. * : : |
  49. * |-----------------------| |
  50. * | | U-Boot(BL3-3) Loaded by BL2 |
  51. * | U-Boot | <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  52. * 0x00000000-->+-----------------------+
  53. *
  54. * Trusted SRAM section 0x4000000..0x4200000:
  55. * ----------------------------------------
  56. * SRAM_BASE = 0x4001000
  57. * BL2_BASE = 0x4006000
  58. * BL2_LIMIT = BL31_BASE
  59. * BL31_BASE = 0x4023000 = (64MB + 256KB - 0x1D000)
  60. * BL31_PROGBITS_LIMIT = BL1_RW_BASE
  61. * BL1_RW_BASE = 0x4037000 = (64MB + 256KB - 0x9000)
  62. * BL1_RW_LIMIT = BL31_LIMIT = 0x4040000
  63. *
  64. *
  65. * PLAT_MARVELL_FIP_BASE = 0x4120000
  66. */
  67. /*
  68. * Since BL33 is loaded by BL2 (and validated by BL31) to DRAM offset 0,
  69. * it is allowed to load/copy images to 'NULL' pointers
  70. */
  71. #if defined(IMAGE_BL2) || defined(IMAGE_BL31)
  72. #define PLAT_ALLOW_ZERO_ADDR_COPY
  73. #endif
  74. #define PLAT_MARVELL_ATF_BASE 0x4000000
  75. #define PLAT_MARVELL_ATF_LOAD_ADDR \
  76. (PLAT_MARVELL_ATF_BASE + 0x100000)
  77. #define PLAT_MARVELL_FIP_BASE \
  78. (PLAT_MARVELL_ATF_LOAD_ADDR + 0x20000)
  79. #define PLAT_MARVELL_FIP_MAX_SIZE 0x4000000
  80. #define PLAT_MARVELL_CLUSTER_CORE_COUNT U(2)
  81. /* DRAM[2MB..66MB] is used as Trusted ROM */
  82. #define PLAT_MARVELL_TRUSTED_ROM_BASE PLAT_MARVELL_ATF_LOAD_ADDR
  83. /* 4 MB for FIP image */
  84. #define PLAT_MARVELL_TRUSTED_ROM_SIZE 0x00400000
  85. /* Reserve 12M for SCP (Secure PayLoad) Trusted RAM
  86. * OP-TEE SHMEM follows this region
  87. */
  88. #define PLAT_MARVELL_TRUSTED_RAM_BASE 0x04400000
  89. #define PLAT_MARVELL_TRUSTED_RAM_SIZE 0x00C00000 /* 12 MB DRAM */
  90. /*
  91. * PLAT_ARM_MAX_BL1_RW_SIZE is calculated using the current BL1 RW debug size
  92. * plus a little space for growth.
  93. */
  94. #define PLAT_MARVELL_MAX_BL1_RW_SIZE 0xA000
  95. /*
  96. * PLAT_ARM_MAX_BL2_SIZE is calculated using the current BL2 debug size plus a
  97. * little space for growth.
  98. */
  99. #define PLAT_MARVELL_MAX_BL2_SIZE 0xF000
  100. /*
  101. * PLAT_ARM_MAX_BL31_SIZE is calculated using the current BL31 debug size plus a
  102. * little space for growth.
  103. */
  104. #define PLAT_MARVEL_MAX_BL31_SIZE 0x5D000
  105. #define PLAT_MARVELL_CPU_ENTRY_ADDR BL1_RO_BASE
  106. /* GIC related definitions */
  107. #define PLAT_MARVELL_GICD_BASE (MVEBU_REGS_BASE + MVEBU_GICD_BASE)
  108. #define PLAT_MARVELL_GICR_BASE (MVEBU_REGS_BASE + MVEBU_GICR_BASE)
  109. #define PLAT_MARVELL_GICC_BASE (MVEBU_REGS_BASE + MVEBU_GICC_BASE)
  110. #define PLAT_MARVELL_G0_IRQ_PROPS(grp) \
  111. INTR_PROP_DESC(MARVELL_IRQ_SEC_SGI_0, GIC_HIGHEST_SEC_PRIORITY, grp, \
  112. GIC_INTR_CFG_LEVEL), \
  113. INTR_PROP_DESC(MARVELL_IRQ_SEC_SGI_6, GIC_HIGHEST_SEC_PRIORITY, grp, \
  114. GIC_INTR_CFG_LEVEL)
  115. #define PLAT_MARVELL_G1S_IRQ_PROPS(grp) \
  116. INTR_PROP_DESC(MARVELL_IRQ_SEC_PHY_TIMER, \
  117. GIC_HIGHEST_SEC_PRIORITY, grp, GIC_INTR_CFG_LEVEL), \
  118. INTR_PROP_DESC(MARVELL_IRQ_SEC_SGI_1, GIC_HIGHEST_SEC_PRIORITY, grp, \
  119. GIC_INTR_CFG_LEVEL), \
  120. INTR_PROP_DESC(MARVELL_IRQ_SEC_SGI_2, GIC_HIGHEST_SEC_PRIORITY, grp, \
  121. GIC_INTR_CFG_LEVEL), \
  122. INTR_PROP_DESC(MARVELL_IRQ_SEC_SGI_3, GIC_HIGHEST_SEC_PRIORITY, grp, \
  123. GIC_INTR_CFG_LEVEL), \
  124. INTR_PROP_DESC(MARVELL_IRQ_SEC_SGI_4, GIC_HIGHEST_SEC_PRIORITY, grp, \
  125. GIC_INTR_CFG_LEVEL), \
  126. INTR_PROP_DESC(MARVELL_IRQ_SEC_SGI_5, GIC_HIGHEST_SEC_PRIORITY, grp, \
  127. GIC_INTR_CFG_LEVEL), \
  128. INTR_PROP_DESC(MARVELL_IRQ_SEC_SGI_7, GIC_HIGHEST_SEC_PRIORITY, grp, \
  129. GIC_INTR_CFG_LEVEL)
  130. #define PLAT_MARVELL_SHARED_RAM_CACHED 1
  131. /* CCI related constants */
  132. #define PLAT_MARVELL_CCI_BASE MVEBU_CCI_BASE
  133. #define PLAT_MARVELL_CCI_CLUSTER0_SL_IFACE_IX 3
  134. #define PLAT_MARVELL_CCI_CLUSTER1_SL_IFACE_IX 4
  135. /*
  136. * Load address of BL3-3 for this platform port
  137. */
  138. #define PLAT_MARVELL_NS_IMAGE_OFFSET 0x0
  139. /* System Reference Clock*/
  140. #define PLAT_REF_CLK_IN_HZ COUNTER_FREQUENCY
  141. /*
  142. * PL011 related constants
  143. */
  144. #define PLAT_MARVELL_UART_BASE (MVEBU_REGS_BASE + 0x12000)
  145. /* Required platform porting definitions */
  146. #define PLAT_MAX_PWR_LVL MPIDR_AFFLVL1
  147. /* System timer related constants */
  148. #define PLAT_MARVELL_NSTIMER_FRAME_ID 1
  149. /* Mailbox base address */
  150. #define PLAT_MARVELL_MAILBOX_BASE (MARVELL_SHARED_RAM_BASE + 0x400)
  151. #define PLAT_MARVELL_MAILBOX_SIZE 0x100
  152. #define PLAT_MARVELL_MAILBOX_MAGIC_NUM 0x6D72766C /* mrvl */
  153. /* DRAM CS memory map registers related constants */
  154. #define MVEBU_CS_MMAP_LOW(cs_num) \
  155. (MVEBU_CS_MMAP_REG_BASE + (cs_num) * 0x8)
  156. #define MVEBU_CS_MMAP_ENABLE 0x1
  157. #define MVEBU_CS_MMAP_AREA_LEN_OFFS 16
  158. #define MVEBU_CS_MMAP_AREA_LEN_MASK \
  159. (0x1f << MVEBU_CS_MMAP_AREA_LEN_OFFS)
  160. #define MVEBU_CS_MMAP_START_ADDR_LOW_OFFS 23
  161. #define MVEBU_CS_MMAP_START_ADDR_LOW_MASK \
  162. (0x1ff << MVEBU_CS_MMAP_START_ADDR_LOW_OFFS)
  163. #define MVEBU_CS_MMAP_HIGH(cs_num) \
  164. (MVEBU_CS_MMAP_REG_BASE + 0x4 + (cs_num) * 0x8)
  165. /* DRAM max CS number */
  166. #define MVEBU_MAX_CS_MMAP_NUM (2)
  167. /* CPU decoder window related constants */
  168. #define CPU_DEC_WIN_CTRL_REG(win_num) \
  169. (MVEBU_CPU_DEC_WIN_REG_BASE + (win_num) * 0x10)
  170. #define CPU_DEC_CR_WIN_ENABLE 0x1
  171. #define CPU_DEC_CR_WIN_TARGET_OFFS 4
  172. #define CPU_DEC_CR_WIN_TARGET_MASK \
  173. (0xf << CPU_DEC_CR_WIN_TARGET_OFFS)
  174. #define CPU_DEC_WIN_SIZE_REG(win_num) \
  175. (MVEBU_CPU_DEC_WIN_REG_BASE + 0x4 + (win_num) * 0x10)
  176. #define CPU_DEC_CR_WIN_SIZE_OFFS 0
  177. #define CPU_DEC_CR_WIN_SIZE_MASK \
  178. (0xffff << CPU_DEC_CR_WIN_SIZE_OFFS)
  179. #define CPU_DEC_CR_WIN_SIZE_ALIGNMENT 0x10000
  180. #define CPU_DEC_WIN_BASE_REG(win_num) \
  181. (MVEBU_CPU_DEC_WIN_REG_BASE + 0x8 + (win_num) * 0x10)
  182. #define CPU_DEC_BR_BASE_OFFS 0
  183. #define CPU_DEC_BR_BASE_MASK \
  184. (0xffff << CPU_DEC_BR_BASE_OFFS)
  185. #define CPU_DEC_REMAP_LOW_REG(win_num) \
  186. (MVEBU_CPU_DEC_WIN_REG_BASE + 0xC + (win_num) * 0x10)
  187. #define CPU_DEC_RLR_REMAP_LOW_OFFS 0
  188. #define CPU_DEC_RLR_REMAP_LOW_MASK \
  189. (0xffff << CPU_DEC_BR_BASE_OFFS)
  190. #define CPU_DEC_CCI_BASE_REG (MVEBU_CPU_DEC_WIN_REG_BASE + 0xe0)
  191. /* Securities */
  192. #define IRQ_SEC_OS_TICK_INT MARVELL_IRQ_SEC_PHY_TIMER
  193. #endif /* PLATFORM_DEF_H */