dram_sun8i_a23.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Sun8i platform dram controller register and constant defines
  4. *
  5. * (C) Copyright 2007-2013
  6. * Allwinner Technology Co., Ltd. <www.allwinnertech.com>
  7. * CPL <cplanxy@allwinnertech.com>
  8. * Jerry Wang <wangflord@allwinnertech.com>
  9. *
  10. * (C) Copyright 2014 Hans de Goede <hdegoede@redhat.com>
  11. */
  12. #ifndef _SUNXI_DRAM_SUN8I_H
  13. #define _SUNXI_DRAM_SUN8I_H
  14. struct dram_para {
  15. u32 clock;
  16. u32 type;
  17. u32 zq;
  18. u32 odt_en;
  19. s32 odt_correction;
  20. u32 para1;
  21. u32 para2;
  22. u32 mr0;
  23. u32 mr1;
  24. u32 mr2;
  25. u32 mr3;
  26. u32 tpr0;
  27. u32 tpr1;
  28. u32 tpr2;
  29. u32 tpr3;
  30. u32 tpr4;
  31. u32 tpr5;
  32. u32 tpr6;
  33. u32 tpr7;
  34. u32 tpr8;
  35. u32 tpr9;
  36. u32 tpr10;
  37. u32 tpr11;
  38. u32 tpr12;
  39. u32 tpr13;
  40. };
  41. struct sunxi_mctl_com_reg {
  42. u32 cr; /* 0x00 */
  43. u32 ccr; /* 0x04 controller configuration register */
  44. u32 dbgcr; /* 0x08 */
  45. u8 res0[0x4]; /* 0x0c */
  46. u32 mcr0_0; /* 0x10 */
  47. u32 mcr1_0; /* 0x14 */
  48. u32 mcr0_1; /* 0x18 */
  49. u32 mcr1_1; /* 0x1c */
  50. u32 mcr0_2; /* 0x20 */
  51. u32 mcr1_2; /* 0x24 */
  52. u32 mcr0_3; /* 0x28 */
  53. u32 mcr1_3; /* 0x2c */
  54. u32 mcr0_4; /* 0x30 */
  55. u32 mcr1_4; /* 0x34 */
  56. u32 mcr0_5; /* 0x38 */
  57. u32 mcr1_5; /* 0x3c */
  58. u32 mcr0_6; /* 0x40 */
  59. u32 mcr1_6; /* 0x44 */
  60. u32 mcr0_7; /* 0x48 */
  61. u32 mcr1_7; /* 0x4c */
  62. u32 mcr0_8; /* 0x50 */
  63. u32 mcr1_8; /* 0x54 */
  64. u32 mcr0_9; /* 0x58 */
  65. u32 mcr1_9; /* 0x5c */
  66. u32 mcr0_10; /* 0x60 */
  67. u32 mcr1_10; /* 0x64 */
  68. u32 mcr0_11; /* 0x68 */
  69. u32 mcr1_11; /* 0x6c */
  70. u32 mcr0_12; /* 0x70 */
  71. u32 mcr1_12; /* 0x74 */
  72. u32 mcr0_13; /* 0x78 */
  73. u32 mcr1_13; /* 0x7c */
  74. u32 mcr0_14; /* 0x80 */
  75. u32 mcr1_14; /* 0x84 */
  76. u32 mcr0_15; /* 0x88 */
  77. u32 mcr1_15; /* 0x8c */
  78. u32 bwcr; /* 0x90 */
  79. u32 maer; /* 0x94 */
  80. u8 res1[0x4]; /* 0x98 */
  81. u32 mcgcr; /* 0x9c */
  82. u32 bwctr; /* 0xa0 */
  83. u8 res2[0x4]; /* 0xa4 */
  84. u32 swonr; /* 0xa8 */
  85. u32 swoffr; /* 0xac */
  86. };
  87. struct sunxi_mctl_ctl_reg {
  88. u32 mstr; /* 0x00 */
  89. u32 statr; /* 0x04 */
  90. u8 res0[0x08]; /* 0x08 */
  91. u32 mrctrl0; /* 0x10 */
  92. u32 mrctrl1; /* 0x14 */
  93. u32 mrstatr; /* 0x18 */
  94. u8 res1[0x04]; /* 0x1c */
  95. u32 derateen; /* 0x20 */
  96. u32 deratenint; /* 0x24 */
  97. u8 res2[0x08]; /* 0x28 */
  98. u32 pwrctl; /* 0x30 */
  99. u32 pwrtmg; /* 0x34 */
  100. u8 res3[0x18]; /* 0x38 */
  101. u32 rfshctl0; /* 0x50 */
  102. u32 rfshctl1; /* 0x54 */
  103. u8 res4[0x8]; /* 0x58 */
  104. u32 rfshctl3; /* 0x60 */
  105. u32 rfshtmg; /* 0x64 */
  106. u8 res6[0x68]; /* 0x68 */
  107. u32 init0; /* 0xd0 */
  108. u32 init1; /* 0xd4 */
  109. u32 init2; /* 0xd8 */
  110. u32 init3; /* 0xdc */
  111. u32 init4; /* 0xe0 */
  112. u32 init5; /* 0xe4 */
  113. u8 res7[0x0c]; /* 0xe8 */
  114. u32 rankctl; /* 0xf4 */
  115. u8 res8[0x08]; /* 0xf8 */
  116. u32 dramtmg0; /* 0x100 */
  117. u32 dramtmg1; /* 0x104 */
  118. u32 dramtmg2; /* 0x108 */
  119. u32 dramtmg3; /* 0x10c */
  120. u32 dramtmg4; /* 0x110 */
  121. u32 dramtmg5; /* 0x114 */
  122. u32 dramtmg6; /* 0x118 */
  123. u32 dramtmg7; /* 0x11c */
  124. u32 dramtmg8; /* 0x120 */
  125. u8 res9[0x5c]; /* 0x124 */
  126. u32 zqctl0; /* 0x180 */
  127. u32 zqctl1; /* 0x184 */
  128. u32 zqctl2; /* 0x188 */
  129. u32 zqstat; /* 0x18c */
  130. u32 pitmg0; /* 0x190 */
  131. u32 pitmg1; /* 0x194 */
  132. u32 plpcfg0; /* 0x198 */
  133. u8 res10[0x04]; /* 0x19c */
  134. u32 upd0; /* 0x1a0 */
  135. u32 upd1; /* 0x1a4 */
  136. u32 upd2; /* 0x1a8 */
  137. u32 upd3; /* 0x1ac */
  138. u32 pimisc; /* 0x1b0 */
  139. u8 res11[0x1c]; /* 0x1b4 */
  140. u32 trainctl0; /* 0x1d0 */
  141. u32 trainctl1; /* 0x1d4 */
  142. u32 trainctl2; /* 0x1d8 */
  143. u32 trainstat; /* 0x1dc */
  144. u8 res12[0x60]; /* 0x1e0 */
  145. u32 odtcfg; /* 0x240 */
  146. u32 odtmap; /* 0x244 */
  147. u8 res13[0x08]; /* 0x248 */
  148. u32 sched; /* 0x250 */
  149. u8 res14[0x04]; /* 0x254 */
  150. u32 perfshpr0; /* 0x258 */
  151. u32 perfshpr1; /* 0x25c */
  152. u32 perflpr0; /* 0x260 */
  153. u32 perflpr1; /* 0x264 */
  154. u32 perfwr0; /* 0x268 */
  155. u32 perfwr1; /* 0x26c */
  156. };
  157. struct sunxi_mctl_phy_reg {
  158. u8 res0[0x04]; /* 0x00 */
  159. u32 pir; /* 0x04 */
  160. u32 pgcr0; /* 0x08 phy general configuration register */
  161. u32 pgcr1; /* 0x0c phy general configuration register */
  162. u32 pgsr0; /* 0x10 */
  163. u32 pgsr1; /* 0x14 */
  164. u32 dllgcr; /* 0x18 */
  165. u32 ptr0; /* 0x1c */
  166. u32 ptr1; /* 0x20 */
  167. u32 ptr2; /* 0x24 */
  168. u32 ptr3; /* 0x28 */
  169. u32 ptr4; /* 0x2c */
  170. u32 acmdlr; /* 0x30 */
  171. u32 acbdlr; /* 0x34 */
  172. u32 aciocr; /* 0x38 */
  173. u32 dxccr; /* 0x3c DATX8 common configuration register */
  174. u32 dsgcr; /* 0x40 dram system general config register */
  175. u32 dcr; /* 0x44 */
  176. u32 dtpr0; /* 0x48 dram timing parameters register 0 */
  177. u32 dtpr1; /* 0x4c dram timing parameters register 1 */
  178. u32 dtpr2; /* 0x50 dram timing parameters register 2 */
  179. u32 mr0; /* 0x54 mode register 0 */
  180. u32 mr1; /* 0x58 mode register 1 */
  181. u32 mr2; /* 0x5c mode register 2 */
  182. u32 mr3; /* 0x60 mode register 3 */
  183. u32 odtcr; /* 0x64 */
  184. u32 dtcr; /* 0x68 */
  185. u32 dtar0; /* 0x6c data training address register 0 */
  186. u32 dtar1; /* 0x70 data training address register 1 */
  187. u32 dtar2; /* 0x74 data training address register 2 */
  188. u32 dtar3; /* 0x78 data training address register 3 */
  189. u32 dtdr0; /* 0x7c */
  190. u32 dtdr1; /* 0x80 */
  191. u32 dtedr0; /* 0x84 */
  192. u32 dtedr1; /* 0x88 */
  193. u32 pgcr2; /* 0x8c */
  194. u8 res1[0x70]; /* 0x90 */
  195. u32 bistrr; /* 0x100 */
  196. u32 bistwcr; /* 0x104 */
  197. u32 bistmskr0; /* 0x108 */
  198. u32 bistmskr1; /* 0x10c */
  199. u32 bistmskr2; /* 0x110 */
  200. u32 bistlsr; /* 0x114 */
  201. u32 bistar0; /* 0x118 */
  202. u32 bistar1; /* 0x11c */
  203. u32 bistar2; /* 0x120 */
  204. u32 bistupdr; /* 0x124 */
  205. u32 bistgsr; /* 0x128 */
  206. u32 bistwer; /* 0x12c */
  207. u32 bistber0; /* 0x130 */
  208. u32 bistber1; /* 0x134 */
  209. u32 bistber2; /* 0x138 */
  210. u32 bistber3; /* 0x13c */
  211. u32 bistwcsr; /* 0x140 */
  212. u32 bistfwr0; /* 0x144 */
  213. u32 bistfwr1; /* 0x148 */
  214. u32 bistfwr2; /* 0x14c */
  215. u8 res2[0x30]; /* 0x150 */
  216. u32 zqcr0; /* 0x180 zq control register 0 */
  217. u32 zqcr1; /* 0x184 zq control register 1 */
  218. u32 zqsr0; /* 0x188 zq status register 0 */
  219. u32 zqsr1; /* 0x18c zq status register 1 */
  220. u32 zqcr2; /* 0x190 zq control register 2 */
  221. u8 res3[0x2c]; /* 0x194 */
  222. u32 dx0gcr; /* 0x1c0 */
  223. u32 dx0gsr0; /* 0x1c4 */
  224. u32 dx0gsr1; /* 0x1c8 */
  225. u32 dx0bdlr0; /* 0x1cc */
  226. u32 dx0bdlr1; /* 0x1d0 */
  227. u32 dx0bdlr2; /* 0x1d4 */
  228. u32 dx0bdlr3; /* 0x1d8 */
  229. u32 dx0bdlr4; /* 0x1dc */
  230. u32 dx0lcdlr0; /* 0x1e0 */
  231. u32 dx0lcdlr1; /* 0x1e4 */
  232. u32 dx0lcdlr2; /* 0x1e8 */
  233. u32 dx0mdlr; /* 0x1ec */
  234. u32 dx0gtr; /* 0x1f0 */
  235. u32 dx0gsr2; /* 0x1f4 */
  236. u8 res4[0x08]; /* 0x1f8 */
  237. u32 dx1gcr; /* 0x200 */
  238. u32 dx1gsr0; /* 0x204 */
  239. u32 dx1gsr1; /* 0x208 */
  240. u32 dx1bdlr0; /* 0x20c */
  241. u32 dx1bdlr1; /* 0x210 */
  242. u32 dx1bdlr2; /* 0x214 */
  243. u32 dx1bdlr3; /* 0x218 */
  244. u32 dx1bdlr4; /* 0x21c */
  245. u32 dx1lcdlr0; /* 0x220 */
  246. u32 dx1lcdlr1; /* 0x224 */
  247. u32 dx1lcdlr2; /* 0x228 */
  248. u32 dx1mdlr; /* 0x22c */
  249. u32 dx1gtr; /* 0x230 */
  250. u32 dx1gsr2; /* 0x234 */
  251. };
  252. /*
  253. * DRAM common (sunxi_mctl_com_reg) register constants.
  254. */
  255. #define MCTL_CR_ROW_MASK (0xf << 4)
  256. #define MCTL_CR_ROW(x) (((x) - 1) << 4)
  257. #define MCTL_CR_PAGE_SIZE_MASK (0xf << 8)
  258. #define MCTL_CR_PAGE_SIZE(x) ((x) << 8)
  259. #endif /* _SUNXI_DRAM_SUN8I_H */