1 // SPDX-License-Identifier: GPL-2.0+
3 * Timing and Organization details of the ddr device parts used in OMAP5
7 * Texas Instruments, <www.ti.com>
9 * Aneesh V <aneesh@ti.com>
10 * Sricharan R <r.sricharan@ti.com>
14 #include <asm/arch/sys_proto.h>
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.
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()
33 #ifdef CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS
34 const struct emif_regs emif_regs_532_mhz_2cs = {
35 .sdram_config_init = 0x80800EBA,
36 .sdram_config = 0x808022BA,
37 .ref_ctrl = 0x0000081A,
38 .sdram_tim1 = 0x772F6873,
39 .sdram_tim2 = 0x304a129a,
40 .sdram_tim3 = 0x02f7e45f,
41 .read_idle_ctrl = 0x00050000,
42 .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
53 const 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,
72 const struct emif_regs emif_regs_266_mhz_2cs = {
73 .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
91 const struct emif_regs emif_regs_ddr3_532_mhz_1cs = {
92 .sdram_config_init = 0x61851B32,
93 .sdram_config = 0x61851B32,
95 .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
115 const struct emif_regs emif_regs_ddr3_532_mhz_1cs_es2 = {
116 .sdram_config_init = 0x61851B32,
117 .sdram_config = 0x61851B32,
118 .sdram_config2 = 0x0,
119 .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
139 const struct dmm_lisa_map_regs lisa_map_4G_x_2_x_2 = {
140 .dmm_lisa_map_0 = 0x0,
141 .dmm_lisa_map_1 = 0x0,
142 .dmm_lisa_map_2 = 0x80740300,
143 .dmm_lisa_map_3 = 0xFF020100,
147 static void emif_get_reg_dump_sdp(u32 emif_nr, const struct emif_regs **regs)
149 switch (omap_revision()) {
151 *regs = &emif_regs_532_mhz_2cs;
154 *regs = &emif_regs_ddr3_532_mhz_1cs;
157 *regs = &emif_regs_532_mhz_2cs_es2;
161 *regs = &emif_regs_ddr3_532_mhz_1cs_es2;
166 void emif_get_reg_dump(u32 emif_nr, const struct emif_regs **regs)
167 __attribute__((weak, alias("emif_get_reg_dump_sdp")));
169 static void emif_get_dmm_regs_sdp(const struct dmm_lisa_map_regs
172 switch (omap_revision()) {
178 *dmm_lisa_regs = &lisa_map_4G_x_2_x_2;
184 void emif_get_dmm_regs(const struct dmm_lisa_map_regs **dmm_lisa_regs)
185 __attribute__((weak, alias("emif_get_dmm_regs_sdp")));
188 static const struct lpddr2_device_details dev_4G_S4_details = {
189 .type = LPDDR2_TYPE_S4,
190 .density = LPDDR2_DENSITY_4Gb,
191 .io_width = LPDDR2_IO_WIDTH_32,
192 .manufacturer = LPDDR2_MANUFACTURER_SAMSUNG
195 static 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)
199 /* EMIF1 & EMIF2 have identical configuration */
200 *cs0_device_details = dev_4G_S4_details;
201 *cs1_device_details = dev_4G_S4_details;
204 void 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")));
209 #endif /* CONFIG_SYS_EMIF_PRECALCULATED_TIMING_REGS */
211 const u32 ext_phy_ctrl_const_base[] = {
234 const u32 ddr3_ext_phy_ctrl_const_base_es1[] = {
257 const u32 ddr3_ext_phy_ctrl_const_base_es2[] = {
280 /* Ext phy ctrl 1-35 regs */
282 dra_ddr3_ext_phy_ctrl_const_base_es1_emif1[] = {
320 /* Ext phy ctrl 1-35 regs */
322 dra_ddr3_ext_phy_ctrl_const_base_es1_emif2[] = {
360 /* Ext phy ctrl 1-35 regs */
362 dra_ddr3_ext_phy_ctrl_const_base_666MHz[] = {
400 const u32 dra_ddr3_ext_phy_ctrl_const_base_666MHz_es2[] = {
439 const struct lpddr2_mr_regs mr_regs = {
440 .mr1 = MR1_BL_8_BT_SEQ_WRAP_EN_NWR_8,
443 .mr10 = MR10_ZQ_ZQINIT,
444 .mr16 = MR16_REF_FULL_ARRAY
447 void __weak emif_get_ext_phy_ctrl_const_regs(u32 emif_nr,
451 switch (omap_revision()) {
454 *regs = ext_phy_ctrl_const_base;
455 *size = ARRAY_SIZE(ext_phy_ctrl_const_base);
458 *regs = ddr3_ext_phy_ctrl_const_base_es1;
459 *size = ARRAY_SIZE(ddr3_ext_phy_ctrl_const_base_es1);
462 *regs = ddr3_ext_phy_ctrl_const_base_es2;
463 *size = ARRAY_SIZE(ddr3_ext_phy_ctrl_const_base_es2);
469 *regs = dra_ddr3_ext_phy_ctrl_const_base_es1_emif1;
471 ARRAY_SIZE(dra_ddr3_ext_phy_ctrl_const_base_es1_emif1);
473 *regs = dra_ddr3_ext_phy_ctrl_const_base_es1_emif2;
475 ARRAY_SIZE(dra_ddr3_ext_phy_ctrl_const_base_es1_emif2);
479 *regs = dra_ddr3_ext_phy_ctrl_const_base_666MHz;
480 *size = ARRAY_SIZE(dra_ddr3_ext_phy_ctrl_const_base_666MHz);
483 case DRA762_ABZ_ES1_0:
484 case DRA762_ACD_ES1_0:
487 *regs = dra_ddr3_ext_phy_ctrl_const_base_666MHz_es2;
488 *size = ARRAY_SIZE(dra_ddr3_ext_phy_ctrl_const_base_666MHz_es2);
491 *regs = ddr3_ext_phy_ctrl_const_base_es2;
492 *size = ARRAY_SIZE(ddr3_ext_phy_ctrl_const_base_es2);
497 void get_lpddr2_mr_regs(const struct lpddr2_mr_regs **regs)
502 static void do_ext_phy_settings_omap5(u32 base, const struct emif_regs *regs)
504 u32 *ext_phy_ctrl_base = 0;
505 u32 *emif_ext_phy_ctrl_base = 0;
507 const u32 *ext_phy_ctrl_const_regs;
511 emif_nr = (base == EMIF1_BASE) ? 1 : 2;
513 struct emif_reg_struct *emif = (struct emif_reg_struct *)base;
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);
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++);
526 * external phy 6-24 registers do not change with
529 emif_get_ext_phy_ctrl_const_regs(emif_nr,
530 &ext_phy_ctrl_const_regs, &size);
532 for (i = 0; i < size; i++) {
533 writel(ext_phy_ctrl_const_regs[i],
534 emif_ext_phy_ctrl_base++);
535 /* Update shadow registers */
536 writel(ext_phy_ctrl_const_regs[i],
537 emif_ext_phy_ctrl_base++);
541 static void do_ext_phy_settings_dra7(u32 base, const struct emif_regs *regs)
543 struct emif_reg_struct *emif = (struct emif_reg_struct *)base;
544 u32 *emif_ext_phy_ctrl_base = 0;
546 const u32 *ext_phy_ctrl_const_regs;
547 u32 i, hw_leveling, size, phy;
549 emif_nr = (base == EMIF1_BASE) ? 1 : 2;
551 hw_leveling = regs->emif_rd_wr_lvl_rmp_ctl >> EMIF_REG_RDWRLVL_EN_SHIFT;
552 phy = regs->emif_ddr_phy_ctlr_1_init;
554 emif_ext_phy_ctrl_base = (u32 *)&(emif->emif_ddr_ext_phy_ctrl_1);
556 emif_get_ext_phy_ctrl_const_regs(emif_nr,
557 &ext_phy_ctrl_const_regs, &size);
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]);
563 * Copy the predefined PHY register values
564 * if leveling is disabled.
566 if (phy & EMIF_DDR_PHY_CTRL_1_RDLVLGATE_MASK_MASK)
567 for (i = 1; i < 6; i++) {
568 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]);
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]);
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]);
592 * Write the init value for HW levling to occur
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]);
603 void do_ext_phy_settings(u32 base, const struct emif_regs *regs)
606 do_ext_phy_settings_omap5(base, regs);
608 do_ext_phy_settings_dra7(base, regs);
611 #ifndef CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS
612 static const struct lpddr2_ac_timings timings_jedec_532_mhz = {
613 .max_freq = 532000000,
635 static const struct lpddr2_min_tck min_tck = {
650 static const struct lpddr2_ac_timings *ac_timings[MAX_NUM_SPEEDBINS] = {
651 &timings_jedec_532_mhz
654 static const struct lpddr2_device_timings dev_4G_S4_timings = {
655 .ac_timings = ac_timings,
660 * List of status registers to be controlled back to control registers
661 * after initial leveling
664 const struct read_write_regs omap5_bug_00339_regs[] = {
679 const struct read_write_regs dra_bug_00339_regs[] = {
702 const struct read_write_regs *get_bug_regs(u32 *iterations)
704 const struct read_write_regs *bug_00339_regs_ptr = NULL;
706 switch (omap_revision()) {
711 bug_00339_regs_ptr = omap5_bug_00339_regs;
712 *iterations = sizeof(omap5_bug_00339_regs)/
713 sizeof(omap5_bug_00339_regs[0]);
715 case DRA762_ABZ_ES1_0:
716 case DRA762_ACD_ES1_0:
724 bug_00339_regs_ptr = dra_bug_00339_regs;
725 *iterations = sizeof(dra_bug_00339_regs)/
726 sizeof(dra_bug_00339_regs[0]);
729 printf("\n Error: UnKnown SOC");
732 return bug_00339_regs_ptr;
735 void 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)
739 /* Identical devices on EMIF1 & EMIF2 */
740 *cs0_device_timings = &dev_4G_S4_timings;
741 *cs1_device_timings = &dev_4G_S4_timings;
744 void 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")));
749 #endif /* CONFIG_SYS_DEFAULT_LPDDR2_TIMINGS */