sdram_elpida.c 7.6 KB

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