blob: 20fc55216a1fb6aeca590695f55da5760dc88b8f [file] [log] [blame]
Aneesh Vcc565582011-07-21 09:10:09 -04001/*
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
Sricharan62a86502011-11-15 09:50:00 -050029#include <asm/emif.h>
Aneesh Vcc565582011-07-21 09:10:09 -040030#include <asm/arch/sys_proto.h>
31
32/*
33 * This file provides details of the LPDDR2 SDRAM parts used on OMAP4430
34 * SDP and Panda. Since the parts used and geometry are identical for
35 * SDP and Panda for a given OMAP4 revision, this information is kept
36 * here instead of being in board directory. However the key functions
37 * exported are weakly linked so that they can be over-ridden in the board
38 * directory if there is a OMAP4 board in the future that uses a different
39 * memory device or geometry.
40 *
41 * For any new board with different memory devices over-ride one or more
42 * of the following functions as per the CONFIG flags you intend to enable:
43 * - emif_get_reg_dump()
44 * - emif_get_dmm_regs()
45 * - emif_get_device_details()
46 * - emif_get_device_timings()
47 */
48
Aneesh Vc0e88522011-07-21 09:10:12 -040049#ifdef CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS
50
Aneesh Vcc565582011-07-21 09:10:09 -040051static const struct emif_regs emif_regs_elpida_200_mhz_2cs = {
52 .sdram_config_init = 0x80000eb9,
53 .sdram_config = 0x80001ab9,
54 .ref_ctrl = 0x0000030c,
55 .sdram_tim1 = 0x08648311,
56 .sdram_tim2 = 0x101b06ca,
57 .sdram_tim3 = 0x0048a19f,
58 .read_idle_ctrl = 0x000501ff,
59 .zq_config = 0x500b3214,
60 .temp_alert_config = 0xd8016893,
61 .emif_ddr_phy_ctlr_1_init = 0x049ffff5,
62 .emif_ddr_phy_ctlr_1 = 0x049ff808
63};
64
65static const struct emif_regs emif_regs_elpida_380_mhz_1cs = {
66 .sdram_config_init = 0x80000eb1,
67 .sdram_config = 0x80001ab1,
68 .ref_ctrl = 0x000005cd,
69 .sdram_tim1 = 0x10cb0622,
70 .sdram_tim2 = 0x20350d52,
71 .sdram_tim3 = 0x00b1431f,
72 .read_idle_ctrl = 0x000501ff,
73 .zq_config = 0x500b3214,
74 .temp_alert_config = 0x58016893,
75 .emif_ddr_phy_ctlr_1_init = 0x049ffff5,
76 .emif_ddr_phy_ctlr_1 = 0x049ff418
77};
78
79const struct emif_regs emif_regs_elpida_400_mhz_2cs = {
80 .sdram_config_init = 0x80000eb9,
81 .sdram_config = 0x80001ab9,
82 .ref_ctrl = 0x00000618,
83 .sdram_tim1 = 0x10eb0662,
84 .sdram_tim2 = 0x20370dd2,
85 .sdram_tim3 = 0x00b1c33f,
86 .read_idle_ctrl = 0x000501ff,
87 .zq_config = 0xd00b3214,
88 .temp_alert_config = 0xd8016893,
89 .emif_ddr_phy_ctlr_1_init = 0x049ffff5,
90 .emif_ddr_phy_ctlr_1 = 0x049ff418
91};
SRICHARAN R3d534962012-03-12 02:25:37 +000092
Aneesh Vcc565582011-07-21 09:10:09 -040093const struct dmm_lisa_map_regs lisa_map_2G_x_1_x_2 = {
94 .dmm_lisa_map_0 = 0xFF020100,
95 .dmm_lisa_map_1 = 0,
96 .dmm_lisa_map_2 = 0,
Lokesh Vutla8caa56c2013-02-12 21:29:07 +000097 .dmm_lisa_map_3 = 0x80540300,
98 .is_ma_present = 0x0
Aneesh Vcc565582011-07-21 09:10:09 -040099};
100
101const struct dmm_lisa_map_regs lisa_map_2G_x_2_x_2 = {
102 .dmm_lisa_map_0 = 0xFF020100,
103 .dmm_lisa_map_1 = 0,
104 .dmm_lisa_map_2 = 0,
Lokesh Vutla8caa56c2013-02-12 21:29:07 +0000105 .dmm_lisa_map_3 = 0x80640300,
106 .is_ma_present = 0x0
Aneesh Vcc565582011-07-21 09:10:09 -0400107};
108
Lokesh Vutla8caa56c2013-02-12 21:29:07 +0000109const struct dmm_lisa_map_regs ma_lisa_map_2G_x_2_x_2 = {
110 .dmm_lisa_map_0 = 0xFF020100,
111 .dmm_lisa_map_1 = 0,
112 .dmm_lisa_map_2 = 0,
113 .dmm_lisa_map_3 = 0x80640300,
114 .is_ma_present = 0x1
115};
116
Aneesh Vcc565582011-07-21 09:10:09 -0400117static void emif_get_reg_dump_sdp(u32 emif_nr, const struct emif_regs **regs)
118{
119 u32 omap4_rev = omap_revision();
120
121 /* Same devices and geometry on both EMIFs */
122 if (omap4_rev == OMAP4430_ES1_0)
123 *regs = &emif_regs_elpida_380_mhz_1cs;
124 else if (omap4_rev == OMAP4430_ES2_0)
125 *regs = &emif_regs_elpida_200_mhz_2cs;
126 else
127 *regs = &emif_regs_elpida_400_mhz_2cs;
128}
129void emif_get_reg_dump(u32 emif_nr, const struct emif_regs **regs)
130 __attribute__((weak, alias("emif_get_reg_dump_sdp")));
131
132static void emif_get_dmm_regs_sdp(const struct dmm_lisa_map_regs
133 **dmm_lisa_regs)
134{
135 u32 omap_rev = omap_revision();
136
137 if (omap_rev == OMAP4430_ES1_0)
138 *dmm_lisa_regs = &lisa_map_2G_x_1_x_2;
Lokesh Vutla8caa56c2013-02-12 21:29:07 +0000139 else if (omap_rev < OMAP4460_ES1_0)
Aneesh Vcc565582011-07-21 09:10:09 -0400140 *dmm_lisa_regs = &lisa_map_2G_x_2_x_2;
Lokesh Vutla8caa56c2013-02-12 21:29:07 +0000141 else
142 *dmm_lisa_regs = &ma_lisa_map_2G_x_2_x_2;
Aneesh Vcc565582011-07-21 09:10:09 -0400143}
144
145void emif_get_dmm_regs(const struct dmm_lisa_map_regs **dmm_lisa_regs)
146 __attribute__((weak, alias("emif_get_dmm_regs_sdp")));
Aneesh Vc0e88522011-07-21 09:10:12 -0400147
148#else
149
150static const struct lpddr2_device_details elpida_2G_S4_details = {
151 .type = LPDDR2_TYPE_S4,
152 .density = LPDDR2_DENSITY_2Gb,
153 .io_width = LPDDR2_IO_WIDTH_32,
154 .manufacturer = LPDDR2_MANUFACTURER_ELPIDA
155};
156
Aneesh V14f821a2011-09-08 11:05:53 -0400157struct lpddr2_device_details *emif_get_device_details_sdp(u32 emif_nr, u8 cs,
158 struct lpddr2_device_details *lpddr2_dev_details)
Aneesh Vc0e88522011-07-21 09:10:12 -0400159{
160 u32 omap_rev = omap_revision();
161
162 /* EMIF1 & EMIF2 have identical configuration */
Aneesh V14f821a2011-09-08 11:05:53 -0400163 if ((omap_rev == OMAP4430_ES1_0) && (cs == CS1)) {
164 /* Nothing connected on CS1 for ES1.0 */
165 return NULL;
166 } else {
167 /* In all other cases Elpida 2G device */
168 *lpddr2_dev_details = elpida_2G_S4_details;
169 return lpddr2_dev_details;
170 }
Aneesh Vc0e88522011-07-21 09:10:12 -0400171}
172
Aneesh V14f821a2011-09-08 11:05:53 -0400173struct lpddr2_device_details *emif_get_device_details(u32 emif_nr, u8 cs,
174 struct lpddr2_device_details *lpddr2_dev_details)
Aneesh Vc0e88522011-07-21 09:10:12 -0400175 __attribute__((weak, alias("emif_get_device_details_sdp")));
176
177#endif /* CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS */
178
179#ifndef CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS
180static const struct lpddr2_ac_timings timings_elpida_400_mhz = {
181 .max_freq = 400000000,
182 .RL = 6,
183 .tRPab = 21,
184 .tRCD = 18,
185 .tWR = 15,
186 .tRASmin = 42,
187 .tRRD = 10,
188 .tWTRx2 = 15,
189 .tXSR = 140,
190 .tXPx2 = 15,
191 .tRFCab = 130,
192 .tRTPx2 = 15,
193 .tCKE = 3,
194 .tCKESR = 15,
195 .tZQCS = 90,
196 .tZQCL = 360,
197 .tZQINIT = 1000,
198 .tDQSCKMAXx2 = 11,
199 .tRASmax = 70,
200 .tFAW = 50
201};
202
203static const struct lpddr2_ac_timings timings_elpida_333_mhz = {
204 .max_freq = 333000000,
205 .RL = 5,
206 .tRPab = 21,
207 .tRCD = 18,
208 .tWR = 15,
209 .tRASmin = 42,
210 .tRRD = 10,
211 .tWTRx2 = 15,
212 .tXSR = 140,
213 .tXPx2 = 15,
214 .tRFCab = 130,
215 .tRTPx2 = 15,
216 .tCKE = 3,
217 .tCKESR = 15,
218 .tZQCS = 90,
219 .tZQCL = 360,
220 .tZQINIT = 1000,
221 .tDQSCKMAXx2 = 11,
222 .tRASmax = 70,
223 .tFAW = 50
224};
225
226static const struct lpddr2_ac_timings timings_elpida_200_mhz = {
227 .max_freq = 200000000,
228 .RL = 3,
229 .tRPab = 21,
230 .tRCD = 18,
231 .tWR = 15,
232 .tRASmin = 42,
233 .tRRD = 10,
234 .tWTRx2 = 20,
235 .tXSR = 140,
236 .tXPx2 = 15,
237 .tRFCab = 130,
238 .tRTPx2 = 15,
239 .tCKE = 3,
240 .tCKESR = 15,
241 .tZQCS = 90,
242 .tZQCL = 360,
243 .tZQINIT = 1000,
244 .tDQSCKMAXx2 = 11,
245 .tRASmax = 70,
246 .tFAW = 50
247};
248
249static const struct lpddr2_min_tck min_tck_elpida = {
250 .tRL = 3,
251 .tRP_AB = 3,
252 .tRCD = 3,
253 .tWR = 3,
254 .tRAS_MIN = 3,
255 .tRRD = 2,
256 .tWTR = 2,
257 .tXP = 2,
258 .tRTP = 2,
259 .tCKE = 3,
260 .tCKESR = 3,
261 .tFAW = 8
262};
263
264static const struct lpddr2_ac_timings *elpida_ac_timings[MAX_NUM_SPEEDBINS] = {
265 &timings_elpida_200_mhz,
266 &timings_elpida_333_mhz,
267 &timings_elpida_400_mhz
268};
269
270static const struct lpddr2_device_timings elpida_2G_S4_timings = {
271 .ac_timings = elpida_ac_timings,
272 .min_tck = &min_tck_elpida,
273};
274
275void emif_get_device_timings_sdp(u32 emif_nr,
276 const struct lpddr2_device_timings **cs0_device_timings,
277 const struct lpddr2_device_timings **cs1_device_timings)
278{
279 u32 omap_rev = omap_revision();
280
281 /* Identical devices on EMIF1 & EMIF2 */
282 *cs0_device_timings = &elpida_2G_S4_timings;
283
284 if (omap_rev == OMAP4430_ES1_0)
285 *cs1_device_timings = NULL;
286 else
287 *cs1_device_timings = &elpida_2G_S4_timings;
288}
289
290void emif_get_device_timings(u32 emif_nr,
291 const struct lpddr2_device_timings **cs0_device_timings,
292 const struct lpddr2_device_timings **cs1_device_timings)
293 __attribute__((weak, alias("emif_get_device_timings_sdp")));
294
295#endif /* CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS */
Lokesh Vutla05dab552013-02-04 04:22:03 +0000296
297const struct lpddr2_mr_regs mr_regs = {
298 .mr1 = MR1_BL_8_BT_SEQ_WRAP_EN_NWR_3,
299 .mr2 = 0x4,
300 .mr3 = -1,
301 .mr10 = MR10_ZQ_ZQINIT,
302 .mr16 = MR16_REF_FULL_ARRAY
303};
304
305void get_lpddr2_mr_regs(const struct lpddr2_mr_regs **regs)
306{
307 *regs = &mr_regs;
308}