sdram_elpida.c 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. /*
  2. * Timing and Organization details of the Elpida parts used in OMAP4
  3. * SDPs and Panda
  4. *
  5. * (C) Copyright 2010
  6. * Texas Instruments, <www.ti.com>
  7. *
  8. * Aneesh V <aneesh@ti.com>
  9. *
  10. * See file CREDITS for list of people who contributed to this
  11. * project.
  12. *
  13. * This program is free software; you can redistribute it and/or
  14. * modify it under the terms of the GNU General Public License as
  15. * published by the Free Software Foundation; either version 2 of
  16. * the License, or (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program; if not, write to the Free Software
  25. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  26. * MA 02111-1307 USA
  27. */
  28. #include <asm/arch/emif.h>
  29. #include <asm/arch/sys_proto.h>
  30. /*
  31. * This file provides details of the LPDDR2 SDRAM parts used on OMAP4430
  32. * SDP and Panda. Since the parts used and geometry are identical for
  33. * SDP and Panda for a given OMAP4 revision, this information is kept
  34. * here instead of being in board directory. However the key functions
  35. * exported are weakly linked so that they can be over-ridden in the board
  36. * directory if there is a OMAP4 board in the future that uses a different
  37. * memory device or geometry.
  38. *
  39. * For any new board with different memory devices over-ride one or more
  40. * of the following functions as per the CONFIG flags you intend to enable:
  41. * - emif_get_reg_dump()
  42. * - emif_get_dmm_regs()
  43. * - emif_get_device_details()
  44. * - emif_get_device_timings()
  45. */
  46. #ifdef CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS
  47. static const struct emif_regs emif_regs_elpida_200_mhz_2cs = {
  48. .sdram_config_init = 0x80000eb9,
  49. .sdram_config = 0x80001ab9,
  50. .ref_ctrl = 0x0000030c,
  51. .sdram_tim1 = 0x08648311,
  52. .sdram_tim2 = 0x101b06ca,
  53. .sdram_tim3 = 0x0048a19f,
  54. .read_idle_ctrl = 0x000501ff,
  55. .zq_config = 0x500b3214,
  56. .temp_alert_config = 0xd8016893,
  57. .emif_ddr_phy_ctlr_1_init = 0x049ffff5,
  58. .emif_ddr_phy_ctlr_1 = 0x049ff808
  59. };
  60. static const struct emif_regs emif_regs_elpida_380_mhz_1cs = {
  61. .sdram_config_init = 0x80000eb1,
  62. .sdram_config = 0x80001ab1,
  63. .ref_ctrl = 0x000005cd,
  64. .sdram_tim1 = 0x10cb0622,
  65. .sdram_tim2 = 0x20350d52,
  66. .sdram_tim3 = 0x00b1431f,
  67. .read_idle_ctrl = 0x000501ff,
  68. .zq_config = 0x500b3214,
  69. .temp_alert_config = 0x58016893,
  70. .emif_ddr_phy_ctlr_1_init = 0x049ffff5,
  71. .emif_ddr_phy_ctlr_1 = 0x049ff418
  72. };
  73. const struct emif_regs emif_regs_elpida_400_mhz_2cs = {
  74. .sdram_config_init = 0x80000eb9,
  75. .sdram_config = 0x80001ab9,
  76. .ref_ctrl = 0x00000618,
  77. .sdram_tim1 = 0x10eb0662,
  78. .sdram_tim2 = 0x20370dd2,
  79. .sdram_tim3 = 0x00b1c33f,
  80. .read_idle_ctrl = 0x000501ff,
  81. .zq_config = 0xd00b3214,
  82. .temp_alert_config = 0xd8016893,
  83. .emif_ddr_phy_ctlr_1_init = 0x049ffff5,
  84. .emif_ddr_phy_ctlr_1 = 0x049ff418
  85. };
  86. const struct dmm_lisa_map_regs lisa_map_2G_x_1_x_2 = {
  87. .dmm_lisa_map_0 = 0xFF020100,
  88. .dmm_lisa_map_1 = 0,
  89. .dmm_lisa_map_2 = 0,
  90. .dmm_lisa_map_3 = 0x80540300
  91. };
  92. const struct dmm_lisa_map_regs lisa_map_2G_x_2_x_2 = {
  93. .dmm_lisa_map_0 = 0xFF020100,
  94. .dmm_lisa_map_1 = 0,
  95. .dmm_lisa_map_2 = 0,
  96. .dmm_lisa_map_3 = 0x80640300
  97. };
  98. static void emif_get_reg_dump_sdp(u32 emif_nr, const struct emif_regs **regs)
  99. {
  100. u32 omap4_rev = omap_revision();
  101. /* Same devices and geometry on both EMIFs */
  102. if (omap4_rev == OMAP4430_ES1_0)
  103. *regs = &emif_regs_elpida_380_mhz_1cs;
  104. else if (omap4_rev == OMAP4430_ES2_0)
  105. *regs = &emif_regs_elpida_200_mhz_2cs;
  106. else
  107. *regs = &emif_regs_elpida_400_mhz_2cs;
  108. }
  109. void emif_get_reg_dump(u32 emif_nr, const struct emif_regs **regs)
  110. __attribute__((weak, alias("emif_get_reg_dump_sdp")));
  111. static void emif_get_dmm_regs_sdp(const struct dmm_lisa_map_regs
  112. **dmm_lisa_regs)
  113. {
  114. u32 omap_rev = omap_revision();
  115. if (omap_rev == OMAP4430_ES1_0)
  116. *dmm_lisa_regs = &lisa_map_2G_x_1_x_2;
  117. else
  118. *dmm_lisa_regs = &lisa_map_2G_x_2_x_2;
  119. }
  120. void emif_get_dmm_regs(const struct dmm_lisa_map_regs **dmm_lisa_regs)
  121. __attribute__((weak, alias("emif_get_dmm_regs_sdp")));
  122. #else
  123. static const struct lpddr2_device_details elpida_2G_S4_details = {
  124. .type = LPDDR2_TYPE_S4,
  125. .density = LPDDR2_DENSITY_2Gb,
  126. .io_width = LPDDR2_IO_WIDTH_32,
  127. .manufacturer = LPDDR2_MANUFACTURER_ELPIDA
  128. };
  129. struct lpddr2_device_details *emif_get_device_details_sdp(u32 emif_nr, u8 cs,
  130. struct lpddr2_device_details *lpddr2_dev_details)
  131. {
  132. u32 omap_rev = omap_revision();
  133. /* EMIF1 & EMIF2 have identical configuration */
  134. if ((omap_rev == OMAP4430_ES1_0) && (cs == CS1)) {
  135. /* Nothing connected on CS1 for ES1.0 */
  136. return NULL;
  137. } else {
  138. /* In all other cases Elpida 2G device */
  139. *lpddr2_dev_details = elpida_2G_S4_details;
  140. return lpddr2_dev_details;
  141. }
  142. }
  143. struct lpddr2_device_details *emif_get_device_details(u32 emif_nr, u8 cs,
  144. struct lpddr2_device_details *lpddr2_dev_details)
  145. __attribute__((weak, alias("emif_get_device_details_sdp")));
  146. #endif /* CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS */
  147. #ifndef CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS
  148. static const struct lpddr2_ac_timings timings_elpida_400_mhz = {
  149. .max_freq = 400000000,
  150. .RL = 6,
  151. .tRPab = 21,
  152. .tRCD = 18,
  153. .tWR = 15,
  154. .tRASmin = 42,
  155. .tRRD = 10,
  156. .tWTRx2 = 15,
  157. .tXSR = 140,
  158. .tXPx2 = 15,
  159. .tRFCab = 130,
  160. .tRTPx2 = 15,
  161. .tCKE = 3,
  162. .tCKESR = 15,
  163. .tZQCS = 90,
  164. .tZQCL = 360,
  165. .tZQINIT = 1000,
  166. .tDQSCKMAXx2 = 11,
  167. .tRASmax = 70,
  168. .tFAW = 50
  169. };
  170. static const struct lpddr2_ac_timings timings_elpida_333_mhz = {
  171. .max_freq = 333000000,
  172. .RL = 5,
  173. .tRPab = 21,
  174. .tRCD = 18,
  175. .tWR = 15,
  176. .tRASmin = 42,
  177. .tRRD = 10,
  178. .tWTRx2 = 15,
  179. .tXSR = 140,
  180. .tXPx2 = 15,
  181. .tRFCab = 130,
  182. .tRTPx2 = 15,
  183. .tCKE = 3,
  184. .tCKESR = 15,
  185. .tZQCS = 90,
  186. .tZQCL = 360,
  187. .tZQINIT = 1000,
  188. .tDQSCKMAXx2 = 11,
  189. .tRASmax = 70,
  190. .tFAW = 50
  191. };
  192. static const struct lpddr2_ac_timings timings_elpida_200_mhz = {
  193. .max_freq = 200000000,
  194. .RL = 3,
  195. .tRPab = 21,
  196. .tRCD = 18,
  197. .tWR = 15,
  198. .tRASmin = 42,
  199. .tRRD = 10,
  200. .tWTRx2 = 20,
  201. .tXSR = 140,
  202. .tXPx2 = 15,
  203. .tRFCab = 130,
  204. .tRTPx2 = 15,
  205. .tCKE = 3,
  206. .tCKESR = 15,
  207. .tZQCS = 90,
  208. .tZQCL = 360,
  209. .tZQINIT = 1000,
  210. .tDQSCKMAXx2 = 11,
  211. .tRASmax = 70,
  212. .tFAW = 50
  213. };
  214. static const struct lpddr2_min_tck min_tck_elpida = {
  215. .tRL = 3,
  216. .tRP_AB = 3,
  217. .tRCD = 3,
  218. .tWR = 3,
  219. .tRAS_MIN = 3,
  220. .tRRD = 2,
  221. .tWTR = 2,
  222. .tXP = 2,
  223. .tRTP = 2,
  224. .tCKE = 3,
  225. .tCKESR = 3,
  226. .tFAW = 8
  227. };
  228. static const struct lpddr2_ac_timings *elpida_ac_timings[MAX_NUM_SPEEDBINS] = {
  229. &timings_elpida_200_mhz,
  230. &timings_elpida_333_mhz,
  231. &timings_elpida_400_mhz
  232. };
  233. static const struct lpddr2_device_timings elpida_2G_S4_timings = {
  234. .ac_timings = elpida_ac_timings,
  235. .min_tck = &min_tck_elpida,
  236. };
  237. void emif_get_device_timings_sdp(u32 emif_nr,
  238. const struct lpddr2_device_timings **cs0_device_timings,
  239. const struct lpddr2_device_timings **cs1_device_timings)
  240. {
  241. u32 omap_rev = omap_revision();
  242. /* Identical devices on EMIF1 & EMIF2 */
  243. *cs0_device_timings = &elpida_2G_S4_timings;
  244. if (omap_rev == OMAP4430_ES1_0)
  245. *cs1_device_timings = NULL;
  246. else
  247. *cs1_device_timings = &elpida_2G_S4_timings;
  248. }
  249. void emif_get_device_timings(u32 emif_nr,
  250. const struct lpddr2_device_timings **cs0_device_timings,
  251. const struct lpddr2_device_timings **cs1_device_timings)
  252. __attribute__((weak, alias("emif_get_device_timings_sdp")));
  253. #endif /* CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS */