1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <console/console.h>
9 const struct mem_timings mem_timings
[] = {
11 .mem_manuf
= MEM_MANUF_ELPIDA
,
12 .mem_type
= DDR_MODE_DDR3
,
34 .pclk_cdrex_ratio
= 0x5,
36 0x00020018, 0x00030000, 0x00010042, 0x00000d70
38 .timing_ref
= 0x000000bb,
39 .timing_row
= 0x8c36660f,
40 .timing_data
= 0x3630580b,
41 .timing_power
= 0x41000a44,
42 .phy0_dqs
= 0x08080808,
43 .phy1_dqs
= 0x08080808,
44 .phy0_dq
= 0x08080808,
45 .phy1_dq
= 0x08080808,
48 .phy0_pulld_dqs
= 0xf,
49 .phy1_pulld_dqs
= 0xf,
51 .lpddr3_ctrl_phy_reset
= 0x1,
52 .ctrl_start_point
= 0x10,
74 * Dynamic Clock: Always Running
75 * Memory Burst length: 8
77 * Memory Bus width: 32 bit
79 * Additional Latancy for PLL: 0 Cycle
81 .memcontrol
= DMC_MEMCONTROL_CLK_STOP_DISABLE
|
82 DMC_MEMCONTROL_DPWRDN_DISABLE
|
83 DMC_MEMCONTROL_DPWRDN_ACTIVE_PRECHARGE
|
84 DMC_MEMCONTROL_TP_DISABLE
|
85 DMC_MEMCONTROL_DSREF_ENABLE
|
86 DMC_MEMCONTROL_ADD_LAT_PALL_CYCLE(0) |
87 DMC_MEMCONTROL_MEM_TYPE_DDR3
|
88 DMC_MEMCONTROL_MEM_WIDTH_32BIT
|
89 DMC_MEMCONTROL_NUM_CHIP_1
|
91 DMC_MEMCONTROL_PZQ_DISABLE
|
92 DMC_MEMCONTROL_MRR_BYTE_7_0
,
93 .memconfig
= DMC_MEMCONFIGx_CHIP_MAP_INTERLEAVED
|
94 DMC_MEMCONFIGx_CHIP_COL_10
|
95 DMC_MEMCONFIGx_CHIP_ROW_15
|
96 DMC_MEMCONFIGx_CHIP_BANK_8
,
97 .membaseconfig0
= DMC_MEMBASECONFIG_VAL(0x40),
98 .membaseconfig1
= DMC_MEMBASECONFIG_VAL(0x80),
99 .prechconfig_tp_cnt
= 0xff,
102 .concontrol
= DMC_CONCONTROL_DFI_INIT_START_DISABLE
|
103 DMC_CONCONTROL_TIMEOUT_LEVEL0
|
104 DMC_CONCONTROL_RD_FETCH_DISABLE
|
105 DMC_CONCONTROL_EMPTY_DISABLE
|
106 DMC_CONCONTROL_AREF_EN_DISABLE
|
107 DMC_CONCONTROL_IO_PD_CON_DISABLE
,
109 .chips_per_channel
= 2,
110 .chips_to_configure
= 1,
112 .impedance
= IMP_OUTPUT_DRV_30_OHM
,
113 .gate_leveling_enable
= 0,
115 .mem_manuf
= MEM_MANUF_SAMSUNG
,
116 .mem_type
= DDR_MODE_DDR3
,
117 .frequency_mhz
= 800,
138 .pclk_cdrex_ratio
= 0x5,
140 0x00020018, 0x00030000, 0x00010000, 0x00000d70
142 .timing_ref
= 0x000000bb,
143 .timing_row
= 0x8c36660f,
144 .timing_data
= 0x3630580b,
145 .timing_power
= 0x41000a44,
146 .phy0_dqs
= 0x08080808,
147 .phy1_dqs
= 0x08080808,
148 .phy0_dq
= 0x08080808,
149 .phy1_dq
= 0x08080808,
152 .phy0_pulld_dqs
= 0xf,
153 .phy1_pulld_dqs
= 0xf,
155 .lpddr3_ctrl_phy_reset
= 0x1,
156 .ctrl_start_point
= 0x10,
178 * Dynamic Clock: Always Running
179 * Memory Burst length: 8
181 * Memory Bus width: 32 bit
183 * Additional Latancy for PLL: 0 Cycle
185 .memcontrol
= DMC_MEMCONTROL_CLK_STOP_DISABLE
|
186 DMC_MEMCONTROL_DPWRDN_DISABLE
|
187 DMC_MEMCONTROL_DPWRDN_ACTIVE_PRECHARGE
|
188 DMC_MEMCONTROL_TP_DISABLE
|
189 DMC_MEMCONTROL_DSREF_ENABLE
|
190 DMC_MEMCONTROL_ADD_LAT_PALL_CYCLE(0) |
191 DMC_MEMCONTROL_MEM_TYPE_DDR3
|
192 DMC_MEMCONTROL_MEM_WIDTH_32BIT
|
193 DMC_MEMCONTROL_NUM_CHIP_1
|
194 DMC_MEMCONTROL_BL_8
|
195 DMC_MEMCONTROL_PZQ_DISABLE
|
196 DMC_MEMCONTROL_MRR_BYTE_7_0
,
197 .memconfig
= DMC_MEMCONFIGx_CHIP_MAP_INTERLEAVED
|
198 DMC_MEMCONFIGx_CHIP_COL_10
|
199 DMC_MEMCONFIGx_CHIP_ROW_15
|
200 DMC_MEMCONFIGx_CHIP_BANK_8
,
201 .membaseconfig0
= DMC_MEMBASECONFIG_VAL(0x40),
202 .membaseconfig1
= DMC_MEMBASECONFIG_VAL(0x80),
203 .prechconfig_tp_cnt
= 0xff,
206 .concontrol
= DMC_CONCONTROL_DFI_INIT_START_DISABLE
|
207 DMC_CONCONTROL_TIMEOUT_LEVEL0
|
208 DMC_CONCONTROL_RD_FETCH_DISABLE
|
209 DMC_CONCONTROL_EMPTY_DISABLE
|
210 DMC_CONCONTROL_AREF_EN_DISABLE
|
211 DMC_CONCONTROL_IO_PD_CON_DISABLE
,
213 .chips_per_channel
= 2,
214 .chips_to_configure
= 1,
216 .impedance
= IMP_OUTPUT_DRV_40_OHM
,
217 .gate_leveling_enable
= 1,
220 .mem_manuf
= MEM_MANUF_ELPIDA
,
221 .mem_type
= DDR_MODE_DDR3
,
222 .frequency_mhz
= 780,
243 .pclk_cdrex_ratio
= 0x5,
245 0x00020018, 0x00030000, 0x00010042, 0x00000d70
247 .timing_ref
= 0x000000bb,
248 .timing_row
= 0x8c36660f,
249 .timing_data
= 0x3630580b,
250 .timing_power
= 0x41000a44,
251 .phy0_dqs
= 0x08080808,
252 .phy1_dqs
= 0x08080808,
253 .phy0_dq
= 0x08080808,
254 .phy1_dq
= 0x08080808,
257 .phy0_pulld_dqs
= 0xf,
258 .phy1_pulld_dqs
= 0xf,
260 .lpddr3_ctrl_phy_reset
= 0x1,
261 .ctrl_start_point
= 0x10,
283 * Dynamic Clock: Always Running
284 * Memory Burst length: 8
286 * Memory Bus width: 32 bit
288 * Additional Latancy for PLL: 0 Cycle
290 .memcontrol
= DMC_MEMCONTROL_CLK_STOP_DISABLE
|
291 DMC_MEMCONTROL_DPWRDN_DISABLE
|
292 DMC_MEMCONTROL_DPWRDN_ACTIVE_PRECHARGE
|
293 DMC_MEMCONTROL_TP_DISABLE
|
294 DMC_MEMCONTROL_DSREF_ENABLE
|
295 DMC_MEMCONTROL_ADD_LAT_PALL_CYCLE(0) |
296 DMC_MEMCONTROL_MEM_TYPE_DDR3
|
297 DMC_MEMCONTROL_MEM_WIDTH_32BIT
|
298 DMC_MEMCONTROL_NUM_CHIP_1
|
299 DMC_MEMCONTROL_BL_8
|
300 DMC_MEMCONTROL_PZQ_DISABLE
|
301 DMC_MEMCONTROL_MRR_BYTE_7_0
,
302 .memconfig
= DMC_MEMCONFIGx_CHIP_MAP_INTERLEAVED
|
303 DMC_MEMCONFIGx_CHIP_COL_10
|
304 DMC_MEMCONFIGx_CHIP_ROW_15
|
305 DMC_MEMCONFIGx_CHIP_BANK_8
,
306 .membaseconfig0
= DMC_MEMBASECONFIG_VAL(0x40),
307 .membaseconfig1
= DMC_MEMBASECONFIG_VAL(0x80),
308 .prechconfig_tp_cnt
= 0xff,
311 .concontrol
= DMC_CONCONTROL_DFI_INIT_START_DISABLE
|
312 DMC_CONCONTROL_TIMEOUT_LEVEL0
|
313 DMC_CONCONTROL_RD_FETCH_DISABLE
|
314 DMC_CONCONTROL_EMPTY_DISABLE
|
315 DMC_CONCONTROL_AREF_EN_DISABLE
|
316 DMC_CONCONTROL_IO_PD_CON_DISABLE
,
318 .chips_per_channel
= 2,
319 .chips_to_configure
= 1,
321 .impedance
= IMP_OUTPUT_DRV_30_OHM
,
322 .gate_leveling_enable
= 0,
324 .mem_manuf
= MEM_MANUF_SAMSUNG
,
325 .mem_type
= DDR_MODE_DDR3
,
326 .frequency_mhz
= 780,
347 .pclk_cdrex_ratio
= 0x5,
349 0x00020018, 0x00030000, 0x00010000, 0x00000d70
351 .timing_ref
= 0x000000bb,
352 .timing_row
= 0x8c36660f,
353 .timing_data
= 0x3630580b,
354 .timing_power
= 0x41000a44,
355 .phy0_dqs
= 0x08080808,
356 .phy1_dqs
= 0x08080808,
357 .phy0_dq
= 0x08080808,
358 .phy1_dq
= 0x08080808,
361 .phy0_pulld_dqs
= 0xf,
362 .phy1_pulld_dqs
= 0xf,
364 .lpddr3_ctrl_phy_reset
= 0x1,
365 .ctrl_start_point
= 0x10,
387 * Dynamic Clock: Always Running
388 * Memory Burst length: 8
390 * Memory Bus width: 32 bit
392 * Additional Latancy for PLL: 0 Cycle
394 .memcontrol
= DMC_MEMCONTROL_CLK_STOP_DISABLE
|
395 DMC_MEMCONTROL_DPWRDN_DISABLE
|
396 DMC_MEMCONTROL_DPWRDN_ACTIVE_PRECHARGE
|
397 DMC_MEMCONTROL_TP_DISABLE
|
398 DMC_MEMCONTROL_DSREF_ENABLE
|
399 DMC_MEMCONTROL_ADD_LAT_PALL_CYCLE(0) |
400 DMC_MEMCONTROL_MEM_TYPE_DDR3
|
401 DMC_MEMCONTROL_MEM_WIDTH_32BIT
|
402 DMC_MEMCONTROL_NUM_CHIP_1
|
403 DMC_MEMCONTROL_BL_8
|
404 DMC_MEMCONTROL_PZQ_DISABLE
|
405 DMC_MEMCONTROL_MRR_BYTE_7_0
,
406 .memconfig
= DMC_MEMCONFIGx_CHIP_MAP_INTERLEAVED
|
407 DMC_MEMCONFIGx_CHIP_COL_10
|
408 DMC_MEMCONFIGx_CHIP_ROW_15
|
409 DMC_MEMCONFIGx_CHIP_BANK_8
,
410 .membaseconfig0
= DMC_MEMBASECONFIG_VAL(0x40),
411 .membaseconfig1
= DMC_MEMBASECONFIG_VAL(0x80),
412 .prechconfig_tp_cnt
= 0xff,
415 .concontrol
= DMC_CONCONTROL_DFI_INIT_START_DISABLE
|
416 DMC_CONCONTROL_TIMEOUT_LEVEL0
|
417 DMC_CONCONTROL_RD_FETCH_DISABLE
|
418 DMC_CONCONTROL_EMPTY_DISABLE
|
419 DMC_CONCONTROL_AREF_EN_DISABLE
|
420 DMC_CONCONTROL_IO_PD_CON_DISABLE
,
422 .chips_per_channel
= 2,
423 .chips_to_configure
= 1,
425 .impedance
= IMP_OUTPUT_DRV_40_OHM
,
426 .gate_leveling_enable
= 1,
430 #define BOARD_ID0_GPIO 88 /* GPD0, pin 0 */
431 #define BOARD_ID1_GPIO 89 /* GPD0, pin 1 */
434 DAISY_CONFIG_UNKNOWN
= -1,
435 DAISY_CONFIG_SAMSUNG_EVT
,
436 DAISY_CONFIG_ELPIDA_EVT
,
437 DAISY_CONFIG_SAMSUNG_DVT
,
438 DAISY_CONFIG_ELPIDA_DVT
,
439 DAISY_CONFIG_SAMSUNG_PVT
,
440 DAISY_CONFIG_ELPIDA_PVT
,
441 DAISY_CONFIG_SAMSUNG_MP
,
442 DAISY_CONFIG_ELPIDA_MP
,
448 enum board_config config
;
451 { LOGIC_0
, LOGIC_0
, DAISY_CONFIG_SAMSUNG_MP
},
452 { LOGIC_0
, LOGIC_1
, DAISY_CONFIG_ELPIDA_MP
},
453 { LOGIC_1
, LOGIC_0
, DAISY_CONFIG_SAMSUNG_DVT
},
454 { LOGIC_1
, LOGIC_1
, DAISY_CONFIG_ELPIDA_DVT
},
455 { LOGIC_0
, LOGIC_Z
, DAISY_CONFIG_SAMSUNG_PVT
},
456 { LOGIC_1
, LOGIC_Z
, DAISY_CONFIG_ELPIDA_PVT
},
457 { LOGIC_Z
, LOGIC_0
, DAISY_CONFIG_SAMSUNG_MP
},
458 { LOGIC_Z
, LOGIC_Z
, DAISY_CONFIG_ELPIDA_MP
},
459 { LOGIC_Z
, LOGIC_1
, DAISY_CONFIG_RSVD
},
462 static int board_get_config(void)
466 enum board_config config
= DAISY_CONFIG_UNKNOWN
;
468 id0
= gpio_read_mvl3(BOARD_ID0_GPIO
);
469 id1
= gpio_read_mvl3(BOARD_ID1_GPIO
);
470 if (id0
< 0 || id1
< 0)
473 for (i
= 0; i
< ARRAY_SIZE(id_map
); i
++) {
474 if (id0
== id_map
[i
].id0
&& id1
== id_map
[i
].id1
) {
475 config
= id_map
[i
].config
;
483 struct mem_timings
*get_mem_timings(void)
486 enum board_config config
;
487 enum ddr_mode mem_type
;
488 unsigned int frequency_mhz
;
489 enum mem_manuf mem_manuf
;
490 const struct mem_timings
*mem
;
492 config
= board_get_config();
494 case DAISY_CONFIG_ELPIDA_EVT
:
495 case DAISY_CONFIG_ELPIDA_DVT
:
496 case DAISY_CONFIG_ELPIDA_PVT
:
497 case DAISY_CONFIG_ELPIDA_MP
:
498 mem_manuf
= MEM_MANUF_ELPIDA
;
499 mem_type
= DDR_MODE_DDR3
;
502 case DAISY_CONFIG_SAMSUNG_EVT
:
503 case DAISY_CONFIG_SAMSUNG_DVT
:
504 case DAISY_CONFIG_SAMSUNG_PVT
:
505 case DAISY_CONFIG_SAMSUNG_MP
:
506 mem_manuf
= MEM_MANUF_SAMSUNG
;
507 mem_type
= DDR_MODE_DDR3
;
511 printk(BIOS_CRIT
, "Unknown board configuration.\n");
515 for (i
= 0, mem
= mem_timings
; i
< ARRAY_SIZE(mem_timings
);
517 if (mem
->mem_type
== mem_type
&&
518 mem
->frequency_mhz
== frequency_mhz
&&
519 mem
->mem_manuf
== mem_manuf
)
520 return (struct mem_timings
*)mem
;