sdram_elpida.c 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  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/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. /* Dummy registers for OMAP44xx */
  87. const u32 ddr3_ext_phy_ctrl_const_base[EMIF_EXT_PHY_CTRL_CONST_REG];
  88. const struct dmm_lisa_map_regs lisa_map_2G_x_1_x_2 = {
  89. .dmm_lisa_map_0 = 0xFF020100,
  90. .dmm_lisa_map_1 = 0,
  91. .dmm_lisa_map_2 = 0,
  92. .dmm_lisa_map_3 = 0x80540300
  93. };
  94. const struct dmm_lisa_map_regs lisa_map_2G_x_2_x_2 = {
  95. .dmm_lisa_map_0 = 0xFF020100,
  96. .dmm_lisa_map_1 = 0,
  97. .dmm_lisa_map_2 = 0,
  98. .dmm_lisa_map_3 = 0x80640300
  99. };
  100. static void emif_get_reg_dump_sdp(u32 emif_nr, const struct emif_regs **regs)
  101. {
  102. u32 omap4_rev = omap_revision();
  103. /* Same devices and geometry on both EMIFs */
  104. if (omap4_rev == OMAP4430_ES1_0)
  105. *regs = &emif_regs_elpida_380_mhz_1cs;
  106. else if (omap4_rev == OMAP4430_ES2_0)
  107. *regs = &emif_regs_elpida_200_mhz_2cs;
  108. else
  109. *regs = &emif_regs_elpida_400_mhz_2cs;
  110. }
  111. void emif_get_reg_dump(u32 emif_nr, const struct emif_regs **regs)
  112. __attribute__((weak, alias("emif_get_reg_dump_sdp")));
  113. static void emif_get_dmm_regs_sdp(const struct dmm_lisa_map_regs
  114. **dmm_lisa_regs)
  115. {
  116. u32 omap_rev = omap_revision();
  117. if (omap_rev == OMAP4430_ES1_0)
  118. *dmm_lisa_regs = &lisa_map_2G_x_1_x_2;
  119. else
  120. *dmm_lisa_regs = &lisa_map_2G_x_2_x_2;
  121. }
  122. void emif_get_dmm_regs(const struct dmm_lisa_map_regs **dmm_lisa_regs)
  123. __attribute__((weak, alias("emif_get_dmm_regs_sdp")));
  124. #else
  125. static const struct lpddr2_device_details elpida_2G_S4_details = {
  126. .type = LPDDR2_TYPE_S4,
  127. .density = LPDDR2_DENSITY_2Gb,
  128. .io_width = LPDDR2_IO_WIDTH_32,
  129. .manufacturer = LPDDR2_MANUFACTURER_ELPIDA
  130. };
  131. struct lpddr2_device_details *emif_get_device_details_sdp(u32 emif_nr, u8 cs,
  132. struct lpddr2_device_details *lpddr2_dev_details)
  133. {
  134. u32 omap_rev = omap_revision();
  135. /* EMIF1 & EMIF2 have identical configuration */
  136. if ((omap_rev == OMAP4430_ES1_0) && (cs == CS1)) {
  137. /* Nothing connected on CS1 for ES1.0 */
  138. return NULL;
  139. } else {
  140. /* In all other cases Elpida 2G device */
  141. *lpddr2_dev_details = elpida_2G_S4_details;
  142. return lpddr2_dev_details;
  143. }
  144. }
  145. struct lpddr2_device_details *emif_get_device_details(u32 emif_nr, u8 cs,
  146. struct lpddr2_device_details *lpddr2_dev_details)
  147. __attribute__((weak, alias("emif_get_device_details_sdp")));
  148. #endif /* CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS */
  149. #ifndef CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS
  150. static const struct lpddr2_ac_timings timings_elpida_400_mhz = {
  151. .max_freq = 400000000,
  152. .RL = 6,
  153. .tRPab = 21,
  154. .tRCD = 18,
  155. .tWR = 15,
  156. .tRASmin = 42,
  157. .tRRD = 10,
  158. .tWTRx2 = 15,
  159. .tXSR = 140,
  160. .tXPx2 = 15,
  161. .tRFCab = 130,
  162. .tRTPx2 = 15,
  163. .tCKE = 3,
  164. .tCKESR = 15,
  165. .tZQCS = 90,
  166. .tZQCL = 360,
  167. .tZQINIT = 1000,
  168. .tDQSCKMAXx2 = 11,
  169. .tRASmax = 70,
  170. .tFAW = 50
  171. };
  172. static const struct lpddr2_ac_timings timings_elpida_333_mhz = {
  173. .max_freq = 333000000,
  174. .RL = 5,
  175. .tRPab = 21,
  176. .tRCD = 18,
  177. .tWR = 15,
  178. .tRASmin = 42,
  179. .tRRD = 10,
  180. .tWTRx2 = 15,
  181. .tXSR = 140,
  182. .tXPx2 = 15,
  183. .tRFCab = 130,
  184. .tRTPx2 = 15,
  185. .tCKE = 3,
  186. .tCKESR = 15,
  187. .tZQCS = 90,
  188. .tZQCL = 360,
  189. .tZQINIT = 1000,
  190. .tDQSCKMAXx2 = 11,
  191. .tRASmax = 70,
  192. .tFAW = 50
  193. };
  194. static const struct lpddr2_ac_timings timings_elpida_200_mhz = {
  195. .max_freq = 200000000,
  196. .RL = 3,
  197. .tRPab = 21,
  198. .tRCD = 18,
  199. .tWR = 15,
  200. .tRASmin = 42,
  201. .tRRD = 10,
  202. .tWTRx2 = 20,
  203. .tXSR = 140,
  204. .tXPx2 = 15,
  205. .tRFCab = 130,
  206. .tRTPx2 = 15,
  207. .tCKE = 3,
  208. .tCKESR = 15,
  209. .tZQCS = 90,
  210. .tZQCL = 360,
  211. .tZQINIT = 1000,
  212. .tDQSCKMAXx2 = 11,
  213. .tRASmax = 70,
  214. .tFAW = 50
  215. };
  216. static const struct lpddr2_min_tck min_tck_elpida = {
  217. .tRL = 3,
  218. .tRP_AB = 3,
  219. .tRCD = 3,
  220. .tWR = 3,
  221. .tRAS_MIN = 3,
  222. .tRRD = 2,
  223. .tWTR = 2,
  224. .tXP = 2,
  225. .tRTP = 2,
  226. .tCKE = 3,
  227. .tCKESR = 3,
  228. .tFAW = 8
  229. };
  230. static const struct lpddr2_ac_timings *elpida_ac_timings[MAX_NUM_SPEEDBINS] = {
  231. &timings_elpida_200_mhz,
  232. &timings_elpida_333_mhz,
  233. &timings_elpida_400_mhz
  234. };
  235. static const struct lpddr2_device_timings elpida_2G_S4_timings = {
  236. .ac_timings = elpida_ac_timings,
  237. .min_tck = &min_tck_elpida,
  238. };
  239. void emif_get_device_timings_sdp(u32 emif_nr,
  240. const struct lpddr2_device_timings **cs0_device_timings,
  241. const struct lpddr2_device_timings **cs1_device_timings)
  242. {
  243. u32 omap_rev = omap_revision();
  244. /* Identical devices on EMIF1 & EMIF2 */
  245. *cs0_device_timings = &elpida_2G_S4_timings;
  246. if (omap_rev == OMAP4430_ES1_0)
  247. *cs1_device_timings = NULL;
  248. else
  249. *cs1_device_timings = &elpida_2G_S4_timings;
  250. }
  251. void emif_get_device_timings(u32 emif_nr,
  252. const struct lpddr2_device_timings **cs0_device_timings,
  253. const struct lpddr2_device_timings **cs1_device_timings)
  254. __attribute__((weak, alias("emif_get_device_timings_sdp")));
  255. #endif /* CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS */