stm32mp1_ddr_regs.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. /*
  2. * Copyright (c) 2017-2022, STMicroelectronics - All Rights Reserved
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
  5. */
  6. #ifndef STM32MP1_DDR_REGS_H
  7. #define STM32MP1_DDR_REGS_H
  8. #include <drivers/st/stm32mp_ddrctrl_regs.h>
  9. #include <lib/utils_def.h>
  10. /* DDR Physical Interface Control (DDRPHYC) registers*/
  11. struct stm32mp_ddrphy {
  12. uint32_t ridr; /* 0x00 R Revision Identification */
  13. uint32_t pir; /* 0x04 R/W PHY Initialization */
  14. uint32_t pgcr; /* 0x08 R/W PHY General Configuration */
  15. uint32_t pgsr; /* 0x0C PHY General Status */
  16. uint32_t dllgcr; /* 0x10 R/W DLL General Control */
  17. uint32_t acdllcr; /* 0x14 R/W AC DLL Control */
  18. uint32_t ptr0; /* 0x18 R/W PHY Timing 0 */
  19. uint32_t ptr1; /* 0x1C R/W PHY Timing 1 */
  20. uint32_t ptr2; /* 0x20 R/W PHY Timing 2 */
  21. uint32_t aciocr; /* 0x24 AC I/O Configuration */
  22. uint32_t dxccr; /* 0x28 DATX8 Common Configuration */
  23. uint32_t dsgcr; /* 0x2C DDR System General Configuration */
  24. uint32_t dcr; /* 0x30 DRAM Configuration */
  25. uint32_t dtpr0; /* 0x34 DRAM Timing Parameters0 */
  26. uint32_t dtpr1; /* 0x38 DRAM Timing Parameters1 */
  27. uint32_t dtpr2; /* 0x3C DRAM Timing Parameters2 */
  28. uint32_t mr0; /* 0x40 Mode 0 */
  29. uint32_t mr1; /* 0x44 Mode 1 */
  30. uint32_t mr2; /* 0x48 Mode 2 */
  31. uint32_t mr3; /* 0x4C Mode 3 */
  32. uint32_t odtcr; /* 0x50 ODT Configuration */
  33. uint32_t dtar; /* 0x54 data training address */
  34. uint32_t dtdr0; /* 0x58 */
  35. uint32_t dtdr1; /* 0x5c */
  36. uint8_t res1[0x0c0 - 0x060]; /* 0x60 */
  37. uint32_t dcuar; /* 0xc0 Address */
  38. uint32_t dcudr; /* 0xc4 DCU Data */
  39. uint32_t dcurr; /* 0xc8 DCU Run */
  40. uint32_t dculr; /* 0xcc DCU Loop */
  41. uint32_t dcugcr; /* 0xd0 DCU General Configuration */
  42. uint32_t dcutpr; /* 0xd4 DCU Timing Parameters */
  43. uint32_t dcusr0; /* 0xd8 DCU Status 0 */
  44. uint32_t dcusr1; /* 0xdc DCU Status 1 */
  45. uint8_t res2[0x100 - 0xe0]; /* 0xe0 */
  46. uint32_t bistrr; /* 0x100 BIST Run */
  47. uint32_t bistmskr0; /* 0x104 BIST Mask 0 */
  48. uint32_t bistmskr1; /* 0x108 BIST Mask 0 */
  49. uint32_t bistwcr; /* 0x10c BIST Word Count */
  50. uint32_t bistlsr; /* 0x110 BIST LFSR Seed */
  51. uint32_t bistar0; /* 0x114 BIST Address 0 */
  52. uint32_t bistar1; /* 0x118 BIST Address 1 */
  53. uint32_t bistar2; /* 0x11c BIST Address 2 */
  54. uint32_t bistupdr; /* 0x120 BIST User Data Pattern */
  55. uint32_t bistgsr; /* 0x124 BIST General Status */
  56. uint32_t bistwer; /* 0x128 BIST Word Error */
  57. uint32_t bistber0; /* 0x12c BIST Bit Error 0 */
  58. uint32_t bistber1; /* 0x130 BIST Bit Error 1 */
  59. uint32_t bistber2; /* 0x134 BIST Bit Error 2 */
  60. uint32_t bistwcsr; /* 0x138 BIST Word Count Status */
  61. uint32_t bistfwr0; /* 0x13c BIST Fail Word 0 */
  62. uint32_t bistfwr1; /* 0x140 BIST Fail Word 1 */
  63. uint8_t res3[0x178 - 0x144]; /* 0x144 */
  64. uint32_t gpr0; /* 0x178 General Purpose 0 (GPR0) */
  65. uint32_t gpr1; /* 0x17C General Purpose 1 (GPR1) */
  66. uint32_t zq0cr0; /* 0x180 zq 0 control 0 */
  67. uint32_t zq0cr1; /* 0x184 zq 0 control 1 */
  68. uint32_t zq0sr0; /* 0x188 zq 0 status 0 */
  69. uint32_t zq0sr1; /* 0x18C zq 0 status 1 */
  70. uint8_t res4[0x1C0 - 0x190]; /* 0x190 */
  71. uint32_t dx0gcr; /* 0x1c0 Byte lane 0 General Configuration */
  72. uint32_t dx0gsr0; /* 0x1c4 Byte lane 0 General Status 0 */
  73. uint32_t dx0gsr1; /* 0x1c8 Byte lane 0 General Status 1 */
  74. uint32_t dx0dllcr; /* 0x1cc Byte lane 0 DLL Control */
  75. uint32_t dx0dqtr; /* 0x1d0 Byte lane 0 DQ Timing */
  76. uint32_t dx0dqstr; /* 0x1d4 Byte lane 0 DQS Timing */
  77. uint8_t res5[0x200 - 0x1d8]; /* 0x1d8 */
  78. uint32_t dx1gcr; /* 0x200 Byte lane 1 General Configuration */
  79. uint32_t dx1gsr0; /* 0x204 Byte lane 1 General Status 0 */
  80. uint32_t dx1gsr1; /* 0x208 Byte lane 1 General Status 1 */
  81. uint32_t dx1dllcr; /* 0x20c Byte lane 1 DLL Control */
  82. uint32_t dx1dqtr; /* 0x210 Byte lane 1 DQ Timing */
  83. uint32_t dx1dqstr; /* 0x214 Byte lane 1 QS Timing */
  84. uint8_t res6[0x240 - 0x218]; /* 0x218 */
  85. #if STM32MP_DDR_32BIT_INTERFACE
  86. uint32_t dx2gcr; /* 0x240 Byte lane 2 General Configuration */
  87. uint32_t dx2gsr0; /* 0x244 Byte lane 2 General Status 0 */
  88. uint32_t dx2gsr1; /* 0x248 Byte lane 2 General Status 1 */
  89. uint32_t dx2dllcr; /* 0x24c Byte lane 2 DLL Control */
  90. uint32_t dx2dqtr; /* 0x250 Byte lane 2 DQ Timing */
  91. uint32_t dx2dqstr; /* 0x254 Byte lane 2 QS Timing */
  92. uint8_t res7[0x280 - 0x258]; /* 0x258 */
  93. uint32_t dx3gcr; /* 0x280 Byte lane 3 General Configuration */
  94. uint32_t dx3gsr0; /* 0x284 Byte lane 3 General Status 0 */
  95. uint32_t dx3gsr1; /* 0x288 Byte lane 3 General Status 1 */
  96. uint32_t dx3dllcr; /* 0x28c Byte lane 3 DLL Control */
  97. uint32_t dx3dqtr; /* 0x290 Byte lane 3 DQ Timing */
  98. uint32_t dx3dqstr; /* 0x294 Byte lane 3 QS Timing */
  99. #endif
  100. } __packed;
  101. /* DDR PHY registers offsets */
  102. #define DDRPHYC_PIR 0x004
  103. #define DDRPHYC_PGCR 0x008
  104. #define DDRPHYC_PGSR 0x00C
  105. #define DDRPHYC_DLLGCR 0x010
  106. #define DDRPHYC_ACDLLCR 0x014
  107. #define DDRPHYC_PTR0 0x018
  108. #define DDRPHYC_ACIOCR 0x024
  109. #define DDRPHYC_DXCCR 0x028
  110. #define DDRPHYC_DSGCR 0x02C
  111. #define DDRPHYC_ZQ0CR0 0x180
  112. #define DDRPHYC_DX0GCR 0x1C0
  113. #define DDRPHYC_DX0DLLCR 0x1CC
  114. #define DDRPHYC_DX1GCR 0x200
  115. #define DDRPHYC_DX1DLLCR 0x20C
  116. #if STM32MP_DDR_32BIT_INTERFACE
  117. #define DDRPHYC_DX2GCR 0x240
  118. #define DDRPHYC_DX2DLLCR 0x24C
  119. #define DDRPHYC_DX3GCR 0x280
  120. #define DDRPHYC_DX3DLLCR 0x28C
  121. #endif
  122. /* DDR PHY Register fields */
  123. #define DDRPHYC_PIR_INIT BIT(0)
  124. #define DDRPHYC_PIR_DLLSRST BIT(1)
  125. #define DDRPHYC_PIR_DLLLOCK BIT(2)
  126. #define DDRPHYC_PIR_ZCAL BIT(3)
  127. #define DDRPHYC_PIR_ITMSRST BIT(4)
  128. #define DDRPHYC_PIR_DRAMRST BIT(5)
  129. #define DDRPHYC_PIR_DRAMINIT BIT(6)
  130. #define DDRPHYC_PIR_QSTRN BIT(7)
  131. #define DDRPHYC_PIR_RVTRN BIT(8)
  132. #define DDRPHYC_PIR_ICPC BIT(16)
  133. #define DDRPHYC_PIR_ZCALBYP BIT(30)
  134. #define DDRPHYC_PIR_INITSTEPS_MASK GENMASK(31, 7)
  135. #define DDRPHYC_PGCR_DFTCMP BIT(2)
  136. #define DDRPHYC_PGCR_PDDISDX BIT(24)
  137. #define DDRPHYC_PGCR_RFSHDT_MASK GENMASK(28, 25)
  138. #define DDRPHYC_PGSR_IDONE BIT(0)
  139. #define DDRPHYC_PGSR_DTERR BIT(5)
  140. #define DDRPHYC_PGSR_DTIERR BIT(6)
  141. #define DDRPHYC_PGSR_DFTERR BIT(7)
  142. #define DDRPHYC_PGSR_RVERR BIT(8)
  143. #define DDRPHYC_PGSR_RVEIRR BIT(9)
  144. #define DDRPHYC_DLLGCR_BPS200 BIT(23)
  145. #define DDRPHYC_ACDLLCR_DLLSRST BIT(30)
  146. #define DDRPHYC_ACDLLCR_DLLDIS BIT(31)
  147. #define DDRPHYC_PTR0_TDLLSRST_OFFSET 0
  148. #define DDRPHYC_PTR0_TDLLSRST_MASK GENMASK(5, 0)
  149. #define DDRPHYC_PTR0_TDLLLOCK_OFFSET 6
  150. #define DDRPHYC_PTR0_TDLLLOCK_MASK GENMASK(17, 6)
  151. #define DDRPHYC_PTR0_TITMSRST_OFFSET 18
  152. #define DDRPHYC_PTR0_TITMSRST_MASK GENMASK(21, 18)
  153. #define DDRPHYC_ACIOCR_ACPDD BIT(3)
  154. #define DDRPHYC_ACIOCR_ACPDR BIT(4)
  155. #define DDRPHYC_ACIOCR_CKPDD_MASK GENMASK(10, 8)
  156. #define DDRPHYC_ACIOCR_CKPDD_0 BIT(8)
  157. #define DDRPHYC_ACIOCR_CKPDR_MASK GENMASK(13, 11)
  158. #define DDRPHYC_ACIOCR_CKPDR_0 BIT(11)
  159. #define DDRPHYC_ACIOCR_CSPDD_MASK GENMASK(21, 18)
  160. #define DDRPHYC_ACIOCR_CSPDD_0 BIT(18)
  161. #define DDRPHYC_ACIOCR_RSTPDD BIT(27)
  162. #define DDRPHYC_ACIOCR_RSTPDR BIT(28)
  163. #define DDRPHYC_DXCCR_DXPDD BIT(2)
  164. #define DDRPHYC_DXCCR_DXPDR BIT(3)
  165. #define DDRPHYC_DSGCR_CKEPDD_MASK GENMASK(19, 16)
  166. #define DDRPHYC_DSGCR_CKEPDD_0 BIT(16)
  167. #define DDRPHYC_DSGCR_ODTPDD_MASK GENMASK(23, 20)
  168. #define DDRPHYC_DSGCR_ODTPDD_0 BIT(20)
  169. #define DDRPHYC_DSGCR_NL2PD BIT(24)
  170. #define DDRPHYC_ZQ0CRN_ZDATA_MASK GENMASK(27, 0)
  171. #define DDRPHYC_ZQ0CRN_ZDATA_SHIFT 0
  172. #define DDRPHYC_ZQ0CRN_ZDEN BIT(28)
  173. #define DDRPHYC_ZQ0CRN_ZQPD BIT(31)
  174. #define DDRPHYC_DXNGCR_DXEN BIT(0)
  175. #define DDRPHYC_DXNDLLCR_DLLSRST BIT(30)
  176. #define DDRPHYC_DXNDLLCR_DLLDIS BIT(31)
  177. #define DDRPHYC_DXNDLLCR_SDPHASE_MASK GENMASK(17, 14)
  178. #define DDRPHYC_DXNDLLCR_SDPHASE_SHIFT 14
  179. #endif /* STM32MP1_DDR_REGS_H */