sdram_elpida.c 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Timing and Organization details of the Elpida parts used in OMAP4
  4. * SDPs and Panda
  5. *
  6. * (C) Copyright 2010
  7. * Texas Instruments, <www.ti.com>
  8. *
  9. * Aneesh V <aneesh@ti.com>
  10. */
  11. #include <asm/emif.h>
  12. #include <asm/arch/sys_proto.h>
  13. /*
  14. * This file provides details of the LPDDR2 SDRAM parts used on OMAP4430
  15. * SDP and Panda. Since the parts used and geometry are identical for
  16. * SDP and Panda for a given OMAP4 revision, this information is kept
  17. * here instead of being in board directory. However the key functions
  18. * exported are weakly linked so that they can be over-ridden in the board
  19. * directory if there is a OMAP4 board in the future that uses a different
  20. * memory device or geometry.
  21. *
  22. * For any new board with different memory devices over-ride one or more
  23. * of the following functions as per the CONFIG flags you intend to enable:
  24. * - emif_get_reg_dump()
  25. * - emif_get_dmm_regs()
  26. * - emif_get_device_details()
  27. * - emif_get_device_timings()
  28. */
  29. #ifdef CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS
  30. const struct emif_regs emif_regs_elpida_200_mhz_2cs = {
  31. .sdram_config_init = 0x80000eb9,
  32. .sdram_config = 0x80001ab9,
  33. .ref_ctrl = 0x0000030c,
  34. .sdram_tim1 = 0x08648311,
  35. .sdram_tim2 = 0x101b06ca,
  36. .sdram_tim3 = 0x0048a19f,
  37. .read_idle_ctrl = 0x000501ff,
  38. .zq_config = 0x500b3214,
  39. .temp_alert_config = 0xd8016893,
  40. .emif_ddr_phy_ctlr_1_init = 0x049ffff5,
  41. .emif_ddr_phy_ctlr_1 = 0x049ff808
  42. };
  43. const struct emif_regs emif_regs_elpida_380_mhz_1cs = {
  44. .sdram_config_init = 0x80000eb1,
  45. .sdram_config = 0x80001ab1,
  46. .ref_ctrl = 0x000005cd,
  47. .sdram_tim1 = 0x10cb0622,
  48. .sdram_tim2 = 0x20350d52,
  49. .sdram_tim3 = 0x00b1431f,
  50. .read_idle_ctrl = 0x000501ff,
  51. .zq_config = 0x500b3214,
  52. .temp_alert_config = 0x58016893,
  53. .emif_ddr_phy_ctlr_1_init = 0x049ffff5,
  54. .emif_ddr_phy_ctlr_1 = 0x049ff418
  55. };
  56. const struct emif_regs emif_regs_elpida_400_mhz_1cs = {
  57. .sdram_config_init = 0x80800eb2,
  58. .sdram_config = 0x80801ab2,
  59. .ref_ctrl = 0x00000618,
  60. .sdram_tim1 = 0x10eb0662,
  61. .sdram_tim2 = 0x20370dd2,
  62. .sdram_tim3 = 0x00b1c33f,
  63. .read_idle_ctrl = 0x000501ff,
  64. .zq_config = 0x500b3215,
  65. .temp_alert_config = 0x58016893,
  66. .emif_ddr_phy_ctlr_1_init = 0x049ffff5,
  67. .emif_ddr_phy_ctlr_1 = 0x049ff418
  68. };
  69. const struct emif_regs emif_regs_elpida_400_mhz_2cs = {
  70. .sdram_config_init = 0x80000eb9,
  71. .sdram_config = 0x80001ab9,
  72. .ref_ctrl = 0x00000618,
  73. .sdram_tim1 = 0x10eb0662,
  74. .sdram_tim2 = 0x20370dd2,
  75. .sdram_tim3 = 0x00b1c33f,
  76. .read_idle_ctrl = 0x000501ff,
  77. .zq_config = 0xd00b3214,
  78. .temp_alert_config = 0xd8016893,
  79. .emif_ddr_phy_ctlr_1_init = 0x049ffff5,
  80. .emif_ddr_phy_ctlr_1 = 0x049ff418
  81. };
  82. const struct dmm_lisa_map_regs lisa_map_2G_x_1_x_2 = {
  83. .dmm_lisa_map_0 = 0xFF020100,
  84. .dmm_lisa_map_1 = 0,
  85. .dmm_lisa_map_2 = 0,
  86. .dmm_lisa_map_3 = 0x80540300,
  87. .is_ma_present = 0x0
  88. };
  89. const struct dmm_lisa_map_regs lisa_map_2G_x_2_x_2 = {
  90. .dmm_lisa_map_0 = 0xFF020100,
  91. .dmm_lisa_map_1 = 0,
  92. .dmm_lisa_map_2 = 0,
  93. .dmm_lisa_map_3 = 0x80640300,
  94. .is_ma_present = 0x0
  95. };
  96. const struct dmm_lisa_map_regs ma_lisa_map_2G_x_2_x_2 = {
  97. .dmm_lisa_map_0 = 0xFF020100,
  98. .dmm_lisa_map_1 = 0,
  99. .dmm_lisa_map_2 = 0,
  100. .dmm_lisa_map_3 = 0x80640300,
  101. .is_ma_present = 0x1
  102. };
  103. static void emif_get_reg_dump_sdp(u32 emif_nr, const struct emif_regs **regs)
  104. {
  105. u32 omap4_rev = omap_revision();
  106. /* Same devices and geometry on both EMIFs */
  107. if (omap4_rev == OMAP4430_ES1_0)
  108. *regs = &emif_regs_elpida_380_mhz_1cs;
  109. else if (omap4_rev == OMAP4430_ES2_0)
  110. *regs = &emif_regs_elpida_200_mhz_2cs;
  111. else if (omap4_rev < OMAP4470_ES1_0)
  112. *regs = &emif_regs_elpida_400_mhz_2cs;
  113. else
  114. *regs = &emif_regs_elpida_400_mhz_1cs;
  115. }
  116. void emif_get_reg_dump(u32 emif_nr, const struct emif_regs **regs)
  117. __attribute__((weak, alias("emif_get_reg_dump_sdp")));
  118. static void emif_get_dmm_regs_sdp(const struct dmm_lisa_map_regs
  119. **dmm_lisa_regs)
  120. {
  121. u32 omap_rev = omap_revision();
  122. if (omap_rev == OMAP4430_ES1_0)
  123. *dmm_lisa_regs = &lisa_map_2G_x_1_x_2;
  124. else if (omap_rev < OMAP4460_ES1_0)
  125. *dmm_lisa_regs = &lisa_map_2G_x_2_x_2;
  126. else
  127. *dmm_lisa_regs = &ma_lisa_map_2G_x_2_x_2;
  128. }
  129. void emif_get_dmm_regs(const struct dmm_lisa_map_regs **dmm_lisa_regs)
  130. __attribute__((weak, alias("emif_get_dmm_regs_sdp")));
  131. #else
  132. const struct lpddr2_device_details elpida_2G_S4_details = {
  133. .type = LPDDR2_TYPE_S4,
  134. .density = LPDDR2_DENSITY_2Gb,
  135. .io_width = LPDDR2_IO_WIDTH_32,
  136. .manufacturer = LPDDR2_MANUFACTURER_ELPIDA
  137. };
  138. const struct lpddr2_device_details elpida_4G_S4_details = {
  139. .type = LPDDR2_TYPE_S4,
  140. .density = LPDDR2_DENSITY_4Gb,
  141. .io_width = LPDDR2_IO_WIDTH_32,
  142. .manufacturer = LPDDR2_MANUFACTURER_ELPIDA
  143. };
  144. struct lpddr2_device_details *emif_get_device_details_sdp(u32 emif_nr, u8 cs,
  145. struct lpddr2_device_details *lpddr2_dev_details)
  146. {
  147. u32 omap_rev = omap_revision();
  148. /* EMIF1 & EMIF2 have identical configuration */
  149. if (((omap_rev == OMAP4430_ES1_0) || (omap_rev == OMAP4470_ES1_0))
  150. && (cs == CS1)) {
  151. /* Nothing connected on CS1 for 4430/4470 ES1.0 */
  152. return NULL;
  153. } else if (omap_rev < OMAP4470_ES1_0) {
  154. /* In all other 4430/4460 cases Elpida 2G device */
  155. *lpddr2_dev_details = elpida_2G_S4_details;
  156. } else {
  157. /* 4470: 4G device */
  158. *lpddr2_dev_details = elpida_4G_S4_details;
  159. }
  160. return lpddr2_dev_details;
  161. }
  162. struct lpddr2_device_details *emif_get_device_details(u32 emif_nr, u8 cs,
  163. struct lpddr2_device_details *lpddr2_dev_details)
  164. __attribute__((weak, alias("emif_get_device_details_sdp")));
  165. #endif /* CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS */
  166. #ifndef CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS
  167. static const struct lpddr2_ac_timings timings_elpida_400_mhz = {
  168. .max_freq = 400000000,
  169. .RL = 6,
  170. .tRPab = 21,
  171. .tRCD = 18,
  172. .tWR = 15,
  173. .tRASmin = 42,
  174. .tRRD = 10,
  175. .tWTRx2 = 15,
  176. .tXSR = 140,
  177. .tXPx2 = 15,
  178. .tRFCab = 130,
  179. .tRTPx2 = 15,
  180. .tCKE = 3,
  181. .tCKESR = 15,
  182. .tZQCS = 90,
  183. .tZQCL = 360,
  184. .tZQINIT = 1000,
  185. .tDQSCKMAXx2 = 11,
  186. .tRASmax = 70,
  187. .tFAW = 50
  188. };
  189. static const struct lpddr2_ac_timings timings_elpida_333_mhz = {
  190. .max_freq = 333000000,
  191. .RL = 5,
  192. .tRPab = 21,
  193. .tRCD = 18,
  194. .tWR = 15,
  195. .tRASmin = 42,
  196. .tRRD = 10,
  197. .tWTRx2 = 15,
  198. .tXSR = 140,
  199. .tXPx2 = 15,
  200. .tRFCab = 130,
  201. .tRTPx2 = 15,
  202. .tCKE = 3,
  203. .tCKESR = 15,
  204. .tZQCS = 90,
  205. .tZQCL = 360,
  206. .tZQINIT = 1000,
  207. .tDQSCKMAXx2 = 11,
  208. .tRASmax = 70,
  209. .tFAW = 50
  210. };
  211. static const struct lpddr2_ac_timings timings_elpida_200_mhz = {
  212. .max_freq = 200000000,
  213. .RL = 3,
  214. .tRPab = 21,
  215. .tRCD = 18,
  216. .tWR = 15,
  217. .tRASmin = 42,
  218. .tRRD = 10,
  219. .tWTRx2 = 20,
  220. .tXSR = 140,
  221. .tXPx2 = 15,
  222. .tRFCab = 130,
  223. .tRTPx2 = 15,
  224. .tCKE = 3,
  225. .tCKESR = 15,
  226. .tZQCS = 90,
  227. .tZQCL = 360,
  228. .tZQINIT = 1000,
  229. .tDQSCKMAXx2 = 11,
  230. .tRASmax = 70,
  231. .tFAW = 50
  232. };
  233. static const struct lpddr2_min_tck min_tck_elpida = {
  234. .tRL = 3,
  235. .tRP_AB = 3,
  236. .tRCD = 3,
  237. .tWR = 3,
  238. .tRAS_MIN = 3,
  239. .tRRD = 2,
  240. .tWTR = 2,
  241. .tXP = 2,
  242. .tRTP = 2,
  243. .tCKE = 3,
  244. .tCKESR = 3,
  245. .tFAW = 8
  246. };
  247. static const struct lpddr2_ac_timings *elpida_ac_timings[MAX_NUM_SPEEDBINS] = {
  248. &timings_elpida_200_mhz,
  249. &timings_elpida_333_mhz,
  250. &timings_elpida_400_mhz
  251. };
  252. const struct lpddr2_device_timings elpida_2G_S4_timings = {
  253. .ac_timings = elpida_ac_timings,
  254. .min_tck = &min_tck_elpida,
  255. };
  256. void emif_get_device_timings_sdp(u32 emif_nr,
  257. const struct lpddr2_device_timings **cs0_device_timings,
  258. const struct lpddr2_device_timings **cs1_device_timings)
  259. {
  260. u32 omap_rev = omap_revision();
  261. /* Identical devices on EMIF1 & EMIF2 */
  262. *cs0_device_timings = &elpida_2G_S4_timings;
  263. if ((omap_rev == OMAP4430_ES1_0) || (omap_rev == OMAP4470_ES1_0))
  264. *cs1_device_timings = NULL;
  265. else
  266. *cs1_device_timings = &elpida_2G_S4_timings;
  267. }
  268. void emif_get_device_timings(u32 emif_nr,
  269. const struct lpddr2_device_timings **cs0_device_timings,
  270. const struct lpddr2_device_timings **cs1_device_timings)
  271. __attribute__((weak, alias("emif_get_device_timings_sdp")));
  272. #endif /* CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS */
  273. const struct lpddr2_mr_regs mr_regs = {
  274. .mr1 = MR1_BL_8_BT_SEQ_WRAP_EN_NWR_3,
  275. .mr2 = 0x4,
  276. .mr3 = -1,
  277. .mr10 = MR10_ZQ_ZQINIT,
  278. .mr16 = MR16_REF_FULL_ARRAY
  279. };
  280. void get_lpddr2_mr_regs(const struct lpddr2_mr_regs **regs)
  281. {
  282. *regs = &mr_regs;
  283. }
  284. __weak const struct read_write_regs *get_bug_regs(u32 *iterations)
  285. {
  286. return 0;
  287. }