mx6-ddr.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. /*
  2. * Copyright (C) 2013 Boundary Devices Inc.
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #ifndef __ASM_ARCH_MX6_DDR_H__
  7. #define __ASM_ARCH_MX6_DDR_H__
  8. #ifndef CONFIG_SPL_BUILD
  9. #ifdef CONFIG_MX6Q
  10. #include "mx6q-ddr.h"
  11. #else
  12. #if defined(CONFIG_MX6DL) || defined(CONFIG_MX6S)
  13. #include "mx6dl-ddr.h"
  14. #else
  15. #error "Please select cpu"
  16. #endif /* CONFIG_MX6DL or CONFIG_MX6S */
  17. #endif /* CONFIG_MX6Q */
  18. #else
  19. /* MMDC P0/P1 Registers */
  20. struct mmdc_p_regs {
  21. u32 mdctl;
  22. u32 mdpdc;
  23. u32 mdotc;
  24. u32 mdcfg0;
  25. u32 mdcfg1;
  26. u32 mdcfg2;
  27. u32 mdmisc;
  28. u32 mdscr;
  29. u32 mdref;
  30. u32 res1[2];
  31. u32 mdrwd;
  32. u32 mdor;
  33. u32 res2[3];
  34. u32 mdasp;
  35. u32 res3[240];
  36. u32 mapsr;
  37. u32 res4[254];
  38. u32 mpzqhwctrl;
  39. u32 res5[2];
  40. u32 mpwldectrl0;
  41. u32 mpwldectrl1;
  42. u32 res6;
  43. u32 mpodtctrl;
  44. u32 mprddqby0dl;
  45. u32 mprddqby1dl;
  46. u32 mprddqby2dl;
  47. u32 mprddqby3dl;
  48. u32 res7[4];
  49. u32 mpdgctrl0;
  50. u32 mpdgctrl1;
  51. u32 res8;
  52. u32 mprddlctl;
  53. u32 res9;
  54. u32 mpwrdlctl;
  55. u32 res10[25];
  56. u32 mpmur0;
  57. };
  58. /*
  59. * MMDC iomux registers (pinctl/padctl) - (different for IMX6DQ vs IMX6SDL)
  60. */
  61. #define MX6DQ_IOM_DDR_BASE 0x020e0500
  62. struct mx6dq_iomux_ddr_regs {
  63. u32 res1[3];
  64. u32 dram_sdqs5;
  65. u32 dram_dqm5;
  66. u32 dram_dqm4;
  67. u32 dram_sdqs4;
  68. u32 dram_sdqs3;
  69. u32 dram_dqm3;
  70. u32 dram_sdqs2;
  71. u32 dram_dqm2;
  72. u32 res2[16];
  73. u32 dram_cas;
  74. u32 res3[2];
  75. u32 dram_ras;
  76. u32 dram_reset;
  77. u32 res4[2];
  78. u32 dram_sdclk_0;
  79. u32 dram_sdba2;
  80. u32 dram_sdcke0;
  81. u32 dram_sdclk_1;
  82. u32 dram_sdcke1;
  83. u32 dram_sdodt0;
  84. u32 dram_sdodt1;
  85. u32 res5;
  86. u32 dram_sdqs0;
  87. u32 dram_dqm0;
  88. u32 dram_sdqs1;
  89. u32 dram_dqm1;
  90. u32 dram_sdqs6;
  91. u32 dram_dqm6;
  92. u32 dram_sdqs7;
  93. u32 dram_dqm7;
  94. };
  95. #define MX6DQ_IOM_GRP_BASE 0x020e0700
  96. struct mx6dq_iomux_grp_regs {
  97. u32 res1[18];
  98. u32 grp_b7ds;
  99. u32 grp_addds;
  100. u32 grp_ddrmode_ctl;
  101. u32 res2;
  102. u32 grp_ddrpke;
  103. u32 res3[6];
  104. u32 grp_ddrmode;
  105. u32 res4[3];
  106. u32 grp_b0ds;
  107. u32 grp_b1ds;
  108. u32 grp_ctlds;
  109. u32 res5;
  110. u32 grp_b2ds;
  111. u32 grp_ddr_type;
  112. u32 grp_b3ds;
  113. u32 grp_b4ds;
  114. u32 grp_b5ds;
  115. u32 grp_b6ds;
  116. };
  117. #define MX6SDL_IOM_DDR_BASE 0x020e0400
  118. struct mx6sdl_iomux_ddr_regs {
  119. u32 res1[25];
  120. u32 dram_cas;
  121. u32 res2[2];
  122. u32 dram_dqm0;
  123. u32 dram_dqm1;
  124. u32 dram_dqm2;
  125. u32 dram_dqm3;
  126. u32 dram_dqm4;
  127. u32 dram_dqm5;
  128. u32 dram_dqm6;
  129. u32 dram_dqm7;
  130. u32 dram_ras;
  131. u32 dram_reset;
  132. u32 res3[2];
  133. u32 dram_sdba2;
  134. u32 dram_sdcke0;
  135. u32 dram_sdcke1;
  136. u32 dram_sdclk_0;
  137. u32 dram_sdclk_1;
  138. u32 dram_sdodt0;
  139. u32 dram_sdodt1;
  140. u32 dram_sdqs0;
  141. u32 dram_sdqs1;
  142. u32 dram_sdqs2;
  143. u32 dram_sdqs3;
  144. u32 dram_sdqs4;
  145. u32 dram_sdqs5;
  146. u32 dram_sdqs6;
  147. u32 dram_sdqs7;
  148. };
  149. #define MX6SDL_IOM_GRP_BASE 0x020e0700
  150. struct mx6sdl_iomux_grp_regs {
  151. u32 res1[18];
  152. u32 grp_b7ds;
  153. u32 grp_addds;
  154. u32 grp_ddrmode_ctl;
  155. u32 grp_ddrpke;
  156. u32 res2[2];
  157. u32 grp_ddrmode;
  158. u32 grp_b0ds;
  159. u32 res3;
  160. u32 grp_ctlds;
  161. u32 grp_b1ds;
  162. u32 grp_ddr_type;
  163. u32 grp_b2ds;
  164. u32 grp_b3ds;
  165. u32 grp_b4ds;
  166. u32 grp_b5ds;
  167. u32 res4;
  168. u32 grp_b6ds;
  169. };
  170. /* Device Information: Varies per DDR3 part number and speed grade */
  171. struct mx6_ddr3_cfg {
  172. u16 mem_speed; /* ie 1600 for DDR3-1600 (800,1066,1333,1600) */
  173. u8 density; /* chip density (Gb) (1,2,4,8) */
  174. u8 width; /* bus width (bits) (4,8,16) */
  175. u8 banks; /* number of banks */
  176. u8 rowaddr; /* row address bits (11-16)*/
  177. u8 coladdr; /* col address bits (9-12) */
  178. u8 pagesz; /* page size (K) (1-2) */
  179. u16 trcd; /* tRCD=tRP=CL (ns*100) */
  180. u16 trcmin; /* tRC min (ns*100) */
  181. u16 trasmin; /* tRAS min (ns*100) */
  182. u8 SRT; /* self-refresh temperature: 0=normal, 1=extended */
  183. };
  184. /* System Information: Varies per board design, layout, and term choices */
  185. struct mx6_ddr_sysinfo {
  186. u8 dsize; /* size of bus (in dwords: 0=16bit,1=32bit,2=64bit) */
  187. u8 cs_density; /* density per chip select (Gb) */
  188. u8 ncs; /* number chip selects used (1|2) */
  189. char cs1_mirror;/* enable address mirror (0|1) */
  190. char bi_on; /* Bank interleaving enable */
  191. u8 rtt_nom; /* Rtt_Nom (DDR3_RTT_*) */
  192. u8 rtt_wr; /* Rtt_Wr (DDR3_RTT_*) */
  193. u8 ralat; /* Read Additional Latency (0-7) */
  194. u8 walat; /* Write Additional Latency (0-3) */
  195. u8 mif3_mode; /* Command prediction working mode */
  196. u8 rst_to_cke; /* Time from SDE enable to CKE rise */
  197. u8 sde_to_rst; /* Time from SDE enable until DDR reset# is high */
  198. };
  199. /*
  200. * Board specific calibration:
  201. * This includes write leveling calibration values as well as DQS gating
  202. * and read/write delays. These values are board/layout/device specific.
  203. * Freescale recommends using the i.MX6 DDR Stress Test Tool V1.0.2
  204. * (DOC-96412) to determine these values over a range of boards and
  205. * temperatures.
  206. */
  207. struct mx6_mmdc_calibration {
  208. /* write leveling calibration */
  209. u32 p0_mpwldectrl0;
  210. u32 p0_mpwldectrl1;
  211. u32 p1_mpwldectrl0;
  212. u32 p1_mpwldectrl1;
  213. /* read DQS gating */
  214. u32 p0_mpdgctrl0;
  215. u32 p0_mpdgctrl1;
  216. u32 p1_mpdgctrl0;
  217. u32 p1_mpdgctrl1;
  218. /* read delay */
  219. u32 p0_mprddlctl;
  220. u32 p1_mprddlctl;
  221. /* write delay */
  222. u32 p0_mpwrdlctl;
  223. u32 p1_mpwrdlctl;
  224. };
  225. /* configure iomux (pinctl/padctl) */
  226. void mx6dq_dram_iocfg(unsigned width,
  227. const struct mx6dq_iomux_ddr_regs *,
  228. const struct mx6dq_iomux_grp_regs *);
  229. void mx6sdl_dram_iocfg(unsigned width,
  230. const struct mx6sdl_iomux_ddr_regs *,
  231. const struct mx6sdl_iomux_grp_regs *);
  232. /* configure mx6 mmdc registers */
  233. void mx6_dram_cfg(const struct mx6_ddr_sysinfo *,
  234. const struct mx6_mmdc_calibration *,
  235. const struct mx6_ddr3_cfg *);
  236. #endif /* CONFIG_SPL_BUILD */
  237. #define MX6_MMDC_P0_MDCTL 0x021b0000
  238. #define MX6_MMDC_P0_MDPDC 0x021b0004
  239. #define MX6_MMDC_P0_MDOTC 0x021b0008
  240. #define MX6_MMDC_P0_MDCFG0 0x021b000c
  241. #define MX6_MMDC_P0_MDCFG1 0x021b0010
  242. #define MX6_MMDC_P0_MDCFG2 0x021b0014
  243. #define MX6_MMDC_P0_MDMISC 0x021b0018
  244. #define MX6_MMDC_P0_MDSCR 0x021b001c
  245. #define MX6_MMDC_P0_MDREF 0x021b0020
  246. #define MX6_MMDC_P0_MDRWD 0x021b002c
  247. #define MX6_MMDC_P0_MDOR 0x021b0030
  248. #define MX6_MMDC_P0_MDASP 0x021b0040
  249. #define MX6_MMDC_P0_MAPSR 0x021b0404
  250. #define MX6_MMDC_P0_MPZQHWCTRL 0x021b0800
  251. #define MX6_MMDC_P0_MPWLDECTRL0 0x021b080c
  252. #define MX6_MMDC_P0_MPWLDECTRL1 0x021b0810
  253. #define MX6_MMDC_P0_MPODTCTRL 0x021b0818
  254. #define MX6_MMDC_P0_MPRDDQBY0DL 0x021b081c
  255. #define MX6_MMDC_P0_MPRDDQBY1DL 0x021b0820
  256. #define MX6_MMDC_P0_MPRDDQBY2DL 0x021b0824
  257. #define MX6_MMDC_P0_MPRDDQBY3DL 0x021b0828
  258. #define MX6_MMDC_P0_MPDGCTRL0 0x021b083c
  259. #define MX6_MMDC_P0_MPDGCTRL1 0x021b0840
  260. #define MX6_MMDC_P0_MPRDDLCTL 0x021b0848
  261. #define MX6_MMDC_P0_MPWRDLCTL 0x021b0850
  262. #define MX6_MMDC_P0_MPMUR0 0x021b08b8
  263. #define MX6_MMDC_P1_MDCTL 0x021b4000
  264. #define MX6_MMDC_P1_MDPDC 0x021b4004
  265. #define MX6_MMDC_P1_MDOTC 0x021b4008
  266. #define MX6_MMDC_P1_MDCFG0 0x021b400c
  267. #define MX6_MMDC_P1_MDCFG1 0x021b4010
  268. #define MX6_MMDC_P1_MDCFG2 0x021b4014
  269. #define MX6_MMDC_P1_MDMISC 0x021b4018
  270. #define MX6_MMDC_P1_MDSCR 0x021b401c
  271. #define MX6_MMDC_P1_MDREF 0x021b4020
  272. #define MX6_MMDC_P1_MDRWD 0x021b402c
  273. #define MX6_MMDC_P1_MDOR 0x021b4030
  274. #define MX6_MMDC_P1_MDASP 0x021b4040
  275. #define MX6_MMDC_P1_MAPSR 0x021b4404
  276. #define MX6_MMDC_P1_MPZQHWCTRL 0x021b4800
  277. #define MX6_MMDC_P1_MPWLDECTRL0 0x021b480c
  278. #define MX6_MMDC_P1_MPWLDECTRL1 0x021b4810
  279. #define MX6_MMDC_P1_MPODTCTRL 0x021b4818
  280. #define MX6_MMDC_P1_MPRDDQBY0DL 0x021b481c
  281. #define MX6_MMDC_P1_MPRDDQBY1DL 0x021b4820
  282. #define MX6_MMDC_P1_MPRDDQBY2DL 0x021b4824
  283. #define MX6_MMDC_P1_MPRDDQBY3DL 0x021b4828
  284. #define MX6_MMDC_P1_MPDGCTRL0 0x021b483c
  285. #define MX6_MMDC_P1_MPDGCTRL1 0x021b4840
  286. #define MX6_MMDC_P1_MPRDDLCTL 0x021b4848
  287. #define MX6_MMDC_P1_MPWRDLCTL 0x021b4850
  288. #define MX6_MMDC_P1_MPMUR0 0x021b48b8
  289. #endif /*__ASM_ARCH_MX6_DDR_H__ */