2 * Copyright 2010-2014 Freescale Semiconductor, Inc.
4 * SPDX-License-Identifier: GPL-2.0+
8 * Generic driver for Freescale DDR/DDR2/DDR3 memory controller.
9 * Based on code from spd_sdram.c
10 * Author: James Yang [at freescale.com]
11 * York Sun [at freescale.com]
15 #include <linux/ctype.h>
16 #include <asm/types.h>
19 #include <fsl_ddr_sdram.h>
22 /* Option parameter Structures */
23 struct options_string {
24 const char *option_name;
30 static unsigned int picos_to_mhz(unsigned int picos)
32 return 1000000 / picos;
35 static void print_option_table(const struct options_string *table,
41 unsigned long long *ptr_l;
43 for (i = 0; i < table_size; i++) {
44 switch (table[i].size) {
46 ptr = (unsigned int *) (base + table[i].offset);
47 if (table[i].printhex) {
48 printf("%s = 0x%08X\n",
49 table[i].option_name, *ptr);
52 table[i].option_name, *ptr);
56 ptr_l = (unsigned long long *) (base + table[i].offset);
58 table[i].option_name, *ptr_l);
61 printf("Unrecognized size!\n");
67 static int handle_option_table(const struct options_string *table,
74 unsigned int value, *ptr;
75 unsigned long long value_l, *ptr_l;
77 for (i = 0; i < table_size; i++) {
78 if (strcmp(table[i].option_name, opt) != 0)
80 switch (table[i].size) {
82 value = simple_strtoul(val, NULL, 0);
83 ptr = base + table[i].offset;
87 value_l = simple_strtoull(val, NULL, 0);
88 ptr_l = base + table[i].offset;
92 printf("Unrecognized size!\n");
101 static void fsl_ddr_generic_edit(void *pdata,
103 unsigned int element_size,
104 unsigned int element_num,
107 char *pcdata = (char *)pdata; /* BIG ENDIAN ONLY */
109 pcdata += element_num * element_size;
110 if ((pcdata + element_size) > (char *) pend) {
111 printf("trying to write past end of data\n");
115 switch (element_size) {
117 __raw_writeb(value, pcdata);
120 __raw_writew(value, pcdata);
123 __raw_writel(value, pcdata);
126 printf("unexpected element size %u\n", element_size);
131 static void fsl_ddr_spd_edit(fsl_ddr_info_t *pinfo,
132 unsigned int ctrl_num,
133 unsigned int dimm_num,
134 unsigned int element_num,
137 generic_spd_eeprom_t *pspd;
139 pspd = &(pinfo->spd_installed_dimms[ctrl_num][dimm_num]);
140 fsl_ddr_generic_edit(pspd, pspd + 1, 1, element_num, value);
143 #define COMMON_TIMING(x) {#x, offsetof(common_timing_params_t, x), \
144 sizeof((common_timing_params_t *)0)->x, 0}
146 static void lowest_common_dimm_parameters_edit(fsl_ddr_info_t *pinfo,
147 unsigned int ctrl_num,
148 const char *optname_str,
149 const char *value_str)
151 common_timing_params_t *p = &pinfo->common_timing_params[ctrl_num];
153 static const struct options_string options[] = {
154 COMMON_TIMING(tckmin_x_ps),
155 COMMON_TIMING(tckmax_ps),
156 COMMON_TIMING(taamin_ps),
157 COMMON_TIMING(trcd_ps),
158 COMMON_TIMING(trp_ps),
159 COMMON_TIMING(tras_ps),
161 #ifdef CONFIG_SYS_FSL_DDR4
162 COMMON_TIMING(trfc1_ps),
163 COMMON_TIMING(trfc2_ps),
164 COMMON_TIMING(trfc4_ps),
165 COMMON_TIMING(trrds_ps),
166 COMMON_TIMING(trrdl_ps),
167 COMMON_TIMING(tccdl_ps),
169 COMMON_TIMING(twtr_ps),
170 COMMON_TIMING(trfc_ps),
171 COMMON_TIMING(trrd_ps),
172 COMMON_TIMING(trtp_ps),
174 COMMON_TIMING(twr_ps),
175 COMMON_TIMING(trc_ps),
176 COMMON_TIMING(refresh_rate_ps),
177 COMMON_TIMING(extended_op_srt),
178 #if defined(CONFIG_SYS_FSL_DDR1) || defined(CONFIG_SYS_FSL_DDR2)
179 COMMON_TIMING(tis_ps),
180 COMMON_TIMING(tih_ps),
181 COMMON_TIMING(tds_ps),
182 COMMON_TIMING(tdh_ps),
183 COMMON_TIMING(tdqsq_max_ps),
184 COMMON_TIMING(tqhs_ps),
186 COMMON_TIMING(ndimms_present),
187 COMMON_TIMING(lowest_common_spd_caslat),
188 COMMON_TIMING(highest_common_derated_caslat),
189 COMMON_TIMING(additive_latency),
190 COMMON_TIMING(all_dimms_burst_lengths_bitmask),
191 COMMON_TIMING(all_dimms_registered),
192 COMMON_TIMING(all_dimms_unbuffered),
193 COMMON_TIMING(all_dimms_ecc_capable),
194 COMMON_TIMING(total_mem),
195 COMMON_TIMING(base_address),
197 static const unsigned int n_opts = ARRAY_SIZE(options);
199 if (handle_option_table(options, n_opts, p, optname_str, value_str))
202 printf("Error: couldn't find option string %s\n", optname_str);
205 #define DIMM_PARM(x) {#x, offsetof(dimm_params_t, x), \
206 sizeof((dimm_params_t *)0)->x, 0}
208 static void fsl_ddr_dimm_parameters_edit(fsl_ddr_info_t *pinfo,
209 unsigned int ctrl_num,
210 unsigned int dimm_num,
211 const char *optname_str,
212 const char *value_str)
214 dimm_params_t *p = &(pinfo->dimm_params[ctrl_num][dimm_num]);
216 static const struct options_string options[] = {
218 DIMM_PARM(data_width),
219 DIMM_PARM(primary_sdram_width),
220 DIMM_PARM(ec_sdram_width),
221 DIMM_PARM(registered_dimm),
222 DIMM_PARM(device_width),
224 DIMM_PARM(n_row_addr),
225 DIMM_PARM(n_col_addr),
226 DIMM_PARM(edc_config),
227 #ifdef CONFIG_SYS_FSL_DDR4
228 DIMM_PARM(bank_addr_bits),
229 DIMM_PARM(bank_group_bits),
231 DIMM_PARM(n_banks_per_sdram_device),
233 DIMM_PARM(burst_lengths_bitmask),
234 DIMM_PARM(row_density),
236 DIMM_PARM(tckmin_x_ps),
237 DIMM_PARM(tckmin_x_minus_1_ps),
238 DIMM_PARM(tckmin_x_minus_2_ps),
239 DIMM_PARM(tckmax_ps),
242 DIMM_PARM(caslat_x_minus_1),
243 DIMM_PARM(caslat_x_minus_2),
245 DIMM_PARM(caslat_lowest_derated),
250 #ifdef CONFIG_SYS_FSL_DDR4
265 DIMM_PARM(refresh_rate_ps),
266 DIMM_PARM(extended_op_srt),
268 #if defined(CONFIG_SYS_FSL_DDR1) || defined(CONFIG_SYS_FSL_DDR2)
273 DIMM_PARM(tdqsq_max_ps),
277 DIMM_PARM(rank_density),
279 DIMM_PARM(base_address),
282 static const unsigned int n_opts = ARRAY_SIZE(options);
284 if (handle_option_table(options, n_opts, p, optname_str, value_str))
287 printf("couldn't find option string %s\n", optname_str);
290 static void print_dimm_parameters(const dimm_params_t *pdimm)
292 static const struct options_string options[] = {
294 DIMM_PARM(data_width),
295 DIMM_PARM(primary_sdram_width),
296 DIMM_PARM(ec_sdram_width),
297 DIMM_PARM(registered_dimm),
298 DIMM_PARM(device_width),
300 DIMM_PARM(n_row_addr),
301 DIMM_PARM(n_col_addr),
302 DIMM_PARM(edc_config),
303 #ifdef CONFIG_SYS_FSL_DDR4
304 DIMM_PARM(bank_addr_bits),
305 DIMM_PARM(bank_group_bits),
307 DIMM_PARM(n_banks_per_sdram_device),
310 DIMM_PARM(tckmin_x_ps),
311 DIMM_PARM(tckmin_x_minus_1_ps),
312 DIMM_PARM(tckmin_x_minus_2_ps),
313 DIMM_PARM(tckmax_ps),
317 DIMM_PARM(caslat_x_minus_1),
318 DIMM_PARM(caslat_x_minus_2),
319 DIMM_PARM(caslat_lowest_derated),
324 #ifdef CONFIG_SYS_FSL_DDR4
339 DIMM_PARM(refresh_rate_ps),
341 #if defined(CONFIG_SYS_FSL_DDR1) || defined(CONFIG_SYS_FSL_DDR2)
346 DIMM_PARM(tdqsq_max_ps),
350 static const unsigned int n_opts = ARRAY_SIZE(options);
352 if (pdimm->n_ranks == 0) {
353 printf("DIMM not present\n");
356 printf("DIMM organization parameters:\n");
357 printf("module part name = %s\n", pdimm->mpart);
358 printf("rank_density = %llu bytes (%llu megabytes)\n",
359 pdimm->rank_density, pdimm->rank_density / 0x100000);
360 printf("capacity = %llu bytes (%llu megabytes)\n",
361 pdimm->capacity, pdimm->capacity / 0x100000);
362 printf("burst_lengths_bitmask = %02X\n",
363 pdimm->burst_lengths_bitmask);
364 printf("base_addresss = %llu (%08llX %08llX)\n",
366 (pdimm->base_address >> 32),
367 pdimm->base_address & 0xFFFFFFFF);
368 print_option_table(options, n_opts, pdimm);
371 static void print_lowest_common_dimm_parameters(
372 const common_timing_params_t *plcd_dimm_params)
374 static const struct options_string options[] = {
375 COMMON_TIMING(taamin_ps),
376 COMMON_TIMING(trcd_ps),
377 COMMON_TIMING(trp_ps),
378 COMMON_TIMING(tras_ps),
379 #ifdef CONFIG_SYS_FSL_DDR4
380 COMMON_TIMING(trfc1_ps),
381 COMMON_TIMING(trfc2_ps),
382 COMMON_TIMING(trfc4_ps),
383 COMMON_TIMING(trrds_ps),
384 COMMON_TIMING(trrdl_ps),
385 COMMON_TIMING(tccdl_ps),
387 COMMON_TIMING(twtr_ps),
388 COMMON_TIMING(trfc_ps),
389 COMMON_TIMING(trrd_ps),
390 COMMON_TIMING(trtp_ps),
392 COMMON_TIMING(twr_ps),
393 COMMON_TIMING(trc_ps),
394 COMMON_TIMING(refresh_rate_ps),
395 COMMON_TIMING(extended_op_srt),
396 #if defined(CONFIG_SYS_FSL_DDR1) || defined(CONFIG_SYS_FSL_DDR2)
397 COMMON_TIMING(tis_ps),
398 COMMON_TIMING(tih_ps),
399 COMMON_TIMING(tds_ps),
400 COMMON_TIMING(tdh_ps),
401 COMMON_TIMING(tdqsq_max_ps),
402 COMMON_TIMING(tqhs_ps),
404 COMMON_TIMING(lowest_common_spd_caslat),
405 COMMON_TIMING(highest_common_derated_caslat),
406 COMMON_TIMING(additive_latency),
407 COMMON_TIMING(ndimms_present),
408 COMMON_TIMING(all_dimms_registered),
409 COMMON_TIMING(all_dimms_unbuffered),
410 COMMON_TIMING(all_dimms_ecc_capable),
412 static const unsigned int n_opts = ARRAY_SIZE(options);
414 /* Clock frequencies */
415 printf("tckmin_x_ps = %u (%u MHz)\n",
416 plcd_dimm_params->tckmin_x_ps,
417 picos_to_mhz(plcd_dimm_params->tckmin_x_ps));
418 printf("tckmax_ps = %u (%u MHz)\n",
419 plcd_dimm_params->tckmax_ps,
420 picos_to_mhz(plcd_dimm_params->tckmax_ps));
421 printf("all_dimms_burst_lengths_bitmask = %02X\n",
422 plcd_dimm_params->all_dimms_burst_lengths_bitmask);
424 print_option_table(options, n_opts, plcd_dimm_params);
426 printf("total_mem = %llu (%llu megabytes)\n",
427 plcd_dimm_params->total_mem,
428 plcd_dimm_params->total_mem / 0x100000);
429 printf("base_address = %llu (%llu megabytes)\n",
430 plcd_dimm_params->base_address,
431 plcd_dimm_params->base_address / 0x100000);
434 #define CTRL_OPTIONS(x) {#x, offsetof(memctl_options_t, x), \
435 sizeof((memctl_options_t *)0)->x, 0}
436 #define CTRL_OPTIONS_CS(x, y) {"cs" #x "_" #y, \
437 offsetof(memctl_options_t, cs_local_opts[x].y), \
438 sizeof((memctl_options_t *)0)->cs_local_opts[x].y, 0}
440 static void fsl_ddr_options_edit(fsl_ddr_info_t *pinfo,
441 unsigned int ctl_num,
442 const char *optname_str,
443 const char *value_str)
445 memctl_options_t *p = &(pinfo->memctl_opts[ctl_num]);
447 * This array all on the stack and *computed* each time this
450 static const struct options_string options[] = {
451 CTRL_OPTIONS_CS(0, odt_rd_cfg),
452 CTRL_OPTIONS_CS(0, odt_wr_cfg),
453 #if (CONFIG_CHIP_SELECTS_PER_CTRL > 1)
454 CTRL_OPTIONS_CS(1, odt_rd_cfg),
455 CTRL_OPTIONS_CS(1, odt_wr_cfg),
457 #if (CONFIG_CHIP_SELECTS_PER_CTRL > 2)
458 CTRL_OPTIONS_CS(2, odt_rd_cfg),
459 CTRL_OPTIONS_CS(2, odt_wr_cfg),
461 #if (CONFIG_CHIP_SELECTS_PER_CTRL > 2)
462 CTRL_OPTIONS_CS(3, odt_rd_cfg),
463 CTRL_OPTIONS_CS(3, odt_wr_cfg),
465 #if defined(CONFIG_SYS_FSL_DDR3)
466 CTRL_OPTIONS_CS(0, odt_rtt_norm),
467 CTRL_OPTIONS_CS(0, odt_rtt_wr),
468 #if (CONFIG_CHIP_SELECTS_PER_CTRL > 1)
469 CTRL_OPTIONS_CS(1, odt_rtt_norm),
470 CTRL_OPTIONS_CS(1, odt_rtt_wr),
472 #if (CONFIG_CHIP_SELECTS_PER_CTRL > 2)
473 CTRL_OPTIONS_CS(2, odt_rtt_norm),
474 CTRL_OPTIONS_CS(2, odt_rtt_wr),
476 #if (CONFIG_CHIP_SELECTS_PER_CTRL > 2)
477 CTRL_OPTIONS_CS(3, odt_rtt_norm),
478 CTRL_OPTIONS_CS(3, odt_rtt_wr),
481 CTRL_OPTIONS(memctl_interleaving),
482 CTRL_OPTIONS(memctl_interleaving_mode),
483 CTRL_OPTIONS(ba_intlv_ctl),
484 CTRL_OPTIONS(ecc_mode),
485 CTRL_OPTIONS(ecc_init_using_memctl),
486 CTRL_OPTIONS(dqs_config),
487 CTRL_OPTIONS(self_refresh_in_sleep),
488 CTRL_OPTIONS(dynamic_power),
489 CTRL_OPTIONS(data_bus_width),
490 CTRL_OPTIONS(burst_length),
491 CTRL_OPTIONS(cas_latency_override),
492 CTRL_OPTIONS(cas_latency_override_value),
493 CTRL_OPTIONS(use_derated_caslat),
494 CTRL_OPTIONS(additive_latency_override),
495 CTRL_OPTIONS(additive_latency_override_value),
496 CTRL_OPTIONS(clk_adjust),
497 CTRL_OPTIONS(cpo_override),
498 CTRL_OPTIONS(write_data_delay),
499 CTRL_OPTIONS(half_strength_driver_enable),
502 * These can probably be changed to 2T_EN and 3T_EN
503 * (using a leading numerical character) without problem
505 CTRL_OPTIONS(twot_en),
506 CTRL_OPTIONS(threet_en),
509 CTRL_OPTIONS(bstopre),
510 CTRL_OPTIONS(wrlvl_override),
511 CTRL_OPTIONS(wrlvl_sample),
512 CTRL_OPTIONS(wrlvl_start),
513 CTRL_OPTIONS(rcw_override),
516 CTRL_OPTIONS(ddr_cdr1),
517 CTRL_OPTIONS(ddr_cdr2),
518 CTRL_OPTIONS(tcke_clock_pulse_width_ps),
519 CTRL_OPTIONS(tfaw_window_four_activates_ps),
520 CTRL_OPTIONS(trwt_override),
522 CTRL_OPTIONS(rtt_override),
523 CTRL_OPTIONS(rtt_override_value),
524 CTRL_OPTIONS(rtt_wr_override_value),
527 static const unsigned int n_opts = ARRAY_SIZE(options);
529 if (handle_option_table(options, n_opts, p,
530 optname_str, value_str))
533 printf("couldn't find option string %s\n", optname_str);
536 #define CFG_REGS(x) {#x, offsetof(fsl_ddr_cfg_regs_t, x), \
537 sizeof((fsl_ddr_cfg_regs_t *)0)->x, 1}
538 #define CFG_REGS_CS(x, y) {"cs" #x "_" #y, \
539 offsetof(fsl_ddr_cfg_regs_t, cs[x].y), \
540 sizeof((fsl_ddr_cfg_regs_t *)0)->cs[x].y, 1}
542 static void print_fsl_memctl_config_regs(const fsl_ddr_cfg_regs_t *ddr)
545 static const struct options_string options[] = {
546 CFG_REGS_CS(0, bnds),
547 CFG_REGS_CS(0, config),
548 CFG_REGS_CS(0, config_2),
549 #if (CONFIG_CHIP_SELECTS_PER_CTRL > 1)
550 CFG_REGS_CS(1, bnds),
551 CFG_REGS_CS(1, config),
552 CFG_REGS_CS(1, config_2),
554 #if (CONFIG_CHIP_SELECTS_PER_CTRL > 2)
555 CFG_REGS_CS(2, bnds),
556 CFG_REGS_CS(2, config),
557 CFG_REGS_CS(2, config_2),
559 #if (CONFIG_CHIP_SELECTS_PER_CTRL > 2)
560 CFG_REGS_CS(3, bnds),
561 CFG_REGS_CS(3, config),
562 CFG_REGS_CS(3, config_2),
564 CFG_REGS(timing_cfg_3),
565 CFG_REGS(timing_cfg_0),
566 CFG_REGS(timing_cfg_1),
567 CFG_REGS(timing_cfg_2),
568 CFG_REGS(ddr_sdram_cfg),
569 CFG_REGS(ddr_sdram_cfg_2),
570 CFG_REGS(ddr_sdram_cfg_3),
571 CFG_REGS(ddr_sdram_mode),
572 CFG_REGS(ddr_sdram_mode_2),
573 CFG_REGS(ddr_sdram_mode_3),
574 CFG_REGS(ddr_sdram_mode_4),
575 CFG_REGS(ddr_sdram_mode_5),
576 CFG_REGS(ddr_sdram_mode_6),
577 CFG_REGS(ddr_sdram_mode_7),
578 CFG_REGS(ddr_sdram_mode_8),
579 #ifdef CONFIG_SYS_FSL_DDR4
580 CFG_REGS(ddr_sdram_mode_9),
581 CFG_REGS(ddr_sdram_mode_10),
582 CFG_REGS(ddr_sdram_mode_11),
583 CFG_REGS(ddr_sdram_mode_12),
584 CFG_REGS(ddr_sdram_mode_13),
585 CFG_REGS(ddr_sdram_mode_14),
586 CFG_REGS(ddr_sdram_mode_15),
587 CFG_REGS(ddr_sdram_mode_16),
589 CFG_REGS(ddr_sdram_interval),
590 CFG_REGS(ddr_data_init),
591 CFG_REGS(ddr_sdram_clk_cntl),
592 CFG_REGS(ddr_init_addr),
593 CFG_REGS(ddr_init_ext_addr),
594 CFG_REGS(timing_cfg_4),
595 CFG_REGS(timing_cfg_5),
596 #ifdef CONFIG_SYS_FSL_DDR4
597 CFG_REGS(timing_cfg_6),
598 CFG_REGS(timing_cfg_7),
599 CFG_REGS(timing_cfg_8),
600 CFG_REGS(timing_cfg_9),
602 CFG_REGS(ddr_zq_cntl),
603 CFG_REGS(ddr_wrlvl_cntl),
604 CFG_REGS(ddr_wrlvl_cntl_2),
605 CFG_REGS(ddr_wrlvl_cntl_3),
606 CFG_REGS(ddr_sr_cntr),
607 CFG_REGS(ddr_sdram_rcw_1),
608 CFG_REGS(ddr_sdram_rcw_2),
615 CFG_REGS(err_disable),
616 CFG_REGS(err_int_en),
619 static const unsigned int n_opts = ARRAY_SIZE(options);
621 print_option_table(options, n_opts, ddr);
623 for (i = 0; i < 32; i++)
624 printf("debug_%02d = 0x%08X\n", i+1, ddr->debug[i]);
627 static void fsl_ddr_regs_edit(fsl_ddr_info_t *pinfo,
628 unsigned int ctrl_num,
630 const char *value_str)
633 fsl_ddr_cfg_regs_t *ddr;
635 static const struct options_string options[] = {
636 CFG_REGS_CS(0, bnds),
637 CFG_REGS_CS(0, config),
638 CFG_REGS_CS(0, config_2),
639 #if (CONFIG_CHIP_SELECTS_PER_CTRL > 1)
640 CFG_REGS_CS(1, bnds),
641 CFG_REGS_CS(1, config),
642 CFG_REGS_CS(1, config_2),
644 #if (CONFIG_CHIP_SELECTS_PER_CTRL > 2)
645 CFG_REGS_CS(2, bnds),
646 CFG_REGS_CS(2, config),
647 CFG_REGS_CS(2, config_2),
649 #if (CONFIG_CHIP_SELECTS_PER_CTRL > 3)
650 CFG_REGS_CS(3, bnds),
651 CFG_REGS_CS(3, config),
652 CFG_REGS_CS(3, config_2),
654 CFG_REGS(timing_cfg_3),
655 CFG_REGS(timing_cfg_0),
656 CFG_REGS(timing_cfg_1),
657 CFG_REGS(timing_cfg_2),
658 CFG_REGS(ddr_sdram_cfg),
659 CFG_REGS(ddr_sdram_cfg_2),
660 CFG_REGS(ddr_sdram_cfg_3),
661 CFG_REGS(ddr_sdram_mode),
662 CFG_REGS(ddr_sdram_mode_2),
663 CFG_REGS(ddr_sdram_mode_3),
664 CFG_REGS(ddr_sdram_mode_4),
665 CFG_REGS(ddr_sdram_mode_5),
666 CFG_REGS(ddr_sdram_mode_6),
667 CFG_REGS(ddr_sdram_mode_7),
668 CFG_REGS(ddr_sdram_mode_8),
669 #ifdef CONFIG_SYS_FSL_DDR4
670 CFG_REGS(ddr_sdram_mode_9),
671 CFG_REGS(ddr_sdram_mode_10),
672 CFG_REGS(ddr_sdram_mode_11),
673 CFG_REGS(ddr_sdram_mode_12),
674 CFG_REGS(ddr_sdram_mode_13),
675 CFG_REGS(ddr_sdram_mode_14),
676 CFG_REGS(ddr_sdram_mode_15),
677 CFG_REGS(ddr_sdram_mode_16),
679 CFG_REGS(ddr_sdram_interval),
680 CFG_REGS(ddr_data_init),
681 CFG_REGS(ddr_sdram_clk_cntl),
682 CFG_REGS(ddr_init_addr),
683 CFG_REGS(ddr_init_ext_addr),
684 CFG_REGS(timing_cfg_4),
685 CFG_REGS(timing_cfg_5),
686 #ifdef CONFIG_SYS_FSL_DDR4
687 CFG_REGS(timing_cfg_6),
688 CFG_REGS(timing_cfg_7),
689 CFG_REGS(timing_cfg_8),
690 CFG_REGS(timing_cfg_9),
692 CFG_REGS(ddr_zq_cntl),
693 CFG_REGS(ddr_wrlvl_cntl),
694 CFG_REGS(ddr_wrlvl_cntl_2),
695 CFG_REGS(ddr_wrlvl_cntl_3),
696 CFG_REGS(ddr_sr_cntr),
697 CFG_REGS(ddr_sdram_rcw_1),
698 CFG_REGS(ddr_sdram_rcw_2),
705 CFG_REGS(err_disable),
706 CFG_REGS(err_int_en),
707 CFG_REGS(ddr_sdram_rcw_2),
708 CFG_REGS(ddr_sdram_rcw_2),
711 static const unsigned int n_opts = ARRAY_SIZE(options);
713 debug("fsl_ddr_regs_edit: ctrl_num = %u, "
714 "regname = %s, value = %s\n",
715 ctrl_num, regname, value_str);
716 if (ctrl_num > CONFIG_NUM_DDR_CONTROLLERS)
719 ddr = &(pinfo->fsl_ddr_config_reg[ctrl_num]);
721 if (handle_option_table(options, n_opts, ddr, regname, value_str))
724 for (i = 0; i < 32; i++) {
725 unsigned int value = simple_strtoul(value_str, NULL, 0);
726 sprintf(buf, "debug_%u", i + 1);
727 if (strcmp(buf, regname) == 0) {
728 ddr->debug[i] = value;
732 printf("Error: couldn't find register string %s\n", regname);
735 #define CTRL_OPTIONS_HEX(x) {#x, offsetof(memctl_options_t, x), \
736 sizeof((memctl_options_t *)0)->x, 1}
738 static void print_memctl_options(const memctl_options_t *popts)
740 static const struct options_string options[] = {
741 CTRL_OPTIONS_CS(0, odt_rd_cfg),
742 CTRL_OPTIONS_CS(0, odt_wr_cfg),
743 #if (CONFIG_CHIP_SELECTS_PER_CTRL > 1)
744 CTRL_OPTIONS_CS(1, odt_rd_cfg),
745 CTRL_OPTIONS_CS(1, odt_wr_cfg),
747 #if (CONFIG_CHIP_SELECTS_PER_CTRL > 2)
748 CTRL_OPTIONS_CS(2, odt_rd_cfg),
749 CTRL_OPTIONS_CS(2, odt_wr_cfg),
751 #if (CONFIG_CHIP_SELECTS_PER_CTRL > 3)
752 CTRL_OPTIONS_CS(3, odt_rd_cfg),
753 CTRL_OPTIONS_CS(3, odt_wr_cfg),
755 #if defined(CONFIG_SYS_FSL_DDR3)
756 CTRL_OPTIONS_CS(0, odt_rtt_norm),
757 CTRL_OPTIONS_CS(0, odt_rtt_wr),
758 #if (CONFIG_CHIP_SELECTS_PER_CTRL > 1)
759 CTRL_OPTIONS_CS(1, odt_rtt_norm),
760 CTRL_OPTIONS_CS(1, odt_rtt_wr),
762 #if (CONFIG_CHIP_SELECTS_PER_CTRL > 2)
763 CTRL_OPTIONS_CS(2, odt_rtt_norm),
764 CTRL_OPTIONS_CS(2, odt_rtt_wr),
766 #if (CONFIG_CHIP_SELECTS_PER_CTRL > 3)
767 CTRL_OPTIONS_CS(3, odt_rtt_norm),
768 CTRL_OPTIONS_CS(3, odt_rtt_wr),
771 CTRL_OPTIONS(memctl_interleaving),
772 CTRL_OPTIONS(memctl_interleaving_mode),
773 CTRL_OPTIONS_HEX(ba_intlv_ctl),
774 CTRL_OPTIONS(ecc_mode),
775 CTRL_OPTIONS(ecc_init_using_memctl),
776 CTRL_OPTIONS(dqs_config),
777 CTRL_OPTIONS(self_refresh_in_sleep),
778 CTRL_OPTIONS(dynamic_power),
779 CTRL_OPTIONS(data_bus_width),
780 CTRL_OPTIONS(burst_length),
781 CTRL_OPTIONS(cas_latency_override),
782 CTRL_OPTIONS(cas_latency_override_value),
783 CTRL_OPTIONS(use_derated_caslat),
784 CTRL_OPTIONS(additive_latency_override),
785 CTRL_OPTIONS(additive_latency_override_value),
786 CTRL_OPTIONS(clk_adjust),
787 CTRL_OPTIONS(cpo_override),
788 CTRL_OPTIONS(write_data_delay),
789 CTRL_OPTIONS(half_strength_driver_enable),
791 * These can probably be changed to 2T_EN and 3T_EN
792 * (using a leading numerical character) without problem
794 CTRL_OPTIONS(twot_en),
795 CTRL_OPTIONS(threet_en),
796 CTRL_OPTIONS(registered_dimm_en),
799 CTRL_OPTIONS(bstopre),
800 CTRL_OPTIONS(wrlvl_override),
801 CTRL_OPTIONS(wrlvl_sample),
802 CTRL_OPTIONS(wrlvl_start),
803 CTRL_OPTIONS(rcw_override),
806 CTRL_OPTIONS_HEX(ddr_cdr1),
807 CTRL_OPTIONS_HEX(ddr_cdr2),
808 CTRL_OPTIONS(tcke_clock_pulse_width_ps),
809 CTRL_OPTIONS(tfaw_window_four_activates_ps),
810 CTRL_OPTIONS(trwt_override),
812 CTRL_OPTIONS(rtt_override),
813 CTRL_OPTIONS(rtt_override_value),
814 CTRL_OPTIONS(rtt_wr_override_value),
816 static const unsigned int n_opts = ARRAY_SIZE(options);
818 print_option_table(options, n_opts, popts);
821 #ifdef CONFIG_SYS_FSL_DDR1
822 void ddr1_spd_dump(const ddr1_spd_eeprom_t *spd)
826 printf("%-3d : %02x %s\n", 0, spd->info_size,
827 " spd->info_size, * 0 # bytes written into serial memory *");
828 printf("%-3d : %02x %s\n", 1, spd->chip_size,
829 " spd->chip_size, * 1 Total # bytes of SPD memory device *");
830 printf("%-3d : %02x %s\n", 2, spd->mem_type,
831 " spd->mem_type, * 2 Fundamental memory type *");
832 printf("%-3d : %02x %s\n", 3, spd->nrow_addr,
833 " spd->nrow_addr, * 3 # of Row Addresses on this assembly *");
834 printf("%-3d : %02x %s\n", 4, spd->ncol_addr,
835 " spd->ncol_addr, * 4 # of Column Addrs on this assembly *");
836 printf("%-3d : %02x %s\n", 5, spd->nrows,
837 " spd->nrows * 5 # of DIMM Banks *");
838 printf("%-3d : %02x %s\n", 6, spd->dataw_lsb,
839 " spd->dataw_lsb, * 6 Data Width lsb of this assembly *");
840 printf("%-3d : %02x %s\n", 7, spd->dataw_msb,
841 " spd->dataw_msb, * 7 Data Width msb of this assembly *");
842 printf("%-3d : %02x %s\n", 8, spd->voltage,
843 " spd->voltage, * 8 Voltage intf std of this assembly *");
844 printf("%-3d : %02x %s\n", 9, spd->clk_cycle,
845 " spd->clk_cycle, * 9 SDRAM Cycle time at CL=X *");
846 printf("%-3d : %02x %s\n", 10, spd->clk_access,
847 " spd->clk_access, * 10 SDRAM Access from Clock at CL=X *");
848 printf("%-3d : %02x %s\n", 11, spd->config,
849 " spd->config, * 11 DIMM Configuration type *");
850 printf("%-3d : %02x %s\n", 12, spd->refresh,
851 " spd->refresh, * 12 Refresh Rate/Type *");
852 printf("%-3d : %02x %s\n", 13, spd->primw,
853 " spd->primw, * 13 Primary SDRAM Width *");
854 printf("%-3d : %02x %s\n", 14, spd->ecw,
855 " spd->ecw, * 14 Error Checking SDRAM width *");
856 printf("%-3d : %02x %s\n", 15, spd->min_delay,
857 " spd->min_delay, * 15 Back to Back Random Access *");
858 printf("%-3d : %02x %s\n", 16, spd->burstl,
859 " spd->burstl, * 16 Burst Lengths Supported *");
860 printf("%-3d : %02x %s\n", 17, spd->nbanks,
861 " spd->nbanks, * 17 # of Banks on Each SDRAM Device *");
862 printf("%-3d : %02x %s\n", 18, spd->cas_lat,
863 " spd->cas_lat, * 18 CAS# Latencies Supported *");
864 printf("%-3d : %02x %s\n", 19, spd->cs_lat,
865 " spd->cs_lat, * 19 Chip Select Latency *");
866 printf("%-3d : %02x %s\n", 20, spd->write_lat,
867 " spd->write_lat, * 20 Write Latency/Recovery *");
868 printf("%-3d : %02x %s\n", 21, spd->mod_attr,
869 " spd->mod_attr, * 21 SDRAM Module Attributes *");
870 printf("%-3d : %02x %s\n", 22, spd->dev_attr,
871 " spd->dev_attr, * 22 SDRAM Device Attributes *");
872 printf("%-3d : %02x %s\n", 23, spd->clk_cycle2,
873 " spd->clk_cycle2, * 23 Min SDRAM Cycle time at CL=X-1 *");
874 printf("%-3d : %02x %s\n", 24, spd->clk_access2,
875 " spd->clk_access2, * 24 SDRAM Access from Clock at CL=X-1 *");
876 printf("%-3d : %02x %s\n", 25, spd->clk_cycle3,
877 " spd->clk_cycle3, * 25 Min SDRAM Cycle time at CL=X-2 *");
878 printf("%-3d : %02x %s\n", 26, spd->clk_access3,
879 " spd->clk_access3, * 26 Max Access from Clock at CL=X-2 *");
880 printf("%-3d : %02x %s\n", 27, spd->trp,
881 " spd->trp, * 27 Min Row Precharge Time (tRP)*");
882 printf("%-3d : %02x %s\n", 28, spd->trrd,
883 " spd->trrd, * 28 Min Row Active to Row Active (tRRD) *");
884 printf("%-3d : %02x %s\n", 29, spd->trcd,
885 " spd->trcd, * 29 Min RAS to CAS Delay (tRCD) *");
886 printf("%-3d : %02x %s\n", 30, spd->tras,
887 " spd->tras, * 30 Minimum RAS Pulse Width (tRAS) *");
888 printf("%-3d : %02x %s\n", 31, spd->bank_dens,
889 " spd->bank_dens, * 31 Density of each bank on module *");
890 printf("%-3d : %02x %s\n", 32, spd->ca_setup,
891 " spd->ca_setup, * 32 Cmd + Addr signal input setup time *");
892 printf("%-3d : %02x %s\n", 33, spd->ca_hold,
893 " spd->ca_hold, * 33 Cmd and Addr signal input hold time *");
894 printf("%-3d : %02x %s\n", 34, spd->data_setup,
895 " spd->data_setup, * 34 Data signal input setup time *");
896 printf("%-3d : %02x %s\n", 35, spd->data_hold,
897 " spd->data_hold, * 35 Data signal input hold time *");
898 printf("%-3d : %02x %s\n", 36, spd->res_36_40[0],
899 " spd->res_36_40[0], * 36 Reserved / tWR *");
900 printf("%-3d : %02x %s\n", 37, spd->res_36_40[1],
901 " spd->res_36_40[1], * 37 Reserved / tWTR *");
902 printf("%-3d : %02x %s\n", 38, spd->res_36_40[2],
903 " spd->res_36_40[2], * 38 Reserved / tRTP *");
904 printf("%-3d : %02x %s\n", 39, spd->res_36_40[3],
905 " spd->res_36_40[3], * 39 Reserved / mem_probe *");
906 printf("%-3d : %02x %s\n", 40, spd->res_36_40[4],
907 " spd->res_36_40[4], * 40 Reserved / trc,trfc extensions *");
908 printf("%-3d : %02x %s\n", 41, spd->trc,
909 " spd->trc, * 41 Min Active to Auto refresh time tRC *");
910 printf("%-3d : %02x %s\n", 42, spd->trfc,
911 " spd->trfc, * 42 Min Auto to Active period tRFC *");
912 printf("%-3d : %02x %s\n", 43, spd->tckmax,
913 " spd->tckmax, * 43 Max device cycle time tCKmax *");
914 printf("%-3d : %02x %s\n", 44, spd->tdqsq,
915 " spd->tdqsq, * 44 Max DQS to DQ skew *");
916 printf("%-3d : %02x %s\n", 45, spd->tqhs,
917 " spd->tqhs, * 45 Max Read DataHold skew tQHS *");
918 printf("%-3d : %02x %s\n", 46, spd->res_46,
919 " spd->res_46, * 46 Reserved/ PLL Relock time *");
920 printf("%-3d : %02x %s\n", 47, spd->dimm_height,
921 " spd->dimm_height * 47 SDRAM DIMM Height *");
923 printf("%-3d-%3d: ", 48, 61);
925 for (i = 0; i < 14; i++)
926 printf("%02x", spd->res_48_61[i]);
928 printf(" * 48-61 IDD in SPD and Reserved space *\n");
930 printf("%-3d : %02x %s\n", 62, spd->spd_rev,
931 " spd->spd_rev, * 62 SPD Data Revision Code *");
932 printf("%-3d : %02x %s\n", 63, spd->cksum,
933 " spd->cksum, * 63 Checksum for bytes 0-62 *");
934 printf("%-3d-%3d: ", 64, 71);
936 for (i = 0; i < 8; i++)
937 printf("%02x", spd->mid[i]);
939 printf("* 64 Mfr's JEDEC ID code per JEP-108E *\n");
940 printf("%-3d : %02x %s\n", 72, spd->mloc,
941 " spd->mloc, * 72 Manufacturing Location *");
943 printf("%-3d-%3d: >>", 73, 90);
945 for (i = 0; i < 18; i++)
946 printf("%c", spd->mpart[i]);
948 printf("<<* 73 Manufacturer's Part Number *\n");
950 printf("%-3d-%3d: %02x %02x %s\n", 91, 92, spd->rev[0], spd->rev[1],
951 "* 91 Revision Code *");
952 printf("%-3d-%3d: %02x %02x %s\n", 93, 94, spd->mdate[0], spd->mdate[1],
953 "* 93 Manufacturing Date *");
954 printf("%-3d-%3d: ", 95, 98);
956 for (i = 0; i < 4; i++)
957 printf("%02x", spd->sernum[i]);
959 printf("* 95 Assembly Serial Number *\n");
961 printf("%-3d-%3d: ", 99, 127);
963 for (i = 0; i < 27; i++)
964 printf("%02x", spd->mspec[i]);
966 printf("* 99 Manufacturer Specific Data *\n");
970 #ifdef CONFIG_SYS_FSL_DDR2
971 void ddr2_spd_dump(const ddr2_spd_eeprom_t *spd)
975 printf("%-3d : %02x %s\n", 0, spd->info_size,
976 " spd->info_size, * 0 # bytes written into serial memory *");
977 printf("%-3d : %02x %s\n", 1, spd->chip_size,
978 " spd->chip_size, * 1 Total # bytes of SPD memory device *");
979 printf("%-3d : %02x %s\n", 2, spd->mem_type,
980 " spd->mem_type, * 2 Fundamental memory type *");
981 printf("%-3d : %02x %s\n", 3, spd->nrow_addr,
982 " spd->nrow_addr, * 3 # of Row Addresses on this assembly *");
983 printf("%-3d : %02x %s\n", 4, spd->ncol_addr,
984 " spd->ncol_addr, * 4 # of Column Addrs on this assembly *");
985 printf("%-3d : %02x %s\n", 5, spd->mod_ranks,
986 " spd->mod_ranks * 5 # of Module Rows on this assembly *");
987 printf("%-3d : %02x %s\n", 6, spd->dataw,
988 " spd->dataw, * 6 Data Width of this assembly *");
989 printf("%-3d : %02x %s\n", 7, spd->res_7,
990 " spd->res_7, * 7 Reserved *");
991 printf("%-3d : %02x %s\n", 8, spd->voltage,
992 " spd->voltage, * 8 Voltage intf std of this assembly *");
993 printf("%-3d : %02x %s\n", 9, spd->clk_cycle,
994 " spd->clk_cycle, * 9 SDRAM Cycle time at CL=X *");
995 printf("%-3d : %02x %s\n", 10, spd->clk_access,
996 " spd->clk_access, * 10 SDRAM Access from Clock at CL=X *");
997 printf("%-3d : %02x %s\n", 11, spd->config,
998 " spd->config, * 11 DIMM Configuration type *");
999 printf("%-3d : %02x %s\n", 12, spd->refresh,
1000 " spd->refresh, * 12 Refresh Rate/Type *");
1001 printf("%-3d : %02x %s\n", 13, spd->primw,
1002 " spd->primw, * 13 Primary SDRAM Width *");
1003 printf("%-3d : %02x %s\n", 14, spd->ecw,
1004 " spd->ecw, * 14 Error Checking SDRAM width *");
1005 printf("%-3d : %02x %s\n", 15, spd->res_15,
1006 " spd->res_15, * 15 Reserved *");
1007 printf("%-3d : %02x %s\n", 16, spd->burstl,
1008 " spd->burstl, * 16 Burst Lengths Supported *");
1009 printf("%-3d : %02x %s\n", 17, spd->nbanks,
1010 " spd->nbanks, * 17 # of Banks on Each SDRAM Device *");
1011 printf("%-3d : %02x %s\n", 18, spd->cas_lat,
1012 " spd->cas_lat, * 18 CAS# Latencies Supported *");
1013 printf("%-3d : %02x %s\n", 19, spd->mech_char,
1014 " spd->mech_char, * 19 Mechanical Characteristics *");
1015 printf("%-3d : %02x %s\n", 20, spd->dimm_type,
1016 " spd->dimm_type, * 20 DIMM type *");
1017 printf("%-3d : %02x %s\n", 21, spd->mod_attr,
1018 " spd->mod_attr, * 21 SDRAM Module Attributes *");
1019 printf("%-3d : %02x %s\n", 22, spd->dev_attr,
1020 " spd->dev_attr, * 22 SDRAM Device Attributes *");
1021 printf("%-3d : %02x %s\n", 23, spd->clk_cycle2,
1022 " spd->clk_cycle2, * 23 Min SDRAM Cycle time at CL=X-1 *");
1023 printf("%-3d : %02x %s\n", 24, spd->clk_access2,
1024 " spd->clk_access2, * 24 SDRAM Access from Clock at CL=X-1 *");
1025 printf("%-3d : %02x %s\n", 25, spd->clk_cycle3,
1026 " spd->clk_cycle3, * 25 Min SDRAM Cycle time at CL=X-2 *");
1027 printf("%-3d : %02x %s\n", 26, spd->clk_access3,
1028 " spd->clk_access3, * 26 Max Access from Clock at CL=X-2 *");
1029 printf("%-3d : %02x %s\n", 27, spd->trp,
1030 " spd->trp, * 27 Min Row Precharge Time (tRP)*");
1031 printf("%-3d : %02x %s\n", 28, spd->trrd,
1032 " spd->trrd, * 28 Min Row Active to Row Active (tRRD) *");
1033 printf("%-3d : %02x %s\n", 29, spd->trcd,
1034 " spd->trcd, * 29 Min RAS to CAS Delay (tRCD) *");
1035 printf("%-3d : %02x %s\n", 30, spd->tras,
1036 " spd->tras, * 30 Minimum RAS Pulse Width (tRAS) *");
1037 printf("%-3d : %02x %s\n", 31, spd->rank_dens,
1038 " spd->rank_dens, * 31 Density of each rank on module *");
1039 printf("%-3d : %02x %s\n", 32, spd->ca_setup,
1040 " spd->ca_setup, * 32 Cmd + Addr signal input setup time *");
1041 printf("%-3d : %02x %s\n", 33, spd->ca_hold,
1042 " spd->ca_hold, * 33 Cmd and Addr signal input hold time *");
1043 printf("%-3d : %02x %s\n", 34, spd->data_setup,
1044 " spd->data_setup, * 34 Data signal input setup time *");
1045 printf("%-3d : %02x %s\n", 35, spd->data_hold,
1046 " spd->data_hold, * 35 Data signal input hold time *");
1047 printf("%-3d : %02x %s\n", 36, spd->twr,
1048 " spd->twr, * 36 Write Recovery time tWR *");
1049 printf("%-3d : %02x %s\n", 37, spd->twtr,
1050 " spd->twtr, * 37 Int write to read delay tWTR *");
1051 printf("%-3d : %02x %s\n", 38, spd->trtp,
1052 " spd->trtp, * 38 Int read to precharge delay tRTP *");
1053 printf("%-3d : %02x %s\n", 39, spd->mem_probe,
1054 " spd->mem_probe, * 39 Mem analysis probe characteristics *");
1055 printf("%-3d : %02x %s\n", 40, spd->trctrfc_ext,
1056 " spd->trctrfc_ext, * 40 Extensions to trc and trfc *");
1057 printf("%-3d : %02x %s\n", 41, spd->trc,
1058 " spd->trc, * 41 Min Active to Auto refresh time tRC *");
1059 printf("%-3d : %02x %s\n", 42, spd->trfc,
1060 " spd->trfc, * 42 Min Auto to Active period tRFC *");
1061 printf("%-3d : %02x %s\n", 43, spd->tckmax,
1062 " spd->tckmax, * 43 Max device cycle time tCKmax *");
1063 printf("%-3d : %02x %s\n", 44, spd->tdqsq,
1064 " spd->tdqsq, * 44 Max DQS to DQ skew *");
1065 printf("%-3d : %02x %s\n", 45, spd->tqhs,
1066 " spd->tqhs, * 45 Max Read DataHold skew tQHS *");
1067 printf("%-3d : %02x %s\n", 46, spd->pll_relock,
1068 " spd->pll_relock, * 46 PLL Relock time *");
1069 printf("%-3d : %02x %s\n", 47, spd->t_casemax,
1070 " spd->t_casemax, * 47 t_casemax *");
1071 printf("%-3d : %02x %s\n", 48, spd->psi_ta_dram,
1072 " spd->psi_ta_dram, * 48 Thermal Resistance of DRAM Package "
1073 "from Top (Case) to Ambient (Psi T-A DRAM) *");
1074 printf("%-3d : %02x %s\n", 49, spd->dt0_mode,
1075 " spd->dt0_mode, * 49 DRAM Case Temperature Rise from "
1076 "Ambient due to Activate-Precharge/Mode Bits "
1077 "(DT0/Mode Bits) *)");
1078 printf("%-3d : %02x %s\n", 50, spd->dt2n_dt2q,
1079 " spd->dt2n_dt2q, * 50 DRAM Case Temperature Rise from "
1080 "Ambient due to Precharge/Quiet Standby "
1082 printf("%-3d : %02x %s\n", 51, spd->dt2p,
1083 " spd->dt2p, * 51 DRAM Case Temperature Rise from "
1084 "Ambient due to Precharge Power-Down (DT2P) *");
1085 printf("%-3d : %02x %s\n", 52, spd->dt3n,
1086 " spd->dt3n, * 52 DRAM Case Temperature Rise from "
1087 "Ambient due to Active Standby (DT3N) *");
1088 printf("%-3d : %02x %s\n", 53, spd->dt3pfast,
1089 " spd->dt3pfast, * 53 DRAM Case Temperature Rise from "
1090 "Ambient due to Active Power-Down with Fast PDN Exit "
1092 printf("%-3d : %02x %s\n", 54, spd->dt3pslow,
1093 " spd->dt3pslow, * 54 DRAM Case Temperature Rise from "
1094 "Ambient due to Active Power-Down with Slow PDN Exit "
1096 printf("%-3d : %02x %s\n", 55, spd->dt4r_dt4r4w,
1097 " spd->dt4r_dt4r4w, * 55 DRAM Case Temperature Rise from "
1098 "Ambient due to Page Open Burst Read/DT4R4W Mode Bit "
1099 "(DT4R/DT4R4W Mode Bit) *");
1100 printf("%-3d : %02x %s\n", 56, spd->dt5b,
1101 " spd->dt5b, * 56 DRAM Case Temperature Rise from "
1102 "Ambient due to Burst Refresh (DT5B) *");
1103 printf("%-3d : %02x %s\n", 57, spd->dt7,
1104 " spd->dt7, * 57 DRAM Case Temperature Rise from "
1105 "Ambient due to Bank Interleave Reads with "
1106 "Auto-Precharge (DT7) *");
1107 printf("%-3d : %02x %s\n", 58, spd->psi_ta_pll,
1108 " spd->psi_ta_pll, * 58 Thermal Resistance of PLL Package form"
1109 " Top (Case) to Ambient (Psi T-A PLL) *");
1110 printf("%-3d : %02x %s\n", 59, spd->psi_ta_reg,
1111 " spd->psi_ta_reg, * 59 Thermal Reisitance of Register Package"
1112 " from Top (Case) to Ambient (Psi T-A Register) *");
1113 printf("%-3d : %02x %s\n", 60, spd->dtpllactive,
1114 " spd->dtpllactive, * 60 PLL Case Temperature Rise from "
1115 "Ambient due to PLL Active (DT PLL Active) *");
1116 printf("%-3d : %02x %s\n", 61, spd->dtregact,
1118 "* 61 Register Case Temperature Rise from Ambient due to "
1119 "Register Active/Mode Bit (DT Register Active/Mode Bit) *");
1120 printf("%-3d : %02x %s\n", 62, spd->spd_rev,
1121 " spd->spd_rev, * 62 SPD Data Revision Code *");
1122 printf("%-3d : %02x %s\n", 63, spd->cksum,
1123 " spd->cksum, * 63 Checksum for bytes 0-62 *");
1125 printf("%-3d-%3d: ", 64, 71);
1127 for (i = 0; i < 8; i++)
1128 printf("%02x", spd->mid[i]);
1130 printf("* 64 Mfr's JEDEC ID code per JEP-108E *\n");
1132 printf("%-3d : %02x %s\n", 72, spd->mloc,
1133 " spd->mloc, * 72 Manufacturing Location *");
1135 printf("%-3d-%3d: >>", 73, 90);
1136 for (i = 0; i < 18; i++)
1137 printf("%c", spd->mpart[i]);
1140 printf("<<* 73 Manufacturer's Part Number *\n");
1142 printf("%-3d-%3d: %02x %02x %s\n", 91, 92, spd->rev[0], spd->rev[1],
1143 "* 91 Revision Code *");
1144 printf("%-3d-%3d: %02x %02x %s\n", 93, 94, spd->mdate[0], spd->mdate[1],
1145 "* 93 Manufacturing Date *");
1146 printf("%-3d-%3d: ", 95, 98);
1148 for (i = 0; i < 4; i++)
1149 printf("%02x", spd->sernum[i]);
1151 printf("* 95 Assembly Serial Number *\n");
1153 printf("%-3d-%3d: ", 99, 127);
1154 for (i = 0; i < 27; i++)
1155 printf("%02x", spd->mspec[i]);
1158 printf("* 99 Manufacturer Specific Data *\n");
1162 #ifdef CONFIG_SYS_FSL_DDR3
1163 void ddr3_spd_dump(const ddr3_spd_eeprom_t *spd)
1167 /* General Section: Bytes 0-59 */
1169 #define PRINT_NXS(x, y, z...) printf("%-3d : %02x " z "\n", x, (u8)y);
1170 #define PRINT_NNXXS(n0, n1, x0, x1, s) \
1171 printf("%-3d-%3d: %02x %02x " s "\n", n0, n1, x0, x1);
1173 PRINT_NXS(0, spd->info_size_crc,
1174 "info_size_crc bytes written into serial memory, "
1176 PRINT_NXS(1, spd->spd_rev,
1177 "spd_rev SPD Revision");
1178 PRINT_NXS(2, spd->mem_type,
1179 "mem_type Key Byte / DRAM Device Type");
1180 PRINT_NXS(3, spd->module_type,
1181 "module_type Key Byte / Module Type");
1182 PRINT_NXS(4, spd->density_banks,
1183 "density_banks SDRAM Density and Banks");
1184 PRINT_NXS(5, spd->addressing,
1185 "addressing SDRAM Addressing");
1186 PRINT_NXS(6, spd->module_vdd,
1187 "module_vdd Module Nominal Voltage, VDD");
1188 PRINT_NXS(7, spd->organization,
1189 "organization Module Organization");
1190 PRINT_NXS(8, spd->bus_width,
1191 "bus_width Module Memory Bus Width");
1192 PRINT_NXS(9, spd->ftb_div,
1193 "ftb_div Fine Timebase (FTB) Dividend / Divisor");
1194 PRINT_NXS(10, spd->mtb_dividend,
1195 "mtb_dividend Medium Timebase (MTB) Dividend");
1196 PRINT_NXS(11, spd->mtb_divisor,
1197 "mtb_divisor Medium Timebase (MTB) Divisor");
1198 PRINT_NXS(12, spd->tck_min,
1199 "tck_min SDRAM Minimum Cycle Time");
1200 PRINT_NXS(13, spd->res_13,
1202 PRINT_NXS(14, spd->caslat_lsb,
1203 "caslat_lsb CAS Latencies Supported, LSB");
1204 PRINT_NXS(15, spd->caslat_msb,
1205 "caslat_msb CAS Latencies Supported, MSB");
1206 PRINT_NXS(16, spd->taa_min,
1207 "taa_min Min CAS Latency Time");
1208 PRINT_NXS(17, spd->twr_min,
1209 "twr_min Min Write REcovery Time");
1210 PRINT_NXS(18, spd->trcd_min,
1211 "trcd_min Min RAS# to CAS# Delay Time");
1212 PRINT_NXS(19, spd->trrd_min,
1213 "trrd_min Min Row Active to Row Active Delay Time");
1214 PRINT_NXS(20, spd->trp_min,
1215 "trp_min Min Row Precharge Delay Time");
1216 PRINT_NXS(21, spd->tras_trc_ext,
1217 "tras_trc_ext Upper Nibbles for tRAS and tRC");
1218 PRINT_NXS(22, spd->tras_min_lsb,
1219 "tras_min_lsb Min Active to Precharge Delay Time, LSB");
1220 PRINT_NXS(23, spd->trc_min_lsb,
1221 "trc_min_lsb Min Active to Active/Refresh Delay Time, LSB");
1222 PRINT_NXS(24, spd->trfc_min_lsb,
1223 "trfc_min_lsb Min Refresh Recovery Delay Time LSB");
1224 PRINT_NXS(25, spd->trfc_min_msb,
1225 "trfc_min_msb Min Refresh Recovery Delay Time MSB");
1226 PRINT_NXS(26, spd->twtr_min,
1227 "twtr_min Min Internal Write to Read Command Delay Time");
1228 PRINT_NXS(27, spd->trtp_min,
1230 "Min Internal Read to Precharge Command Delay Time");
1231 PRINT_NXS(28, spd->tfaw_msb,
1232 "tfaw_msb Upper Nibble for tFAW");
1233 PRINT_NXS(29, spd->tfaw_min,
1234 "tfaw_min Min Four Activate Window Delay Time");
1235 PRINT_NXS(30, spd->opt_features,
1236 "opt_features SDRAM Optional Features");
1237 PRINT_NXS(31, spd->therm_ref_opt,
1238 "therm_ref_opt SDRAM Thermal and Refresh Opts");
1239 PRINT_NXS(32, spd->therm_sensor,
1240 "therm_sensor SDRAM Thermal Sensor");
1241 PRINT_NXS(33, spd->device_type,
1242 "device_type SDRAM Device Type");
1243 PRINT_NXS(34, spd->fine_tck_min,
1244 "fine_tck_min Fine offset for tCKmin");
1245 PRINT_NXS(35, spd->fine_taa_min,
1246 "fine_taa_min Fine offset for tAAmin");
1247 PRINT_NXS(36, spd->fine_trcd_min,
1248 "fine_trcd_min Fine offset for tRCDmin");
1249 PRINT_NXS(37, spd->fine_trp_min,
1250 "fine_trp_min Fine offset for tRPmin");
1251 PRINT_NXS(38, spd->fine_trc_min,
1252 "fine_trc_min Fine offset for tRCmin");
1254 printf("%-3d-%3d: ", 39, 59); /* Reserved, General Section */
1256 for (i = 39; i <= 59; i++)
1257 printf("%02x ", spd->res_39_59[i - 39]);
1261 switch (spd->module_type) {
1262 case 0x02: /* UDIMM */
1263 case 0x03: /* SO-DIMM */
1264 case 0x04: /* Micro-DIMM */
1265 case 0x06: /* Mini-UDIMM */
1266 PRINT_NXS(60, spd->mod_section.unbuffered.mod_height,
1267 "mod_height (Unbuffered) Module Nominal Height");
1268 PRINT_NXS(61, spd->mod_section.unbuffered.mod_thickness,
1269 "mod_thickness (Unbuffered) Module Maximum Thickness");
1270 PRINT_NXS(62, spd->mod_section.unbuffered.ref_raw_card,
1271 "ref_raw_card (Unbuffered) Reference Raw Card Used");
1272 PRINT_NXS(63, spd->mod_section.unbuffered.addr_mapping,
1273 "addr_mapping (Unbuffered) Address mapping from "
1274 "Edge Connector to DRAM");
1276 case 0x01: /* RDIMM */
1277 case 0x05: /* Mini-RDIMM */
1278 PRINT_NXS(60, spd->mod_section.registered.mod_height,
1279 "mod_height (Registered) Module Nominal Height");
1280 PRINT_NXS(61, spd->mod_section.registered.mod_thickness,
1281 "mod_thickness (Registered) Module Maximum Thickness");
1282 PRINT_NXS(62, spd->mod_section.registered.ref_raw_card,
1283 "ref_raw_card (Registered) Reference Raw Card Used");
1284 PRINT_NXS(63, spd->mod_section.registered.modu_attr,
1285 "modu_attr (Registered) DIMM Module Attributes");
1286 PRINT_NXS(64, spd->mod_section.registered.thermal,
1287 "thermal (Registered) Thermal Heat "
1288 "Spreader Solution");
1289 PRINT_NXS(65, spd->mod_section.registered.reg_id_lo,
1290 "reg_id_lo (Registered) Register Manufacturer ID "
1292 PRINT_NXS(66, spd->mod_section.registered.reg_id_hi,
1293 "reg_id_hi (Registered) Register Manufacturer ID "
1295 PRINT_NXS(67, spd->mod_section.registered.reg_rev,
1296 "reg_rev (Registered) Register "
1298 PRINT_NXS(68, spd->mod_section.registered.reg_type,
1299 "reg_type (Registered) Register Type");
1300 for (i = 69; i <= 76; i++) {
1301 printf("%-3d : %02x rcw[%d]\n", i,
1302 spd->mod_section.registered.rcw[i-69], i-69);
1306 /* Module-specific Section, Unsupported Module Type */
1307 printf("%-3d-%3d: ", 60, 116);
1309 for (i = 60; i <= 116; i++)
1310 printf("%02x", spd->mod_section.uc[i - 60]);
1315 /* Unique Module ID: Bytes 117-125 */
1316 PRINT_NXS(117, spd->mmid_lsb, "Module MfgID Code LSB - JEP-106");
1317 PRINT_NXS(118, spd->mmid_msb, "Module MfgID Code MSB - JEP-106");
1318 PRINT_NXS(119, spd->mloc, "Mfg Location");
1319 PRINT_NNXXS(120, 121, spd->mdate[0], spd->mdate[1], "Mfg Date");
1321 printf("%-3d-%3d: ", 122, 125);
1323 for (i = 122; i <= 125; i++)
1324 printf("%02x ", spd->sernum[i - 122]);
1325 printf(" Module Serial Number\n");
1327 /* CRC: Bytes 126-127 */
1328 PRINT_NNXXS(126, 127, spd->crc[0], spd->crc[1], " SPD CRC");
1330 /* Other Manufacturer Fields and User Space: Bytes 128-255 */
1331 printf("%-3d-%3d: ", 128, 145);
1332 for (i = 128; i <= 145; i++)
1333 printf("%02x ", spd->mpart[i - 128]);
1334 printf(" Mfg's Module Part Number\n");
1336 PRINT_NNXXS(146, 147, spd->mrev[0], spd->mrev[1],
1337 "Module Revision code");
1339 PRINT_NXS(148, spd->dmid_lsb, "DRAM MfgID Code LSB - JEP-106");
1340 PRINT_NXS(149, spd->dmid_msb, "DRAM MfgID Code MSB - JEP-106");
1342 printf("%-3d-%3d: ", 150, 175);
1343 for (i = 150; i <= 175; i++)
1344 printf("%02x ", spd->msd[i - 150]);
1345 printf(" Mfg's Specific Data\n");
1347 printf("%-3d-%3d: ", 176, 255);
1348 for (i = 176; i <= 255; i++)
1349 printf("%02x", spd->cust[i - 176]);
1350 printf(" Mfg's Specific Data\n");
1355 #ifdef CONFIG_SYS_FSL_DDR4
1356 void ddr4_spd_dump(const struct ddr4_spd_eeprom_s *spd)
1360 /* General Section: Bytes 0-127 */
1362 #define PRINT_NXS(x, y, z...) printf("%-3d : %02x " z "\n", x, (u8)y);
1363 #define PRINT_NNXXS(n0, n1, x0, x1, s) \
1364 printf("%-3d-%3d: %02x %02x " s "\n", n0, n1, x0, x1);
1366 PRINT_NXS(0, spd->info_size_crc,
1367 "info_size_crc bytes written into serial memory, CRC coverage");
1368 PRINT_NXS(1, spd->spd_rev,
1369 "spd_rev SPD Revision");
1370 PRINT_NXS(2, spd->mem_type,
1371 "mem_type Key Byte / DRAM Device Type");
1372 PRINT_NXS(3, spd->module_type,
1373 "module_type Key Byte / Module Type");
1374 PRINT_NXS(4, spd->density_banks,
1375 "density_banks SDRAM Density and Banks");
1376 PRINT_NXS(5, spd->addressing,
1377 "addressing SDRAM Addressing");
1378 PRINT_NXS(6, spd->package_type,
1379 "package_type Package type");
1380 PRINT_NXS(7, spd->opt_feature,
1381 "opt_feature Optional features");
1382 PRINT_NXS(8, spd->thermal_ref,
1383 "thermal_ref Thermal and Refresh options");
1384 PRINT_NXS(9, spd->oth_opt_features,
1385 "oth_opt_features Other SDRAM optional features");
1386 PRINT_NXS(10, spd->res_10,
1388 PRINT_NXS(11, spd->module_vdd,
1389 "module_vdd Module Nominal Voltage, VDD");
1390 PRINT_NXS(12, spd->organization,
1391 "organization Module Organization");
1392 PRINT_NXS(13, spd->bus_width,
1393 "bus_width Module Memory Bus Width");
1394 PRINT_NXS(14, spd->therm_sensor,
1395 "therm_sensor Module Thermal Sensor");
1396 PRINT_NXS(15, spd->ext_type,
1397 "ext_type Extended module type");
1398 PRINT_NXS(16, spd->res_16,
1400 PRINT_NXS(17, spd->timebases,
1401 "timebases MTb and FTB");
1402 PRINT_NXS(18, spd->tck_min,
1403 "tck_min tCKAVGmin");
1404 PRINT_NXS(19, spd->tck_max,
1405 "tck_max TCKAVGmax");
1406 PRINT_NXS(20, spd->caslat_b1,
1407 "caslat_b1 CAS latencies, 1st byte");
1408 PRINT_NXS(21, spd->caslat_b2,
1409 "caslat_b2 CAS latencies, 2nd byte");
1410 PRINT_NXS(22, spd->caslat_b3,
1411 "caslat_b3 CAS latencies, 3rd byte ");
1412 PRINT_NXS(23, spd->caslat_b4,
1413 "caslat_b4 CAS latencies, 4th byte");
1414 PRINT_NXS(24, spd->taa_min,
1415 "taa_min Min CAS Latency Time");
1416 PRINT_NXS(25, spd->trcd_min,
1417 "trcd_min Min RAS# to CAS# Delay Time");
1418 PRINT_NXS(26, spd->trp_min,
1419 "trp_min Min Row Precharge Delay Time");
1420 PRINT_NXS(27, spd->tras_trc_ext,
1421 "tras_trc_ext Upper Nibbles for tRAS and tRC");
1422 PRINT_NXS(28, spd->tras_min_lsb,
1423 "tras_min_lsb tRASmin, lsb");
1424 PRINT_NXS(29, spd->trc_min_lsb,
1425 "trc_min_lsb tRCmin, lsb");
1426 PRINT_NXS(30, spd->trfc1_min_lsb,
1427 "trfc1_min_lsb Min Refresh Recovery Delay Time, LSB");
1428 PRINT_NXS(31, spd->trfc1_min_msb,
1429 "trfc1_min_msb Min Refresh Recovery Delay Time, MSB ");
1430 PRINT_NXS(32, spd->trfc2_min_lsb,
1431 "trfc2_min_lsb Min Refresh Recovery Delay Time, LSB");
1432 PRINT_NXS(33, spd->trfc2_min_msb,
1433 "trfc2_min_msb Min Refresh Recovery Delay Time, MSB");
1434 PRINT_NXS(34, spd->trfc4_min_lsb,
1435 "trfc4_min_lsb Min Refresh Recovery Delay Time, LSB");
1436 PRINT_NXS(35, spd->trfc4_min_msb,
1437 "trfc4_min_msb Min Refresh Recovery Delay Time, MSB");
1438 PRINT_NXS(36, spd->tfaw_msb,
1439 "tfaw_msb Upper Nibble for tFAW");
1440 PRINT_NXS(37, spd->tfaw_min,
1441 "tfaw_min tFAW, lsb");
1442 PRINT_NXS(38, spd->trrds_min,
1443 "trrds_min tRRD_Smin, MTB");
1444 PRINT_NXS(39, spd->trrdl_min,
1445 "trrdl_min tRRD_Lmin, MTB");
1446 PRINT_NXS(40, spd->tccdl_min,
1447 "tccdl_min tCCS_Lmin, MTB");
1449 printf("%-3d-%3d: ", 41, 59); /* Reserved, General Section */
1450 for (i = 41; i <= 59; i++)
1451 printf("%02x ", spd->res_41[i - 41]);
1454 printf("%-3d-%3d: ", 60, 77);
1455 for (i = 60; i <= 77; i++)
1456 printf("%02x ", spd->mapping[i - 60]);
1457 puts(" mapping[] Connector to SDRAM bit map\n");
1459 PRINT_NXS(117, spd->fine_tccdl_min,
1460 "fine_tccdl_min Fine offset for tCCD_Lmin");
1461 PRINT_NXS(118, spd->fine_trrdl_min,
1462 "fine_trrdl_min Fine offset for tRRD_Lmin");
1463 PRINT_NXS(119, spd->fine_trrds_min,
1464 "fine_trrds_min Fine offset for tRRD_Smin");
1465 PRINT_NXS(120, spd->fine_trc_min,
1466 "fine_trc_min Fine offset for tRCmin");
1467 PRINT_NXS(121, spd->fine_trp_min,
1468 "fine_trp_min Fine offset for tRPmin");
1469 PRINT_NXS(122, spd->fine_trcd_min,
1470 "fine_trcd_min Fine offset for tRCDmin");
1471 PRINT_NXS(123, spd->fine_taa_min,
1472 "fine_taa_min Fine offset for tAAmin");
1473 PRINT_NXS(124, spd->fine_tck_max,
1474 "fine_tck_max Fine offset for tCKAVGmax");
1475 PRINT_NXS(125, spd->fine_tck_min,
1476 "fine_tck_min Fine offset for tCKAVGmin");
1478 /* CRC: Bytes 126-127 */
1479 PRINT_NNXXS(126, 127, spd->crc[0], spd->crc[1], " SPD CRC");
1481 switch (spd->module_type) {
1482 case 0x02: /* UDIMM */
1483 case 0x03: /* SO-DIMM */
1484 PRINT_NXS(128, spd->mod_section.unbuffered.mod_height,
1485 "mod_height (Unbuffered) Module Nominal Height");
1486 PRINT_NXS(129, spd->mod_section.unbuffered.mod_thickness,
1487 "mod_thickness (Unbuffered) Module Maximum Thickness");
1488 PRINT_NXS(130, spd->mod_section.unbuffered.ref_raw_card,
1489 "ref_raw_card (Unbuffered) Reference Raw Card Used");
1490 PRINT_NXS(131, spd->mod_section.unbuffered.addr_mapping,
1491 "addr_mapping (Unbuffered) Address mapping from Edge Connector to DRAM");
1492 PRINT_NNXXS(254, 255, spd->mod_section.unbuffered.crc[0],
1493 spd->mod_section.unbuffered.crc[1], " Module CRC");
1495 case 0x01: /* RDIMM */
1496 PRINT_NXS(128, spd->mod_section.registered.mod_height,
1497 "mod_height (Registered) Module Nominal Height");
1498 PRINT_NXS(129, spd->mod_section.registered.mod_thickness,
1499 "mod_thickness (Registered) Module Maximum Thickness");
1500 PRINT_NXS(130, spd->mod_section.registered.ref_raw_card,
1501 "ref_raw_card (Registered) Reference Raw Card Used");
1502 PRINT_NXS(131, spd->mod_section.registered.modu_attr,
1503 "modu_attr (Registered) DIMM Module Attributes");
1504 PRINT_NXS(132, spd->mod_section.registered.thermal,
1505 "thermal (Registered) Thermal Heat Spreader Solution");
1506 PRINT_NXS(133, spd->mod_section.registered.reg_id_lo,
1507 "reg_id_lo (Registered) Register Manufacturer ID Code, LSB");
1508 PRINT_NXS(134, spd->mod_section.registered.reg_id_hi,
1509 "reg_id_hi (Registered) Register Manufacturer ID Code, MSB");
1510 PRINT_NXS(135, spd->mod_section.registered.reg_rev,
1511 "reg_rev (Registered) Register Revision Number");
1512 PRINT_NXS(136, spd->mod_section.registered.reg_map,
1513 "reg_map (Registered) Address mapping");
1514 PRINT_NNXXS(254, 255, spd->mod_section.registered.crc[0],
1515 spd->mod_section.registered.crc[1], " Module CRC");
1517 case 0x04: /* LRDIMM */
1518 PRINT_NXS(128, spd->mod_section.loadreduced.mod_height,
1519 "mod_height (Loadreduced) Module Nominal Height");
1520 PRINT_NXS(129, spd->mod_section.loadreduced.mod_thickness,
1521 "mod_thickness (Loadreduced) Module Maximum Thickness");
1522 PRINT_NXS(130, spd->mod_section.loadreduced.ref_raw_card,
1523 "ref_raw_card (Loadreduced) Reference Raw Card Used");
1524 PRINT_NXS(131, spd->mod_section.loadreduced.modu_attr,
1525 "modu_attr (Loadreduced) DIMM Module Attributes");
1526 PRINT_NXS(132, spd->mod_section.loadreduced.thermal,
1527 "thermal (Loadreduced) Thermal Heat Spreader Solution");
1528 PRINT_NXS(133, spd->mod_section.loadreduced.reg_id_lo,
1529 "reg_id_lo (Loadreduced) Register Manufacturer ID Code, LSB");
1530 PRINT_NXS(134, spd->mod_section.loadreduced.reg_id_hi,
1531 "reg_id_hi (Loadreduced) Register Manufacturer ID Code, MSB");
1532 PRINT_NXS(135, spd->mod_section.loadreduced.reg_rev,
1533 "reg_rev (Loadreduced) Register Revision Number");
1534 PRINT_NXS(136, spd->mod_section.loadreduced.reg_map,
1535 "reg_map (Loadreduced) Address mapping");
1536 PRINT_NXS(137, spd->mod_section.loadreduced.reg_drv,
1537 "reg_drv (Loadreduced) Reg output drive strength");
1538 PRINT_NXS(138, spd->mod_section.loadreduced.reg_drv_ck,
1539 "reg_drv_ck (Loadreduced) Reg output drive strength for CK");
1540 PRINT_NXS(139, spd->mod_section.loadreduced.data_buf_rev,
1541 "data_buf_rev (Loadreduced) Data Buffer Revision Numbe");
1542 PRINT_NXS(140, spd->mod_section.loadreduced.vrefqe_r0,
1543 "vrefqe_r0 (Loadreduced) DRAM VrefDQ for Package Rank 0");
1544 PRINT_NXS(141, spd->mod_section.loadreduced.vrefqe_r1,
1545 "vrefqe_r1 (Loadreduced) DRAM VrefDQ for Package Rank 1");
1546 PRINT_NXS(142, spd->mod_section.loadreduced.vrefqe_r2,
1547 "vrefqe_r2 (Loadreduced) DRAM VrefDQ for Package Rank 2");
1548 PRINT_NXS(143, spd->mod_section.loadreduced.vrefqe_r3,
1549 "vrefqe_r3 (Loadreduced) DRAM VrefDQ for Package Rank 3");
1550 PRINT_NXS(144, spd->mod_section.loadreduced.data_intf,
1551 "data_intf (Loadreduced) Data Buffer VrefDQ for DRAM Interface");
1552 PRINT_NXS(145, spd->mod_section.loadreduced.data_drv_1866,
1553 "data_drv_1866 (Loadreduced) Data Buffer MDQ Drive Strength and RTT");
1554 PRINT_NXS(146, spd->mod_section.loadreduced.data_drv_2400,
1555 "data_drv_2400 (Loadreduced) Data Buffer MDQ Drive Strength and RTT");
1556 PRINT_NXS(147, spd->mod_section.loadreduced.data_drv_3200,
1557 "data_drv_3200 (Loadreduced) Data Buffer MDQ Drive Strength and RTT");
1558 PRINT_NXS(148, spd->mod_section.loadreduced.dram_drv,
1559 "dram_drv (Loadreduced) DRAM Drive Strength");
1560 PRINT_NXS(149, spd->mod_section.loadreduced.dram_odt_1866,
1561 "dram_odt_1866 (Loadreduced) DRAM ODT (RTT_WR, RTT_NOM)");
1562 PRINT_NXS(150, spd->mod_section.loadreduced.dram_odt_2400,
1563 "dram_odt_2400 (Loadreduced) DRAM ODT (RTT_WR, RTT_NOM)");
1564 PRINT_NXS(151, spd->mod_section.loadreduced.dram_odt_3200,
1565 "dram_odt_3200 (Loadreduced) DRAM ODT (RTT_WR, RTT_NOM)");
1566 PRINT_NXS(152, spd->mod_section.loadreduced.dram_odt_park_1866,
1567 "dram_odt_park_1866 (Loadreduced) DRAM ODT (RTT_PARK)");
1568 PRINT_NXS(153, spd->mod_section.loadreduced.dram_odt_park_2400,
1569 "dram_odt_park_2400 (Loadreduced) DRAM ODT (RTT_PARK)");
1570 PRINT_NXS(154, spd->mod_section.loadreduced.dram_odt_park_3200,
1571 "dram_odt_park_3200 (Loadreduced) DRAM ODT (RTT_PARK)");
1572 PRINT_NNXXS(254, 255, spd->mod_section.loadreduced.crc[0],
1573 spd->mod_section.loadreduced.crc[1],
1577 /* Module-specific Section, Unsupported Module Type */
1578 printf("%-3d-%3d: ", 128, 255);
1580 for (i = 128; i <= 255; i++)
1581 printf("%02x", spd->mod_section.uc[i - 60]);
1586 /* Unique Module ID: Bytes 320-383 */
1587 PRINT_NXS(320, spd->mmid_lsb, "Module MfgID Code LSB - JEP-106");
1588 PRINT_NXS(321, spd->mmid_msb, "Module MfgID Code MSB - JEP-106");
1589 PRINT_NXS(322, spd->mloc, "Mfg Location");
1590 PRINT_NNXXS(323, 324, spd->mdate[0], spd->mdate[1], "Mfg Date");
1592 printf("%-3d-%3d: ", 325, 328);
1594 for (i = 325; i <= 328; i++)
1595 printf("%02x ", spd->sernum[i - 325]);
1596 printf(" Module Serial Number\n");
1598 printf("%-3d-%3d: ", 329, 348);
1599 for (i = 329; i <= 348; i++)
1600 printf("%02x ", spd->mpart[i - 329]);
1601 printf(" Mfg's Module Part Number\n");
1603 PRINT_NXS(349, spd->mrev, "Module Revision code");
1604 PRINT_NXS(350, spd->dmid_lsb, "DRAM MfgID Code LSB - JEP-106");
1605 PRINT_NXS(351, spd->dmid_msb, "DRAM MfgID Code MSB - JEP-106");
1606 PRINT_NXS(352, spd->stepping, "DRAM stepping");
1608 printf("%-3d-%3d: ", 353, 381);
1609 for (i = 353; i <= 381; i++)
1610 printf("%02x ", spd->msd[i - 353]);
1611 printf(" Mfg's Specific Data\n");
1615 static inline void generic_spd_dump(const generic_spd_eeprom_t *spd)
1617 #if defined(CONFIG_SYS_FSL_DDR1)
1619 #elif defined(CONFIG_SYS_FSL_DDR2)
1621 #elif defined(CONFIG_SYS_FSL_DDR3)
1623 #elif defined(CONFIG_SYS_FSL_DDR4)
1628 static void fsl_ddr_printinfo(const fsl_ddr_info_t *pinfo,
1629 unsigned int ctrl_mask,
1630 unsigned int dimm_mask,
1631 unsigned int do_mask)
1633 unsigned int i, j, retval;
1635 /* STEP 1: DIMM SPD data */
1636 if (do_mask & STEP_GET_SPD) {
1637 for (i = 0; i < CONFIG_NUM_DDR_CONTROLLERS; i++) {
1638 if (!(ctrl_mask & (1 << i)))
1641 for (j = 0; j < CONFIG_DIMM_SLOTS_PER_CTLR; j++) {
1642 if (!(dimm_mask & (1 << j)))
1645 printf("SPD info: Controller=%u "
1648 &(pinfo->spd_installed_dimms[i][j]));
1656 /* STEP 2: DIMM Parameters */
1657 if (do_mask & STEP_COMPUTE_DIMM_PARMS) {
1658 for (i = 0; i < CONFIG_NUM_DDR_CONTROLLERS; i++) {
1659 if (!(ctrl_mask & (1 << i)))
1661 for (j = 0; j < CONFIG_DIMM_SLOTS_PER_CTLR; j++) {
1662 if (!(dimm_mask & (1 << j)))
1664 printf("DIMM parameters: Controller=%u "
1666 print_dimm_parameters(
1667 &(pinfo->dimm_params[i][j]));
1675 /* STEP 3: Common Parameters */
1676 if (do_mask & STEP_COMPUTE_COMMON_PARMS) {
1677 for (i = 0; i < CONFIG_NUM_DDR_CONTROLLERS; i++) {
1678 if (!(ctrl_mask & (1 << i)))
1680 printf("\"lowest common\" DIMM parameters: "
1681 "Controller=%u\n", i);
1682 print_lowest_common_dimm_parameters(
1683 &pinfo->common_timing_params[i]);
1689 /* STEP 4: User Configuration Options */
1690 if (do_mask & STEP_GATHER_OPTS) {
1691 for (i = 0; i < CONFIG_NUM_DDR_CONTROLLERS; i++) {
1692 if (!(ctrl_mask & (1 << i)))
1694 printf("User Config Options: Controller=%u\n", i);
1695 print_memctl_options(&pinfo->memctl_opts[i]);
1701 /* STEP 5: Address assignment */
1702 if (do_mask & STEP_ASSIGN_ADDRESSES) {
1703 for (i = 0; i < CONFIG_NUM_DDR_CONTROLLERS; i++) {
1704 if (!(ctrl_mask & (1 << i)))
1706 for (j = 0; j < CONFIG_DIMM_SLOTS_PER_CTLR; j++) {
1707 printf("Address Assignment: Controller=%u "
1709 printf("Don't have this functionality yet\n");
1716 /* STEP 6: computed controller register values */
1717 if (do_mask & STEP_COMPUTE_REGS) {
1718 for (i = 0; i < CONFIG_NUM_DDR_CONTROLLERS; i++) {
1719 if (!(ctrl_mask & (1 << i)))
1721 printf("Computed Register Values: Controller=%u\n", i);
1722 print_fsl_memctl_config_regs(
1723 &pinfo->fsl_ddr_config_reg[i]);
1724 retval = check_fsl_memctl_config_regs(
1725 &pinfo->fsl_ddr_config_reg[i]);
1727 printf("check_fsl_memctl_config_regs "
1728 "result = %u\n", retval);
1736 struct data_strings {
1737 const char *data_name;
1738 unsigned int step_mask;
1739 unsigned int dimm_number_required;
1742 #define DATA_OPTIONS(name, step, dimm) {#name, step, dimm}
1744 static unsigned int fsl_ddr_parse_interactive_cmd(
1747 unsigned int *pstep_mask,
1748 unsigned int *pctlr_mask,
1749 unsigned int *pdimm_mask,
1750 unsigned int *pdimm_number_required
1753 static const struct data_strings options[] = {
1754 DATA_OPTIONS(spd, STEP_GET_SPD, 1),
1755 DATA_OPTIONS(dimmparms, STEP_COMPUTE_DIMM_PARMS, 1),
1756 DATA_OPTIONS(commonparms, STEP_COMPUTE_COMMON_PARMS, 0),
1757 DATA_OPTIONS(opts, STEP_GATHER_OPTS, 0),
1758 DATA_OPTIONS(addresses, STEP_ASSIGN_ADDRESSES, 0),
1759 DATA_OPTIONS(regs, STEP_COMPUTE_REGS, 0),
1761 static const unsigned int n_opts = ARRAY_SIZE(options);
1764 unsigned int error = 0;
1766 for (i = 1; i < argc; i++) {
1767 unsigned int matched = 0;
1769 for (j = 0; j < n_opts; j++) {
1770 if (strcmp(options[j].data_name, argv[i]) != 0)
1772 *pstep_mask |= options[j].step_mask;
1773 *pdimm_number_required =
1774 options[j].dimm_number_required;
1782 if (argv[i][0] == 'c') {
1783 char c = argv[i][1];
1785 *pctlr_mask |= 1 << (c - '0');
1789 if (argv[i][0] == 'd') {
1790 char c = argv[i][1];
1792 *pdimm_mask |= 1 << (c - '0');
1796 printf("unknown arg %s\n", argv[i]);
1805 int fsl_ddr_interactive_env_var_exists(void)
1807 char buffer[CONFIG_SYS_CBSIZE];
1809 if (getenv_f("ddr_interactive", buffer, CONFIG_SYS_CBSIZE) >= 0)
1815 unsigned long long fsl_ddr_interactive(fsl_ddr_info_t *pinfo, int var_is_set)
1817 unsigned long long ddrsize;
1818 const char *prompt = "FSL DDR>";
1819 char buffer[CONFIG_SYS_CBSIZE];
1820 char buffer2[CONFIG_SYS_CBSIZE];
1822 char *argv[CONFIG_SYS_MAXARGS + 1]; /* NULL terminated */
1824 unsigned int next_step = STEP_GET_SPD;
1825 const char *usage = {
1827 "print print SPD and intermediate computed data\n"
1828 "reset reboot machine\n"
1829 "recompute reload SPD and options to default and recompute regs\n"
1830 "edit modify spd, parameter, or option\n"
1831 "compute recompute registers from current next_step to end\n"
1832 "copy copy parameters\n"
1833 "next_step shows current next_step\n"
1834 "help this message\n"
1835 "go program the memory controller and continue with u-boot\n"
1839 if (getenv_f("ddr_interactive", buffer2, CONFIG_SYS_CBSIZE) > 0) {
1847 * The strategy for next_step is that it points to the next
1848 * step in the computation process that needs to be done.
1852 char *pend = strchr(p, ';');
1854 /* found command separator, copy sub-command */
1859 /* separator not found, copy whole string */
1866 * No need to worry for buffer overflow here in
1867 * this function; readline() maxes out at CFG_CBSIZE
1869 readline_into_buffer(prompt, buffer, 0);
1871 argc = parse_line(buffer, argv);
1876 if (strcmp(argv[0], "help") == 0) {
1881 if (strcmp(argv[0], "next_step") == 0) {
1882 printf("next_step = 0x%02X (%s)\n",
1884 step_to_string(next_step));
1888 if (strcmp(argv[0], "copy") == 0) {
1889 unsigned int error = 0;
1890 unsigned int step_mask = 0;
1891 unsigned int src_ctlr_mask = 0;
1892 unsigned int src_dimm_mask = 0;
1893 unsigned int dimm_number_required = 0;
1894 unsigned int src_ctlr_num = 0;
1895 unsigned int src_dimm_num = 0;
1896 unsigned int dst_ctlr_num = -1;
1897 unsigned int dst_dimm_num = -1;
1898 unsigned int i, num_dest_parms;
1901 printf("copy <src c#> <src d#> <spd|dimmparms|commonparms|opts|addresses|regs> <dst c#> <dst d#>\n");
1905 error = fsl_ddr_parse_interactive_cmd(
1910 &dimm_number_required
1913 /* XXX: only dimm_number_required and step_mask will
1914 be used by this function. Parse the controller and
1915 DIMM number separately because it is easier. */
1920 /* parse source destination controller / DIMM */
1922 num_dest_parms = dimm_number_required ? 2 : 1;
1924 for (i = 0; i < argc; i++) {
1925 if (argv[i][0] == 'c') {
1926 char c = argv[i][1];
1928 src_ctlr_num = (c - '0');
1934 for (i = 0; i < argc; i++) {
1935 if (argv[i][0] == 'd') {
1936 char c = argv[i][1];
1938 src_dimm_num = (c - '0');
1944 /* parse destination controller / DIMM */
1946 for (i = argc - 1; i >= argc - num_dest_parms; i--) {
1947 if (argv[i][0] == 'c') {
1948 char c = argv[i][1];
1950 dst_ctlr_num = (c - '0');
1956 for (i = argc - 1; i >= argc - num_dest_parms; i--) {
1957 if (argv[i][0] == 'd') {
1958 char c = argv[i][1];
1960 dst_dimm_num = (c - '0');
1966 /* TODO: validate inputs */
1968 debug("src_ctlr_num = %u, src_dimm_num = %u, dst_ctlr_num = %u, dst_dimm_num = %u, step_mask = %x\n",
1969 src_ctlr_num, src_dimm_num, dst_ctlr_num, dst_dimm_num, step_mask);
1972 switch (step_mask) {
1975 memcpy(&(pinfo->spd_installed_dimms[dst_ctlr_num][dst_dimm_num]),
1976 &(pinfo->spd_installed_dimms[src_ctlr_num][src_dimm_num]),
1977 sizeof(pinfo->spd_installed_dimms[0][0]));
1980 case STEP_COMPUTE_DIMM_PARMS:
1981 memcpy(&(pinfo->dimm_params[dst_ctlr_num][dst_dimm_num]),
1982 &(pinfo->dimm_params[src_ctlr_num][src_dimm_num]),
1983 sizeof(pinfo->dimm_params[0][0]));
1986 case STEP_COMPUTE_COMMON_PARMS:
1987 memcpy(&(pinfo->common_timing_params[dst_ctlr_num]),
1988 &(pinfo->common_timing_params[src_ctlr_num]),
1989 sizeof(pinfo->common_timing_params[0]));
1992 case STEP_GATHER_OPTS:
1993 memcpy(&(pinfo->memctl_opts[dst_ctlr_num]),
1994 &(pinfo->memctl_opts[src_ctlr_num]),
1995 sizeof(pinfo->memctl_opts[0]));
1998 /* someday be able to have addresses to copy addresses... */
2000 case STEP_COMPUTE_REGS:
2001 memcpy(&(pinfo->fsl_ddr_config_reg[dst_ctlr_num]),
2002 &(pinfo->fsl_ddr_config_reg[src_ctlr_num]),
2003 sizeof(pinfo->memctl_opts[0]));
2007 printf("unexpected step_mask value\n");
2014 if (strcmp(argv[0], "edit") == 0) {
2015 unsigned int error = 0;
2016 unsigned int step_mask = 0;
2017 unsigned int ctlr_mask = 0;
2018 unsigned int dimm_mask = 0;
2019 char *p_element = NULL;
2020 char *p_value = NULL;
2021 unsigned int dimm_number_required = 0;
2022 unsigned int ctrl_num;
2023 unsigned int dimm_num;
2026 /* Only the element and value must be last */
2027 printf("edit <c#> <d#> "
2028 "<spd|dimmparms|commonparms|opts|"
2029 "addresses|regs> <element> <value>\n");
2030 printf("for spd, specify byte number for "
2035 error = fsl_ddr_parse_interactive_cmd(
2040 &dimm_number_required
2047 /* Check arguments */
2049 /* ERROR: If no steps were found */
2050 if (step_mask == 0) {
2051 printf("Error: No valid steps were specified "
2056 /* ERROR: If multiple steps were found */
2057 if (step_mask & (step_mask - 1)) {
2058 printf("Error: Multiple steps specified in "
2063 /* ERROR: Controller not specified */
2064 if (ctlr_mask == 0) {
2065 printf("Error: controller number not "
2066 "specified or no element and "
2067 "value specified\n");
2071 if (ctlr_mask & (ctlr_mask - 1)) {
2072 printf("Error: multiple controllers "
2073 "specified, %X\n", ctlr_mask);
2077 /* ERROR: DIMM number not specified */
2078 if (dimm_number_required && dimm_mask == 0) {
2079 printf("Error: DIMM number number not "
2080 "specified or no element and "
2081 "value specified\n");
2085 if (dimm_mask & (dimm_mask - 1)) {
2086 printf("Error: multipled DIMMs specified\n");
2090 p_element = argv[argc - 2];
2091 p_value = argv[argc - 1];
2093 ctrl_num = __ilog2(ctlr_mask);
2094 dimm_num = __ilog2(dimm_mask);
2096 switch (step_mask) {
2099 unsigned int element_num;
2102 element_num = simple_strtoul(p_element,
2104 value = simple_strtoul(p_value,
2106 fsl_ddr_spd_edit(pinfo,
2111 next_step = STEP_COMPUTE_DIMM_PARMS;
2115 case STEP_COMPUTE_DIMM_PARMS:
2116 fsl_ddr_dimm_parameters_edit(
2117 pinfo, ctrl_num, dimm_num,
2118 p_element, p_value);
2119 next_step = STEP_COMPUTE_COMMON_PARMS;
2122 case STEP_COMPUTE_COMMON_PARMS:
2123 lowest_common_dimm_parameters_edit(pinfo,
2124 ctrl_num, p_element, p_value);
2125 next_step = STEP_GATHER_OPTS;
2128 case STEP_GATHER_OPTS:
2129 fsl_ddr_options_edit(pinfo, ctrl_num,
2130 p_element, p_value);
2131 next_step = STEP_ASSIGN_ADDRESSES;
2134 case STEP_ASSIGN_ADDRESSES:
2135 printf("editing of address assignment "
2136 "not yet implemented\n");
2139 case STEP_COMPUTE_REGS:
2141 fsl_ddr_regs_edit(pinfo,
2145 next_step = STEP_PROGRAM_REGS;
2150 printf("programming error\n");
2158 if (strcmp(argv[0], "reset") == 0) {
2161 * Args don't seem to matter because this
2164 do_reset(NULL, 0, 0, NULL);
2165 printf("Reset didn't work\n");
2168 if (strcmp(argv[0], "recompute") == 0) {
2170 * Recalculate everything, starting with
2171 * loading SPD EEPROM from DIMMs
2173 next_step = STEP_GET_SPD;
2174 ddrsize = fsl_ddr_compute(pinfo, next_step, 0);
2178 if (strcmp(argv[0], "compute") == 0) {
2180 * Compute rest of steps starting at
2181 * the current next_step/
2183 ddrsize = fsl_ddr_compute(pinfo, next_step, 0);
2187 if (strcmp(argv[0], "print") == 0) {
2188 unsigned int error = 0;
2189 unsigned int step_mask = 0;
2190 unsigned int ctlr_mask = 0;
2191 unsigned int dimm_mask = 0;
2192 unsigned int dimm_number_required = 0;
2195 printf("print [c<n>] [d<n>] [spd] [dimmparms] "
2196 "[commonparms] [opts] [addresses] [regs]\n");
2200 error = fsl_ddr_parse_interactive_cmd(
2205 &dimm_number_required
2211 /* If no particular controller was found, print all */
2215 /* If no particular dimm was found, print all dimms. */
2219 /* If no steps were found, print all steps. */
2221 step_mask = STEP_ALL;
2223 fsl_ddr_printinfo(pinfo, ctlr_mask,
2224 dimm_mask, step_mask);
2228 if (strcmp(argv[0], "go") == 0) {
2230 ddrsize = fsl_ddr_compute(pinfo, next_step, 0);
2234 printf("unknown command %s\n", argv[0]);
2237 debug("end of memory = %llu\n", (u64)ddrsize);