stm32mp1_def.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  1. /*
  2. * Copyright (c) 2015-2024, Arm Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef STM32MP1_DEF_H
  7. #define STM32MP1_DEF_H
  8. #include <common/tbbr/tbbr_img_def.h>
  9. #include <drivers/st/stm32mp1_rcc.h>
  10. #include <dt-bindings/clock/stm32mp1-clks.h>
  11. #include <dt-bindings/gpio/stm32-gpio.h>
  12. #include <dt-bindings/reset/stm32mp1-resets.h>
  13. #include <lib/utils_def.h>
  14. #include <lib/xlat_tables/xlat_tables_defs.h>
  15. #ifndef __ASSEMBLER__
  16. #include <drivers/st/bsec.h>
  17. #include <drivers/st/stm32mp1_clk.h>
  18. #include <boot_api.h>
  19. #include <stm32mp_common.h>
  20. #include <stm32mp_dt.h>
  21. #include <stm32mp1_dbgmcu.h>
  22. #include <stm32mp1_private.h>
  23. #include <stm32mp1_shared_resources.h>
  24. #endif
  25. #include "stm32mp1_fip_def.h"
  26. /*******************************************************************************
  27. * CHIP ID
  28. ******************************************************************************/
  29. #if STM32MP13
  30. #define STM32MP1_CHIP_ID U(0x501)
  31. #define STM32MP135C_PART_NB U(0x05010000)
  32. #define STM32MP135A_PART_NB U(0x05010001)
  33. #define STM32MP133C_PART_NB U(0x050100C0)
  34. #define STM32MP133A_PART_NB U(0x050100C1)
  35. #define STM32MP131C_PART_NB U(0x050106C8)
  36. #define STM32MP131A_PART_NB U(0x050106C9)
  37. #define STM32MP135F_PART_NB U(0x05010800)
  38. #define STM32MP135D_PART_NB U(0x05010801)
  39. #define STM32MP133F_PART_NB U(0x050108C0)
  40. #define STM32MP133D_PART_NB U(0x050108C1)
  41. #define STM32MP131F_PART_NB U(0x05010EC8)
  42. #define STM32MP131D_PART_NB U(0x05010EC9)
  43. #endif
  44. #if STM32MP15
  45. #define STM32MP1_CHIP_ID U(0x500)
  46. #define STM32MP157C_PART_NB U(0x05000000)
  47. #define STM32MP157A_PART_NB U(0x05000001)
  48. #define STM32MP153C_PART_NB U(0x05000024)
  49. #define STM32MP153A_PART_NB U(0x05000025)
  50. #define STM32MP151C_PART_NB U(0x0500002E)
  51. #define STM32MP151A_PART_NB U(0x0500002F)
  52. #define STM32MP157F_PART_NB U(0x05000080)
  53. #define STM32MP157D_PART_NB U(0x05000081)
  54. #define STM32MP153F_PART_NB U(0x050000A4)
  55. #define STM32MP153D_PART_NB U(0x050000A5)
  56. #define STM32MP151F_PART_NB U(0x050000AE)
  57. #define STM32MP151D_PART_NB U(0x050000AF)
  58. #endif
  59. #define STM32MP1_REV_B U(0x2000)
  60. #if STM32MP13
  61. #define STM32MP1_REV_Y U(0x1003)
  62. #define STM32MP1_REV_Z U(0x1001)
  63. #endif
  64. #if STM32MP15
  65. #define STM32MP1_REV_Z U(0x2001)
  66. #endif
  67. /*******************************************************************************
  68. * PACKAGE ID
  69. ******************************************************************************/
  70. #if STM32MP15
  71. #define PKG_AA_LFBGA448 U(4)
  72. #define PKG_AB_LFBGA354 U(3)
  73. #define PKG_AC_TFBGA361 U(2)
  74. #define PKG_AD_TFBGA257 U(1)
  75. #endif
  76. /*******************************************************************************
  77. * STM32MP1 memory map related constants
  78. ******************************************************************************/
  79. #define STM32MP_ROM_BASE U(0x00000000)
  80. #define STM32MP_ROM_SIZE U(0x00020000)
  81. #define STM32MP_ROM_SIZE_2MB_ALIGNED U(0x00200000)
  82. #if STM32MP13
  83. #define STM32MP_SYSRAM_BASE U(0x2FFE0000)
  84. #define STM32MP_SYSRAM_SIZE U(0x00020000)
  85. #define SRAM1_BASE U(0x30000000)
  86. #define SRAM1_SIZE U(0x00004000)
  87. #define SRAM2_BASE U(0x30004000)
  88. #define SRAM2_SIZE U(0x00002000)
  89. #define SRAM3_BASE U(0x30006000)
  90. #define SRAM3_SIZE U(0x00002000)
  91. #define SRAMS_BASE SRAM1_BASE
  92. #define SRAMS_SIZE_2MB_ALIGNED U(0x00200000)
  93. #endif /* STM32MP13 */
  94. #if STM32MP15
  95. #define STM32MP_SYSRAM_BASE U(0x2FFC0000)
  96. #define STM32MP_SYSRAM_SIZE U(0x00040000)
  97. #endif /* STM32MP15 */
  98. #define STM32MP_NS_SYSRAM_SIZE PAGE_SIZE
  99. #define STM32MP_NS_SYSRAM_BASE (STM32MP_SYSRAM_BASE + \
  100. STM32MP_SYSRAM_SIZE - \
  101. STM32MP_NS_SYSRAM_SIZE)
  102. #define STM32MP_SCMI_NS_SHM_BASE STM32MP_NS_SYSRAM_BASE
  103. #define STM32MP_SCMI_NS_SHM_SIZE STM32MP_NS_SYSRAM_SIZE
  104. #define STM32MP_SEC_SYSRAM_BASE STM32MP_SYSRAM_BASE
  105. #define STM32MP_SEC_SYSRAM_SIZE (STM32MP_SYSRAM_SIZE - \
  106. STM32MP_NS_SYSRAM_SIZE)
  107. /* DDR configuration */
  108. #define STM32MP_DDR_BASE U(0xC0000000)
  109. #define STM32MP_DDR_MAX_SIZE U(0x40000000) /* Max 1GB */
  110. /* DDR power initializations */
  111. #ifndef __ASSEMBLER__
  112. enum ddr_type {
  113. STM32MP_DDR3,
  114. STM32MP_LPDDR2,
  115. STM32MP_LPDDR3
  116. };
  117. #endif
  118. /* Section used inside TF binaries */
  119. #if STM32MP13
  120. /* 512 Octets reserved for header */
  121. #define STM32MP_HEADER_RESERVED_SIZE U(0x200)
  122. #define STM32MP_BINARY_BASE STM32MP_SEC_SYSRAM_BASE
  123. #define STM32MP_BINARY_SIZE STM32MP_SEC_SYSRAM_SIZE
  124. #endif
  125. #if STM32MP15
  126. #define STM32MP_PARAM_LOAD_SIZE U(0x00002400) /* 9 KB for param */
  127. /* 256 Octets reserved for header */
  128. #define STM32MP_HEADER_SIZE U(0x00000100)
  129. /* round_up(STM32MP_PARAM_LOAD_SIZE + STM32MP_HEADER_SIZE, PAGE_SIZE) */
  130. #define STM32MP_HEADER_RESERVED_SIZE U(0x3000)
  131. #define STM32MP_BINARY_BASE (STM32MP_SEC_SYSRAM_BASE + \
  132. STM32MP_PARAM_LOAD_SIZE + \
  133. STM32MP_HEADER_SIZE)
  134. #define STM32MP_BINARY_SIZE (STM32MP_SEC_SYSRAM_SIZE - \
  135. (STM32MP_PARAM_LOAD_SIZE + \
  136. STM32MP_HEADER_SIZE))
  137. #endif
  138. /* BL2 and BL32/sp_min require finer granularity tables */
  139. #if defined(IMAGE_BL2)
  140. #define MAX_XLAT_TABLES U(2) /* 8 KB for mapping */
  141. #endif
  142. #if defined(IMAGE_BL32)
  143. #define MAX_XLAT_TABLES U(4) /* 16 KB for mapping */
  144. #endif
  145. /*
  146. * MAX_MMAP_REGIONS is usually:
  147. * BL stm32mp1_mmap size + mmap regions in *_plat_arch_setup
  148. */
  149. #if defined(IMAGE_BL2)
  150. #if STM32MP_USB_PROGRAMMER
  151. #define MAX_MMAP_REGIONS 8
  152. #else
  153. #define MAX_MMAP_REGIONS 7
  154. #endif
  155. #endif
  156. #if STM32MP13
  157. #define STM32MP_BL33_BASE STM32MP_DDR_BASE
  158. #endif
  159. #if STM32MP15
  160. #define STM32MP_BL33_BASE (STM32MP_DDR_BASE + U(0x100000))
  161. #endif
  162. #define STM32MP_BL33_MAX_SIZE U(0x400000)
  163. /* Define location for the MTD scratch buffer */
  164. #if STM32MP13
  165. #define STM32MP_MTD_BUFFER (SRAM1_BASE + \
  166. SRAM1_SIZE - \
  167. PLATFORM_MTD_MAX_PAGE_SIZE)
  168. #endif
  169. /*******************************************************************************
  170. * STM32MP1 device/io map related constants (used for MMU)
  171. ******************************************************************************/
  172. #define STM32MP1_DEVICE1_BASE U(0x40000000)
  173. #define STM32MP1_DEVICE1_SIZE U(0x40000000)
  174. #define STM32MP1_DEVICE2_BASE U(0x80000000)
  175. #define STM32MP1_DEVICE2_SIZE U(0x40000000)
  176. /*******************************************************************************
  177. * STM32MP1 RCC
  178. ******************************************************************************/
  179. #define RCC_BASE U(0x50000000)
  180. /*******************************************************************************
  181. * STM32MP1 PWR
  182. ******************************************************************************/
  183. #define PWR_BASE U(0x50001000)
  184. /*******************************************************************************
  185. * STM32MP1 GPIO
  186. ******************************************************************************/
  187. #define GPIOA_BASE U(0x50002000)
  188. #define GPIOB_BASE U(0x50003000)
  189. #define GPIOC_BASE U(0x50004000)
  190. #define GPIOD_BASE U(0x50005000)
  191. #define GPIOE_BASE U(0x50006000)
  192. #define GPIOF_BASE U(0x50007000)
  193. #define GPIOG_BASE U(0x50008000)
  194. #define GPIOH_BASE U(0x50009000)
  195. #define GPIOI_BASE U(0x5000A000)
  196. #if STM32MP15
  197. #define GPIOJ_BASE U(0x5000B000)
  198. #define GPIOK_BASE U(0x5000C000)
  199. #define GPIOZ_BASE U(0x54004000)
  200. #endif
  201. #define GPIO_BANK_OFFSET U(0x1000)
  202. #if STM32MP15
  203. #define STM32MP_GPIOZ_PIN_MAX_COUNT 8
  204. #endif
  205. /*******************************************************************************
  206. * STM32MP1 UART
  207. ******************************************************************************/
  208. #if STM32MP13
  209. #define USART1_BASE U(0x4C000000)
  210. #define USART2_BASE U(0x4C001000)
  211. #endif
  212. #if STM32MP15
  213. #define USART1_BASE U(0x5C000000)
  214. #define USART2_BASE U(0x4000E000)
  215. #endif
  216. #define USART3_BASE U(0x4000F000)
  217. #define UART4_BASE U(0x40010000)
  218. #define UART5_BASE U(0x40011000)
  219. #define USART6_BASE U(0x44003000)
  220. #define UART7_BASE U(0x40018000)
  221. #define UART8_BASE U(0x40019000)
  222. /* For UART crash console */
  223. #define STM32MP_DEBUG_USART_BASE UART4_BASE
  224. #if STM32MP13
  225. /* UART4 on HSI@64MHz, TX on GPIOF12 Alternate 8 (Disco board) */
  226. #define STM32MP_DEBUG_USART_CLK_FRQ 64000000
  227. #define DEBUG_UART_TX_GPIO_BANK_ADDRESS GPIOD_BASE
  228. #define DEBUG_UART_TX_GPIO_BANK_CLK_REG RCC_MP_S_AHB4ENSETR
  229. #define DEBUG_UART_TX_GPIO_BANK_CLK_EN RCC_MP_S_AHB4ENSETR_GPIODEN
  230. #define DEBUG_UART_TX_GPIO_PORT 6
  231. #define DEBUG_UART_TX_GPIO_ALTERNATE 8
  232. #define DEBUG_UART_TX_CLKSRC_REG RCC_UART4CKSELR
  233. #define DEBUG_UART_TX_CLKSRC RCC_UART4CKSELR_HSI
  234. #endif /* STM32MP13 */
  235. #if STM32MP15
  236. /* UART4 on HSI@64MHz, TX on GPIOG11 Alternate 6 */
  237. #define STM32MP_DEBUG_USART_CLK_FRQ 64000000
  238. #define DEBUG_UART_TX_GPIO_BANK_ADDRESS GPIOG_BASE
  239. #define DEBUG_UART_TX_GPIO_BANK_CLK_REG RCC_MP_AHB4ENSETR
  240. #define DEBUG_UART_TX_GPIO_BANK_CLK_EN RCC_MP_AHB4ENSETR_GPIOGEN
  241. #define DEBUG_UART_TX_GPIO_PORT 11
  242. #define DEBUG_UART_TX_GPIO_ALTERNATE 6
  243. #define DEBUG_UART_TX_CLKSRC_REG RCC_UART24CKSELR
  244. #define DEBUG_UART_TX_CLKSRC RCC_UART24CKSELR_HSI
  245. #endif /* STM32MP15 */
  246. #define DEBUG_UART_TX_EN_REG RCC_MP_APB1ENSETR
  247. #define DEBUG_UART_TX_EN RCC_MP_APB1ENSETR_UART4EN
  248. #define DEBUG_UART_RST_REG RCC_APB1RSTSETR
  249. #define DEBUG_UART_RST_BIT RCC_APB1RSTSETR_UART4RST
  250. /*******************************************************************************
  251. * STM32MP1 ETZPC
  252. ******************************************************************************/
  253. #define STM32MP1_ETZPC_BASE U(0x5C007000)
  254. /* ETZPC TZMA IDs */
  255. #define STM32MP1_ETZPC_TZMA_ROM U(0)
  256. #define STM32MP1_ETZPC_TZMA_SYSRAM U(1)
  257. #define STM32MP1_ETZPC_TZMA_ALL_SECURE GENMASK_32(9, 0)
  258. /* ETZPC DECPROT IDs */
  259. #define STM32MP1_ETZPC_STGENC_ID 0
  260. #define STM32MP1_ETZPC_BKPSRAM_ID 1
  261. #define STM32MP1_ETZPC_IWDG1_ID 2
  262. #define STM32MP1_ETZPC_USART1_ID 3
  263. #define STM32MP1_ETZPC_SPI6_ID 4
  264. #define STM32MP1_ETZPC_I2C4_ID 5
  265. #define STM32MP1_ETZPC_RNG1_ID 7
  266. #define STM32MP1_ETZPC_HASH1_ID 8
  267. #define STM32MP1_ETZPC_CRYP1_ID 9
  268. #define STM32MP1_ETZPC_DDRCTRL_ID 10
  269. #define STM32MP1_ETZPC_DDRPHYC_ID 11
  270. #define STM32MP1_ETZPC_I2C6_ID 12
  271. #define STM32MP1_ETZPC_SEC_ID_LIMIT 13
  272. #define STM32MP1_ETZPC_TIM2_ID 16
  273. #define STM32MP1_ETZPC_TIM3_ID 17
  274. #define STM32MP1_ETZPC_TIM4_ID 18
  275. #define STM32MP1_ETZPC_TIM5_ID 19
  276. #define STM32MP1_ETZPC_TIM6_ID 20
  277. #define STM32MP1_ETZPC_TIM7_ID 21
  278. #define STM32MP1_ETZPC_TIM12_ID 22
  279. #define STM32MP1_ETZPC_TIM13_ID 23
  280. #define STM32MP1_ETZPC_TIM14_ID 24
  281. #define STM32MP1_ETZPC_LPTIM1_ID 25
  282. #define STM32MP1_ETZPC_WWDG1_ID 26
  283. #define STM32MP1_ETZPC_SPI2_ID 27
  284. #define STM32MP1_ETZPC_SPI3_ID 28
  285. #define STM32MP1_ETZPC_SPDIFRX_ID 29
  286. #define STM32MP1_ETZPC_USART2_ID 30
  287. #define STM32MP1_ETZPC_USART3_ID 31
  288. #define STM32MP1_ETZPC_UART4_ID 32
  289. #define STM32MP1_ETZPC_UART5_ID 33
  290. #define STM32MP1_ETZPC_I2C1_ID 34
  291. #define STM32MP1_ETZPC_I2C2_ID 35
  292. #define STM32MP1_ETZPC_I2C3_ID 36
  293. #define STM32MP1_ETZPC_I2C5_ID 37
  294. #define STM32MP1_ETZPC_CEC_ID 38
  295. #define STM32MP1_ETZPC_DAC_ID 39
  296. #define STM32MP1_ETZPC_UART7_ID 40
  297. #define STM32MP1_ETZPC_UART8_ID 41
  298. #define STM32MP1_ETZPC_MDIOS_ID 44
  299. #define STM32MP1_ETZPC_TIM1_ID 48
  300. #define STM32MP1_ETZPC_TIM8_ID 49
  301. #define STM32MP1_ETZPC_USART6_ID 51
  302. #define STM32MP1_ETZPC_SPI1_ID 52
  303. #define STM32MP1_ETZPC_SPI4_ID 53
  304. #define STM32MP1_ETZPC_TIM15_ID 54
  305. #define STM32MP1_ETZPC_TIM16_ID 55
  306. #define STM32MP1_ETZPC_TIM17_ID 56
  307. #define STM32MP1_ETZPC_SPI5_ID 57
  308. #define STM32MP1_ETZPC_SAI1_ID 58
  309. #define STM32MP1_ETZPC_SAI2_ID 59
  310. #define STM32MP1_ETZPC_SAI3_ID 60
  311. #define STM32MP1_ETZPC_DFSDM_ID 61
  312. #define STM32MP1_ETZPC_TT_FDCAN_ID 62
  313. #define STM32MP1_ETZPC_LPTIM2_ID 64
  314. #define STM32MP1_ETZPC_LPTIM3_ID 65
  315. #define STM32MP1_ETZPC_LPTIM4_ID 66
  316. #define STM32MP1_ETZPC_LPTIM5_ID 67
  317. #define STM32MP1_ETZPC_SAI4_ID 68
  318. #define STM32MP1_ETZPC_VREFBUF_ID 69
  319. #define STM32MP1_ETZPC_DCMI_ID 70
  320. #define STM32MP1_ETZPC_CRC2_ID 71
  321. #define STM32MP1_ETZPC_ADC_ID 72
  322. #define STM32MP1_ETZPC_HASH2_ID 73
  323. #define STM32MP1_ETZPC_RNG2_ID 74
  324. #define STM32MP1_ETZPC_CRYP2_ID 75
  325. #define STM32MP1_ETZPC_SRAM1_ID 80
  326. #define STM32MP1_ETZPC_SRAM2_ID 81
  327. #define STM32MP1_ETZPC_SRAM3_ID 82
  328. #define STM32MP1_ETZPC_SRAM4_ID 83
  329. #define STM32MP1_ETZPC_RETRAM_ID 84
  330. #define STM32MP1_ETZPC_OTG_ID 85
  331. #define STM32MP1_ETZPC_SDMMC3_ID 86
  332. #define STM32MP1_ETZPC_DLYBSD3_ID 87
  333. #define STM32MP1_ETZPC_DMA1_ID 88
  334. #define STM32MP1_ETZPC_DMA2_ID 89
  335. #define STM32MP1_ETZPC_DMAMUX_ID 90
  336. #define STM32MP1_ETZPC_FMC_ID 91
  337. #define STM32MP1_ETZPC_QSPI_ID 92
  338. #define STM32MP1_ETZPC_DLYBQ_ID 93
  339. #define STM32MP1_ETZPC_ETH_ID 94
  340. #define STM32MP1_ETZPC_RSV_ID 95
  341. #define STM32MP_ETZPC_MAX_ID 96
  342. /*******************************************************************************
  343. * STM32MP1 TZC (TZ400)
  344. ******************************************************************************/
  345. #define STM32MP1_TZC_BASE U(0x5C006000)
  346. #if STM32MP13
  347. #define STM32MP1_FILTER_BIT_ALL TZC_400_REGION_ATTR_FILTER_BIT(0)
  348. #endif
  349. #if STM32MP15
  350. #define STM32MP1_FILTER_BIT_ALL (TZC_400_REGION_ATTR_FILTER_BIT(0) | \
  351. TZC_400_REGION_ATTR_FILTER_BIT(1))
  352. #endif
  353. /*******************************************************************************
  354. * STM32MP1 SDMMC
  355. ******************************************************************************/
  356. #define STM32MP_SDMMC1_BASE U(0x58005000)
  357. #define STM32MP_SDMMC2_BASE U(0x58007000)
  358. #define STM32MP_SDMMC3_BASE U(0x48004000)
  359. /*******************************************************************************
  360. * STM32MP1 BSEC / OTP
  361. ******************************************************************************/
  362. #define STM32MP1_OTP_MAX_ID 0x5FU
  363. #define STM32MP1_UPPER_OTP_START 0x20U
  364. #define OTP_MAX_SIZE (STM32MP1_OTP_MAX_ID + 1U)
  365. /* OTP labels */
  366. #define CFG0_OTP "cfg0-otp"
  367. #define PART_NUMBER_OTP "part-number-otp"
  368. #if STM32MP15
  369. #define PACKAGE_OTP "package-otp"
  370. #endif
  371. #define HW2_OTP "hw2-otp"
  372. #if STM32MP13
  373. #define NAND_OTP "cfg9-otp"
  374. #define NAND2_OTP "cfg10-otp"
  375. #endif
  376. #if STM32MP15
  377. #define NAND_OTP "nand-otp"
  378. #endif
  379. #define MONOTONIC_OTP "monotonic-otp"
  380. #define UID_OTP "uid-otp"
  381. #define PKH_OTP "pkh-otp"
  382. #define ENCKEY_OTP "oem-enc-key"
  383. #define BOARD_ID_OTP "board-id"
  384. /* OTP mask */
  385. /* CFG0 */
  386. #if STM32MP13
  387. #define CFG0_OTP_MODE_MASK GENMASK_32(9, 0)
  388. #define CFG0_OTP_MODE_SHIFT 0
  389. #define CFG0_OPEN_DEVICE 0x17U
  390. #define CFG0_CLOSED_DEVICE 0x3FU
  391. #define CFG0_CLOSED_DEVICE_NO_BOUNDARY_SCAN 0x17FU
  392. #define CFG0_CLOSED_DEVICE_NO_JTAG 0x3FFU
  393. #endif
  394. #if STM32MP15
  395. #define CFG0_CLOSED_DEVICE BIT(6)
  396. #endif
  397. /* PART NUMBER */
  398. #if STM32MP13
  399. #define PART_NUMBER_OTP_PART_MASK GENMASK_32(11, 0)
  400. #endif
  401. #if STM32MP15
  402. #define PART_NUMBER_OTP_PART_MASK GENMASK_32(7, 0)
  403. #endif
  404. #define PART_NUMBER_OTP_PART_SHIFT 0
  405. /* PACKAGE */
  406. #if STM32MP15
  407. #define PACKAGE_OTP_PKG_MASK GENMASK_32(29, 27)
  408. #define PACKAGE_OTP_PKG_SHIFT 27
  409. #endif
  410. /* IWDG OTP */
  411. #define HW2_OTP_IWDG_HW_POS U(3)
  412. #define HW2_OTP_IWDG_FZ_STOP_POS U(5)
  413. #define HW2_OTP_IWDG_FZ_STANDBY_POS U(7)
  414. /* HW2 OTP */
  415. #define HW2_OTP_PRODUCT_BELOW_2V5 BIT(13)
  416. /* NAND OTP */
  417. /* NAND parameter storage flag */
  418. #define NAND_PARAM_STORED_IN_OTP BIT(31)
  419. /* NAND page size in bytes */
  420. #define NAND_PAGE_SIZE_MASK GENMASK_32(30, 29)
  421. #define NAND_PAGE_SIZE_SHIFT 29
  422. #define NAND_PAGE_SIZE_2K U(0)
  423. #define NAND_PAGE_SIZE_4K U(1)
  424. #define NAND_PAGE_SIZE_8K U(2)
  425. /* NAND block size in pages */
  426. #define NAND_BLOCK_SIZE_MASK GENMASK_32(28, 27)
  427. #define NAND_BLOCK_SIZE_SHIFT 27
  428. #define NAND_BLOCK_SIZE_64_PAGES U(0)
  429. #define NAND_BLOCK_SIZE_128_PAGES U(1)
  430. #define NAND_BLOCK_SIZE_256_PAGES U(2)
  431. /* NAND number of block (in unit of 256 blocks) */
  432. #define NAND_BLOCK_NB_MASK GENMASK_32(26, 19)
  433. #define NAND_BLOCK_NB_SHIFT 19
  434. #define NAND_BLOCK_NB_UNIT U(256)
  435. /* NAND bus width in bits */
  436. #define NAND_WIDTH_MASK BIT(18)
  437. #define NAND_WIDTH_SHIFT 18
  438. /* NAND number of ECC bits per 512 bytes */
  439. #define NAND_ECC_BIT_NB_MASK GENMASK_32(17, 15)
  440. #define NAND_ECC_BIT_NB_SHIFT 15
  441. #define NAND_ECC_BIT_NB_UNSET U(0)
  442. #define NAND_ECC_BIT_NB_1_BITS U(1)
  443. #define NAND_ECC_BIT_NB_4_BITS U(2)
  444. #define NAND_ECC_BIT_NB_8_BITS U(3)
  445. #define NAND_ECC_ON_DIE U(4)
  446. /* NAND number of planes */
  447. #define NAND_PLANE_BIT_NB_MASK BIT(14)
  448. /* NAND2 OTP */
  449. #define NAND2_PAGE_SIZE_SHIFT 16
  450. /* NAND2 config distribution */
  451. #define NAND2_CONFIG_DISTRIB BIT(0)
  452. #define NAND2_PNAND_NAND2_SNAND_NAND1 U(0)
  453. #define NAND2_PNAND_NAND1_SNAND_NAND2 U(1)
  454. /* MONOTONIC OTP */
  455. #define MAX_MONOTONIC_VALUE 32
  456. /* UID OTP */
  457. #define UID_WORD_NB U(3)
  458. /*******************************************************************************
  459. * STM32MP1 TAMP
  460. ******************************************************************************/
  461. #define TAMP_BASE U(0x5C00A000)
  462. #define TAMP_BKP_REGISTER_BASE (TAMP_BASE + U(0x100))
  463. #define TAMP_BKP_REG_CLK RTCAPB
  464. #define TAMP_COUNTR U(0x40)
  465. #if !(defined(__LINKER__) || defined(__ASSEMBLER__))
  466. static inline uintptr_t tamp_bkpr(uint32_t idx)
  467. {
  468. return TAMP_BKP_REGISTER_BASE + (idx << 2);
  469. }
  470. #endif
  471. /*******************************************************************************
  472. * STM32MP1 USB
  473. ******************************************************************************/
  474. #define USB_OTG_BASE U(0x49000000)
  475. /*******************************************************************************
  476. * STM32MP1 DDRCTRL
  477. ******************************************************************************/
  478. #define DDRCTRL_BASE U(0x5A003000)
  479. /*******************************************************************************
  480. * STM32MP1 DDRPHYC
  481. ******************************************************************************/
  482. #define DDRPHYC_BASE U(0x5A004000)
  483. /*******************************************************************************
  484. * STM32MP1 IWDG
  485. ******************************************************************************/
  486. #define IWDG_MAX_INSTANCE U(2)
  487. #define IWDG1_INST U(0)
  488. #define IWDG2_INST U(1)
  489. #define IWDG1_BASE U(0x5C003000)
  490. #define IWDG2_BASE U(0x5A002000)
  491. /*******************************************************************************
  492. * Miscellaneous STM32MP1 peripherals base address
  493. ******************************************************************************/
  494. #define BSEC_BASE U(0x5C005000)
  495. #if STM32MP13
  496. #define CRYP_BASE U(0x54002000)
  497. #endif
  498. #if STM32MP15
  499. #define CRYP1_BASE U(0x54001000)
  500. #endif
  501. #define DBGMCU_BASE U(0x50081000)
  502. #if STM32MP13
  503. #define HASH_BASE U(0x54003000)
  504. #endif
  505. #if STM32MP15
  506. #define HASH1_BASE U(0x54002000)
  507. #endif
  508. #if STM32MP13
  509. #define I2C3_BASE U(0x4C004000)
  510. #define I2C4_BASE U(0x4C005000)
  511. #define I2C5_BASE U(0x4C006000)
  512. #endif
  513. #if STM32MP15
  514. #define I2C4_BASE U(0x5C002000)
  515. #define I2C6_BASE U(0x5c009000)
  516. #endif
  517. #if STM32MP13
  518. #define RNG_BASE U(0x54004000)
  519. #endif
  520. #if STM32MP15
  521. #define RNG1_BASE U(0x54003000)
  522. #endif
  523. #define RTC_BASE U(0x5c004000)
  524. #if STM32MP13
  525. #define SPI4_BASE U(0x4C002000)
  526. #define SPI5_BASE U(0x4C003000)
  527. #endif
  528. #if STM32MP15
  529. #define SPI6_BASE U(0x5c001000)
  530. #endif
  531. #define STGEN_BASE U(0x5c008000)
  532. #define SYSCFG_BASE U(0x50020000)
  533. /*******************************************************************************
  534. * STM32MP13 SAES
  535. ******************************************************************************/
  536. #define SAES_BASE U(0x54005000)
  537. /*******************************************************************************
  538. * STM32MP13 PKA
  539. ******************************************************************************/
  540. #define PKA_BASE U(0x54006000)
  541. /*******************************************************************************
  542. * REGULATORS
  543. ******************************************************************************/
  544. /* 3 PWR + 1 VREFBUF + 14 PMIC regulators + 1 FIXED */
  545. #define PLAT_NB_RDEVS U(19)
  546. /* 2 FIXED */
  547. #define PLAT_NB_FIXED_REGUS U(2)
  548. /*******************************************************************************
  549. * STM32MP1 CLOCKS
  550. ******************************************************************************/
  551. #define PLL1_NOMINAL_FREQ_IN_KHZ U(650000) /* 650MHz */
  552. /*******************************************************************************
  553. * Device Tree defines
  554. ******************************************************************************/
  555. #if STM32MP13
  556. #define DT_BSEC_COMPAT "st,stm32mp13-bsec"
  557. #define DT_DDR_COMPAT "st,stm32mp13-ddr"
  558. #endif
  559. #if STM32MP15
  560. #define DT_BSEC_COMPAT "st,stm32mp15-bsec"
  561. #define DT_DDR_COMPAT "st,stm32mp1-ddr"
  562. #endif
  563. #define DT_IWDG_COMPAT "st,stm32mp1-iwdg"
  564. #define DT_PWR_COMPAT "st,stm32mp1,pwr-reg"
  565. #if STM32MP13
  566. #define DT_RCC_CLK_COMPAT "st,stm32mp13-rcc"
  567. #define DT_RCC_SEC_CLK_COMPAT "st,stm32mp13-rcc-secure"
  568. #endif
  569. #if STM32MP15
  570. #define DT_RCC_CLK_COMPAT "st,stm32mp1-rcc"
  571. #define DT_RCC_SEC_CLK_COMPAT "st,stm32mp1-rcc-secure"
  572. #endif
  573. #define DT_SDMMC2_COMPAT "st,stm32-sdmmc2"
  574. #define DT_UART_COMPAT "st,stm32h7-uart"
  575. #endif /* STM32MP1_DEF_H */