stm32mp2_def.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  1. /*
  2. * Copyright (c) 2023-2024, STMicroelectronics - All Rights Reserved
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef STM32MP2_DEF_H
  7. #define STM32MP2_DEF_H
  8. #include <common/tbbr/tbbr_img_def.h>
  9. #ifndef __ASSEMBLER__
  10. #include <drivers/st/bsec.h>
  11. #endif
  12. #include <drivers/st/stm32mp25_rcc.h>
  13. #ifndef __ASSEMBLER__
  14. #include <drivers/st/stm32mp2_clk.h>
  15. #endif
  16. #include <drivers/st/stm32mp2_pwr.h>
  17. #include <dt-bindings/clock/stm32mp25-clks.h>
  18. #include <dt-bindings/clock/stm32mp25-clksrc.h>
  19. #include <dt-bindings/gpio/stm32-gpio.h>
  20. #include <dt-bindings/reset/stm32mp25-resets.h>
  21. #ifndef __ASSEMBLER__
  22. #include <boot_api.h>
  23. #include <stm32mp2_private.h>
  24. #include <stm32mp_common.h>
  25. #include <stm32mp_dt.h>
  26. #include <stm32mp_shared_resources.h>
  27. #endif
  28. /*******************************************************************************
  29. * CHIP ID
  30. ******************************************************************************/
  31. #define STM32MP2_CHIP_ID U(0x505)
  32. #define STM32MP251A_PART_NB U(0x400B3E6D)
  33. #define STM32MP251C_PART_NB U(0x000B306D)
  34. #define STM32MP251D_PART_NB U(0xC00B3E6D)
  35. #define STM32MP251F_PART_NB U(0x800B306D)
  36. #define STM32MP253A_PART_NB U(0x400B3E0C)
  37. #define STM32MP253C_PART_NB U(0x000B300C)
  38. #define STM32MP253D_PART_NB U(0xC00B3E0C)
  39. #define STM32MP253F_PART_NB U(0x800B300C)
  40. #define STM32MP255A_PART_NB U(0x40082E00)
  41. #define STM32MP255C_PART_NB U(0x00082000)
  42. #define STM32MP255D_PART_NB U(0xC0082E00)
  43. #define STM32MP255F_PART_NB U(0x80082000)
  44. #define STM32MP257A_PART_NB U(0x40002E00)
  45. #define STM32MP257C_PART_NB U(0x00002000)
  46. #define STM32MP257D_PART_NB U(0xC0002E00)
  47. #define STM32MP257F_PART_NB U(0x80002000)
  48. #define STM32MP2_REV_A U(0x08)
  49. #define STM32MP2_REV_B U(0x10)
  50. #define STM32MP2_REV_X U(0x12)
  51. #define STM32MP2_REV_Y U(0x11)
  52. #define STM32MP2_REV_Z U(0x09)
  53. /*******************************************************************************
  54. * PACKAGE ID
  55. ******************************************************************************/
  56. #define STM32MP25_PKG_CUSTOM U(0)
  57. #define STM32MP25_PKG_AL_VFBGA361 U(1)
  58. #define STM32MP25_PKG_AK_VFBGA424 U(3)
  59. #define STM32MP25_PKG_AI_TFBGA436 U(5)
  60. #define STM32MP25_PKG_UNKNOWN U(7)
  61. /*******************************************************************************
  62. * STM32MP2 memory map related constants
  63. ******************************************************************************/
  64. #define STM32MP_SYSRAM_BASE U(0x0E000000)
  65. #define STM32MP_SYSRAM_SIZE U(0x00040000)
  66. #define SRAM1_BASE U(0x0E040000)
  67. #define SRAM1_SIZE_FOR_TFA U(0x00010000)
  68. #define RETRAM_BASE U(0x0E080000)
  69. #define RETRAM_SIZE U(0x00020000)
  70. #define STM32MP_SEC_SYSRAM_SIZE STM32MP_SYSRAM_SIZE
  71. /* DDR configuration */
  72. #define STM32MP_DDR_BASE U(0x80000000)
  73. #define STM32MP_DDR_MAX_SIZE UL(0x100000000) /* Max 4GB */
  74. /* DDR power initializations */
  75. #ifndef __ASSEMBLER__
  76. enum ddr_type {
  77. STM32MP_DDR3,
  78. STM32MP_DDR4,
  79. STM32MP_LPDDR4
  80. };
  81. #endif
  82. /* Section used inside TF binaries */
  83. #define STM32MP_PARAM_LOAD_SIZE U(0x00002400) /* 9 KB for param */
  84. /* 512 Bytes reserved for header */
  85. #define STM32MP_HEADER_SIZE U(0x00000200)
  86. #define STM32MP_HEADER_BASE (STM32MP_SYSRAM_BASE + \
  87. STM32MP_PARAM_LOAD_SIZE)
  88. /* round_up(STM32MP_PARAM_LOAD_SIZE + STM32MP_HEADER_SIZE, PAGE_SIZE) */
  89. #define STM32MP_HEADER_RESERVED_SIZE U(0x3000)
  90. #define STM32MP_BINARY_BASE (STM32MP_SYSRAM_BASE + \
  91. STM32MP_PARAM_LOAD_SIZE + \
  92. STM32MP_HEADER_SIZE)
  93. #define STM32MP_BINARY_SIZE (STM32MP_SYSRAM_SIZE - \
  94. (STM32MP_PARAM_LOAD_SIZE + \
  95. STM32MP_HEADER_SIZE))
  96. #define STM32MP_BL2_RO_SIZE U(0x00020000) /* 128 KB */
  97. #define STM32MP_BL2_SIZE U(0x00029000) /* 164 KB for BL2 */
  98. /* Allocate remaining sysram to BL31 Binary only */
  99. #define STM32MP_BL31_SIZE (STM32MP_SEC_SYSRAM_SIZE - \
  100. STM32MP_BL2_SIZE)
  101. #define BL31_PROGBITS_LIMIT STM32MP_BL31_SIZE
  102. #define STM32MP_BL2_BASE (STM32MP_SYSRAM_BASE + \
  103. STM32MP_SYSRAM_SIZE - \
  104. STM32MP_BL2_SIZE)
  105. #define STM32MP_BL2_RO_BASE STM32MP_BL2_BASE
  106. #define STM32MP_BL2_RW_BASE (STM32MP_BL2_RO_BASE + \
  107. STM32MP_BL2_RO_SIZE)
  108. #define STM32MP_BL2_RW_SIZE (STM32MP_SYSRAM_BASE + \
  109. STM32MP_SYSRAM_SIZE - \
  110. STM32MP_BL2_RW_BASE)
  111. /* BL2 and BL32/sp_min require 4 tables */
  112. #define MAX_XLAT_TABLES U(4) /* 16 KB for mapping */
  113. /*
  114. * MAX_MMAP_REGIONS is usually:
  115. * BL stm32mp2_mmap size + mmap regions in *_plat_arch_setup
  116. */
  117. #if defined(IMAGE_BL31)
  118. #define MAX_MMAP_REGIONS 7
  119. #else
  120. #define MAX_MMAP_REGIONS 6
  121. #endif
  122. /* DTB initialization value */
  123. #define STM32MP_BL2_DTB_SIZE U(0x00006000) /* 24 KB for DTB */
  124. #define STM32MP_BL2_DTB_BASE (STM32MP_BL2_BASE - \
  125. STM32MP_BL2_DTB_SIZE)
  126. #if defined(IMAGE_BL2)
  127. #define STM32MP_DTB_SIZE STM32MP_BL2_DTB_SIZE
  128. #define STM32MP_DTB_BASE STM32MP_BL2_DTB_BASE
  129. #endif
  130. #if STM32MP_DDR_FIP_IO_STORAGE
  131. #define STM32MP_DDR_FW_BASE SRAM1_BASE
  132. #define STM32MP_DDR_FW_DMEM_OFFSET U(0x400)
  133. #define STM32MP_DDR_FW_IMEM_OFFSET U(0x800)
  134. #define STM32MP_DDR_FW_MAX_SIZE U(0x8800)
  135. #endif
  136. #define STM32MP_FW_CONFIG_MAX_SIZE PAGE_SIZE
  137. #define STM32MP_FW_CONFIG_BASE STM32MP_SYSRAM_BASE
  138. #define STM32MP_BL33_BASE (STM32MP_DDR_BASE + U(0x04000000))
  139. #define STM32MP_BL33_MAX_SIZE U(0x400000)
  140. #define STM32MP_HW_CONFIG_BASE (STM32MP_BL33_BASE + \
  141. STM32MP_BL33_MAX_SIZE)
  142. #define STM32MP_HW_CONFIG_MAX_SIZE U(0x40000)
  143. #define STM32MP_SOC_FW_CONFIG_MAX_SIZE U(0x10000) /* 64kB for BL31 DT */
  144. /*******************************************************************************
  145. * STM32MP2 device/io map related constants (used for MMU)
  146. ******************************************************************************/
  147. #define STM32MP_DEVICE_BASE U(0x40000000)
  148. #define STM32MP_DEVICE_SIZE U(0x40000000)
  149. /*******************************************************************************
  150. * STM32MP2 RCC
  151. ******************************************************************************/
  152. #define RCC_BASE U(0x44200000)
  153. /*******************************************************************************
  154. * STM32MP2 PWR
  155. ******************************************************************************/
  156. #define PWR_BASE U(0x44210000)
  157. /*******************************************************************************
  158. * STM32MP2 GPIO
  159. ******************************************************************************/
  160. #define GPIOA_BASE U(0x44240000)
  161. #define GPIOB_BASE U(0x44250000)
  162. #define GPIOC_BASE U(0x44260000)
  163. #define GPIOD_BASE U(0x44270000)
  164. #define GPIOE_BASE U(0x44280000)
  165. #define GPIOF_BASE U(0x44290000)
  166. #define GPIOG_BASE U(0x442A0000)
  167. #define GPIOH_BASE U(0x442B0000)
  168. #define GPIOI_BASE U(0x442C0000)
  169. #define GPIOJ_BASE U(0x442D0000)
  170. #define GPIOK_BASE U(0x442E0000)
  171. #define GPIOZ_BASE U(0x46200000)
  172. #define GPIO_BANK_OFFSET U(0x10000)
  173. #define STM32MP_GPIOS_PIN_MAX_COUNT 16
  174. #define STM32MP_GPIOZ_PIN_MAX_COUNT 8
  175. /*******************************************************************************
  176. * STM32MP2 UART
  177. ******************************************************************************/
  178. #define USART1_BASE U(0x40330000)
  179. #define USART2_BASE U(0x400E0000)
  180. #define USART3_BASE U(0x400F0000)
  181. #define UART4_BASE U(0x40100000)
  182. #define UART5_BASE U(0x40110000)
  183. #define USART6_BASE U(0x40220000)
  184. #define UART7_BASE U(0x40370000)
  185. #define UART8_BASE U(0x40380000)
  186. #define UART9_BASE U(0x402C0000)
  187. #define STM32MP_NB_OF_UART U(9)
  188. /* For UART crash console */
  189. #define STM32MP_DEBUG_USART_CLK_FRQ 64000000
  190. /* USART2 on HSI@64MHz, TX on GPIOA4 Alternate 6 */
  191. #define STM32MP_DEBUG_USART_BASE USART2_BASE
  192. #define DEBUG_UART_TX_GPIO_BANK_ADDRESS GPIOA_BASE
  193. #define DEBUG_UART_TX_GPIO_BANK_CLK_REG RCC_GPIOACFGR
  194. #define DEBUG_UART_TX_GPIO_BANK_CLK_EN RCC_GPIOxCFGR_GPIOxEN
  195. #define DEBUG_UART_TX_GPIO_PORT 4
  196. #define DEBUG_UART_TX_GPIO_ALTERNATE 6
  197. #define DEBUG_UART_TX_CLKSRC_REG RCC_XBAR8CFGR
  198. #define DEBUG_UART_TX_CLKSRC XBAR_SRC_HSI
  199. #define DEBUG_UART_TX_EN_REG RCC_USART2CFGR
  200. #define DEBUG_UART_TX_EN RCC_UARTxCFGR_UARTxEN
  201. #define DEBUG_UART_RST_REG RCC_USART2CFGR
  202. #define DEBUG_UART_RST_BIT RCC_UARTxCFGR_UARTxRST
  203. #define DEBUG_UART_PREDIV_CFGR RCC_PREDIV8CFGR
  204. #define DEBUG_UART_FINDIV_CFGR RCC_FINDIV8CFGR
  205. /*******************************************************************************
  206. * STM32MP2 SDMMC
  207. ******************************************************************************/
  208. #define STM32MP_SDMMC1_BASE U(0x48220000)
  209. #define STM32MP_SDMMC2_BASE U(0x48230000)
  210. #define STM32MP_SDMMC3_BASE U(0x48240000)
  211. /*******************************************************************************
  212. * STM32MP2 BSEC / OTP
  213. ******************************************************************************/
  214. /*
  215. * 367 available OTPs, the other are masked
  216. * - ECIES key: 368 to 375 (only readable by bootrom)
  217. * - HWKEY: 376 to 383 (never reloadable or readable)
  218. */
  219. #define STM32MP2_OTP_MAX_ID U(0x16F)
  220. #define STM32MP2_MID_OTP_START U(0x80)
  221. #define STM32MP2_UPPER_OTP_START U(0x100)
  222. /* OTP labels */
  223. #define PART_NUMBER_OTP "part-number-otp"
  224. #define REVISION_OTP "rev_otp"
  225. #define PACKAGE_OTP "package-otp"
  226. #define HCONF1_OTP "otp124"
  227. #define NAND_OTP "otp16"
  228. #define NAND2_OTP "otp20"
  229. #define BOARD_ID_OTP "board-id"
  230. #define UID_OTP "uid-otp"
  231. #define LIFECYCLE2_OTP "otp18"
  232. #define PKH_OTP "otp144"
  233. #define ENCKEY_OTP "otp260"
  234. /* OTP mask */
  235. /* PACKAGE */
  236. #define PACKAGE_OTP_PKG_MASK GENMASK_32(2, 0)
  237. #define PACKAGE_OTP_PKG_SHIFT U(0)
  238. /* IWDG OTP */
  239. #define HCONF1_OTP_IWDG_HW_POS U(0)
  240. #define HCONF1_OTP_IWDG_FZ_STOP_POS U(1)
  241. #define HCONF1_OTP_IWDG_FZ_STANDBY_POS U(2)
  242. /* NAND OTP */
  243. /* NAND parameter storage flag */
  244. #define NAND_PARAM_STORED_IN_OTP BIT_32(31)
  245. /* NAND page size in bytes */
  246. #define NAND_PAGE_SIZE_MASK GENMASK_32(30, 29)
  247. #define NAND_PAGE_SIZE_SHIFT U(29)
  248. #define NAND_PAGE_SIZE_2K U(0)
  249. #define NAND_PAGE_SIZE_4K U(1)
  250. #define NAND_PAGE_SIZE_8K U(2)
  251. /* NAND block size in pages */
  252. #define NAND_BLOCK_SIZE_MASK GENMASK_32(28, 27)
  253. #define NAND_BLOCK_SIZE_SHIFT U(27)
  254. #define NAND_BLOCK_SIZE_64_PAGES U(0)
  255. #define NAND_BLOCK_SIZE_128_PAGES U(1)
  256. #define NAND_BLOCK_SIZE_256_PAGES U(2)
  257. /* NAND number of block (in unit of 256 blocks) */
  258. #define NAND_BLOCK_NB_MASK GENMASK_32(26, 19)
  259. #define NAND_BLOCK_NB_SHIFT U(19)
  260. #define NAND_BLOCK_NB_UNIT U(256)
  261. /* NAND bus width in bits */
  262. #define NAND_WIDTH_MASK BIT_32(18)
  263. #define NAND_WIDTH_SHIFT U(18)
  264. /* NAND number of ECC bits per 512 bytes */
  265. #define NAND_ECC_BIT_NB_MASK GENMASK_32(17, 15)
  266. #define NAND_ECC_BIT_NB_SHIFT U(15)
  267. #define NAND_ECC_BIT_NB_UNSET U(0)
  268. #define NAND_ECC_BIT_NB_1_BITS U(1)
  269. #define NAND_ECC_BIT_NB_4_BITS U(2)
  270. #define NAND_ECC_BIT_NB_8_BITS U(3)
  271. #define NAND_ECC_ON_DIE U(4)
  272. /* NAND number of planes */
  273. #define NAND_PLANE_BIT_NB_MASK BIT_32(14)
  274. /* NAND2 OTP */
  275. #define NAND2_PAGE_SIZE_SHIFT U(16)
  276. /* NAND2 config distribution */
  277. #define NAND2_CONFIG_DISTRIB BIT_32(0)
  278. #define NAND2_PNAND_NAND2_SNAND_NAND1 U(0)
  279. #define NAND2_PNAND_NAND1_SNAND_NAND2 U(1)
  280. /* MONOTONIC OTP */
  281. #define MAX_MONOTONIC_VALUE U(32)
  282. /* UID OTP */
  283. #define UID_WORD_NB U(3)
  284. /* Lifecycle OTP */
  285. #define SECURE_BOOT_CLOSED_SECURE GENMASK_32(3, 0)
  286. /*******************************************************************************
  287. * STM32MP2 TAMP
  288. ******************************************************************************/
  289. #define PLAT_MAX_TAMP_INT U(5)
  290. #define PLAT_MAX_TAMP_EXT U(3)
  291. #define TAMP_BASE U(0x46010000)
  292. #define TAMP_SMCR (TAMP_BASE + U(0x20))
  293. #define TAMP_BKP_REGISTER_BASE (TAMP_BASE + U(0x100))
  294. #define TAMP_BKP_REG_CLK CK_BUS_RTC
  295. #define TAMP_BKP_SEC_NUMBER U(10)
  296. #define TAMP_COUNTR U(0x40)
  297. #if !(defined(__LINKER__) || defined(__ASSEMBLER__))
  298. static inline uintptr_t tamp_bkpr(uint32_t idx)
  299. {
  300. return TAMP_BKP_REGISTER_BASE + (idx << 2);
  301. }
  302. #endif
  303. /*******************************************************************************
  304. * STM32MP2 DDRCTRL
  305. ******************************************************************************/
  306. #define DDRCTRL_BASE U(0x48040000)
  307. /*******************************************************************************
  308. * STM32MP2 DDRDBG
  309. ******************************************************************************/
  310. #define DDRDBG_BASE U(0x48050000)
  311. /*******************************************************************************
  312. * STM32MP2 DDRPHYC
  313. ******************************************************************************/
  314. #define DDRPHYC_BASE U(0x48C00000)
  315. /*******************************************************************************
  316. * Miscellaneous STM32MP1 peripherals base address
  317. ******************************************************************************/
  318. #define BSEC_BASE U(0x44000000)
  319. #define DBGMCU_BASE U(0x4A010000)
  320. #define HASH_BASE U(0x42010000)
  321. #define RTC_BASE U(0x46000000)
  322. #define STGEN_BASE U(0x48080000)
  323. #define SYSCFG_BASE U(0x44230000)
  324. /*******************************************************************************
  325. * STM32MP RIF
  326. ******************************************************************************/
  327. #define RISAB3_BASE U(0x42110000)
  328. #define RISAB5_BASE U(0x42130000)
  329. /*******************************************************************************
  330. * STM32MP CA35SSC
  331. ******************************************************************************/
  332. #define A35SSC_BASE U(0x48800000)
  333. /*******************************************************************************
  334. * REGULATORS
  335. ******************************************************************************/
  336. /* 3 PWR + 1 VREFBUF + 14 PMIC regulators + 1 FIXED */
  337. #define PLAT_NB_RDEVS U(19)
  338. /* 2 FIXED */
  339. #define PLAT_NB_FIXED_REGUS U(2)
  340. /* No GPIO regu */
  341. #define PLAT_NB_GPIO_REGUS U(0)
  342. /*******************************************************************************
  343. * Device Tree defines
  344. ******************************************************************************/
  345. #define DT_BSEC_COMPAT "st,stm32mp25-bsec"
  346. #define DT_DDR_COMPAT "st,stm32mp2-ddr"
  347. #define DT_PWR_COMPAT "st,stm32mp25-pwr"
  348. #define DT_RCC_CLK_COMPAT "st,stm32mp25-rcc"
  349. #define DT_SDMMC2_COMPAT "st,stm32mp25-sdmmc2"
  350. #define DT_UART_COMPAT "st,stm32h7-uart"
  351. #endif /* STM32MP2_DEF_H */