blob: 6bf4cf4a75825867cff2eeac7b6ff35efd779184 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Sricharanbb772a52011-11-15 09:50:00 -05002/*
SRICHARAN R971f2ba2012-03-12 02:25:45 +00003 * Timing and Organization details of the ddr device parts used in OMAP5
Sricharanbb772a52011-11-15 09:50:00 -05004 * EVM
5 *
6 * (C) Copyright 2010
7 * Texas Instruments, <www.ti.com>
8 *
9 * Aneesh V <aneesh@ti.com>
10 * Sricharan R <r.sricharan@ti.com>
Sricharanbb772a52011-11-15 09:50:00 -050011 */
12
13#include <asm/emif.h>
14#include <asm/arch/sys_proto.h>
15
16/*
17 * This file provides details of the LPDDR2 SDRAM parts used on OMAP5
18 * EVM. Since the parts used and geometry are identical for
19 * evm for a given OMAP5 revision, this information is kept
20 * here instead of being in board directory. However the key functions
21 * exported are weakly linked so that they can be over-ridden in the board
22 * directory if there is a OMAP5 board in the future that uses a different
23 * memory device or geometry.
24 *
25 * For any new board with different memory devices over-ride one or more
26 * of the following functions as per the CONFIG flags you intend to enable:
27 * - emif_get_reg_dump()
28 * - emif_get_dmm_regs()
29 * - emif_get_device_details()
30 * - emif_get_device_timings()
31 */
32
33#ifdef CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS
SRICHARAN R971f2ba2012-03-12 02:25:45 +000034const struct emif_regs emif_regs_532_mhz_2cs = {
SRICHARAN Rf4010732012-03-12 02:25:37 +000035 .sdram_config_init = 0x80800EBA,
36 .sdram_config = 0x808022BA,
Sricharanbb772a52011-11-15 09:50:00 -050037 .ref_ctrl = 0x0000081A,
38 .sdram_tim1 = 0x772F6873,
SRICHARAN Rf4010732012-03-12 02:25:37 +000039 .sdram_tim2 = 0x304a129a,
40 .sdram_tim3 = 0x02f7e45f,
Sricharanbb772a52011-11-15 09:50:00 -050041 .read_idle_ctrl = 0x00050000,
SRICHARAN Rf4010732012-03-12 02:25:37 +000042 .zq_config = 0x000b3215,
43 .temp_alert_config = 0x08000a05,
44 .emif_ddr_phy_ctlr_1_init = 0x0E28420d,
45 .emif_ddr_phy_ctlr_1 = 0x0E28420d,
46 .emif_ddr_ext_phy_ctrl_1 = 0x04020080,
47 .emif_ddr_ext_phy_ctrl_2 = 0x28C518A3,
48 .emif_ddr_ext_phy_ctrl_3 = 0x518A3146,
49 .emif_ddr_ext_phy_ctrl_4 = 0x0014628C,
50 .emif_ddr_ext_phy_ctrl_5 = 0x04010040
Sricharanbb772a52011-11-15 09:50:00 -050051};
52
Lokesh Vutla9100ede2013-02-12 01:33:44 +000053const struct emif_regs emif_regs_532_mhz_2cs_es2 = {
54 .sdram_config_init = 0x80800EBA,
55 .sdram_config = 0x808022BA,
56 .ref_ctrl = 0x0000081A,
57 .sdram_tim1 = 0x772F6873,
58 .sdram_tim2 = 0x304a129a,
59 .sdram_tim3 = 0x02f7e45f,
60 .read_idle_ctrl = 0x00050000,
61 .zq_config = 0x100b3215,
62 .temp_alert_config = 0x08000a05,
63 .emif_ddr_phy_ctlr_1_init = 0x0E30400d,
64 .emif_ddr_phy_ctlr_1 = 0x0E30400d,
65 .emif_ddr_ext_phy_ctrl_1 = 0x04020080,
66 .emif_ddr_ext_phy_ctrl_2 = 0x28C518A3,
67 .emif_ddr_ext_phy_ctrl_3 = 0x518A3146,
68 .emif_ddr_ext_phy_ctrl_4 = 0x0014628C,
69 .emif_ddr_ext_phy_ctrl_5 = 0xC330CC33,
70};
71
SRICHARAN R971f2ba2012-03-12 02:25:45 +000072const struct emif_regs emif_regs_266_mhz_2cs = {
SRICHARAN Rf4010732012-03-12 02:25:37 +000073 .sdram_config_init = 0x80800EBA,
74 .sdram_config = 0x808022BA,
75 .ref_ctrl = 0x0000040D,
76 .sdram_tim1 = 0x2A86B419,
77 .sdram_tim2 = 0x1025094A,
78 .sdram_tim3 = 0x026BA22F,
79 .read_idle_ctrl = 0x00050000,
80 .zq_config = 0x000b3215,
81 .temp_alert_config = 0x08000a05,
82 .emif_ddr_phy_ctlr_1_init = 0x0E28420d,
83 .emif_ddr_phy_ctlr_1 = 0x0E28420d,
84 .emif_ddr_ext_phy_ctrl_1 = 0x04020080,
85 .emif_ddr_ext_phy_ctrl_2 = 0x0A414829,
86 .emif_ddr_ext_phy_ctrl_3 = 0x14829052,
87 .emif_ddr_ext_phy_ctrl_4 = 0x000520A4,
88 .emif_ddr_ext_phy_ctrl_5 = 0x04010040
89};
90
Lokesh Vutla43037d72012-05-22 00:03:24 +000091const struct emif_regs emif_regs_ddr3_532_mhz_1cs = {
92 .sdram_config_init = 0x61851B32,
93 .sdram_config = 0x61851B32,
Sricharan R92b04822013-05-30 03:19:39 +000094 .sdram_config2 = 0x0,
Lokesh Vutla43037d72012-05-22 00:03:24 +000095 .ref_ctrl = 0x00001035,
96 .sdram_tim1 = 0xCCCF36B3,
97 .sdram_tim2 = 0x308F7FDA,
98 .sdram_tim3 = 0x027F88A8,
99 .read_idle_ctrl = 0x00050000,
100 .zq_config = 0x0007190B,
101 .temp_alert_config = 0x00000000,
102 .emif_ddr_phy_ctlr_1_init = 0x0020420A,
103 .emif_ddr_phy_ctlr_1 = 0x0024420A,
104 .emif_ddr_ext_phy_ctrl_1 = 0x04040100,
105 .emif_ddr_ext_phy_ctrl_2 = 0x00000000,
106 .emif_ddr_ext_phy_ctrl_3 = 0x00000000,
107 .emif_ddr_ext_phy_ctrl_4 = 0x00000000,
108 .emif_ddr_ext_phy_ctrl_5 = 0x04010040,
109 .emif_rd_wr_lvl_rmp_win = 0x00000000,
110 .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
111 .emif_rd_wr_lvl_ctl = 0x00000000,
112 .emif_rd_wr_exec_thresh = 0x00000305
113};
114
Lokesh Vutla9100ede2013-02-12 01:33:44 +0000115const struct emif_regs emif_regs_ddr3_532_mhz_1cs_es2 = {
116 .sdram_config_init = 0x61851B32,
117 .sdram_config = 0x61851B32,
Sricharan R92b04822013-05-30 03:19:39 +0000118 .sdram_config2 = 0x0,
Lokesh Vutla9100ede2013-02-12 01:33:44 +0000119 .ref_ctrl = 0x00001035,
120 .sdram_tim1 = 0xCCCF36B3,
121 .sdram_tim2 = 0x308F7FDA,
122 .sdram_tim3 = 0x027F88A8,
123 .read_idle_ctrl = 0x00050000,
124 .zq_config = 0x1007190B,
125 .temp_alert_config = 0x00000000,
126 .emif_ddr_phy_ctlr_1_init = 0x0030400A,
127 .emif_ddr_phy_ctlr_1 = 0x0034400A,
128 .emif_ddr_ext_phy_ctrl_1 = 0x04040100,
129 .emif_ddr_ext_phy_ctrl_2 = 0x00000000,
130 .emif_ddr_ext_phy_ctrl_3 = 0x00000000,
131 .emif_ddr_ext_phy_ctrl_4 = 0x00000000,
132 .emif_ddr_ext_phy_ctrl_5 = 0x4350D435,
133 .emif_rd_wr_lvl_rmp_win = 0x00000000,
134 .emif_rd_wr_lvl_rmp_ctl = 0x80000000,
135 .emif_rd_wr_lvl_ctl = 0x00000000,
136 .emif_rd_wr_exec_thresh = 0x40000305
137};
138
SRICHARAN Rf4010732012-03-12 02:25:37 +0000139const struct dmm_lisa_map_regs lisa_map_4G_x_2_x_2 = {
140 .dmm_lisa_map_0 = 0x0,
SRICHARAN R77efdeb2012-05-17 00:12:07 +0000141 .dmm_lisa_map_1 = 0x0,
142 .dmm_lisa_map_2 = 0x80740300,
Lokesh Vutla78314192013-02-12 21:29:07 +0000143 .dmm_lisa_map_3 = 0xFF020100,
144 .is_ma_present = 0x1
145};
146
Sricharanbb772a52011-11-15 09:50:00 -0500147static void emif_get_reg_dump_sdp(u32 emif_nr, const struct emif_regs **regs)
148{
Lokesh Vutlae05a4f12013-02-04 04:22:03 +0000149 switch (omap_revision()) {
150 case OMAP5430_ES1_0:
Lokesh Vutla43037d72012-05-22 00:03:24 +0000151 *regs = &emif_regs_532_mhz_2cs;
Lokesh Vutlae05a4f12013-02-04 04:22:03 +0000152 break;
153 case OMAP5432_ES1_0:
154 *regs = &emif_regs_ddr3_532_mhz_1cs;
155 break;
Lokesh Vutla9100ede2013-02-12 01:33:44 +0000156 case OMAP5430_ES2_0:
157 *regs = &emif_regs_532_mhz_2cs_es2;
158 break;
159 case OMAP5432_ES2_0:
Lokesh Vutlaa7638832016-03-08 09:18:06 +0530160 default:
Lokesh Vutla9100ede2013-02-12 01:33:44 +0000161 *regs = &emif_regs_ddr3_532_mhz_1cs_es2;
Sricharan R92b04822013-05-30 03:19:39 +0000162 break;
Lokesh Vutlae05a4f12013-02-04 04:22:03 +0000163 }
Sricharanbb772a52011-11-15 09:50:00 -0500164}
Lokesh Vutlae05a4f12013-02-04 04:22:03 +0000165
Sricharanbb772a52011-11-15 09:50:00 -0500166void emif_get_reg_dump(u32 emif_nr, const struct emif_regs **regs)
167 __attribute__((weak, alias("emif_get_reg_dump_sdp")));
168
169static void emif_get_dmm_regs_sdp(const struct dmm_lisa_map_regs
170 **dmm_lisa_regs)
171{
Lokesh Vutla78314192013-02-12 21:29:07 +0000172 switch (omap_revision()) {
173 case OMAP5430_ES1_0:
174 case OMAP5430_ES2_0:
175 case OMAP5432_ES1_0:
176 case OMAP5432_ES2_0:
Lokesh Vutlaa7638832016-03-08 09:18:06 +0530177 default:
Lokesh Vutla78314192013-02-12 21:29:07 +0000178 *dmm_lisa_regs = &lisa_map_4G_x_2_x_2;
179 break;
Lokesh Vutla78314192013-02-12 21:29:07 +0000180 }
181
Sricharanbb772a52011-11-15 09:50:00 -0500182}
183
184void emif_get_dmm_regs(const struct dmm_lisa_map_regs **dmm_lisa_regs)
185 __attribute__((weak, alias("emif_get_dmm_regs_sdp")));
Sricharanbb772a52011-11-15 09:50:00 -0500186#else
187
SRICHARAN R971f2ba2012-03-12 02:25:45 +0000188static const struct lpddr2_device_details dev_4G_S4_details = {
Sricharanbb772a52011-11-15 09:50:00 -0500189 .type = LPDDR2_TYPE_S4,
190 .density = LPDDR2_DENSITY_4Gb,
191 .io_width = LPDDR2_IO_WIDTH_32,
SRICHARAN R971f2ba2012-03-12 02:25:45 +0000192 .manufacturer = LPDDR2_MANUFACTURER_SAMSUNG
Sricharanbb772a52011-11-15 09:50:00 -0500193};
194
195static void emif_get_device_details_sdp(u32 emif_nr,
196 struct lpddr2_device_details *cs0_device_details,
197 struct lpddr2_device_details *cs1_device_details)
198{
199 /* EMIF1 & EMIF2 have identical configuration */
SRICHARAN R971f2ba2012-03-12 02:25:45 +0000200 *cs0_device_details = dev_4G_S4_details;
201 *cs1_device_details = dev_4G_S4_details;
Sricharanbb772a52011-11-15 09:50:00 -0500202}
203
204void emif_get_device_details(u32 emif_nr,
205 struct lpddr2_device_details *cs0_device_details,
206 struct lpddr2_device_details *cs1_device_details)
207 __attribute__((weak, alias("emif_get_device_details_sdp")));
208
209#endif /* CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS */
210
SRICHARAN R6c709352013-11-08 17:40:37 +0530211const u32 ext_phy_ctrl_const_base[] = {
Lokesh Vutlae05a4f12013-02-04 04:22:03 +0000212 0x01004010,
213 0x00001004,
214 0x04010040,
215 0x01004010,
216 0x00001004,
217 0x00000000,
218 0x00000000,
219 0x00000000,
220 0x80080080,
221 0x00800800,
222 0x08102040,
223 0x00000001,
224 0x540A8150,
225 0xA81502a0,
226 0x002A0540,
227 0x00000000,
228 0x00000000,
229 0x00000000,
Sricharan R92b04822013-05-30 03:19:39 +0000230 0x00000077,
231 0x0
Lokesh Vutlae05a4f12013-02-04 04:22:03 +0000232};
233
SRICHARAN R6c709352013-11-08 17:40:37 +0530234const u32 ddr3_ext_phy_ctrl_const_base_es1[] = {
Lokesh Vutlae05a4f12013-02-04 04:22:03 +0000235 0x01004010,
236 0x00001004,
237 0x04010040,
238 0x01004010,
239 0x00001004,
240 0x00000000,
241 0x00000000,
242 0x00000000,
243 0x80080080,
244 0x00800800,
245 0x08102040,
246 0x00000002,
247 0x0,
248 0x0,
249 0x0,
250 0x00000000,
251 0x00000000,
252 0x00000000,
Sricharan R92b04822013-05-30 03:19:39 +0000253 0x00000057,
254 0x0
Lokesh Vutlae05a4f12013-02-04 04:22:03 +0000255};
256
SRICHARAN R6c709352013-11-08 17:40:37 +0530257const u32 ddr3_ext_phy_ctrl_const_base_es2[] = {
Lokesh Vutla9100ede2013-02-12 01:33:44 +0000258 0x50D4350D,
259 0x00000D43,
260 0x04010040,
261 0x01004010,
262 0x00001004,
263 0x00000000,
264 0x00000000,
265 0x00000000,
266 0x80080080,
267 0x00800800,
268 0x08102040,
269 0x00000002,
270 0x00000000,
271 0x00000000,
272 0x00000000,
273 0x00000000,
274 0x00000000,
275 0x00000000,
Sricharan R92b04822013-05-30 03:19:39 +0000276 0x00000057,
277 0x0
278};
279
Lokesh Vutla6213db72015-06-03 14:43:21 +0530280/* Ext phy ctrl 1-35 regs */
Sricharan R92b04822013-05-30 03:19:39 +0000281const u32
SRICHARAN R6c709352013-11-08 17:40:37 +0530282dra_ddr3_ext_phy_ctrl_const_base_es1_emif1[] = {
Lokesh Vutla6213db72015-06-03 14:43:21 +0530283 0x10040100,
284 0x00910091,
285 0x00950095,
286 0x009B009B,
287 0x009E009E,
Lokesh Vutla1860d102015-02-16 10:15:57 +0530288 0x00980098,
289 0x00340034,
290 0x00350035,
291 0x00340034,
292 0x00310031,
293 0x00340034,
Sricharan Rf2a1b932014-07-31 12:05:50 +0530294 0x007F007F,
295 0x007F007F,
296 0x007F007F,
297 0x007F007F,
298 0x007F007F,
Lokesh Vutla1860d102015-02-16 10:15:57 +0530299 0x00480048,
300 0x004A004A,
301 0x00520052,
302 0x00550055,
303 0x00500050,
Sricharan Rf2a1b932014-07-31 12:05:50 +0530304 0x00000000,
305 0x00600020,
Lokesh Vutla6213db72015-06-03 14:43:21 +0530306 0x40011080,
SRICHARAN R6c709352013-11-08 17:40:37 +0530307 0x08102040,
308 0x0,
309 0x0,
310 0x0,
311 0x0,
Lokesh Vutla920638f2015-06-03 14:43:23 +0530312 0x0,
313 0x0,
314 0x0,
315 0x0,
316 0x0,
SRICHARAN R6c709352013-11-08 17:40:37 +0530317 0x0
Sricharan R92b04822013-05-30 03:19:39 +0000318};
319
Lokesh Vutla6213db72015-06-03 14:43:21 +0530320/* Ext phy ctrl 1-35 regs */
Sricharan R92b04822013-05-30 03:19:39 +0000321const u32
SRICHARAN R6c709352013-11-08 17:40:37 +0530322dra_ddr3_ext_phy_ctrl_const_base_es1_emif2[] = {
Lokesh Vutla6213db72015-06-03 14:43:21 +0530323 0x10040100,
324 0x00910091,
325 0x00950095,
326 0x009B009B,
327 0x009E009E,
Lokesh Vutla1860d102015-02-16 10:15:57 +0530328 0x00980098,
329 0x00330033,
330 0x00330033,
331 0x002F002F,
332 0x00320032,
333 0x00310031,
SRICHARAN R6c709352013-11-08 17:40:37 +0530334 0x007F007F,
335 0x007F007F,
336 0x007F007F,
337 0x007F007F,
338 0x007F007F,
Lokesh Vutla1860d102015-02-16 10:15:57 +0530339 0x00520052,
340 0x00520052,
341 0x00470047,
342 0x00490049,
343 0x00500050,
Sricharan Rf2a1b932014-07-31 12:05:50 +0530344 0x00000000,
SRICHARAN R6c709352013-11-08 17:40:37 +0530345 0x00600020,
Lokesh Vutla6213db72015-06-03 14:43:21 +0530346 0x40011080,
SRICHARAN R6c709352013-11-08 17:40:37 +0530347 0x08102040,
348 0x0,
349 0x0,
350 0x0,
351 0x0,
Lokesh Vutla920638f2015-06-03 14:43:23 +0530352 0x0,
353 0x0,
354 0x0,
355 0x0,
356 0x0,
SRICHARAN R6c709352013-11-08 17:40:37 +0530357 0x0
Lokesh Vutla9100ede2013-02-12 01:33:44 +0000358};
359
Lokesh Vutla6213db72015-06-03 14:43:21 +0530360/* Ext phy ctrl 1-35 regs */
R Sricharan681f7852014-08-28 12:01:04 +0530361const u32
362dra_ddr3_ext_phy_ctrl_const_base_666MHz[] = {
Lokesh Vutla6213db72015-06-03 14:43:21 +0530363 0x10040100,
364 0x00A400A4,
365 0x00A900A9,
366 0x00B000B0,
367 0x00B000B0,
R Sricharan681f7852014-08-28 12:01:04 +0530368 0x00A400A4,
369 0x00390039,
370 0x00320032,
371 0x00320032,
372 0x00320032,
373 0x00440044,
374 0x00550055,
375 0x00550055,
376 0x00550055,
377 0x00550055,
378 0x007F007F,
379 0x004D004D,
380 0x00430043,
381 0x00560056,
382 0x00540054,
383 0x00600060,
384 0x0,
385 0x00600020,
386 0x40010080,
387 0x08102040,
388 0x0,
389 0x0,
390 0x0,
391 0x0,
Lokesh Vutlaf308b4f2015-06-03 14:43:24 +0530392 0x0,
393 0x0,
394 0x0,
395 0x0,
396 0x0,
R Sricharan681f7852014-08-28 12:01:04 +0530397 0x0
398};
399
Nishanth Menon9c90f512016-03-15 18:09:13 -0500400const u32 dra_ddr3_ext_phy_ctrl_const_base_666MHz_es2[] = {
401 0x04040100,
402 0x006B009F,
403 0x006B00A2,
404 0x006B00A8,
405 0x006B00A8,
406 0x006B00B2,
407 0x002F002F,
408 0x002F002F,
409 0x002F002F,
410 0x002F002F,
411 0x002F002F,
412 0x00600073,
413 0x00600071,
414 0x0060007C,
415 0x0060007E,
416 0x00600084,
417 0x00400053,
418 0x00400051,
419 0x0040005C,
420 0x0040005E,
421 0x00400064,
422 0x00800080,
423 0x00800080,
424 0x40010080,
425 0x08102040,
426 0x005B008F,
427 0x005B0092,
428 0x005B0098,
429 0x005B0098,
430 0x005B00A2,
431 0x00300043,
432 0x00300041,
433 0x0030004C,
434 0x0030004E,
435 0x00300054,
436 0x00000077
437};
438
Lokesh Vutlae05a4f12013-02-04 04:22:03 +0000439const struct lpddr2_mr_regs mr_regs = {
440 .mr1 = MR1_BL_8_BT_SEQ_WRAP_EN_NWR_8,
441 .mr2 = 0x6,
442 .mr3 = 0x1,
443 .mr10 = MR10_ZQ_ZQINIT,
444 .mr16 = MR16_REF_FULL_ARRAY
445};
446
Felipe Balbieedd9912014-11-06 08:28:49 -0600447void __weak emif_get_ext_phy_ctrl_const_regs(u32 emif_nr,
SRICHARAN R6c709352013-11-08 17:40:37 +0530448 const u32 **regs,
449 u32 *size)
Lokesh Vutlae05a4f12013-02-04 04:22:03 +0000450{
451 switch (omap_revision()) {
452 case OMAP5430_ES1_0:
Lokesh Vutla9100ede2013-02-12 01:33:44 +0000453 case OMAP5430_ES2_0:
Lokesh Vutlae05a4f12013-02-04 04:22:03 +0000454 *regs = ext_phy_ctrl_const_base;
SRICHARAN R6c709352013-11-08 17:40:37 +0530455 *size = ARRAY_SIZE(ext_phy_ctrl_const_base);
Lokesh Vutlae05a4f12013-02-04 04:22:03 +0000456 break;
457 case OMAP5432_ES1_0:
458 *regs = ddr3_ext_phy_ctrl_const_base_es1;
SRICHARAN R6c709352013-11-08 17:40:37 +0530459 *size = ARRAY_SIZE(ddr3_ext_phy_ctrl_const_base_es1);
Lokesh Vutlae05a4f12013-02-04 04:22:03 +0000460 break;
Lokesh Vutla9100ede2013-02-12 01:33:44 +0000461 case OMAP5432_ES2_0:
Sricharan R92b04822013-05-30 03:19:39 +0000462 *regs = ddr3_ext_phy_ctrl_const_base_es2;
SRICHARAN R6c709352013-11-08 17:40:37 +0530463 *size = ARRAY_SIZE(ddr3_ext_phy_ctrl_const_base_es2);
Sricharan R92b04822013-05-30 03:19:39 +0000464 break;
Lokesh Vutla78314192013-02-12 21:29:07 +0000465 case DRA752_ES1_0:
Nishanth Menon3ac8c0b2014-01-14 10:54:42 -0600466 case DRA752_ES1_1:
Nishanth Menonc1ea3be2015-08-13 09:50:58 -0500467 case DRA752_ES2_0:
SRICHARAN R6c709352013-11-08 17:40:37 +0530468 if (emif_nr == 1) {
Sricharan R92b04822013-05-30 03:19:39 +0000469 *regs = dra_ddr3_ext_phy_ctrl_const_base_es1_emif1;
SRICHARAN R6c709352013-11-08 17:40:37 +0530470 *size =
471 ARRAY_SIZE(dra_ddr3_ext_phy_ctrl_const_base_es1_emif1);
472 } else {
Sricharan R92b04822013-05-30 03:19:39 +0000473 *regs = dra_ddr3_ext_phy_ctrl_const_base_es1_emif2;
SRICHARAN R6c709352013-11-08 17:40:37 +0530474 *size =
475 ARRAY_SIZE(dra_ddr3_ext_phy_ctrl_const_base_es1_emif2);
476 }
Sricharan R92b04822013-05-30 03:19:39 +0000477 break;
R Sricharan681f7852014-08-28 12:01:04 +0530478 case DRA722_ES1_0:
479 *regs = dra_ddr3_ext_phy_ctrl_const_base_666MHz;
480 *size = ARRAY_SIZE(dra_ddr3_ext_phy_ctrl_const_base_666MHz);
481 break;
Lokesh Vutlac9a7c172017-08-21 12:50:55 +0530482 case DRA762_ES1_0:
Lokesh Vutla941f2fc2017-12-29 11:47:51 +0530483 case DRA762_ABZ_ES1_0:
484 case DRA762_ACD_ES1_0:
Nishanth Menon9c90f512016-03-15 18:09:13 -0500485 case DRA722_ES2_0:
Vishal Mahaveerba396082017-08-26 16:51:22 -0500486 case DRA722_ES2_1:
Nishanth Menon9c90f512016-03-15 18:09:13 -0500487 *regs = dra_ddr3_ext_phy_ctrl_const_base_666MHz_es2;
488 *size = ARRAY_SIZE(dra_ddr3_ext_phy_ctrl_const_base_666MHz_es2);
489 break;
Lokesh Vutlae05a4f12013-02-04 04:22:03 +0000490 default:
Lokesh Vutla9100ede2013-02-12 01:33:44 +0000491 *regs = ddr3_ext_phy_ctrl_const_base_es2;
SRICHARAN R6c709352013-11-08 17:40:37 +0530492 *size = ARRAY_SIZE(ddr3_ext_phy_ctrl_const_base_es2);
Lokesh Vutla9100ede2013-02-12 01:33:44 +0000493
Lokesh Vutlae05a4f12013-02-04 04:22:03 +0000494 }
495}
496
497void get_lpddr2_mr_regs(const struct lpddr2_mr_regs **regs)
498{
499 *regs = &mr_regs;
500}
501
Lokesh Vutla6213db72015-06-03 14:43:21 +0530502static void do_ext_phy_settings_omap5(u32 base, const struct emif_regs *regs)
SRICHARAN R25476382012-06-04 03:40:23 +0000503{
504 u32 *ext_phy_ctrl_base = 0;
505 u32 *emif_ext_phy_ctrl_base = 0;
Sricharan R92b04822013-05-30 03:19:39 +0000506 u32 emif_nr;
Lokesh Vutlae05a4f12013-02-04 04:22:03 +0000507 const u32 *ext_phy_ctrl_const_regs;
SRICHARAN R25476382012-06-04 03:40:23 +0000508 u32 i = 0;
SRICHARAN R6c709352013-11-08 17:40:37 +0530509 u32 size;
SRICHARAN R25476382012-06-04 03:40:23 +0000510
Sricharan R92b04822013-05-30 03:19:39 +0000511 emif_nr = (base == EMIF1_BASE) ? 1 : 2;
512
SRICHARAN R25476382012-06-04 03:40:23 +0000513 struct emif_reg_struct *emif = (struct emif_reg_struct *)base;
514
515 ext_phy_ctrl_base = (u32 *) &(regs->emif_ddr_ext_phy_ctrl_1);
516 emif_ext_phy_ctrl_base = (u32 *) &(emif->emif_ddr_ext_phy_ctrl_1);
517
518 /* Configure external phy control timing registers */
519 for (i = 0; i < EMIF_EXT_PHY_CTRL_TIMING_REG; i++) {
520 writel(*ext_phy_ctrl_base, emif_ext_phy_ctrl_base++);
521 /* Update shadow registers */
522 writel(*ext_phy_ctrl_base++, emif_ext_phy_ctrl_base++);
523 }
524
525 /*
526 * external phy 6-24 registers do not change with
527 * ddr frequency
528 */
SRICHARAN R6c709352013-11-08 17:40:37 +0530529 emif_get_ext_phy_ctrl_const_regs(emif_nr,
530 &ext_phy_ctrl_const_regs, &size);
531
532 for (i = 0; i < size; i++) {
Lokesh Vutlae05a4f12013-02-04 04:22:03 +0000533 writel(ext_phy_ctrl_const_regs[i],
534 emif_ext_phy_ctrl_base++);
SRICHARAN R25476382012-06-04 03:40:23 +0000535 /* Update shadow registers */
Lokesh Vutlae05a4f12013-02-04 04:22:03 +0000536 writel(ext_phy_ctrl_const_regs[i],
537 emif_ext_phy_ctrl_base++);
SRICHARAN R25476382012-06-04 03:40:23 +0000538 }
539}
540
Lokesh Vutla6213db72015-06-03 14:43:21 +0530541static void do_ext_phy_settings_dra7(u32 base, const struct emif_regs *regs)
542{
543 struct emif_reg_struct *emif = (struct emif_reg_struct *)base;
544 u32 *emif_ext_phy_ctrl_base = 0;
545 u32 emif_nr;
546 const u32 *ext_phy_ctrl_const_regs;
Lokesh Vutlae3ce3aa2016-03-05 17:32:30 +0530547 u32 i, hw_leveling, size, phy;
Lokesh Vutla6213db72015-06-03 14:43:21 +0530548
549 emif_nr = (base == EMIF1_BASE) ? 1 : 2;
550
551 hw_leveling = regs->emif_rd_wr_lvl_rmp_ctl >> EMIF_REG_RDWRLVL_EN_SHIFT;
Lokesh Vutlae3ce3aa2016-03-05 17:32:30 +0530552 phy = regs->emif_ddr_phy_ctlr_1_init;
Lokesh Vutla6213db72015-06-03 14:43:21 +0530553
554 emif_ext_phy_ctrl_base = (u32 *)&(emif->emif_ddr_ext_phy_ctrl_1);
555
556 emif_get_ext_phy_ctrl_const_regs(emif_nr,
557 &ext_phy_ctrl_const_regs, &size);
558
559 writel(ext_phy_ctrl_const_regs[0], &emif_ext_phy_ctrl_base[0]);
560 writel(ext_phy_ctrl_const_regs[0], &emif_ext_phy_ctrl_base[1]);
561
Lokesh Vutlae3ce3aa2016-03-05 17:32:30 +0530562 /*
563 * Copy the predefined PHY register values
564 * if leveling is disabled.
565 */
566 if (phy & EMIF_DDR_PHY_CTRL_1_RDLVLGATE_MASK_MASK)
567 for (i = 1; i < 6; i++) {
Lokesh Vutla6213db72015-06-03 14:43:21 +0530568 writel(ext_phy_ctrl_const_regs[i],
569 &emif_ext_phy_ctrl_base[i * 2]);
570 writel(ext_phy_ctrl_const_regs[i],
571 &emif_ext_phy_ctrl_base[i * 2 + 1]);
572 }
Lokesh Vutlae3ce3aa2016-03-05 17:32:30 +0530573
574 if (phy & EMIF_DDR_PHY_CTRL_1_RDLVL_MASK_MASK)
575 for (i = 6; i < 11; i++) {
576 writel(ext_phy_ctrl_const_regs[i],
577 &emif_ext_phy_ctrl_base[i * 2]);
578 writel(ext_phy_ctrl_const_regs[i],
579 &emif_ext_phy_ctrl_base[i * 2 + 1]);
580 }
581
582 if (phy & EMIF_DDR_PHY_CTRL_1_WRLVL_MASK_MASK)
583 for (i = 11; i < 25; i++) {
584 writel(ext_phy_ctrl_const_regs[i],
585 &emif_ext_phy_ctrl_base[i * 2]);
586 writel(ext_phy_ctrl_const_regs[i],
587 &emif_ext_phy_ctrl_base[i * 2 + 1]);
588 }
589
590 if (hw_leveling) {
Lokesh Vutla6213db72015-06-03 14:43:21 +0530591 /*
592 * Write the init value for HW levling to occur
593 */
594 for (i = 21; i < 35; i++) {
595 writel(ext_phy_ctrl_const_regs[i],
596 &emif_ext_phy_ctrl_base[i * 2]);
597 writel(ext_phy_ctrl_const_regs[i],
598 &emif_ext_phy_ctrl_base[i * 2 + 1]);
599 }
600 }
601}
602
603void do_ext_phy_settings(u32 base, const struct emif_regs *regs)
604{
605 if (is_omap54xx())
606 do_ext_phy_settings_omap5(base, regs);
607 else
608 do_ext_phy_settings_dra7(base, regs);
609}
610
Sricharanbb772a52011-11-15 09:50:00 -0500611#ifndef CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS
612static const struct lpddr2_ac_timings timings_jedec_532_mhz = {
613 .max_freq = 532000000,
614 .RL = 8,
615 .tRPab = 21,
616 .tRCD = 18,
617 .tWR = 15,
618 .tRASmin = 42,
619 .tRRD = 10,
620 .tWTRx2 = 15,
621 .tXSR = 140,
622 .tXPx2 = 15,
623 .tRFCab = 130,
624 .tRTPx2 = 15,
625 .tCKE = 3,
626 .tCKESR = 15,
627 .tZQCS = 90,
628 .tZQCL = 360,
629 .tZQINIT = 1000,
630 .tDQSCKMAXx2 = 11,
631 .tRASmax = 70,
632 .tFAW = 50
633};
634
SRICHARAN R971f2ba2012-03-12 02:25:45 +0000635static const struct lpddr2_min_tck min_tck = {
Sricharanbb772a52011-11-15 09:50:00 -0500636 .tRL = 3,
637 .tRP_AB = 3,
638 .tRCD = 3,
639 .tWR = 3,
640 .tRAS_MIN = 3,
641 .tRRD = 2,
642 .tWTR = 2,
643 .tXP = 2,
644 .tRTP = 2,
645 .tCKE = 3,
646 .tCKESR = 3,
647 .tFAW = 8
648};
649
SRICHARAN R971f2ba2012-03-12 02:25:45 +0000650static const struct lpddr2_ac_timings *ac_timings[MAX_NUM_SPEEDBINS] = {
Sricharanbb772a52011-11-15 09:50:00 -0500651 &timings_jedec_532_mhz
652};
653
SRICHARAN R971f2ba2012-03-12 02:25:45 +0000654static const struct lpddr2_device_timings dev_4G_S4_timings = {
655 .ac_timings = ac_timings,
656 .min_tck = &min_tck,
Sricharanbb772a52011-11-15 09:50:00 -0500657};
658
SRICHARAN R54d022e2013-11-08 17:40:38 +0530659/*
660 * List of status registers to be controlled back to control registers
661 * after initial leveling
662 * readreg, writereg
663 */
664const struct read_write_regs omap5_bug_00339_regs[] = {
665 { 8, 5 },
666 { 9, 6 },
667 { 10, 7 },
668 { 14, 8 },
669 { 15, 9 },
670 { 16, 10 },
671 { 11, 2 },
672 { 12, 3 },
673 { 13, 4 },
674 { 17, 11 },
675 { 18, 12 },
676 { 19, 13 },
677};
678
679const struct read_write_regs dra_bug_00339_regs[] = {
680 { 7, 7 },
681 { 8, 8 },
682 { 9, 9 },
683 { 10, 10 },
684 { 11, 11 },
685 { 12, 2 },
686 { 13, 3 },
687 { 14, 4 },
688 { 15, 5 },
689 { 16, 6 },
690 { 17, 12 },
691 { 18, 13 },
692 { 19, 14 },
693 { 20, 15 },
694 { 21, 16 },
695 { 22, 17 },
696 { 23, 18 },
697 { 24, 19 },
698 { 25, 20 },
699 { 26, 21}
700};
701
702const struct read_write_regs *get_bug_regs(u32 *iterations)
703{
704 const struct read_write_regs *bug_00339_regs_ptr = NULL;
705
706 switch (omap_revision()) {
707 case OMAP5430_ES1_0:
708 case OMAP5430_ES2_0:
709 case OMAP5432_ES1_0:
710 case OMAP5432_ES2_0:
711 bug_00339_regs_ptr = omap5_bug_00339_regs;
712 *iterations = sizeof(omap5_bug_00339_regs)/
713 sizeof(omap5_bug_00339_regs[0]);
714 break;
Lokesh Vutla941f2fc2017-12-29 11:47:51 +0530715 case DRA762_ABZ_ES1_0:
716 case DRA762_ACD_ES1_0:
Lokesh Vutlac9a7c172017-08-21 12:50:55 +0530717 case DRA762_ES1_0:
SRICHARAN R54d022e2013-11-08 17:40:38 +0530718 case DRA752_ES1_0:
Nishanth Menon3ac8c0b2014-01-14 10:54:42 -0600719 case DRA752_ES1_1:
Nishanth Menonc1ea3be2015-08-13 09:50:58 -0500720 case DRA752_ES2_0:
Lokesh Vutla9fcf3d32014-05-15 11:08:41 +0530721 case DRA722_ES1_0:
Ravi Babud851ad32016-03-15 18:09:11 -0500722 case DRA722_ES2_0:
Vishal Mahaveerba396082017-08-26 16:51:22 -0500723 case DRA722_ES2_1:
SRICHARAN R54d022e2013-11-08 17:40:38 +0530724 bug_00339_regs_ptr = dra_bug_00339_regs;
725 *iterations = sizeof(dra_bug_00339_regs)/
726 sizeof(dra_bug_00339_regs[0]);
727 break;
728 default:
729 printf("\n Error: UnKnown SOC");
730 }
731
732 return bug_00339_regs_ptr;
733}
734
Sricharanbb772a52011-11-15 09:50:00 -0500735void emif_get_device_timings_sdp(u32 emif_nr,
736 const struct lpddr2_device_timings **cs0_device_timings,
737 const struct lpddr2_device_timings **cs1_device_timings)
738{
739 /* Identical devices on EMIF1 & EMIF2 */
SRICHARAN R971f2ba2012-03-12 02:25:45 +0000740 *cs0_device_timings = &dev_4G_S4_timings;
741 *cs1_device_timings = &dev_4G_S4_timings;
Sricharanbb772a52011-11-15 09:50:00 -0500742}
743
744void emif_get_device_timings(u32 emif_nr,
745 const struct lpddr2_device_timings **cs0_device_timings,
746 const struct lpddr2_device_timings **cs1_device_timings)
747 __attribute__((weak, alias("emif_get_device_timings_sdp")));
748
749#endif /* CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS */