2 * This file is part of the coreboot project.
4 * Copyright (C) 2012 Samsung Electronics
5 * Copyright 2013 Google Inc.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
17 #include <console/console.h>
19 #include <soc/setup.h>
25 const struct mem_timings mem_timings
[] = {
27 .mem_manuf
= MEM_MANUF_ELPIDA
,
28 .mem_type
= DDR_MODE_DDR3
,
50 .pclk_cdrex_ratio
= 0x5,
52 0x00020018, 0x00030000, 0x00010042, 0x00000d70
54 .timing_ref
= 0x000000bb,
55 .timing_row
= 0x8c36660f,
56 .timing_data
= 0x3630580b,
57 .timing_power
= 0x41000a44,
58 .phy0_dqs
= 0x08080808,
59 .phy1_dqs
= 0x08080808,
60 .phy0_dq
= 0x08080808,
61 .phy1_dq
= 0x08080808,
64 .phy0_pulld_dqs
= 0xf,
65 .phy1_pulld_dqs
= 0xf,
67 .lpddr3_ctrl_phy_reset
= 0x1,
68 .ctrl_start_point
= 0x10,
90 * Dynamic Clock: Always Running
91 * Memory Burst length: 8
93 * Memory Bus width: 32 bit
95 * Additional Latancy for PLL: 0 Cycle
97 .memcontrol
= DMC_MEMCONTROL_CLK_STOP_DISABLE
|
98 DMC_MEMCONTROL_DPWRDN_DISABLE
|
99 DMC_MEMCONTROL_DPWRDN_ACTIVE_PRECHARGE
|
100 DMC_MEMCONTROL_TP_DISABLE
|
101 DMC_MEMCONTROL_DSREF_ENABLE
|
102 DMC_MEMCONTROL_ADD_LAT_PALL_CYCLE(0) |
103 DMC_MEMCONTROL_MEM_TYPE_DDR3
|
104 DMC_MEMCONTROL_MEM_WIDTH_32BIT
|
105 DMC_MEMCONTROL_NUM_CHIP_1
|
106 DMC_MEMCONTROL_BL_8
|
107 DMC_MEMCONTROL_PZQ_DISABLE
|
108 DMC_MEMCONTROL_MRR_BYTE_7_0
,
109 .memconfig
= DMC_MEMCONFIGx_CHIP_MAP_INTERLEAVED
|
110 DMC_MEMCONFIGx_CHIP_COL_10
|
111 DMC_MEMCONFIGx_CHIP_ROW_15
|
112 DMC_MEMCONFIGx_CHIP_BANK_8
,
113 .membaseconfig0
= DMC_MEMBASECONFIG_VAL(0x40),
114 .membaseconfig1
= DMC_MEMBASECONFIG_VAL(0x80),
115 .prechconfig_tp_cnt
= 0xff,
118 .concontrol
= DMC_CONCONTROL_DFI_INIT_START_DISABLE
|
119 DMC_CONCONTROL_TIMEOUT_LEVEL0
|
120 DMC_CONCONTROL_RD_FETCH_DISABLE
|
121 DMC_CONCONTROL_EMPTY_DISABLE
|
122 DMC_CONCONTROL_AREF_EN_DISABLE
|
123 DMC_CONCONTROL_IO_PD_CON_DISABLE
,
125 .chips_per_channel
= 2,
126 .chips_to_configure
= 1,
128 .impedance
= IMP_OUTPUT_DRV_30_OHM
,
129 .gate_leveling_enable
= 0,
131 .mem_manuf
= MEM_MANUF_SAMSUNG
,
132 .mem_type
= DDR_MODE_DDR3
,
133 .frequency_mhz
= 800,
154 .pclk_cdrex_ratio
= 0x5,
156 0x00020018, 0x00030000, 0x00010000, 0x00000d70
158 .timing_ref
= 0x000000bb,
159 .timing_row
= 0x8c36660f,
160 .timing_data
= 0x3630580b,
161 .timing_power
= 0x41000a44,
162 .phy0_dqs
= 0x08080808,
163 .phy1_dqs
= 0x08080808,
164 .phy0_dq
= 0x08080808,
165 .phy1_dq
= 0x08080808,
168 .phy0_pulld_dqs
= 0xf,
169 .phy1_pulld_dqs
= 0xf,
171 .lpddr3_ctrl_phy_reset
= 0x1,
172 .ctrl_start_point
= 0x10,
194 * Dynamic Clock: Always Running
195 * Memory Burst length: 8
197 * Memory Bus width: 32 bit
199 * Additional Latancy for PLL: 0 Cycle
201 .memcontrol
= DMC_MEMCONTROL_CLK_STOP_DISABLE
|
202 DMC_MEMCONTROL_DPWRDN_DISABLE
|
203 DMC_MEMCONTROL_DPWRDN_ACTIVE_PRECHARGE
|
204 DMC_MEMCONTROL_TP_DISABLE
|
205 DMC_MEMCONTROL_DSREF_ENABLE
|
206 DMC_MEMCONTROL_ADD_LAT_PALL_CYCLE(0) |
207 DMC_MEMCONTROL_MEM_TYPE_DDR3
|
208 DMC_MEMCONTROL_MEM_WIDTH_32BIT
|
209 DMC_MEMCONTROL_NUM_CHIP_1
|
210 DMC_MEMCONTROL_BL_8
|
211 DMC_MEMCONTROL_PZQ_DISABLE
|
212 DMC_MEMCONTROL_MRR_BYTE_7_0
,
213 .memconfig
= DMC_MEMCONFIGx_CHIP_MAP_INTERLEAVED
|
214 DMC_MEMCONFIGx_CHIP_COL_10
|
215 DMC_MEMCONFIGx_CHIP_ROW_15
|
216 DMC_MEMCONFIGx_CHIP_BANK_8
,
217 .membaseconfig0
= DMC_MEMBASECONFIG_VAL(0x40),
218 .membaseconfig1
= DMC_MEMBASECONFIG_VAL(0x80),
219 .prechconfig_tp_cnt
= 0xff,
222 .concontrol
= DMC_CONCONTROL_DFI_INIT_START_DISABLE
|
223 DMC_CONCONTROL_TIMEOUT_LEVEL0
|
224 DMC_CONCONTROL_RD_FETCH_DISABLE
|
225 DMC_CONCONTROL_EMPTY_DISABLE
|
226 DMC_CONCONTROL_AREF_EN_DISABLE
|
227 DMC_CONCONTROL_IO_PD_CON_DISABLE
,
229 .chips_per_channel
= 2,
230 .chips_to_configure
= 1,
232 .impedance
= IMP_OUTPUT_DRV_40_OHM
,
233 .gate_leveling_enable
= 1,
236 .mem_manuf
= MEM_MANUF_ELPIDA
,
237 .mem_type
= DDR_MODE_DDR3
,
238 .frequency_mhz
= 780,
259 .pclk_cdrex_ratio
= 0x5,
261 0x00020018, 0x00030000, 0x00010042, 0x00000d70
263 .timing_ref
= 0x000000bb,
264 .timing_row
= 0x8c36660f,
265 .timing_data
= 0x3630580b,
266 .timing_power
= 0x41000a44,
267 .phy0_dqs
= 0x08080808,
268 .phy1_dqs
= 0x08080808,
269 .phy0_dq
= 0x08080808,
270 .phy1_dq
= 0x08080808,
273 .phy0_pulld_dqs
= 0xf,
274 .phy1_pulld_dqs
= 0xf,
276 .lpddr3_ctrl_phy_reset
= 0x1,
277 .ctrl_start_point
= 0x10,
299 * Dynamic Clock: Always Running
300 * Memory Burst length: 8
302 * Memory Bus width: 32 bit
304 * Additional Latancy for PLL: 0 Cycle
306 .memcontrol
= DMC_MEMCONTROL_CLK_STOP_DISABLE
|
307 DMC_MEMCONTROL_DPWRDN_DISABLE
|
308 DMC_MEMCONTROL_DPWRDN_ACTIVE_PRECHARGE
|
309 DMC_MEMCONTROL_TP_DISABLE
|
310 DMC_MEMCONTROL_DSREF_ENABLE
|
311 DMC_MEMCONTROL_ADD_LAT_PALL_CYCLE(0) |
312 DMC_MEMCONTROL_MEM_TYPE_DDR3
|
313 DMC_MEMCONTROL_MEM_WIDTH_32BIT
|
314 DMC_MEMCONTROL_NUM_CHIP_1
|
315 DMC_MEMCONTROL_BL_8
|
316 DMC_MEMCONTROL_PZQ_DISABLE
|
317 DMC_MEMCONTROL_MRR_BYTE_7_0
,
318 .memconfig
= DMC_MEMCONFIGx_CHIP_MAP_INTERLEAVED
|
319 DMC_MEMCONFIGx_CHIP_COL_10
|
320 DMC_MEMCONFIGx_CHIP_ROW_15
|
321 DMC_MEMCONFIGx_CHIP_BANK_8
,
322 .membaseconfig0
= DMC_MEMBASECONFIG_VAL(0x40),
323 .membaseconfig1
= DMC_MEMBASECONFIG_VAL(0x80),
324 .prechconfig_tp_cnt
= 0xff,
327 .concontrol
= DMC_CONCONTROL_DFI_INIT_START_DISABLE
|
328 DMC_CONCONTROL_TIMEOUT_LEVEL0
|
329 DMC_CONCONTROL_RD_FETCH_DISABLE
|
330 DMC_CONCONTROL_EMPTY_DISABLE
|
331 DMC_CONCONTROL_AREF_EN_DISABLE
|
332 DMC_CONCONTROL_IO_PD_CON_DISABLE
,
334 .chips_per_channel
= 2,
335 .chips_to_configure
= 1,
337 .impedance
= IMP_OUTPUT_DRV_30_OHM
,
338 .gate_leveling_enable
= 0,
340 .mem_manuf
= MEM_MANUF_SAMSUNG
,
341 .mem_type
= DDR_MODE_DDR3
,
342 .frequency_mhz
= 780,
363 .pclk_cdrex_ratio
= 0x5,
365 0x00020018, 0x00030000, 0x00010000, 0x00000d70
367 .timing_ref
= 0x000000bb,
368 .timing_row
= 0x8c36660f,
369 .timing_data
= 0x3630580b,
370 .timing_power
= 0x41000a44,
371 .phy0_dqs
= 0x08080808,
372 .phy1_dqs
= 0x08080808,
373 .phy0_dq
= 0x08080808,
374 .phy1_dq
= 0x08080808,
377 .phy0_pulld_dqs
= 0xf,
378 .phy1_pulld_dqs
= 0xf,
380 .lpddr3_ctrl_phy_reset
= 0x1,
381 .ctrl_start_point
= 0x10,
403 * Dynamic Clock: Always Running
404 * Memory Burst length: 8
406 * Memory Bus width: 32 bit
408 * Additional Latancy for PLL: 0 Cycle
410 .memcontrol
= DMC_MEMCONTROL_CLK_STOP_DISABLE
|
411 DMC_MEMCONTROL_DPWRDN_DISABLE
|
412 DMC_MEMCONTROL_DPWRDN_ACTIVE_PRECHARGE
|
413 DMC_MEMCONTROL_TP_DISABLE
|
414 DMC_MEMCONTROL_DSREF_ENABLE
|
415 DMC_MEMCONTROL_ADD_LAT_PALL_CYCLE(0) |
416 DMC_MEMCONTROL_MEM_TYPE_DDR3
|
417 DMC_MEMCONTROL_MEM_WIDTH_32BIT
|
418 DMC_MEMCONTROL_NUM_CHIP_1
|
419 DMC_MEMCONTROL_BL_8
|
420 DMC_MEMCONTROL_PZQ_DISABLE
|
421 DMC_MEMCONTROL_MRR_BYTE_7_0
,
422 .memconfig
= DMC_MEMCONFIGx_CHIP_MAP_INTERLEAVED
|
423 DMC_MEMCONFIGx_CHIP_COL_10
|
424 DMC_MEMCONFIGx_CHIP_ROW_15
|
425 DMC_MEMCONFIGx_CHIP_BANK_8
,
426 .membaseconfig0
= DMC_MEMBASECONFIG_VAL(0x40),
427 .membaseconfig1
= DMC_MEMBASECONFIG_VAL(0x80),
428 .prechconfig_tp_cnt
= 0xff,
431 .concontrol
= DMC_CONCONTROL_DFI_INIT_START_DISABLE
|
432 DMC_CONCONTROL_TIMEOUT_LEVEL0
|
433 DMC_CONCONTROL_RD_FETCH_DISABLE
|
434 DMC_CONCONTROL_EMPTY_DISABLE
|
435 DMC_CONCONTROL_AREF_EN_DISABLE
|
436 DMC_CONCONTROL_IO_PD_CON_DISABLE
,
438 .chips_per_channel
= 2,
439 .chips_to_configure
= 1,
441 .impedance
= IMP_OUTPUT_DRV_40_OHM
,
442 .gate_leveling_enable
= 1,
446 #define BOARD_ID0_GPIO 88 /* GPD0, pin 0 */
447 #define BOARD_ID1_GPIO 89 /* GPD0, pin 1 */
450 DAISY_CONFIG_UNKNOWN
= -1,
451 DAISY_CONFIG_SAMSUNG_EVT
,
452 DAISY_CONFIG_ELPIDA_EVT
,
453 DAISY_CONFIG_SAMSUNG_DVT
,
454 DAISY_CONFIG_ELPIDA_DVT
,
455 DAISY_CONFIG_SAMSUNG_PVT
,
456 DAISY_CONFIG_ELPIDA_PVT
,
457 DAISY_CONFIG_SAMSUNG_MP
,
458 DAISY_CONFIG_ELPIDA_MP
,
464 enum board_config config
;
467 { LOGIC_0
, LOGIC_0
, DAISY_CONFIG_SAMSUNG_MP
},
468 { LOGIC_0
, LOGIC_1
, DAISY_CONFIG_ELPIDA_MP
},
469 { LOGIC_1
, LOGIC_0
, DAISY_CONFIG_SAMSUNG_DVT
},
470 { LOGIC_1
, LOGIC_1
, DAISY_CONFIG_ELPIDA_DVT
},
471 { LOGIC_0
, LOGIC_Z
, DAISY_CONFIG_SAMSUNG_PVT
},
472 { LOGIC_1
, LOGIC_Z
, DAISY_CONFIG_ELPIDA_PVT
},
473 { LOGIC_Z
, LOGIC_0
, DAISY_CONFIG_SAMSUNG_MP
},
474 { LOGIC_Z
, LOGIC_Z
, DAISY_CONFIG_ELPIDA_MP
},
475 { LOGIC_Z
, LOGIC_1
, DAISY_CONFIG_RSVD
},
478 static int board_get_config(void)
482 enum board_config config
= DAISY_CONFIG_UNKNOWN
;
484 id0
= gpio_read_mvl3(BOARD_ID0_GPIO
);
485 id1
= gpio_read_mvl3(BOARD_ID1_GPIO
);
486 if (id0
< 0 || id1
< 0)
489 for (i
= 0; i
< ARRAY_SIZE(id_map
); i
++) {
490 if (id0
== id_map
[i
].id0
&& id1
== id_map
[i
].id1
) {
491 config
= id_map
[i
].config
;
499 struct mem_timings
*get_mem_timings(void)
502 enum board_config config
;
503 enum ddr_mode mem_type
;
504 unsigned int frequency_mhz
;
505 enum mem_manuf mem_manuf
;
506 const struct mem_timings
*mem
;
508 config
= board_get_config();
510 case DAISY_CONFIG_ELPIDA_EVT
:
511 case DAISY_CONFIG_ELPIDA_DVT
:
512 case DAISY_CONFIG_ELPIDA_PVT
:
513 case DAISY_CONFIG_ELPIDA_MP
:
514 mem_manuf
= MEM_MANUF_ELPIDA
;
515 mem_type
= DDR_MODE_DDR3
;
518 case DAISY_CONFIG_SAMSUNG_EVT
:
519 case DAISY_CONFIG_SAMSUNG_DVT
:
520 case DAISY_CONFIG_SAMSUNG_PVT
:
521 case DAISY_CONFIG_SAMSUNG_MP
:
522 mem_manuf
= MEM_MANUF_SAMSUNG
;
523 mem_type
= DDR_MODE_DDR3
;
527 printk(BIOS_CRIT
, "Unknown board configuration.\n");
531 for (i
= 0, mem
= mem_timings
; i
< ARRAY_SIZE(mem_timings
);
533 if (mem
->mem_type
== mem_type
&&
534 mem
->frequency_mhz
== frequency_mhz
&&
535 mem
->mem_manuf
== mem_manuf
)
536 return (struct mem_timings
*)mem
;