platform_def.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. /*
  2. * Copyright (c) 2019, ARM Limited and Contributors. All rights reserved.
  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 <drivers/arm/gic_common.h>
  10. #define PLAT_PRIMARY_CPU 0x0
  11. #define IO_PHYS 0x10000000
  12. #define INFRACFG_AO_BASE (IO_PHYS + 0x1000)
  13. #define PERI_BASE (IO_PHYS + 0x3000)
  14. #define GPIO_BASE (IO_PHYS + 0x5000)
  15. #define SPM_BASE (IO_PHYS + 0x6000)
  16. #define SLEEP_REG_MD_BASE (IO_PHYS + 0xf000)
  17. #define RGU_BASE (IO_PHYS + 0x7000)
  18. #define I2C4_BASE_SE (IO_PHYS + 0x1008000)
  19. #define I2C2_BASE_SE (IO_PHYS + 0x1009000)
  20. #define PMIC_WRAP_BASE (IO_PHYS + 0xd000)
  21. #define MCUCFG_BASE 0x0c530000
  22. #define CFG_SF_CTRL 0x0c510014
  23. #define CFG_SF_INI 0x0c510010
  24. #define EMI_BASE (IO_PHYS + 0x219000)
  25. #define EMI_MPU_BASE (IO_PHYS + 0x226000)
  26. #define TRNG_base (IO_PHYS + 0x20f000)
  27. #define MT_GIC_BASE 0x0c000000
  28. #define PLAT_MT_CCI_BASE 0x0c500000
  29. #define CCI_SIZE 0x00010000
  30. #define EINT_BASE 0x1000b000
  31. #define DVFSRC_BASE (IO_PHYS + 0x12000)
  32. #define SSPM_CFGREG_BASE (IO_PHYS + 0x440000)
  33. #define SSPM_MBOX_3_BASE (IO_PHYS + 0x480000)
  34. #define INFRACFG_AO_BASE (IO_PHYS + 0x1000)
  35. #define TOPCKGEN_BASE (IO_PHYS + 0x0)
  36. #define CLK_SCP_CFG_0 (TOPCKGEN_BASE + 0x200)
  37. #define CLK_SCP_CFG_1 (TOPCKGEN_BASE + 0x204)
  38. #define APMIXEDSYS (IO_PHYS + 0xC000)
  39. #define AP_PLL_CON3 (APMIXEDSYS + 0xC)
  40. #define AP_PLL_CON4 (APMIXEDSYS + 0x10)
  41. #define AP_PLL_CON6 (APMIXEDSYS + 0x18)
  42. #define ARMPLL_LL_CON0 (APMIXEDSYS + 0x200)
  43. #define ARMPLL_L_CON0 (APMIXEDSYS + 0x210)
  44. #define ARMPLL_L_PWR_CON0 (APMIXEDSYS + 0x21c)
  45. #define MAINPLL_CON0 (APMIXEDSYS + 0x220)
  46. #define CCIPLL_CON0 (APMIXEDSYS + 0x290)
  47. #define TOP_CKMUXSEL (INFRACFG_AO_BASE + 0x0)
  48. #define armpll_mux1_sel_big_mask (0xf << 4)
  49. #define armpll_mux1_sel_big_ARMSPLL (0x1 << 4)
  50. #define armpll_mux1_sel_sml_mask (0xf << 8)
  51. #define armpll_mux1_sel_sml_ARMSPLL (0x1 << 8)
  52. /* Aggregate of all devices in the first GB */
  53. #define MTK_DEV_RNG0_BASE IO_PHYS
  54. #define MTK_DEV_RNG0_SIZE 0x490000
  55. #define MTK_DEV_RNG1_BASE (IO_PHYS + 0x1000000)
  56. #define MTK_DEV_RNG1_SIZE 0x4000000
  57. #define MTK_DEV_RNG2_BASE 0x0c000000
  58. #define MTK_DEV_RNG2_SIZE 0x600000
  59. #define MT_MCUSYS_SIZE 0x90000
  60. #define RAM_CONSOLE_BASE 0x11d000
  61. #define RAM_CONSOLE_SIZE 0x1000
  62. /*******************************************************************************
  63. * MSDC
  64. ******************************************************************************/
  65. #define MSDC0_BASE (IO_PHYS + 0x01230000)
  66. /*******************************************************************************
  67. * MCUSYS related constants
  68. ******************************************************************************/
  69. #define MT_L2_WRITE_ACCESS_RATE (MCUCFG_BASE + 0x604)
  70. #define MP0_CA7L_CACHE_CONFIG (MCUCFG_BASE + 0x7f0)
  71. #define MP1_CA7L_CACHE_CONFIG (MCUCFG_BASE + 0x7f4)
  72. #define EMI_WFIFO (MCUCFG_BASE + 0x0b5c)
  73. /*******************************************************************************
  74. * GIC related constants
  75. ******************************************************************************/
  76. #define MT_POLARITY_LOW 0
  77. #define MT_POLARITY_HIGH 1
  78. #define MT_EDGE_SENSITIVE 1
  79. #define MT_LEVEL_SENSITIVE 0
  80. /*******************************************************************************
  81. * UART related constants
  82. ******************************************************************************/
  83. #define UART0_BASE (IO_PHYS + 0x01002000)
  84. #define UART1_BASE (IO_PHYS + 0x01003000)
  85. #define UART_BAUDRATE 115200
  86. #define UART_CLOCK 26000000
  87. /*******************************************************************************
  88. * System counter frequency related constants
  89. ******************************************************************************/
  90. #define SYS_COUNTER_FREQ_IN_TICKS 13000000
  91. #define SYS_COUNTER_FREQ_IN_MHZ 13
  92. /*******************************************************************************
  93. * GIC-400 & interrupt handling related constants
  94. ******************************************************************************/
  95. /* Base MTK_platform compatible GIC memory map */
  96. #define BASE_GICD_BASE MT_GIC_BASE
  97. #define BASE_GICC_BASE (MT_GIC_BASE + 0x400000)
  98. #define MT_GIC_RDIST_BASE (MT_GIC_BASE + 0x100000)
  99. #define BASE_GICR_BASE (MT_GIC_BASE + 0x100000)
  100. #define BASE_GICH_BASE (MT_GIC_BASE + 0x4000)
  101. #define BASE_GICV_BASE (MT_GIC_BASE + 0x6000)
  102. #define INT_POL_CTL0 (MCUCFG_BASE + 0xa80)
  103. #define SEC_POL_CTL_EN0 (MCUCFG_BASE + 0xa00)
  104. #define GIC_SYNC_DCM (MCUCFG_BASE + 0x758)
  105. #define GIC_SYNC_DCM_MASK 0x3
  106. #define GIC_SYNC_DCM_ON 0x3
  107. #define GIC_SYNC_DCM_OFF 0x0
  108. #define GIC_PRIVATE_SIGNALS 32
  109. #define PLAT_ARM_GICD_BASE BASE_GICD_BASE
  110. #define PLAT_ARM_GICC_BASE BASE_GICC_BASE
  111. #define PLAT_ARM_G1S_IRQ_PROPS(grp) ( \
  112. INTR_PROP_DESC(MT_IRQ_SEC_SGI_0, GIC_HIGHEST_SEC_PRIORITY, grp, \
  113. GIC_INTR_CFG_EDGE), \
  114. INTR_PROP_DESC(MT_IRQ_SEC_SGI_1, GIC_HIGHEST_SEC_PRIORITY, grp, \
  115. GIC_INTR_CFG_EDGE), \
  116. INTR_PROP_DESC(MT_IRQ_SEC_SGI_2, GIC_HIGHEST_SEC_PRIORITY, grp, \
  117. GIC_INTR_CFG_EDGE), \
  118. INTR_PROP_DESC(MT_IRQ_SEC_SGI_3, GIC_HIGHEST_SEC_PRIORITY, grp, \
  119. GIC_INTR_CFG_EDGE), \
  120. INTR_PROP_DESC(MT_IRQ_SEC_SGI_4, GIC_HIGHEST_SEC_PRIORITY, grp, \
  121. GIC_INTR_CFG_EDGE), \
  122. INTR_PROP_DESC(MT_IRQ_SEC_SGI_5, GIC_HIGHEST_SEC_PRIORITY, grp, \
  123. GIC_INTR_CFG_EDGE), \
  124. INTR_PROP_DESC(MT_IRQ_SEC_SGI_6, GIC_HIGHEST_SEC_PRIORITY, grp, \
  125. GIC_INTR_CFG_EDGE), \
  126. INTR_PROP_DESC(MT_IRQ_SEC_SGI_7, GIC_HIGHEST_SEC_PRIORITY, grp, \
  127. GIC_INTR_CFG_EDGE)) \
  128. #define PLAT_ARM_G0_IRQ_PROPS(grp)
  129. /*******************************************************************************
  130. * CCI-400 related constants
  131. ******************************************************************************/
  132. #define PLAT_MT_CCI_CLUSTER0_SL_IFACE_IX 4
  133. #define PLAT_MT_CCI_CLUSTER1_SL_IFACE_IX 3
  134. /*******************************************************************************
  135. * WDT Registers
  136. ******************************************************************************/
  137. #define MTK_WDT_BASE (IO_PHYS + 0x00007000)
  138. #define MTK_WDT_SIZE 0x1000
  139. #define MTK_WDT_MODE (MTK_WDT_BASE + 0x0000)
  140. #define MTK_WDT_LENGTH (MTK_WDT_BASE + 0x0004)
  141. #define MTK_WDT_RESTART (MTK_WDT_BASE + 0x0008)
  142. #define MTK_WDT_STATUS (MTK_WDT_BASE + 0x000C)
  143. #define MTK_WDT_INTERVAL (MTK_WDT_BASE + 0x0010)
  144. #define MTK_WDT_SWRST (MTK_WDT_BASE + 0x0014)
  145. #define MTK_WDT_SWSYSRST (MTK_WDT_BASE + 0x0018)
  146. #define MTK_WDT_NONRST_REG (MTK_WDT_BASE + 0x0020)
  147. #define MTK_WDT_NONRST_REG2 (MTK_WDT_BASE + 0x0024)
  148. #define MTK_WDT_REQ_MODE (MTK_WDT_BASE + 0x0030)
  149. #define MTK_WDT_REQ_IRQ_EN (MTK_WDT_BASE + 0x0034)
  150. #define MTK_WDT_EXT_REQ_CON (MTK_WDT_BASE + 0x0038)
  151. #define MTK_WDT_DEBUG_CTL (MTK_WDT_BASE + 0x0040)
  152. #define MTK_WDT_LATCH_CTL (MTK_WDT_BASE + 0x0044)
  153. #define MTK_WDT_DEBUG_CTL2 (MTK_WDT_BASE + 0x00A0)
  154. #define MTK_WDT_COUNTER (MTK_WDT_BASE + 0x0514)
  155. /* WDT_STATUS */
  156. #define MTK_WDT_STATUS_SPM_THERMAL_RST (1 << 0)
  157. #define MTK_WDT_STATUS_SPM_RST (1 << 1)
  158. #define MTK_WDT_STATUS_EINT_RST (1 << 2)
  159. #define MTK_WDT_STATUS_SYSRST_RST (1 << 3) /* from PMIC */
  160. #define MTK_WDT_STATUS_DVFSP_RST (1 << 4)
  161. #define MTK_WDT_STATUS_PMCU_RST (1 << 16)
  162. #define MTK_WDT_STATUS_MDDBG_RST (1 << 17)
  163. #define MTK_WDT_STATUS_THERMAL_DIRECT_RST (1 << 18)
  164. #define MTK_WDT_STATUS_DEBUG_RST (1 << 19)
  165. #define MTK_WDT_STATUS_SECURITY_RST (1 << 28)
  166. #define MTK_WDT_STATUS_IRQ_ASSERT (1 << 29)
  167. #define MTK_WDT_STATUS_SW_WDT_RST (1 << 30)
  168. #define MTK_WDT_STATUS_HW_WDT_RST (1U << 31)
  169. /* RGU other related */
  170. #define MTK_WDT_MODE_DUAL_MODE 0x0040
  171. #define MTK_WDT_MODE_IRQ 0x0008
  172. #define MTK_WDT_MODE_KEY 0x22000000
  173. #define MTK_WDT_MODE_EXTEN 0x0004
  174. #define MTK_WDT_SWRST_KEY 0x1209
  175. #define MTK_WDT_RESTART_KEY 0x1971
  176. /*******************************************************************************
  177. * TRNG Registers
  178. ******************************************************************************/
  179. #define TRNG_BASE_ADDR TRNG_base
  180. #define TRNG_BASE_SIZE 0x1000
  181. #define TRNG_CTRL (TRNG_base + 0x0000)
  182. #define TRNG_TIME (TRNG_base + 0x0004)
  183. #define TRNG_DATA (TRNG_base + 0x0008)
  184. #define TRNG_PDN_base 0x10001000
  185. #define TRNG_PDN_BASE_ADDR TRNG_PDN_BASE_ADDR
  186. #define TRNG_PDN_BASE_SIZE 0x1000
  187. #define TRNG_PDN_SET (TRNG_PDN_base + 0x0088)
  188. #define TRNG_PDN_CLR (TRNG_PDN_base + 0x008c)
  189. #define TRNG_PDN_STATUS (TRNG_PDN_base + 0x0094)
  190. #define TRNG_CTRL_RDY 0x80000000
  191. #define TRNG_CTRL_START 0x00000001
  192. #define TRNG_PDN_VALUE 0x200
  193. /* FIQ platform related define */
  194. #define MT_IRQ_SEC_SGI_0 8
  195. #define MT_IRQ_SEC_SGI_1 9
  196. #define MT_IRQ_SEC_SGI_2 10
  197. #define MT_IRQ_SEC_SGI_3 11
  198. #define MT_IRQ_SEC_SGI_4 12
  199. #define MT_IRQ_SEC_SGI_5 13
  200. #define MT_IRQ_SEC_SGI_6 14
  201. #define MT_IRQ_SEC_SGI_7 15
  202. #define FIQ_SMP_CALL_SGI 13
  203. #define WDT_IRQ_BIT_ID 174
  204. #define ATF_LOG_IRQ_ID 277
  205. #define ATF_AMMS_IRQ_ID 338
  206. #define PCCIF1_IRQ0_BIT_ID 185
  207. #define PCCIF1_IRQ1_BIT_ID 186
  208. #define DEBUG_XLAT_TABLE 0
  209. /*******************************************************************************
  210. * Platform binary types for linking
  211. ******************************************************************************/
  212. #define PLATFORM_LINKER_FORMAT "elf64-littleaarch64"
  213. #define PLATFORM_LINKER_ARCH aarch64
  214. /*******************************************************************************
  215. * Generic platform constants
  216. ******************************************************************************/
  217. /* Size of cacheable stacks */
  218. #if DEBUG_XLAT_TABLE
  219. #define PLATFORM_STACK_SIZE 0x800
  220. #elif IMAGE_BL1
  221. #define PLATFORM_STACK_SIZE 0x440
  222. #elif IMAGE_BL2
  223. #define PLATFORM_STACK_SIZE 0x400
  224. #elif IMAGE_BL31
  225. #define PLATFORM_STACK_SIZE 0x800
  226. #elif IMAGE_BL32
  227. #define PLATFORM_STACK_SIZE 0x440
  228. #endif
  229. #define FIRMWARE_WELCOME_STR "Booting Trusted Firmware\n"
  230. #define PLAT_MAX_PWR_LVL U(2)
  231. #define PLAT_MAX_RET_STATE U(1)
  232. #define PLAT_MAX_OFF_STATE U(2)
  233. #define PLATFORM_CACHE_LINE_SIZE 64
  234. #define PLATFORM_SYSTEM_COUNT U(1)
  235. #define PLATFORM_CLUSTER_COUNT U(2)
  236. #define PLATFORM_CLUSTER0_CORE_COUNT U(4)
  237. #define PLATFORM_CLUSTER1_CORE_COUNT U(4)
  238. #define PLATFORM_CORE_COUNT (PLATFORM_CLUSTER1_CORE_COUNT + \
  239. PLATFORM_CLUSTER0_CORE_COUNT)
  240. #define PLATFORM_MAX_CPUS_PER_CLUSTER U(4)
  241. #define PLATFORM_NUM_AFFS (PLATFORM_SYSTEM_COUNT + \
  242. PLATFORM_CLUSTER_COUNT + \
  243. PLATFORM_CORE_COUNT)
  244. #define SOC_CHIP_ID U(0x8183)
  245. /*******************************************************************************
  246. * Platform memory map related constants
  247. ******************************************************************************/
  248. #define TZRAM_BASE 0x54600000
  249. #define TZRAM_SIZE 0x00030000
  250. /*******************************************************************************
  251. * BL31 specific defines.
  252. ******************************************************************************/
  253. /*
  254. * Put BL31 at the top of the Trusted SRAM (just below the shared memory, if
  255. * present). BL31_BASE is calculated using the current BL31 debug size plus a
  256. * little space for growth.
  257. */
  258. #define BL31_BASE (TZRAM_BASE + 0x1000)
  259. #define BL31_LIMIT (TZRAM_BASE + TZRAM_SIZE)
  260. /*******************************************************************************
  261. * Platform specific page table and MMU setup constants
  262. ******************************************************************************/
  263. #define PLAT_PHY_ADDR_SPACE_SIZE (1ULL << 32)
  264. #define PLAT_VIRT_ADDR_SPACE_SIZE (1ULL << 32)
  265. #define MAX_XLAT_TABLES 16
  266. #define MAX_MMAP_REGIONS 16
  267. /*******************************************************************************
  268. * Declarations and constants to access the mailboxes safely. Each mailbox is
  269. * aligned on the biggest cache line size in the platform. This is known only
  270. * to the platform as it might have a combination of integrated and external
  271. * caches. Such alignment ensures that two maiboxes do not sit on the same cache
  272. * line at any cache level. They could belong to different cpus/clusters &
  273. * get written while being protected by different locks causing corruption of
  274. * a valid mailbox address.
  275. ******************************************************************************/
  276. #define CACHE_WRITEBACK_SHIFT 6
  277. #define CACHE_WRITEBACK_GRANULE (1 << CACHE_WRITEBACK_SHIFT)
  278. #endif /* PLATFORM_DEF_H */