blob: ea8bcbeb5162fe2ae150f863dd218c455c8b0d97 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
York Sunbd495cf2011-09-16 13:21:35 -07002/*
York Sun6db4fdd2018-01-29 09:44:35 -08003 * Copyright 2010-2016 Freescale Semiconductor, Inc.
4 * Copyright 2017-2018 NXP Semiconductor
York Sunbd495cf2011-09-16 13:21:35 -07005 */
6
7/*
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]
12 */
13
14#include <common.h>
Simon Glassdec3c012014-04-10 20:01:25 -060015#include <cli.h>
Simon Glassed38aef2020-05-10 11:40:03 -060016#include <command.h>
Simon Glassdb229612019-08-01 09:46:42 -060017#include <env.h>
Simon Glass0f2af882020-05-10 11:40:05 -060018#include <log.h>
York Sunbd495cf2011-09-16 13:21:35 -070019#include <linux/ctype.h>
20#include <asm/types.h>
York Sunf0626592013-09-30 09:22:09 -070021#include <asm/io.h>
York Sunbd495cf2011-09-16 13:21:35 -070022
York Sunf0626592013-09-30 09:22:09 -070023#include <fsl_ddr_sdram.h>
24#include <fsl_ddr.h>
York Sunbd495cf2011-09-16 13:21:35 -070025
26/* Option parameter Structures */
27struct options_string {
28 const char *option_name;
29 size_t offset;
30 unsigned int size;
31 const char printhex;
32};
33
34static unsigned int picos_to_mhz(unsigned int picos)
35{
36 return 1000000 / picos;
37}
38
39static void print_option_table(const struct options_string *table,
40 int table_size,
41 const void *base)
42{
43 unsigned int i;
44 unsigned int *ptr;
45 unsigned long long *ptr_l;
46
47 for (i = 0; i < table_size; i++) {
48 switch (table[i].size) {
49 case 4:
50 ptr = (unsigned int *) (base + table[i].offset);
51 if (table[i].printhex) {
52 printf("%s = 0x%08X\n",
53 table[i].option_name, *ptr);
54 } else {
55 printf("%s = %u\n",
56 table[i].option_name, *ptr);
57 }
58 break;
59 case 8:
60 ptr_l = (unsigned long long *) (base + table[i].offset);
61 printf("%s = %llu\n",
62 table[i].option_name, *ptr_l);
63 break;
64 default:
65 printf("Unrecognized size!\n");
66 break;
67 }
68 }
69}
70
71static int handle_option_table(const struct options_string *table,
72 int table_size,
73 void *base,
74 const char *opt,
75 const char *val)
76{
77 unsigned int i;
78 unsigned int value, *ptr;
79 unsigned long long value_l, *ptr_l;
80
81 for (i = 0; i < table_size; i++) {
82 if (strcmp(table[i].option_name, opt) != 0)
83 continue;
84 switch (table[i].size) {
85 case 4:
86 value = simple_strtoul(val, NULL, 0);
87 ptr = base + table[i].offset;
88 *ptr = value;
89 break;
90 case 8:
91 value_l = simple_strtoull(val, NULL, 0);
92 ptr_l = base + table[i].offset;
93 *ptr_l = value_l;
94 break;
95 default:
96 printf("Unrecognized size!\n");
97 break;
98 }
99 return 1;
100 }
101
102 return 0;
103}
104
105static void fsl_ddr_generic_edit(void *pdata,
106 void *pend,
107 unsigned int element_size,
108 unsigned int element_num,
109 unsigned int value)
110{
111 char *pcdata = (char *)pdata; /* BIG ENDIAN ONLY */
112
113 pcdata += element_num * element_size;
114 if ((pcdata + element_size) > (char *) pend) {
115 printf("trying to write past end of data\n");
116 return;
117 }
118
119 switch (element_size) {
120 case 1:
121 __raw_writeb(value, pcdata);
122 break;
123 case 2:
124 __raw_writew(value, pcdata);
125 break;
126 case 4:
127 __raw_writel(value, pcdata);
128 break;
129 default:
130 printf("unexpected element size %u\n", element_size);
131 break;
132 }
133}
134
135static void fsl_ddr_spd_edit(fsl_ddr_info_t *pinfo,
136 unsigned int ctrl_num,
137 unsigned int dimm_num,
138 unsigned int element_num,
139 unsigned int value)
140{
141 generic_spd_eeprom_t *pspd;
142
143 pspd = &(pinfo->spd_installed_dimms[ctrl_num][dimm_num]);
144 fsl_ddr_generic_edit(pspd, pspd + 1, 1, element_num, value);
145}
146
147#define COMMON_TIMING(x) {#x, offsetof(common_timing_params_t, x), \
148 sizeof((common_timing_params_t *)0)->x, 0}
149
150static void lowest_common_dimm_parameters_edit(fsl_ddr_info_t *pinfo,
151 unsigned int ctrl_num,
152 const char *optname_str,
153 const char *value_str)
154{
155 common_timing_params_t *p = &pinfo->common_timing_params[ctrl_num];
156
157 static const struct options_string options[] = {
Priyanka Jain4a717412013-09-25 10:41:19 +0530158 COMMON_TIMING(tckmin_x_ps),
159 COMMON_TIMING(tckmax_ps),
York Sunf43278e2017-05-25 17:03:23 -0700160#if defined(CONFIG_SYS_FSL_DDR3) || defined(CONFIG_SYS_FSL_DDR4)
York Sun2896cb72014-03-27 17:54:47 -0700161 COMMON_TIMING(taamin_ps),
York Sunf43278e2017-05-25 17:03:23 -0700162#endif
Priyanka Jain4a717412013-09-25 10:41:19 +0530163 COMMON_TIMING(trcd_ps),
164 COMMON_TIMING(trp_ps),
165 COMMON_TIMING(tras_ps),
York Sun2896cb72014-03-27 17:54:47 -0700166
167#ifdef CONFIG_SYS_FSL_DDR4
168 COMMON_TIMING(trfc1_ps),
169 COMMON_TIMING(trfc2_ps),
170 COMMON_TIMING(trfc4_ps),
171 COMMON_TIMING(trrds_ps),
172 COMMON_TIMING(trrdl_ps),
173 COMMON_TIMING(tccdl_ps),
York Sun6db4fdd2018-01-29 09:44:35 -0800174 COMMON_TIMING(trfc_slr_ps),
York Sun2896cb72014-03-27 17:54:47 -0700175#else
Priyanka Jain4a717412013-09-25 10:41:19 +0530176 COMMON_TIMING(twtr_ps),
177 COMMON_TIMING(trfc_ps),
178 COMMON_TIMING(trrd_ps),
York Sun2896cb72014-03-27 17:54:47 -0700179 COMMON_TIMING(trtp_ps),
180#endif
181 COMMON_TIMING(twr_ps),
Priyanka Jain4a717412013-09-25 10:41:19 +0530182 COMMON_TIMING(trc_ps),
York Sunbd495cf2011-09-16 13:21:35 -0700183 COMMON_TIMING(refresh_rate_ps),
York Sun2896cb72014-03-27 17:54:47 -0700184 COMMON_TIMING(extended_op_srt),
185#if defined(CONFIG_SYS_FSL_DDR1) || defined(CONFIG_SYS_FSL_DDR2)
Priyanka Jain4a717412013-09-25 10:41:19 +0530186 COMMON_TIMING(tis_ps),
187 COMMON_TIMING(tih_ps),
188 COMMON_TIMING(tds_ps),
189 COMMON_TIMING(tdh_ps),
Priyanka Jain4a717412013-09-25 10:41:19 +0530190 COMMON_TIMING(tdqsq_max_ps),
191 COMMON_TIMING(tqhs_ps),
York Sun2896cb72014-03-27 17:54:47 -0700192#endif
York Sunbd495cf2011-09-16 13:21:35 -0700193 COMMON_TIMING(ndimms_present),
York Sun2896cb72014-03-27 17:54:47 -0700194 COMMON_TIMING(lowest_common_spd_caslat),
York Sunbd495cf2011-09-16 13:21:35 -0700195 COMMON_TIMING(highest_common_derated_caslat),
196 COMMON_TIMING(additive_latency),
Priyanka Jain4a717412013-09-25 10:41:19 +0530197 COMMON_TIMING(all_dimms_burst_lengths_bitmask),
198 COMMON_TIMING(all_dimms_registered),
199 COMMON_TIMING(all_dimms_unbuffered),
200 COMMON_TIMING(all_dimms_ecc_capable),
York Sunbd495cf2011-09-16 13:21:35 -0700201 COMMON_TIMING(total_mem),
202 COMMON_TIMING(base_address),
203 };
204 static const unsigned int n_opts = ARRAY_SIZE(options);
205
206 if (handle_option_table(options, n_opts, p, optname_str, value_str))
207 return;
208
209 printf("Error: couldn't find option string %s\n", optname_str);
210}
211
212#define DIMM_PARM(x) {#x, offsetof(dimm_params_t, x), \
213 sizeof((dimm_params_t *)0)->x, 0}
York Sun55eb5fa2015-03-19 09:30:26 -0700214#define DIMM_PARM_HEX(x) {#x, offsetof(dimm_params_t, x), \
215 sizeof((dimm_params_t *)0)->x, 1}
York Sunbd495cf2011-09-16 13:21:35 -0700216
217static void fsl_ddr_dimm_parameters_edit(fsl_ddr_info_t *pinfo,
218 unsigned int ctrl_num,
219 unsigned int dimm_num,
220 const char *optname_str,
221 const char *value_str)
222{
223 dimm_params_t *p = &(pinfo->dimm_params[ctrl_num][dimm_num]);
224
225 static const struct options_string options[] = {
226 DIMM_PARM(n_ranks),
227 DIMM_PARM(data_width),
228 DIMM_PARM(primary_sdram_width),
229 DIMM_PARM(ec_sdram_width),
York Sun6db4fdd2018-01-29 09:44:35 -0800230 DIMM_PARM(package_3ds),
York Sunbd495cf2011-09-16 13:21:35 -0700231 DIMM_PARM(registered_dimm),
York Sun55eb5fa2015-03-19 09:30:26 -0700232 DIMM_PARM(mirrored_dimm),
York Sun4889c982013-06-25 11:37:47 -0700233 DIMM_PARM(device_width),
York Sunbd495cf2011-09-16 13:21:35 -0700234
235 DIMM_PARM(n_row_addr),
236 DIMM_PARM(n_col_addr),
237 DIMM_PARM(edc_config),
York Sun2896cb72014-03-27 17:54:47 -0700238#ifdef CONFIG_SYS_FSL_DDR4
239 DIMM_PARM(bank_addr_bits),
240 DIMM_PARM(bank_group_bits),
York Sun6db4fdd2018-01-29 09:44:35 -0800241 DIMM_PARM_HEX(die_density),
York Sun2896cb72014-03-27 17:54:47 -0700242#else
York Sunbd495cf2011-09-16 13:21:35 -0700243 DIMM_PARM(n_banks_per_sdram_device),
York Sun2896cb72014-03-27 17:54:47 -0700244#endif
York Sunbd495cf2011-09-16 13:21:35 -0700245 DIMM_PARM(burst_lengths_bitmask),
York Sunbd495cf2011-09-16 13:21:35 -0700246
Priyanka Jain4a717412013-09-25 10:41:19 +0530247 DIMM_PARM(tckmin_x_ps),
248 DIMM_PARM(tckmin_x_minus_1_ps),
249 DIMM_PARM(tckmin_x_minus_2_ps),
250 DIMM_PARM(tckmax_ps),
York Sunbd495cf2011-09-16 13:21:35 -0700251
Priyanka Jain4a717412013-09-25 10:41:19 +0530252 DIMM_PARM(caslat_x),
253 DIMM_PARM(caslat_x_minus_1),
254 DIMM_PARM(caslat_x_minus_2),
York Sunbd495cf2011-09-16 13:21:35 -0700255
256 DIMM_PARM(caslat_lowest_derated),
257
Priyanka Jain4a717412013-09-25 10:41:19 +0530258 DIMM_PARM(trcd_ps),
259 DIMM_PARM(trp_ps),
260 DIMM_PARM(tras_ps),
York Sun2896cb72014-03-27 17:54:47 -0700261#ifdef CONFIG_SYS_FSL_DDR4
262 DIMM_PARM(trfc1_ps),
263 DIMM_PARM(trfc2_ps),
264 DIMM_PARM(trfc4_ps),
265 DIMM_PARM(trrds_ps),
266 DIMM_PARM(trrdl_ps),
267 DIMM_PARM(tccdl_ps),
York Sun6db4fdd2018-01-29 09:44:35 -0800268 DIMM_PARM(trfc_slr_ps),
York Sun2896cb72014-03-27 17:54:47 -0700269#else
Priyanka Jain4a717412013-09-25 10:41:19 +0530270 DIMM_PARM(twr_ps),
271 DIMM_PARM(twtr_ps),
272 DIMM_PARM(trfc_ps),
273 DIMM_PARM(trrd_ps),
York Sun2896cb72014-03-27 17:54:47 -0700274 DIMM_PARM(trtp_ps),
275#endif
Priyanka Jain4a717412013-09-25 10:41:19 +0530276 DIMM_PARM(trc_ps),
York Sunbd495cf2011-09-16 13:21:35 -0700277 DIMM_PARM(refresh_rate_ps),
York Sun2896cb72014-03-27 17:54:47 -0700278 DIMM_PARM(extended_op_srt),
York Sunbd495cf2011-09-16 13:21:35 -0700279
York Sun2896cb72014-03-27 17:54:47 -0700280#if defined(CONFIG_SYS_FSL_DDR1) || defined(CONFIG_SYS_FSL_DDR2)
Priyanka Jain4a717412013-09-25 10:41:19 +0530281 DIMM_PARM(tis_ps),
282 DIMM_PARM(tih_ps),
283 DIMM_PARM(tds_ps),
284 DIMM_PARM(tdh_ps),
Priyanka Jain4a717412013-09-25 10:41:19 +0530285 DIMM_PARM(tdqsq_max_ps),
286 DIMM_PARM(tqhs_ps),
York Sun2896cb72014-03-27 17:54:47 -0700287#endif
York Sun55eb5fa2015-03-19 09:30:26 -0700288#ifdef CONFIG_SYS_FSL_DDR4
289 DIMM_PARM_HEX(dq_mapping[0]),
290 DIMM_PARM_HEX(dq_mapping[1]),
291 DIMM_PARM_HEX(dq_mapping[2]),
292 DIMM_PARM_HEX(dq_mapping[3]),
293 DIMM_PARM_HEX(dq_mapping[4]),
294 DIMM_PARM_HEX(dq_mapping[5]),
295 DIMM_PARM_HEX(dq_mapping[6]),
296 DIMM_PARM_HEX(dq_mapping[7]),
297 DIMM_PARM_HEX(dq_mapping[8]),
298 DIMM_PARM_HEX(dq_mapping[9]),
299 DIMM_PARM_HEX(dq_mapping[10]),
300 DIMM_PARM_HEX(dq_mapping[11]),
301 DIMM_PARM_HEX(dq_mapping[12]),
302 DIMM_PARM_HEX(dq_mapping[13]),
303 DIMM_PARM_HEX(dq_mapping[14]),
304 DIMM_PARM_HEX(dq_mapping[15]),
305 DIMM_PARM_HEX(dq_mapping[16]),
306 DIMM_PARM_HEX(dq_mapping[17]),
307 DIMM_PARM(dq_mapping_ors),
308#endif
York Sunbd495cf2011-09-16 13:21:35 -0700309 DIMM_PARM(rank_density),
310 DIMM_PARM(capacity),
311 DIMM_PARM(base_address),
312 };
313
314 static const unsigned int n_opts = ARRAY_SIZE(options);
315
316 if (handle_option_table(options, n_opts, p, optname_str, value_str))
317 return;
318
319 printf("couldn't find option string %s\n", optname_str);
320}
321
322static void print_dimm_parameters(const dimm_params_t *pdimm)
323{
324 static const struct options_string options[] = {
325 DIMM_PARM(n_ranks),
326 DIMM_PARM(data_width),
327 DIMM_PARM(primary_sdram_width),
328 DIMM_PARM(ec_sdram_width),
York Sun6db4fdd2018-01-29 09:44:35 -0800329 DIMM_PARM(package_3ds),
York Sunbd495cf2011-09-16 13:21:35 -0700330 DIMM_PARM(registered_dimm),
York Sun55eb5fa2015-03-19 09:30:26 -0700331 DIMM_PARM(mirrored_dimm),
York Sun4889c982013-06-25 11:37:47 -0700332 DIMM_PARM(device_width),
York Sunbd495cf2011-09-16 13:21:35 -0700333
334 DIMM_PARM(n_row_addr),
335 DIMM_PARM(n_col_addr),
336 DIMM_PARM(edc_config),
York Sun2896cb72014-03-27 17:54:47 -0700337#ifdef CONFIG_SYS_FSL_DDR4
338 DIMM_PARM(bank_addr_bits),
339 DIMM_PARM(bank_group_bits),
York Sun6db4fdd2018-01-29 09:44:35 -0800340 DIMM_PARM_HEX(die_density),
York Sun2896cb72014-03-27 17:54:47 -0700341#else
York Sunbd495cf2011-09-16 13:21:35 -0700342 DIMM_PARM(n_banks_per_sdram_device),
York Sun2896cb72014-03-27 17:54:47 -0700343#endif
York Sunbd495cf2011-09-16 13:21:35 -0700344
Priyanka Jain4a717412013-09-25 10:41:19 +0530345 DIMM_PARM(tckmin_x_ps),
346 DIMM_PARM(tckmin_x_minus_1_ps),
347 DIMM_PARM(tckmin_x_minus_2_ps),
348 DIMM_PARM(tckmax_ps),
York Sunbd495cf2011-09-16 13:21:35 -0700349
Priyanka Jain4a717412013-09-25 10:41:19 +0530350 DIMM_PARM(caslat_x),
York Sun55eb5fa2015-03-19 09:30:26 -0700351 DIMM_PARM_HEX(caslat_x),
Priyanka Jain4a717412013-09-25 10:41:19 +0530352 DIMM_PARM(taa_ps),
353 DIMM_PARM(caslat_x_minus_1),
354 DIMM_PARM(caslat_x_minus_2),
York Sunbd495cf2011-09-16 13:21:35 -0700355 DIMM_PARM(caslat_lowest_derated),
356
Priyanka Jain4a717412013-09-25 10:41:19 +0530357 DIMM_PARM(trcd_ps),
358 DIMM_PARM(trp_ps),
359 DIMM_PARM(tras_ps),
York Sun55eb5fa2015-03-19 09:30:26 -0700360#if defined(CONFIG_SYS_FSL_DDR4) || defined(CONFIG_SYS_FSL_DDR3)
361 DIMM_PARM(tfaw_ps),
362#endif
York Sun2896cb72014-03-27 17:54:47 -0700363#ifdef CONFIG_SYS_FSL_DDR4
364 DIMM_PARM(trfc1_ps),
365 DIMM_PARM(trfc2_ps),
366 DIMM_PARM(trfc4_ps),
367 DIMM_PARM(trrds_ps),
368 DIMM_PARM(trrdl_ps),
369 DIMM_PARM(tccdl_ps),
York Sun6db4fdd2018-01-29 09:44:35 -0800370 DIMM_PARM(trfc_slr_ps),
York Sun2896cb72014-03-27 17:54:47 -0700371#else
Priyanka Jain4a717412013-09-25 10:41:19 +0530372 DIMM_PARM(twr_ps),
373 DIMM_PARM(twtr_ps),
374 DIMM_PARM(trfc_ps),
375 DIMM_PARM(trrd_ps),
York Sun2896cb72014-03-27 17:54:47 -0700376 DIMM_PARM(trtp_ps),
377#endif
Priyanka Jain4a717412013-09-25 10:41:19 +0530378 DIMM_PARM(trc_ps),
York Sunbd495cf2011-09-16 13:21:35 -0700379 DIMM_PARM(refresh_rate_ps),
380
York Sun2896cb72014-03-27 17:54:47 -0700381#if defined(CONFIG_SYS_FSL_DDR1) || defined(CONFIG_SYS_FSL_DDR2)
Priyanka Jain4a717412013-09-25 10:41:19 +0530382 DIMM_PARM(tis_ps),
383 DIMM_PARM(tih_ps),
384 DIMM_PARM(tds_ps),
385 DIMM_PARM(tdh_ps),
Priyanka Jain4a717412013-09-25 10:41:19 +0530386 DIMM_PARM(tdqsq_max_ps),
387 DIMM_PARM(tqhs_ps),
York Sun2896cb72014-03-27 17:54:47 -0700388#endif
York Sun55eb5fa2015-03-19 09:30:26 -0700389#ifdef CONFIG_SYS_FSL_DDR4
390 DIMM_PARM_HEX(dq_mapping[0]),
391 DIMM_PARM_HEX(dq_mapping[1]),
392 DIMM_PARM_HEX(dq_mapping[2]),
393 DIMM_PARM_HEX(dq_mapping[3]),
394 DIMM_PARM_HEX(dq_mapping[4]),
395 DIMM_PARM_HEX(dq_mapping[5]),
396 DIMM_PARM_HEX(dq_mapping[6]),
397 DIMM_PARM_HEX(dq_mapping[7]),
398 DIMM_PARM_HEX(dq_mapping[8]),
399 DIMM_PARM_HEX(dq_mapping[9]),
400 DIMM_PARM_HEX(dq_mapping[10]),
401 DIMM_PARM_HEX(dq_mapping[11]),
402 DIMM_PARM_HEX(dq_mapping[12]),
403 DIMM_PARM_HEX(dq_mapping[13]),
404 DIMM_PARM_HEX(dq_mapping[14]),
405 DIMM_PARM_HEX(dq_mapping[15]),
406 DIMM_PARM_HEX(dq_mapping[16]),
407 DIMM_PARM_HEX(dq_mapping[17]),
408 DIMM_PARM(dq_mapping_ors),
409#endif
York Sunbd495cf2011-09-16 13:21:35 -0700410 };
411 static const unsigned int n_opts = ARRAY_SIZE(options);
412
413 if (pdimm->n_ranks == 0) {
414 printf("DIMM not present\n");
415 return;
416 }
417 printf("DIMM organization parameters:\n");
418 printf("module part name = %s\n", pdimm->mpart);
419 printf("rank_density = %llu bytes (%llu megabytes)\n",
420 pdimm->rank_density, pdimm->rank_density / 0x100000);
421 printf("capacity = %llu bytes (%llu megabytes)\n",
422 pdimm->capacity, pdimm->capacity / 0x100000);
423 printf("burst_lengths_bitmask = %02X\n",
424 pdimm->burst_lengths_bitmask);
425 printf("base_addresss = %llu (%08llX %08llX)\n",
426 pdimm->base_address,
427 (pdimm->base_address >> 32),
428 pdimm->base_address & 0xFFFFFFFF);
429 print_option_table(options, n_opts, pdimm);
430}
431
432static void print_lowest_common_dimm_parameters(
433 const common_timing_params_t *plcd_dimm_params)
434{
435 static const struct options_string options[] = {
York Sunf43278e2017-05-25 17:03:23 -0700436#if defined(CONFIG_SYS_FSL_DDR3) || defined(CONFIG_SYS_FSL_DDR4)
York Sun2896cb72014-03-27 17:54:47 -0700437 COMMON_TIMING(taamin_ps),
York Sunf43278e2017-05-25 17:03:23 -0700438#endif
Priyanka Jain4a717412013-09-25 10:41:19 +0530439 COMMON_TIMING(trcd_ps),
440 COMMON_TIMING(trp_ps),
441 COMMON_TIMING(tras_ps),
York Sun2896cb72014-03-27 17:54:47 -0700442#ifdef CONFIG_SYS_FSL_DDR4
443 COMMON_TIMING(trfc1_ps),
444 COMMON_TIMING(trfc2_ps),
445 COMMON_TIMING(trfc4_ps),
446 COMMON_TIMING(trrds_ps),
447 COMMON_TIMING(trrdl_ps),
448 COMMON_TIMING(tccdl_ps),
York Sun6db4fdd2018-01-29 09:44:35 -0800449 COMMON_TIMING(trfc_slr_ps),
York Sun2896cb72014-03-27 17:54:47 -0700450#else
Priyanka Jain4a717412013-09-25 10:41:19 +0530451 COMMON_TIMING(twtr_ps),
452 COMMON_TIMING(trfc_ps),
453 COMMON_TIMING(trrd_ps),
York Sun2896cb72014-03-27 17:54:47 -0700454 COMMON_TIMING(trtp_ps),
455#endif
456 COMMON_TIMING(twr_ps),
Priyanka Jain4a717412013-09-25 10:41:19 +0530457 COMMON_TIMING(trc_ps),
York Sunbd495cf2011-09-16 13:21:35 -0700458 COMMON_TIMING(refresh_rate_ps),
York Sun2896cb72014-03-27 17:54:47 -0700459 COMMON_TIMING(extended_op_srt),
460#if defined(CONFIG_SYS_FSL_DDR1) || defined(CONFIG_SYS_FSL_DDR2)
Priyanka Jain4a717412013-09-25 10:41:19 +0530461 COMMON_TIMING(tis_ps),
York Sun2896cb72014-03-27 17:54:47 -0700462 COMMON_TIMING(tih_ps),
Priyanka Jain4a717412013-09-25 10:41:19 +0530463 COMMON_TIMING(tds_ps),
464 COMMON_TIMING(tdh_ps),
Priyanka Jain4a717412013-09-25 10:41:19 +0530465 COMMON_TIMING(tdqsq_max_ps),
466 COMMON_TIMING(tqhs_ps),
York Sun2896cb72014-03-27 17:54:47 -0700467#endif
468 COMMON_TIMING(lowest_common_spd_caslat),
York Sunbd495cf2011-09-16 13:21:35 -0700469 COMMON_TIMING(highest_common_derated_caslat),
470 COMMON_TIMING(additive_latency),
471 COMMON_TIMING(ndimms_present),
Priyanka Jain4a717412013-09-25 10:41:19 +0530472 COMMON_TIMING(all_dimms_registered),
473 COMMON_TIMING(all_dimms_unbuffered),
474 COMMON_TIMING(all_dimms_ecc_capable),
York Sunbd495cf2011-09-16 13:21:35 -0700475 };
476 static const unsigned int n_opts = ARRAY_SIZE(options);
477
478 /* Clock frequencies */
Priyanka Jain4a717412013-09-25 10:41:19 +0530479 printf("tckmin_x_ps = %u (%u MHz)\n",
480 plcd_dimm_params->tckmin_x_ps,
481 picos_to_mhz(plcd_dimm_params->tckmin_x_ps));
482 printf("tckmax_ps = %u (%u MHz)\n",
483 plcd_dimm_params->tckmax_ps,
484 picos_to_mhz(plcd_dimm_params->tckmax_ps));
485 printf("all_dimms_burst_lengths_bitmask = %02X\n",
486 plcd_dimm_params->all_dimms_burst_lengths_bitmask);
York Sunbd495cf2011-09-16 13:21:35 -0700487
488 print_option_table(options, n_opts, plcd_dimm_params);
489
490 printf("total_mem = %llu (%llu megabytes)\n",
491 plcd_dimm_params->total_mem,
492 plcd_dimm_params->total_mem / 0x100000);
493 printf("base_address = %llu (%llu megabytes)\n",
494 plcd_dimm_params->base_address,
495 plcd_dimm_params->base_address / 0x100000);
496}
497
498#define CTRL_OPTIONS(x) {#x, offsetof(memctl_options_t, x), \
499 sizeof((memctl_options_t *)0)->x, 0}
500#define CTRL_OPTIONS_CS(x, y) {"cs" #x "_" #y, \
501 offsetof(memctl_options_t, cs_local_opts[x].y), \
502 sizeof((memctl_options_t *)0)->cs_local_opts[x].y, 0}
503
504static void fsl_ddr_options_edit(fsl_ddr_info_t *pinfo,
505 unsigned int ctl_num,
506 const char *optname_str,
507 const char *value_str)
508{
509 memctl_options_t *p = &(pinfo->memctl_opts[ctl_num]);
510 /*
511 * This array all on the stack and *computed* each time this
512 * function is rung.
513 */
514 static const struct options_string options[] = {
515 CTRL_OPTIONS_CS(0, odt_rd_cfg),
516 CTRL_OPTIONS_CS(0, odt_wr_cfg),
517#if (CONFIG_CHIP_SELECTS_PER_CTRL > 1)
518 CTRL_OPTIONS_CS(1, odt_rd_cfg),
519 CTRL_OPTIONS_CS(1, odt_wr_cfg),
520#endif
521#if (CONFIG_CHIP_SELECTS_PER_CTRL > 2)
522 CTRL_OPTIONS_CS(2, odt_rd_cfg),
523 CTRL_OPTIONS_CS(2, odt_wr_cfg),
524#endif
525#if (CONFIG_CHIP_SELECTS_PER_CTRL > 2)
526 CTRL_OPTIONS_CS(3, odt_rd_cfg),
527 CTRL_OPTIONS_CS(3, odt_wr_cfg),
528#endif
York Sunfc63b282015-03-19 09:30:27 -0700529#if defined(CONFIG_SYS_FSL_DDR3) || defined(CONFIG_SYS_FSL_DDR4)
York Sunbd495cf2011-09-16 13:21:35 -0700530 CTRL_OPTIONS_CS(0, odt_rtt_norm),
531 CTRL_OPTIONS_CS(0, odt_rtt_wr),
532#if (CONFIG_CHIP_SELECTS_PER_CTRL > 1)
533 CTRL_OPTIONS_CS(1, odt_rtt_norm),
534 CTRL_OPTIONS_CS(1, odt_rtt_wr),
535#endif
536#if (CONFIG_CHIP_SELECTS_PER_CTRL > 2)
537 CTRL_OPTIONS_CS(2, odt_rtt_norm),
538 CTRL_OPTIONS_CS(2, odt_rtt_wr),
539#endif
540#if (CONFIG_CHIP_SELECTS_PER_CTRL > 2)
541 CTRL_OPTIONS_CS(3, odt_rtt_norm),
542 CTRL_OPTIONS_CS(3, odt_rtt_wr),
543#endif
544#endif
545 CTRL_OPTIONS(memctl_interleaving),
546 CTRL_OPTIONS(memctl_interleaving_mode),
547 CTRL_OPTIONS(ba_intlv_ctl),
Priyanka Jain4a717412013-09-25 10:41:19 +0530548 CTRL_OPTIONS(ecc_mode),
549 CTRL_OPTIONS(ecc_init_using_memctl),
550 CTRL_OPTIONS(dqs_config),
York Sunbd495cf2011-09-16 13:21:35 -0700551 CTRL_OPTIONS(self_refresh_in_sleep),
552 CTRL_OPTIONS(dynamic_power),
553 CTRL_OPTIONS(data_bus_width),
554 CTRL_OPTIONS(burst_length),
555 CTRL_OPTIONS(cas_latency_override),
556 CTRL_OPTIONS(cas_latency_override_value),
557 CTRL_OPTIONS(use_derated_caslat),
558 CTRL_OPTIONS(additive_latency_override),
559 CTRL_OPTIONS(additive_latency_override_value),
560 CTRL_OPTIONS(clk_adjust),
561 CTRL_OPTIONS(cpo_override),
562 CTRL_OPTIONS(write_data_delay),
563 CTRL_OPTIONS(half_strength_driver_enable),
564
565 /*
566 * These can probably be changed to 2T_EN and 3T_EN
567 * (using a leading numerical character) without problem
568 */
Priyanka Jain4a717412013-09-25 10:41:19 +0530569 CTRL_OPTIONS(twot_en),
570 CTRL_OPTIONS(threet_en),
York Sund9f7fa02018-01-29 09:44:33 -0800571 CTRL_OPTIONS(mirrored_dimm),
York Sunbd495cf2011-09-16 13:21:35 -0700572 CTRL_OPTIONS(ap_en),
York Sun4889c982013-06-25 11:37:47 -0700573 CTRL_OPTIONS(x4_en),
York Sun6db4fdd2018-01-29 09:44:35 -0800574 CTRL_OPTIONS(package_3ds),
York Sunbd495cf2011-09-16 13:21:35 -0700575 CTRL_OPTIONS(bstopre),
576 CTRL_OPTIONS(wrlvl_override),
577 CTRL_OPTIONS(wrlvl_sample),
578 CTRL_OPTIONS(wrlvl_start),
York Sune0f60462014-09-05 13:52:43 +0800579 CTRL_OPTIONS(cswl_override),
York Sunbd495cf2011-09-16 13:21:35 -0700580 CTRL_OPTIONS(rcw_override),
581 CTRL_OPTIONS(rcw_1),
582 CTRL_OPTIONS(rcw_2),
York Sund9f7fa02018-01-29 09:44:33 -0800583 CTRL_OPTIONS(rcw_3),
York Sun7d69ea32012-10-08 07:44:22 +0000584 CTRL_OPTIONS(ddr_cdr1),
585 CTRL_OPTIONS(ddr_cdr2),
Priyanka Jain4a717412013-09-25 10:41:19 +0530586 CTRL_OPTIONS(tfaw_window_four_activates_ps),
York Sunbd495cf2011-09-16 13:21:35 -0700587 CTRL_OPTIONS(trwt_override),
588 CTRL_OPTIONS(trwt),
York Sun2896cb72014-03-27 17:54:47 -0700589 CTRL_OPTIONS(rtt_override),
590 CTRL_OPTIONS(rtt_override_value),
591 CTRL_OPTIONS(rtt_wr_override_value),
York Sunbd495cf2011-09-16 13:21:35 -0700592 };
593
594 static const unsigned int n_opts = ARRAY_SIZE(options);
595
596 if (handle_option_table(options, n_opts, p,
597 optname_str, value_str))
598 return;
599
600 printf("couldn't find option string %s\n", optname_str);
601}
602
603#define CFG_REGS(x) {#x, offsetof(fsl_ddr_cfg_regs_t, x), \
604 sizeof((fsl_ddr_cfg_regs_t *)0)->x, 1}
605#define CFG_REGS_CS(x, y) {"cs" #x "_" #y, \
606 offsetof(fsl_ddr_cfg_regs_t, cs[x].y), \
607 sizeof((fsl_ddr_cfg_regs_t *)0)->cs[x].y, 1}
608
609static void print_fsl_memctl_config_regs(const fsl_ddr_cfg_regs_t *ddr)
610{
611 unsigned int i;
612 static const struct options_string options[] = {
613 CFG_REGS_CS(0, bnds),
614 CFG_REGS_CS(0, config),
615 CFG_REGS_CS(0, config_2),
616#if (CONFIG_CHIP_SELECTS_PER_CTRL > 1)
617 CFG_REGS_CS(1, bnds),
618 CFG_REGS_CS(1, config),
619 CFG_REGS_CS(1, config_2),
620#endif
621#if (CONFIG_CHIP_SELECTS_PER_CTRL > 2)
622 CFG_REGS_CS(2, bnds),
623 CFG_REGS_CS(2, config),
624 CFG_REGS_CS(2, config_2),
625#endif
626#if (CONFIG_CHIP_SELECTS_PER_CTRL > 2)
627 CFG_REGS_CS(3, bnds),
628 CFG_REGS_CS(3, config),
629 CFG_REGS_CS(3, config_2),
630#endif
631 CFG_REGS(timing_cfg_3),
632 CFG_REGS(timing_cfg_0),
633 CFG_REGS(timing_cfg_1),
634 CFG_REGS(timing_cfg_2),
635 CFG_REGS(ddr_sdram_cfg),
636 CFG_REGS(ddr_sdram_cfg_2),
York Sun2896cb72014-03-27 17:54:47 -0700637 CFG_REGS(ddr_sdram_cfg_3),
York Sunbd495cf2011-09-16 13:21:35 -0700638 CFG_REGS(ddr_sdram_mode),
639 CFG_REGS(ddr_sdram_mode_2),
640 CFG_REGS(ddr_sdram_mode_3),
641 CFG_REGS(ddr_sdram_mode_4),
642 CFG_REGS(ddr_sdram_mode_5),
643 CFG_REGS(ddr_sdram_mode_6),
644 CFG_REGS(ddr_sdram_mode_7),
645 CFG_REGS(ddr_sdram_mode_8),
York Sun2896cb72014-03-27 17:54:47 -0700646#ifdef CONFIG_SYS_FSL_DDR4
647 CFG_REGS(ddr_sdram_mode_9),
648 CFG_REGS(ddr_sdram_mode_10),
649 CFG_REGS(ddr_sdram_mode_11),
650 CFG_REGS(ddr_sdram_mode_12),
651 CFG_REGS(ddr_sdram_mode_13),
652 CFG_REGS(ddr_sdram_mode_14),
653 CFG_REGS(ddr_sdram_mode_15),
654 CFG_REGS(ddr_sdram_mode_16),
655#endif
York Sunbd495cf2011-09-16 13:21:35 -0700656 CFG_REGS(ddr_sdram_interval),
657 CFG_REGS(ddr_data_init),
658 CFG_REGS(ddr_sdram_clk_cntl),
659 CFG_REGS(ddr_init_addr),
660 CFG_REGS(ddr_init_ext_addr),
661 CFG_REGS(timing_cfg_4),
662 CFG_REGS(timing_cfg_5),
York Sun2896cb72014-03-27 17:54:47 -0700663#ifdef CONFIG_SYS_FSL_DDR4
664 CFG_REGS(timing_cfg_6),
665 CFG_REGS(timing_cfg_7),
666 CFG_REGS(timing_cfg_8),
667 CFG_REGS(timing_cfg_9),
668#endif
York Sunbd495cf2011-09-16 13:21:35 -0700669 CFG_REGS(ddr_zq_cntl),
670 CFG_REGS(ddr_wrlvl_cntl),
York Sun7d69ea32012-10-08 07:44:22 +0000671 CFG_REGS(ddr_wrlvl_cntl_2),
672 CFG_REGS(ddr_wrlvl_cntl_3),
York Sunbd495cf2011-09-16 13:21:35 -0700673 CFG_REGS(ddr_sr_cntr),
674 CFG_REGS(ddr_sdram_rcw_1),
675 CFG_REGS(ddr_sdram_rcw_2),
York Sund9f7fa02018-01-29 09:44:33 -0800676 CFG_REGS(ddr_sdram_rcw_3),
York Sunbd495cf2011-09-16 13:21:35 -0700677 CFG_REGS(ddr_cdr1),
678 CFG_REGS(ddr_cdr2),
York Sun2896cb72014-03-27 17:54:47 -0700679 CFG_REGS(dq_map_0),
680 CFG_REGS(dq_map_1),
681 CFG_REGS(dq_map_2),
682 CFG_REGS(dq_map_3),
York Sunbd495cf2011-09-16 13:21:35 -0700683 CFG_REGS(err_disable),
684 CFG_REGS(err_int_en),
York Sun7d69ea32012-10-08 07:44:22 +0000685 CFG_REGS(ddr_eor),
York Sunbd495cf2011-09-16 13:21:35 -0700686 };
687 static const unsigned int n_opts = ARRAY_SIZE(options);
688
689 print_option_table(options, n_opts, ddr);
690
York Sun7c725782016-08-29 17:04:12 +0800691 for (i = 0; i < 64; i++)
York Sunbd495cf2011-09-16 13:21:35 -0700692 printf("debug_%02d = 0x%08X\n", i+1, ddr->debug[i]);
693}
694
695static void fsl_ddr_regs_edit(fsl_ddr_info_t *pinfo,
696 unsigned int ctrl_num,
697 const char *regname,
698 const char *value_str)
699{
700 unsigned int i;
701 fsl_ddr_cfg_regs_t *ddr;
702 char buf[20];
703 static const struct options_string options[] = {
704 CFG_REGS_CS(0, bnds),
705 CFG_REGS_CS(0, config),
706 CFG_REGS_CS(0, config_2),
707#if (CONFIG_CHIP_SELECTS_PER_CTRL > 1)
708 CFG_REGS_CS(1, bnds),
709 CFG_REGS_CS(1, config),
710 CFG_REGS_CS(1, config_2),
711#endif
712#if (CONFIG_CHIP_SELECTS_PER_CTRL > 2)
713 CFG_REGS_CS(2, bnds),
714 CFG_REGS_CS(2, config),
715 CFG_REGS_CS(2, config_2),
716#endif
717#if (CONFIG_CHIP_SELECTS_PER_CTRL > 3)
718 CFG_REGS_CS(3, bnds),
719 CFG_REGS_CS(3, config),
720 CFG_REGS_CS(3, config_2),
721#endif
722 CFG_REGS(timing_cfg_3),
723 CFG_REGS(timing_cfg_0),
724 CFG_REGS(timing_cfg_1),
725 CFG_REGS(timing_cfg_2),
726 CFG_REGS(ddr_sdram_cfg),
727 CFG_REGS(ddr_sdram_cfg_2),
York Sun2896cb72014-03-27 17:54:47 -0700728 CFG_REGS(ddr_sdram_cfg_3),
York Sunbd495cf2011-09-16 13:21:35 -0700729 CFG_REGS(ddr_sdram_mode),
730 CFG_REGS(ddr_sdram_mode_2),
731 CFG_REGS(ddr_sdram_mode_3),
732 CFG_REGS(ddr_sdram_mode_4),
733 CFG_REGS(ddr_sdram_mode_5),
734 CFG_REGS(ddr_sdram_mode_6),
735 CFG_REGS(ddr_sdram_mode_7),
736 CFG_REGS(ddr_sdram_mode_8),
York Sun2896cb72014-03-27 17:54:47 -0700737#ifdef CONFIG_SYS_FSL_DDR4
738 CFG_REGS(ddr_sdram_mode_9),
739 CFG_REGS(ddr_sdram_mode_10),
740 CFG_REGS(ddr_sdram_mode_11),
741 CFG_REGS(ddr_sdram_mode_12),
742 CFG_REGS(ddr_sdram_mode_13),
743 CFG_REGS(ddr_sdram_mode_14),
744 CFG_REGS(ddr_sdram_mode_15),
745 CFG_REGS(ddr_sdram_mode_16),
746#endif
York Sunbd495cf2011-09-16 13:21:35 -0700747 CFG_REGS(ddr_sdram_interval),
748 CFG_REGS(ddr_data_init),
749 CFG_REGS(ddr_sdram_clk_cntl),
750 CFG_REGS(ddr_init_addr),
751 CFG_REGS(ddr_init_ext_addr),
752 CFG_REGS(timing_cfg_4),
753 CFG_REGS(timing_cfg_5),
York Sun2896cb72014-03-27 17:54:47 -0700754#ifdef CONFIG_SYS_FSL_DDR4
755 CFG_REGS(timing_cfg_6),
756 CFG_REGS(timing_cfg_7),
757 CFG_REGS(timing_cfg_8),
758 CFG_REGS(timing_cfg_9),
759#endif
York Sunbd495cf2011-09-16 13:21:35 -0700760 CFG_REGS(ddr_zq_cntl),
761 CFG_REGS(ddr_wrlvl_cntl),
York Sun7d69ea32012-10-08 07:44:22 +0000762 CFG_REGS(ddr_wrlvl_cntl_2),
763 CFG_REGS(ddr_wrlvl_cntl_3),
York Sunbd495cf2011-09-16 13:21:35 -0700764 CFG_REGS(ddr_sr_cntr),
765 CFG_REGS(ddr_sdram_rcw_1),
766 CFG_REGS(ddr_sdram_rcw_2),
York Sund9f7fa02018-01-29 09:44:33 -0800767 CFG_REGS(ddr_sdram_rcw_3),
York Sunbd495cf2011-09-16 13:21:35 -0700768 CFG_REGS(ddr_cdr1),
769 CFG_REGS(ddr_cdr2),
York Sun2896cb72014-03-27 17:54:47 -0700770 CFG_REGS(dq_map_0),
771 CFG_REGS(dq_map_1),
772 CFG_REGS(dq_map_2),
773 CFG_REGS(dq_map_3),
York Sunbd495cf2011-09-16 13:21:35 -0700774 CFG_REGS(err_disable),
775 CFG_REGS(err_int_en),
776 CFG_REGS(ddr_sdram_rcw_2),
777 CFG_REGS(ddr_sdram_rcw_2),
York Sun7d69ea32012-10-08 07:44:22 +0000778 CFG_REGS(ddr_eor),
York Sunbd495cf2011-09-16 13:21:35 -0700779 };
780 static const unsigned int n_opts = ARRAY_SIZE(options);
781
782 debug("fsl_ddr_regs_edit: ctrl_num = %u, "
783 "regname = %s, value = %s\n",
784 ctrl_num, regname, value_str);
York Sunfe845072016-12-28 08:43:45 -0800785 if (ctrl_num > CONFIG_SYS_NUM_DDR_CTLRS)
York Sunbd495cf2011-09-16 13:21:35 -0700786 return;
787
788 ddr = &(pinfo->fsl_ddr_config_reg[ctrl_num]);
789
790 if (handle_option_table(options, n_opts, ddr, regname, value_str))
791 return;
792
York Sun7c725782016-08-29 17:04:12 +0800793 for (i = 0; i < 64; i++) {
York Sunbd495cf2011-09-16 13:21:35 -0700794 unsigned int value = simple_strtoul(value_str, NULL, 0);
795 sprintf(buf, "debug_%u", i + 1);
796 if (strcmp(buf, regname) == 0) {
797 ddr->debug[i] = value;
798 return;
799 }
800 }
801 printf("Error: couldn't find register string %s\n", regname);
802}
803
804#define CTRL_OPTIONS_HEX(x) {#x, offsetof(memctl_options_t, x), \
805 sizeof((memctl_options_t *)0)->x, 1}
806
807static void print_memctl_options(const memctl_options_t *popts)
808{
809 static const struct options_string options[] = {
810 CTRL_OPTIONS_CS(0, odt_rd_cfg),
811 CTRL_OPTIONS_CS(0, odt_wr_cfg),
812#if (CONFIG_CHIP_SELECTS_PER_CTRL > 1)
813 CTRL_OPTIONS_CS(1, odt_rd_cfg),
814 CTRL_OPTIONS_CS(1, odt_wr_cfg),
815#endif
816#if (CONFIG_CHIP_SELECTS_PER_CTRL > 2)
817 CTRL_OPTIONS_CS(2, odt_rd_cfg),
818 CTRL_OPTIONS_CS(2, odt_wr_cfg),
819#endif
820#if (CONFIG_CHIP_SELECTS_PER_CTRL > 3)
821 CTRL_OPTIONS_CS(3, odt_rd_cfg),
822 CTRL_OPTIONS_CS(3, odt_wr_cfg),
823#endif
York Sunfc63b282015-03-19 09:30:27 -0700824#if defined(CONFIG_SYS_FSL_DDR3) || defined(CONFIG_SYS_FSL_DDR4)
York Sunbd495cf2011-09-16 13:21:35 -0700825 CTRL_OPTIONS_CS(0, odt_rtt_norm),
826 CTRL_OPTIONS_CS(0, odt_rtt_wr),
827#if (CONFIG_CHIP_SELECTS_PER_CTRL > 1)
828 CTRL_OPTIONS_CS(1, odt_rtt_norm),
829 CTRL_OPTIONS_CS(1, odt_rtt_wr),
830#endif
831#if (CONFIG_CHIP_SELECTS_PER_CTRL > 2)
832 CTRL_OPTIONS_CS(2, odt_rtt_norm),
833 CTRL_OPTIONS_CS(2, odt_rtt_wr),
834#endif
835#if (CONFIG_CHIP_SELECTS_PER_CTRL > 3)
836 CTRL_OPTIONS_CS(3, odt_rtt_norm),
837 CTRL_OPTIONS_CS(3, odt_rtt_wr),
838#endif
839#endif
840 CTRL_OPTIONS(memctl_interleaving),
841 CTRL_OPTIONS(memctl_interleaving_mode),
842 CTRL_OPTIONS_HEX(ba_intlv_ctl),
Priyanka Jain4a717412013-09-25 10:41:19 +0530843 CTRL_OPTIONS(ecc_mode),
844 CTRL_OPTIONS(ecc_init_using_memctl),
845 CTRL_OPTIONS(dqs_config),
York Sunbd495cf2011-09-16 13:21:35 -0700846 CTRL_OPTIONS(self_refresh_in_sleep),
847 CTRL_OPTIONS(dynamic_power),
848 CTRL_OPTIONS(data_bus_width),
849 CTRL_OPTIONS(burst_length),
850 CTRL_OPTIONS(cas_latency_override),
851 CTRL_OPTIONS(cas_latency_override_value),
852 CTRL_OPTIONS(use_derated_caslat),
853 CTRL_OPTIONS(additive_latency_override),
854 CTRL_OPTIONS(additive_latency_override_value),
855 CTRL_OPTIONS(clk_adjust),
856 CTRL_OPTIONS(cpo_override),
857 CTRL_OPTIONS(write_data_delay),
858 CTRL_OPTIONS(half_strength_driver_enable),
859 /*
860 * These can probably be changed to 2T_EN and 3T_EN
861 * (using a leading numerical character) without problem
862 */
Priyanka Jain4a717412013-09-25 10:41:19 +0530863 CTRL_OPTIONS(twot_en),
864 CTRL_OPTIONS(threet_en),
York Sunbd495cf2011-09-16 13:21:35 -0700865 CTRL_OPTIONS(registered_dimm_en),
York Sunfc63b282015-03-19 09:30:27 -0700866 CTRL_OPTIONS(mirrored_dimm),
York Sunbd495cf2011-09-16 13:21:35 -0700867 CTRL_OPTIONS(ap_en),
York Sun4889c982013-06-25 11:37:47 -0700868 CTRL_OPTIONS(x4_en),
York Sun6db4fdd2018-01-29 09:44:35 -0800869 CTRL_OPTIONS(package_3ds),
York Sunbd495cf2011-09-16 13:21:35 -0700870 CTRL_OPTIONS(bstopre),
871 CTRL_OPTIONS(wrlvl_override),
872 CTRL_OPTIONS(wrlvl_sample),
873 CTRL_OPTIONS(wrlvl_start),
York Sune0f60462014-09-05 13:52:43 +0800874 CTRL_OPTIONS_HEX(cswl_override),
York Sunbd495cf2011-09-16 13:21:35 -0700875 CTRL_OPTIONS(rcw_override),
York Sund9f7fa02018-01-29 09:44:33 -0800876 CTRL_OPTIONS_HEX(rcw_1),
877 CTRL_OPTIONS_HEX(rcw_2),
878 CTRL_OPTIONS_HEX(rcw_3),
York Sun7d69ea32012-10-08 07:44:22 +0000879 CTRL_OPTIONS_HEX(ddr_cdr1),
880 CTRL_OPTIONS_HEX(ddr_cdr2),
Priyanka Jain4a717412013-09-25 10:41:19 +0530881 CTRL_OPTIONS(tfaw_window_four_activates_ps),
York Sunbd495cf2011-09-16 13:21:35 -0700882 CTRL_OPTIONS(trwt_override),
883 CTRL_OPTIONS(trwt),
York Sun2896cb72014-03-27 17:54:47 -0700884 CTRL_OPTIONS(rtt_override),
885 CTRL_OPTIONS(rtt_override_value),
886 CTRL_OPTIONS(rtt_wr_override_value),
York Sunbd495cf2011-09-16 13:21:35 -0700887 };
888 static const unsigned int n_opts = ARRAY_SIZE(options);
889
890 print_option_table(options, n_opts, popts);
891}
892
York Sunf0626592013-09-30 09:22:09 -0700893#ifdef CONFIG_SYS_FSL_DDR1
York Sunbd495cf2011-09-16 13:21:35 -0700894void ddr1_spd_dump(const ddr1_spd_eeprom_t *spd)
895{
896 unsigned int i;
897
898 printf("%-3d : %02x %s\n", 0, spd->info_size,
899 " spd->info_size, * 0 # bytes written into serial memory *");
900 printf("%-3d : %02x %s\n", 1, spd->chip_size,
901 " spd->chip_size, * 1 Total # bytes of SPD memory device *");
902 printf("%-3d : %02x %s\n", 2, spd->mem_type,
903 " spd->mem_type, * 2 Fundamental memory type *");
904 printf("%-3d : %02x %s\n", 3, spd->nrow_addr,
905 " spd->nrow_addr, * 3 # of Row Addresses on this assembly *");
906 printf("%-3d : %02x %s\n", 4, spd->ncol_addr,
907 " spd->ncol_addr, * 4 # of Column Addrs on this assembly *");
908 printf("%-3d : %02x %s\n", 5, spd->nrows,
909 " spd->nrows * 5 # of DIMM Banks *");
910 printf("%-3d : %02x %s\n", 6, spd->dataw_lsb,
911 " spd->dataw_lsb, * 6 Data Width lsb of this assembly *");
912 printf("%-3d : %02x %s\n", 7, spd->dataw_msb,
913 " spd->dataw_msb, * 7 Data Width msb of this assembly *");
914 printf("%-3d : %02x %s\n", 8, spd->voltage,
915 " spd->voltage, * 8 Voltage intf std of this assembly *");
916 printf("%-3d : %02x %s\n", 9, spd->clk_cycle,
917 " spd->clk_cycle, * 9 SDRAM Cycle time at CL=X *");
918 printf("%-3d : %02x %s\n", 10, spd->clk_access,
919 " spd->clk_access, * 10 SDRAM Access from Clock at CL=X *");
920 printf("%-3d : %02x %s\n", 11, spd->config,
921 " spd->config, * 11 DIMM Configuration type *");
922 printf("%-3d : %02x %s\n", 12, spd->refresh,
923 " spd->refresh, * 12 Refresh Rate/Type *");
924 printf("%-3d : %02x %s\n", 13, spd->primw,
925 " spd->primw, * 13 Primary SDRAM Width *");
926 printf("%-3d : %02x %s\n", 14, spd->ecw,
927 " spd->ecw, * 14 Error Checking SDRAM width *");
928 printf("%-3d : %02x %s\n", 15, spd->min_delay,
929 " spd->min_delay, * 15 Back to Back Random Access *");
930 printf("%-3d : %02x %s\n", 16, spd->burstl,
931 " spd->burstl, * 16 Burst Lengths Supported *");
932 printf("%-3d : %02x %s\n", 17, spd->nbanks,
933 " spd->nbanks, * 17 # of Banks on Each SDRAM Device *");
934 printf("%-3d : %02x %s\n", 18, spd->cas_lat,
935 " spd->cas_lat, * 18 CAS# Latencies Supported *");
936 printf("%-3d : %02x %s\n", 19, spd->cs_lat,
937 " spd->cs_lat, * 19 Chip Select Latency *");
938 printf("%-3d : %02x %s\n", 20, spd->write_lat,
939 " spd->write_lat, * 20 Write Latency/Recovery *");
940 printf("%-3d : %02x %s\n", 21, spd->mod_attr,
941 " spd->mod_attr, * 21 SDRAM Module Attributes *");
942 printf("%-3d : %02x %s\n", 22, spd->dev_attr,
943 " spd->dev_attr, * 22 SDRAM Device Attributes *");
944 printf("%-3d : %02x %s\n", 23, spd->clk_cycle2,
945 " spd->clk_cycle2, * 23 Min SDRAM Cycle time at CL=X-1 *");
946 printf("%-3d : %02x %s\n", 24, spd->clk_access2,
947 " spd->clk_access2, * 24 SDRAM Access from Clock at CL=X-1 *");
948 printf("%-3d : %02x %s\n", 25, spd->clk_cycle3,
949 " spd->clk_cycle3, * 25 Min SDRAM Cycle time at CL=X-2 *");
950 printf("%-3d : %02x %s\n", 26, spd->clk_access3,
951 " spd->clk_access3, * 26 Max Access from Clock at CL=X-2 *");
952 printf("%-3d : %02x %s\n", 27, spd->trp,
953 " spd->trp, * 27 Min Row Precharge Time (tRP)*");
954 printf("%-3d : %02x %s\n", 28, spd->trrd,
955 " spd->trrd, * 28 Min Row Active to Row Active (tRRD) *");
956 printf("%-3d : %02x %s\n", 29, spd->trcd,
957 " spd->trcd, * 29 Min RAS to CAS Delay (tRCD) *");
958 printf("%-3d : %02x %s\n", 30, spd->tras,
959 " spd->tras, * 30 Minimum RAS Pulse Width (tRAS) *");
960 printf("%-3d : %02x %s\n", 31, spd->bank_dens,
961 " spd->bank_dens, * 31 Density of each bank on module *");
962 printf("%-3d : %02x %s\n", 32, spd->ca_setup,
963 " spd->ca_setup, * 32 Cmd + Addr signal input setup time *");
964 printf("%-3d : %02x %s\n", 33, spd->ca_hold,
965 " spd->ca_hold, * 33 Cmd and Addr signal input hold time *");
966 printf("%-3d : %02x %s\n", 34, spd->data_setup,
967 " spd->data_setup, * 34 Data signal input setup time *");
968 printf("%-3d : %02x %s\n", 35, spd->data_hold,
969 " spd->data_hold, * 35 Data signal input hold time *");
970 printf("%-3d : %02x %s\n", 36, spd->res_36_40[0],
971 " spd->res_36_40[0], * 36 Reserved / tWR *");
972 printf("%-3d : %02x %s\n", 37, spd->res_36_40[1],
973 " spd->res_36_40[1], * 37 Reserved / tWTR *");
974 printf("%-3d : %02x %s\n", 38, spd->res_36_40[2],
975 " spd->res_36_40[2], * 38 Reserved / tRTP *");
976 printf("%-3d : %02x %s\n", 39, spd->res_36_40[3],
977 " spd->res_36_40[3], * 39 Reserved / mem_probe *");
978 printf("%-3d : %02x %s\n", 40, spd->res_36_40[4],
979 " spd->res_36_40[4], * 40 Reserved / trc,trfc extensions *");
980 printf("%-3d : %02x %s\n", 41, spd->trc,
981 " spd->trc, * 41 Min Active to Auto refresh time tRC *");
982 printf("%-3d : %02x %s\n", 42, spd->trfc,
983 " spd->trfc, * 42 Min Auto to Active period tRFC *");
984 printf("%-3d : %02x %s\n", 43, spd->tckmax,
985 " spd->tckmax, * 43 Max device cycle time tCKmax *");
986 printf("%-3d : %02x %s\n", 44, spd->tdqsq,
987 " spd->tdqsq, * 44 Max DQS to DQ skew *");
988 printf("%-3d : %02x %s\n", 45, spd->tqhs,
989 " spd->tqhs, * 45 Max Read DataHold skew tQHS *");
990 printf("%-3d : %02x %s\n", 46, spd->res_46,
991 " spd->res_46, * 46 Reserved/ PLL Relock time *");
992 printf("%-3d : %02x %s\n", 47, spd->dimm_height,
993 " spd->dimm_height * 47 SDRAM DIMM Height *");
994
995 printf("%-3d-%3d: ", 48, 61);
996
997 for (i = 0; i < 14; i++)
998 printf("%02x", spd->res_48_61[i]);
999
1000 printf(" * 48-61 IDD in SPD and Reserved space *\n");
1001
1002 printf("%-3d : %02x %s\n", 62, spd->spd_rev,
1003 " spd->spd_rev, * 62 SPD Data Revision Code *");
1004 printf("%-3d : %02x %s\n", 63, spd->cksum,
1005 " spd->cksum, * 63 Checksum for bytes 0-62 *");
1006 printf("%-3d-%3d: ", 64, 71);
1007
1008 for (i = 0; i < 8; i++)
1009 printf("%02x", spd->mid[i]);
1010
1011 printf("* 64 Mfr's JEDEC ID code per JEP-108E *\n");
1012 printf("%-3d : %02x %s\n", 72, spd->mloc,
1013 " spd->mloc, * 72 Manufacturing Location *");
1014
1015 printf("%-3d-%3d: >>", 73, 90);
1016
1017 for (i = 0; i < 18; i++)
1018 printf("%c", spd->mpart[i]);
1019
1020 printf("<<* 73 Manufacturer's Part Number *\n");
1021
1022 printf("%-3d-%3d: %02x %02x %s\n", 91, 92, spd->rev[0], spd->rev[1],
1023 "* 91 Revision Code *");
1024 printf("%-3d-%3d: %02x %02x %s\n", 93, 94, spd->mdate[0], spd->mdate[1],
1025 "* 93 Manufacturing Date *");
1026 printf("%-3d-%3d: ", 95, 98);
1027
1028 for (i = 0; i < 4; i++)
1029 printf("%02x", spd->sernum[i]);
1030
1031 printf("* 95 Assembly Serial Number *\n");
1032
1033 printf("%-3d-%3d: ", 99, 127);
1034
1035 for (i = 0; i < 27; i++)
1036 printf("%02x", spd->mspec[i]);
1037
1038 printf("* 99 Manufacturer Specific Data *\n");
1039}
1040#endif
1041
York Sunf0626592013-09-30 09:22:09 -07001042#ifdef CONFIG_SYS_FSL_DDR2
York Sunbd495cf2011-09-16 13:21:35 -07001043void ddr2_spd_dump(const ddr2_spd_eeprom_t *spd)
1044{
1045 unsigned int i;
1046
1047 printf("%-3d : %02x %s\n", 0, spd->info_size,
1048 " spd->info_size, * 0 # bytes written into serial memory *");
1049 printf("%-3d : %02x %s\n", 1, spd->chip_size,
1050 " spd->chip_size, * 1 Total # bytes of SPD memory device *");
1051 printf("%-3d : %02x %s\n", 2, spd->mem_type,
1052 " spd->mem_type, * 2 Fundamental memory type *");
1053 printf("%-3d : %02x %s\n", 3, spd->nrow_addr,
1054 " spd->nrow_addr, * 3 # of Row Addresses on this assembly *");
1055 printf("%-3d : %02x %s\n", 4, spd->ncol_addr,
1056 " spd->ncol_addr, * 4 # of Column Addrs on this assembly *");
1057 printf("%-3d : %02x %s\n", 5, spd->mod_ranks,
1058 " spd->mod_ranks * 5 # of Module Rows on this assembly *");
1059 printf("%-3d : %02x %s\n", 6, spd->dataw,
1060 " spd->dataw, * 6 Data Width of this assembly *");
1061 printf("%-3d : %02x %s\n", 7, spd->res_7,
1062 " spd->res_7, * 7 Reserved *");
1063 printf("%-3d : %02x %s\n", 8, spd->voltage,
1064 " spd->voltage, * 8 Voltage intf std of this assembly *");
1065 printf("%-3d : %02x %s\n", 9, spd->clk_cycle,
1066 " spd->clk_cycle, * 9 SDRAM Cycle time at CL=X *");
1067 printf("%-3d : %02x %s\n", 10, spd->clk_access,
1068 " spd->clk_access, * 10 SDRAM Access from Clock at CL=X *");
1069 printf("%-3d : %02x %s\n", 11, spd->config,
1070 " spd->config, * 11 DIMM Configuration type *");
1071 printf("%-3d : %02x %s\n", 12, spd->refresh,
1072 " spd->refresh, * 12 Refresh Rate/Type *");
1073 printf("%-3d : %02x %s\n", 13, spd->primw,
1074 " spd->primw, * 13 Primary SDRAM Width *");
1075 printf("%-3d : %02x %s\n", 14, spd->ecw,
1076 " spd->ecw, * 14 Error Checking SDRAM width *");
1077 printf("%-3d : %02x %s\n", 15, spd->res_15,
1078 " spd->res_15, * 15 Reserved *");
1079 printf("%-3d : %02x %s\n", 16, spd->burstl,
1080 " spd->burstl, * 16 Burst Lengths Supported *");
1081 printf("%-3d : %02x %s\n", 17, spd->nbanks,
1082 " spd->nbanks, * 17 # of Banks on Each SDRAM Device *");
1083 printf("%-3d : %02x %s\n", 18, spd->cas_lat,
1084 " spd->cas_lat, * 18 CAS# Latencies Supported *");
1085 printf("%-3d : %02x %s\n", 19, spd->mech_char,
1086 " spd->mech_char, * 19 Mechanical Characteristics *");
1087 printf("%-3d : %02x %s\n", 20, spd->dimm_type,
1088 " spd->dimm_type, * 20 DIMM type *");
1089 printf("%-3d : %02x %s\n", 21, spd->mod_attr,
1090 " spd->mod_attr, * 21 SDRAM Module Attributes *");
1091 printf("%-3d : %02x %s\n", 22, spd->dev_attr,
1092 " spd->dev_attr, * 22 SDRAM Device Attributes *");
1093 printf("%-3d : %02x %s\n", 23, spd->clk_cycle2,
1094 " spd->clk_cycle2, * 23 Min SDRAM Cycle time at CL=X-1 *");
1095 printf("%-3d : %02x %s\n", 24, spd->clk_access2,
1096 " spd->clk_access2, * 24 SDRAM Access from Clock at CL=X-1 *");
1097 printf("%-3d : %02x %s\n", 25, spd->clk_cycle3,
1098 " spd->clk_cycle3, * 25 Min SDRAM Cycle time at CL=X-2 *");
1099 printf("%-3d : %02x %s\n", 26, spd->clk_access3,
1100 " spd->clk_access3, * 26 Max Access from Clock at CL=X-2 *");
1101 printf("%-3d : %02x %s\n", 27, spd->trp,
1102 " spd->trp, * 27 Min Row Precharge Time (tRP)*");
1103 printf("%-3d : %02x %s\n", 28, spd->trrd,
1104 " spd->trrd, * 28 Min Row Active to Row Active (tRRD) *");
1105 printf("%-3d : %02x %s\n", 29, spd->trcd,
1106 " spd->trcd, * 29 Min RAS to CAS Delay (tRCD) *");
1107 printf("%-3d : %02x %s\n", 30, spd->tras,
1108 " spd->tras, * 30 Minimum RAS Pulse Width (tRAS) *");
1109 printf("%-3d : %02x %s\n", 31, spd->rank_dens,
1110 " spd->rank_dens, * 31 Density of each rank on module *");
1111 printf("%-3d : %02x %s\n", 32, spd->ca_setup,
1112 " spd->ca_setup, * 32 Cmd + Addr signal input setup time *");
1113 printf("%-3d : %02x %s\n", 33, spd->ca_hold,
1114 " spd->ca_hold, * 33 Cmd and Addr signal input hold time *");
1115 printf("%-3d : %02x %s\n", 34, spd->data_setup,
1116 " spd->data_setup, * 34 Data signal input setup time *");
1117 printf("%-3d : %02x %s\n", 35, spd->data_hold,
1118 " spd->data_hold, * 35 Data signal input hold time *");
1119 printf("%-3d : %02x %s\n", 36, spd->twr,
1120 " spd->twr, * 36 Write Recovery time tWR *");
1121 printf("%-3d : %02x %s\n", 37, spd->twtr,
1122 " spd->twtr, * 37 Int write to read delay tWTR *");
1123 printf("%-3d : %02x %s\n", 38, spd->trtp,
1124 " spd->trtp, * 38 Int read to precharge delay tRTP *");
1125 printf("%-3d : %02x %s\n", 39, spd->mem_probe,
1126 " spd->mem_probe, * 39 Mem analysis probe characteristics *");
1127 printf("%-3d : %02x %s\n", 40, spd->trctrfc_ext,
1128 " spd->trctrfc_ext, * 40 Extensions to trc and trfc *");
1129 printf("%-3d : %02x %s\n", 41, spd->trc,
1130 " spd->trc, * 41 Min Active to Auto refresh time tRC *");
1131 printf("%-3d : %02x %s\n", 42, spd->trfc,
1132 " spd->trfc, * 42 Min Auto to Active period tRFC *");
1133 printf("%-3d : %02x %s\n", 43, spd->tckmax,
1134 " spd->tckmax, * 43 Max device cycle time tCKmax *");
1135 printf("%-3d : %02x %s\n", 44, spd->tdqsq,
1136 " spd->tdqsq, * 44 Max DQS to DQ skew *");
1137 printf("%-3d : %02x %s\n", 45, spd->tqhs,
1138 " spd->tqhs, * 45 Max Read DataHold skew tQHS *");
1139 printf("%-3d : %02x %s\n", 46, spd->pll_relock,
1140 " spd->pll_relock, * 46 PLL Relock time *");
Priyanka Jain4a717412013-09-25 10:41:19 +05301141 printf("%-3d : %02x %s\n", 47, spd->t_casemax,
1142 " spd->t_casemax, * 47 t_casemax *");
1143 printf("%-3d : %02x %s\n", 48, spd->psi_ta_dram,
1144 " spd->psi_ta_dram, * 48 Thermal Resistance of DRAM Package "
York Sunbd495cf2011-09-16 13:21:35 -07001145 "from Top (Case) to Ambient (Psi T-A DRAM) *");
1146 printf("%-3d : %02x %s\n", 49, spd->dt0_mode,
1147 " spd->dt0_mode, * 49 DRAM Case Temperature Rise from "
1148 "Ambient due to Activate-Precharge/Mode Bits "
1149 "(DT0/Mode Bits) *)");
1150 printf("%-3d : %02x %s\n", 50, spd->dt2n_dt2q,
1151 " spd->dt2n_dt2q, * 50 DRAM Case Temperature Rise from "
1152 "Ambient due to Precharge/Quiet Standby "
1153 "(DT2N/DT2Q) *");
1154 printf("%-3d : %02x %s\n", 51, spd->dt2p,
1155 " spd->dt2p, * 51 DRAM Case Temperature Rise from "
1156 "Ambient due to Precharge Power-Down (DT2P) *");
1157 printf("%-3d : %02x %s\n", 52, spd->dt3n,
1158 " spd->dt3n, * 52 DRAM Case Temperature Rise from "
1159 "Ambient due to Active Standby (DT3N) *");
1160 printf("%-3d : %02x %s\n", 53, spd->dt3pfast,
1161 " spd->dt3pfast, * 53 DRAM Case Temperature Rise from "
1162 "Ambient due to Active Power-Down with Fast PDN Exit "
1163 "(DT3Pfast) *");
1164 printf("%-3d : %02x %s\n", 54, spd->dt3pslow,
1165 " spd->dt3pslow, * 54 DRAM Case Temperature Rise from "
1166 "Ambient due to Active Power-Down with Slow PDN Exit "
1167 "(DT3Pslow) *");
1168 printf("%-3d : %02x %s\n", 55, spd->dt4r_dt4r4w,
1169 " spd->dt4r_dt4r4w, * 55 DRAM Case Temperature Rise from "
1170 "Ambient due to Page Open Burst Read/DT4R4W Mode Bit "
1171 "(DT4R/DT4R4W Mode Bit) *");
1172 printf("%-3d : %02x %s\n", 56, spd->dt5b,
1173 " spd->dt5b, * 56 DRAM Case Temperature Rise from "
1174 "Ambient due to Burst Refresh (DT5B) *");
1175 printf("%-3d : %02x %s\n", 57, spd->dt7,
1176 " spd->dt7, * 57 DRAM Case Temperature Rise from "
1177 "Ambient due to Bank Interleave Reads with "
1178 "Auto-Precharge (DT7) *");
Priyanka Jain4a717412013-09-25 10:41:19 +05301179 printf("%-3d : %02x %s\n", 58, spd->psi_ta_pll,
1180 " spd->psi_ta_pll, * 58 Thermal Resistance of PLL Package form"
York Sunbd495cf2011-09-16 13:21:35 -07001181 " Top (Case) to Ambient (Psi T-A PLL) *");
Priyanka Jain4a717412013-09-25 10:41:19 +05301182 printf("%-3d : %02x %s\n", 59, spd->psi_ta_reg,
1183 " spd->psi_ta_reg, * 59 Thermal Reisitance of Register Package"
York Sunbd495cf2011-09-16 13:21:35 -07001184 " from Top (Case) to Ambient (Psi T-A Register) *");
1185 printf("%-3d : %02x %s\n", 60, spd->dtpllactive,
1186 " spd->dtpllactive, * 60 PLL Case Temperature Rise from "
1187 "Ambient due to PLL Active (DT PLL Active) *");
1188 printf("%-3d : %02x %s\n", 61, spd->dtregact,
1189 " spd->dtregact, "
1190 "* 61 Register Case Temperature Rise from Ambient due to "
1191 "Register Active/Mode Bit (DT Register Active/Mode Bit) *");
1192 printf("%-3d : %02x %s\n", 62, spd->spd_rev,
1193 " spd->spd_rev, * 62 SPD Data Revision Code *");
1194 printf("%-3d : %02x %s\n", 63, spd->cksum,
1195 " spd->cksum, * 63 Checksum for bytes 0-62 *");
1196
1197 printf("%-3d-%3d: ", 64, 71);
1198
1199 for (i = 0; i < 8; i++)
1200 printf("%02x", spd->mid[i]);
1201
1202 printf("* 64 Mfr's JEDEC ID code per JEP-108E *\n");
1203
1204 printf("%-3d : %02x %s\n", 72, spd->mloc,
1205 " spd->mloc, * 72 Manufacturing Location *");
1206
1207 printf("%-3d-%3d: >>", 73, 90);
1208 for (i = 0; i < 18; i++)
1209 printf("%c", spd->mpart[i]);
1210
1211
1212 printf("<<* 73 Manufacturer's Part Number *\n");
1213
1214 printf("%-3d-%3d: %02x %02x %s\n", 91, 92, spd->rev[0], spd->rev[1],
1215 "* 91 Revision Code *");
1216 printf("%-3d-%3d: %02x %02x %s\n", 93, 94, spd->mdate[0], spd->mdate[1],
1217 "* 93 Manufacturing Date *");
1218 printf("%-3d-%3d: ", 95, 98);
1219
1220 for (i = 0; i < 4; i++)
1221 printf("%02x", spd->sernum[i]);
1222
1223 printf("* 95 Assembly Serial Number *\n");
1224
1225 printf("%-3d-%3d: ", 99, 127);
1226 for (i = 0; i < 27; i++)
1227 printf("%02x", spd->mspec[i]);
1228
1229
1230 printf("* 99 Manufacturer Specific Data *\n");
1231}
1232#endif
1233
York Sunf0626592013-09-30 09:22:09 -07001234#ifdef CONFIG_SYS_FSL_DDR3
York Sunbd495cf2011-09-16 13:21:35 -07001235void ddr3_spd_dump(const ddr3_spd_eeprom_t *spd)
1236{
1237 unsigned int i;
1238
1239 /* General Section: Bytes 0-59 */
1240
York Sun48d2b862012-08-17 08:22:43 +00001241#define PRINT_NXS(x, y, z...) printf("%-3d : %02x " z "\n", x, (u8)y);
York Sunbd495cf2011-09-16 13:21:35 -07001242#define PRINT_NNXXS(n0, n1, x0, x1, s) \
1243 printf("%-3d-%3d: %02x %02x " s "\n", n0, n1, x0, x1);
1244
1245 PRINT_NXS(0, spd->info_size_crc,
1246 "info_size_crc bytes written into serial memory, "
1247 "CRC coverage");
1248 PRINT_NXS(1, spd->spd_rev,
1249 "spd_rev SPD Revision");
1250 PRINT_NXS(2, spd->mem_type,
1251 "mem_type Key Byte / DRAM Device Type");
1252 PRINT_NXS(3, spd->module_type,
1253 "module_type Key Byte / Module Type");
1254 PRINT_NXS(4, spd->density_banks,
1255 "density_banks SDRAM Density and Banks");
1256 PRINT_NXS(5, spd->addressing,
1257 "addressing SDRAM Addressing");
1258 PRINT_NXS(6, spd->module_vdd,
1259 "module_vdd Module Nominal Voltage, VDD");
1260 PRINT_NXS(7, spd->organization,
1261 "organization Module Organization");
1262 PRINT_NXS(8, spd->bus_width,
1263 "bus_width Module Memory Bus Width");
1264 PRINT_NXS(9, spd->ftb_div,
1265 "ftb_div Fine Timebase (FTB) Dividend / Divisor");
1266 PRINT_NXS(10, spd->mtb_dividend,
1267 "mtb_dividend Medium Timebase (MTB) Dividend");
1268 PRINT_NXS(11, spd->mtb_divisor,
1269 "mtb_divisor Medium Timebase (MTB) Divisor");
Priyanka Jain4a717412013-09-25 10:41:19 +05301270 PRINT_NXS(12, spd->tck_min,
1271 "tck_min SDRAM Minimum Cycle Time");
York Sunbd495cf2011-09-16 13:21:35 -07001272 PRINT_NXS(13, spd->res_13,
1273 "res_13 Reserved");
1274 PRINT_NXS(14, spd->caslat_lsb,
1275 "caslat_lsb CAS Latencies Supported, LSB");
1276 PRINT_NXS(15, spd->caslat_msb,
1277 "caslat_msb CAS Latencies Supported, MSB");
Priyanka Jain4a717412013-09-25 10:41:19 +05301278 PRINT_NXS(16, spd->taa_min,
1279 "taa_min Min CAS Latency Time");
1280 PRINT_NXS(17, spd->twr_min,
1281 "twr_min Min Write REcovery Time");
1282 PRINT_NXS(18, spd->trcd_min,
1283 "trcd_min Min RAS# to CAS# Delay Time");
1284 PRINT_NXS(19, spd->trrd_min,
1285 "trrd_min Min Row Active to Row Active Delay Time");
1286 PRINT_NXS(20, spd->trp_min,
1287 "trp_min Min Row Precharge Delay Time");
1288 PRINT_NXS(21, spd->tras_trc_ext,
1289 "tras_trc_ext Upper Nibbles for tRAS and tRC");
1290 PRINT_NXS(22, spd->tras_min_lsb,
1291 "tras_min_lsb Min Active to Precharge Delay Time, LSB");
1292 PRINT_NXS(23, spd->trc_min_lsb,
1293 "trc_min_lsb Min Active to Active/Refresh Delay Time, LSB");
1294 PRINT_NXS(24, spd->trfc_min_lsb,
1295 "trfc_min_lsb Min Refresh Recovery Delay Time LSB");
1296 PRINT_NXS(25, spd->trfc_min_msb,
1297 "trfc_min_msb Min Refresh Recovery Delay Time MSB");
1298 PRINT_NXS(26, spd->twtr_min,
1299 "twtr_min Min Internal Write to Read Command Delay Time");
1300 PRINT_NXS(27, spd->trtp_min,
1301 "trtp_min "
1302 "Min Internal Read to Precharge Command Delay Time");
1303 PRINT_NXS(28, spd->tfaw_msb,
1304 "tfaw_msb Upper Nibble for tFAW");
1305 PRINT_NXS(29, spd->tfaw_min,
1306 "tfaw_min Min Four Activate Window Delay Time");
York Sunbd495cf2011-09-16 13:21:35 -07001307 PRINT_NXS(30, spd->opt_features,
1308 "opt_features SDRAM Optional Features");
1309 PRINT_NXS(31, spd->therm_ref_opt,
1310 "therm_ref_opt SDRAM Thermal and Refresh Opts");
1311 PRINT_NXS(32, spd->therm_sensor,
1312 "therm_sensor SDRAM Thermal Sensor");
1313 PRINT_NXS(33, spd->device_type,
1314 "device_type SDRAM Device Type");
Priyanka Jain4a717412013-09-25 10:41:19 +05301315 PRINT_NXS(34, spd->fine_tck_min,
1316 "fine_tck_min Fine offset for tCKmin");
1317 PRINT_NXS(35, spd->fine_taa_min,
1318 "fine_taa_min Fine offset for tAAmin");
1319 PRINT_NXS(36, spd->fine_trcd_min,
1320 "fine_trcd_min Fine offset for tRCDmin");
1321 PRINT_NXS(37, spd->fine_trp_min,
1322 "fine_trp_min Fine offset for tRPmin");
1323 PRINT_NXS(38, spd->fine_trc_min,
1324 "fine_trc_min Fine offset for tRCmin");
York Sunbd495cf2011-09-16 13:21:35 -07001325
York Sun794c6922012-08-17 08:22:37 +00001326 printf("%-3d-%3d: ", 39, 59); /* Reserved, General Section */
York Sunbd495cf2011-09-16 13:21:35 -07001327
York Sun794c6922012-08-17 08:22:37 +00001328 for (i = 39; i <= 59; i++)
1329 printf("%02x ", spd->res_39_59[i - 39]);
York Sunbd495cf2011-09-16 13:21:35 -07001330
1331 puts("\n");
1332
1333 switch (spd->module_type) {
1334 case 0x02: /* UDIMM */
1335 case 0x03: /* SO-DIMM */
1336 case 0x04: /* Micro-DIMM */
1337 case 0x06: /* Mini-UDIMM */
1338 PRINT_NXS(60, spd->mod_section.unbuffered.mod_height,
1339 "mod_height (Unbuffered) Module Nominal Height");
1340 PRINT_NXS(61, spd->mod_section.unbuffered.mod_thickness,
1341 "mod_thickness (Unbuffered) Module Maximum Thickness");
1342 PRINT_NXS(62, spd->mod_section.unbuffered.ref_raw_card,
1343 "ref_raw_card (Unbuffered) Reference Raw Card Used");
1344 PRINT_NXS(63, spd->mod_section.unbuffered.addr_mapping,
1345 "addr_mapping (Unbuffered) Address mapping from "
1346 "Edge Connector to DRAM");
1347 break;
1348 case 0x01: /* RDIMM */
1349 case 0x05: /* Mini-RDIMM */
1350 PRINT_NXS(60, spd->mod_section.registered.mod_height,
1351 "mod_height (Registered) Module Nominal Height");
1352 PRINT_NXS(61, spd->mod_section.registered.mod_thickness,
1353 "mod_thickness (Registered) Module Maximum Thickness");
1354 PRINT_NXS(62, spd->mod_section.registered.ref_raw_card,
1355 "ref_raw_card (Registered) Reference Raw Card Used");
1356 PRINT_NXS(63, spd->mod_section.registered.modu_attr,
1357 "modu_attr (Registered) DIMM Module Attributes");
1358 PRINT_NXS(64, spd->mod_section.registered.thermal,
1359 "thermal (Registered) Thermal Heat "
1360 "Spreader Solution");
1361 PRINT_NXS(65, spd->mod_section.registered.reg_id_lo,
1362 "reg_id_lo (Registered) Register Manufacturer ID "
1363 "Code, LSB");
1364 PRINT_NXS(66, spd->mod_section.registered.reg_id_hi,
1365 "reg_id_hi (Registered) Register Manufacturer ID "
1366 "Code, MSB");
1367 PRINT_NXS(67, spd->mod_section.registered.reg_rev,
1368 "reg_rev (Registered) Register "
1369 "Revision Number");
1370 PRINT_NXS(68, spd->mod_section.registered.reg_type,
1371 "reg_type (Registered) Register Type");
1372 for (i = 69; i <= 76; i++) {
1373 printf("%-3d : %02x rcw[%d]\n", i,
1374 spd->mod_section.registered.rcw[i-69], i-69);
1375 }
1376 break;
1377 default:
1378 /* Module-specific Section, Unsupported Module Type */
1379 printf("%-3d-%3d: ", 60, 116);
1380
1381 for (i = 60; i <= 116; i++)
1382 printf("%02x", spd->mod_section.uc[i - 60]);
1383
1384 break;
1385 }
1386
1387 /* Unique Module ID: Bytes 117-125 */
1388 PRINT_NXS(117, spd->mmid_lsb, "Module MfgID Code LSB - JEP-106");
1389 PRINT_NXS(118, spd->mmid_msb, "Module MfgID Code MSB - JEP-106");
1390 PRINT_NXS(119, spd->mloc, "Mfg Location");
1391 PRINT_NNXXS(120, 121, spd->mdate[0], spd->mdate[1], "Mfg Date");
1392
1393 printf("%-3d-%3d: ", 122, 125);
1394
1395 for (i = 122; i <= 125; i++)
1396 printf("%02x ", spd->sernum[i - 122]);
1397 printf(" Module Serial Number\n");
1398
1399 /* CRC: Bytes 126-127 */
1400 PRINT_NNXXS(126, 127, spd->crc[0], spd->crc[1], " SPD CRC");
1401
1402 /* Other Manufacturer Fields and User Space: Bytes 128-255 */
1403 printf("%-3d-%3d: ", 128, 145);
1404 for (i = 128; i <= 145; i++)
1405 printf("%02x ", spd->mpart[i - 128]);
1406 printf(" Mfg's Module Part Number\n");
1407
1408 PRINT_NNXXS(146, 147, spd->mrev[0], spd->mrev[1],
1409 "Module Revision code");
1410
1411 PRINT_NXS(148, spd->dmid_lsb, "DRAM MfgID Code LSB - JEP-106");
1412 PRINT_NXS(149, spd->dmid_msb, "DRAM MfgID Code MSB - JEP-106");
1413
1414 printf("%-3d-%3d: ", 150, 175);
1415 for (i = 150; i <= 175; i++)
1416 printf("%02x ", spd->msd[i - 150]);
1417 printf(" Mfg's Specific Data\n");
1418
1419 printf("%-3d-%3d: ", 176, 255);
1420 for (i = 176; i <= 255; i++)
1421 printf("%02x", spd->cust[i - 176]);
1422 printf(" Mfg's Specific Data\n");
1423
York Sun2896cb72014-03-27 17:54:47 -07001424}
1425#endif
1426
1427#ifdef CONFIG_SYS_FSL_DDR4
1428void ddr4_spd_dump(const struct ddr4_spd_eeprom_s *spd)
1429{
1430 unsigned int i;
1431
1432 /* General Section: Bytes 0-127 */
1433
1434#define PRINT_NXS(x, y, z...) printf("%-3d : %02x " z "\n", x, (u8)y);
1435#define PRINT_NNXXS(n0, n1, x0, x1, s) \
1436 printf("%-3d-%3d: %02x %02x " s "\n", n0, n1, x0, x1);
1437
1438 PRINT_NXS(0, spd->info_size_crc,
1439 "info_size_crc bytes written into serial memory, CRC coverage");
1440 PRINT_NXS(1, spd->spd_rev,
1441 "spd_rev SPD Revision");
1442 PRINT_NXS(2, spd->mem_type,
1443 "mem_type Key Byte / DRAM Device Type");
1444 PRINT_NXS(3, spd->module_type,
1445 "module_type Key Byte / Module Type");
1446 PRINT_NXS(4, spd->density_banks,
1447 "density_banks SDRAM Density and Banks");
1448 PRINT_NXS(5, spd->addressing,
1449 "addressing SDRAM Addressing");
1450 PRINT_NXS(6, spd->package_type,
1451 "package_type Package type");
1452 PRINT_NXS(7, spd->opt_feature,
1453 "opt_feature Optional features");
1454 PRINT_NXS(8, spd->thermal_ref,
1455 "thermal_ref Thermal and Refresh options");
1456 PRINT_NXS(9, spd->oth_opt_features,
1457 "oth_opt_features Other SDRAM optional features");
1458 PRINT_NXS(10, spd->res_10,
1459 "res_10 Reserved");
1460 PRINT_NXS(11, spd->module_vdd,
1461 "module_vdd Module Nominal Voltage, VDD");
1462 PRINT_NXS(12, spd->organization,
1463 "organization Module Organization");
1464 PRINT_NXS(13, spd->bus_width,
1465 "bus_width Module Memory Bus Width");
1466 PRINT_NXS(14, spd->therm_sensor,
1467 "therm_sensor Module Thermal Sensor");
1468 PRINT_NXS(15, spd->ext_type,
1469 "ext_type Extended module type");
1470 PRINT_NXS(16, spd->res_16,
1471 "res_16 Reserved");
1472 PRINT_NXS(17, spd->timebases,
1473 "timebases MTb and FTB");
1474 PRINT_NXS(18, spd->tck_min,
1475 "tck_min tCKAVGmin");
1476 PRINT_NXS(19, spd->tck_max,
1477 "tck_max TCKAVGmax");
1478 PRINT_NXS(20, spd->caslat_b1,
1479 "caslat_b1 CAS latencies, 1st byte");
1480 PRINT_NXS(21, spd->caslat_b2,
1481 "caslat_b2 CAS latencies, 2nd byte");
1482 PRINT_NXS(22, spd->caslat_b3,
1483 "caslat_b3 CAS latencies, 3rd byte ");
1484 PRINT_NXS(23, spd->caslat_b4,
1485 "caslat_b4 CAS latencies, 4th byte");
1486 PRINT_NXS(24, spd->taa_min,
1487 "taa_min Min CAS Latency Time");
1488 PRINT_NXS(25, spd->trcd_min,
1489 "trcd_min Min RAS# to CAS# Delay Time");
1490 PRINT_NXS(26, spd->trp_min,
1491 "trp_min Min Row Precharge Delay Time");
1492 PRINT_NXS(27, spd->tras_trc_ext,
1493 "tras_trc_ext Upper Nibbles for tRAS and tRC");
1494 PRINT_NXS(28, spd->tras_min_lsb,
1495 "tras_min_lsb tRASmin, lsb");
1496 PRINT_NXS(29, spd->trc_min_lsb,
1497 "trc_min_lsb tRCmin, lsb");
1498 PRINT_NXS(30, spd->trfc1_min_lsb,
1499 "trfc1_min_lsb Min Refresh Recovery Delay Time, LSB");
1500 PRINT_NXS(31, spd->trfc1_min_msb,
1501 "trfc1_min_msb Min Refresh Recovery Delay Time, MSB ");
1502 PRINT_NXS(32, spd->trfc2_min_lsb,
1503 "trfc2_min_lsb Min Refresh Recovery Delay Time, LSB");
1504 PRINT_NXS(33, spd->trfc2_min_msb,
1505 "trfc2_min_msb Min Refresh Recovery Delay Time, MSB");
1506 PRINT_NXS(34, spd->trfc4_min_lsb,
1507 "trfc4_min_lsb Min Refresh Recovery Delay Time, LSB");
1508 PRINT_NXS(35, spd->trfc4_min_msb,
1509 "trfc4_min_msb Min Refresh Recovery Delay Time, MSB");
1510 PRINT_NXS(36, spd->tfaw_msb,
1511 "tfaw_msb Upper Nibble for tFAW");
1512 PRINT_NXS(37, spd->tfaw_min,
1513 "tfaw_min tFAW, lsb");
1514 PRINT_NXS(38, spd->trrds_min,
1515 "trrds_min tRRD_Smin, MTB");
1516 PRINT_NXS(39, spd->trrdl_min,
1517 "trrdl_min tRRD_Lmin, MTB");
1518 PRINT_NXS(40, spd->tccdl_min,
1519 "tccdl_min tCCS_Lmin, MTB");
1520
1521 printf("%-3d-%3d: ", 41, 59); /* Reserved, General Section */
1522 for (i = 41; i <= 59; i++)
1523 printf("%02x ", spd->res_41[i - 41]);
1524
1525 puts("\n");
1526 printf("%-3d-%3d: ", 60, 77);
1527 for (i = 60; i <= 77; i++)
1528 printf("%02x ", spd->mapping[i - 60]);
1529 puts(" mapping[] Connector to SDRAM bit map\n");
1530
1531 PRINT_NXS(117, spd->fine_tccdl_min,
1532 "fine_tccdl_min Fine offset for tCCD_Lmin");
1533 PRINT_NXS(118, spd->fine_trrdl_min,
1534 "fine_trrdl_min Fine offset for tRRD_Lmin");
1535 PRINT_NXS(119, spd->fine_trrds_min,
1536 "fine_trrds_min Fine offset for tRRD_Smin");
1537 PRINT_NXS(120, spd->fine_trc_min,
1538 "fine_trc_min Fine offset for tRCmin");
1539 PRINT_NXS(121, spd->fine_trp_min,
1540 "fine_trp_min Fine offset for tRPmin");
1541 PRINT_NXS(122, spd->fine_trcd_min,
1542 "fine_trcd_min Fine offset for tRCDmin");
1543 PRINT_NXS(123, spd->fine_taa_min,
1544 "fine_taa_min Fine offset for tAAmin");
1545 PRINT_NXS(124, spd->fine_tck_max,
1546 "fine_tck_max Fine offset for tCKAVGmax");
1547 PRINT_NXS(125, spd->fine_tck_min,
1548 "fine_tck_min Fine offset for tCKAVGmin");
1549
1550 /* CRC: Bytes 126-127 */
1551 PRINT_NNXXS(126, 127, spd->crc[0], spd->crc[1], " SPD CRC");
1552
1553 switch (spd->module_type) {
1554 case 0x02: /* UDIMM */
1555 case 0x03: /* SO-DIMM */
1556 PRINT_NXS(128, spd->mod_section.unbuffered.mod_height,
1557 "mod_height (Unbuffered) Module Nominal Height");
1558 PRINT_NXS(129, spd->mod_section.unbuffered.mod_thickness,
1559 "mod_thickness (Unbuffered) Module Maximum Thickness");
1560 PRINT_NXS(130, spd->mod_section.unbuffered.ref_raw_card,
1561 "ref_raw_card (Unbuffered) Reference Raw Card Used");
1562 PRINT_NXS(131, spd->mod_section.unbuffered.addr_mapping,
1563 "addr_mapping (Unbuffered) Address mapping from Edge Connector to DRAM");
1564 PRINT_NNXXS(254, 255, spd->mod_section.unbuffered.crc[0],
1565 spd->mod_section.unbuffered.crc[1], " Module CRC");
1566 break;
1567 case 0x01: /* RDIMM */
1568 PRINT_NXS(128, spd->mod_section.registered.mod_height,
1569 "mod_height (Registered) Module Nominal Height");
1570 PRINT_NXS(129, spd->mod_section.registered.mod_thickness,
1571 "mod_thickness (Registered) Module Maximum Thickness");
1572 PRINT_NXS(130, spd->mod_section.registered.ref_raw_card,
1573 "ref_raw_card (Registered) Reference Raw Card Used");
1574 PRINT_NXS(131, spd->mod_section.registered.modu_attr,
1575 "modu_attr (Registered) DIMM Module Attributes");
1576 PRINT_NXS(132, spd->mod_section.registered.thermal,
1577 "thermal (Registered) Thermal Heat Spreader Solution");
1578 PRINT_NXS(133, spd->mod_section.registered.reg_id_lo,
1579 "reg_id_lo (Registered) Register Manufacturer ID Code, LSB");
1580 PRINT_NXS(134, spd->mod_section.registered.reg_id_hi,
1581 "reg_id_hi (Registered) Register Manufacturer ID Code, MSB");
1582 PRINT_NXS(135, spd->mod_section.registered.reg_rev,
1583 "reg_rev (Registered) Register Revision Number");
1584 PRINT_NXS(136, spd->mod_section.registered.reg_map,
1585 "reg_map (Registered) Address mapping");
1586 PRINT_NNXXS(254, 255, spd->mod_section.registered.crc[0],
1587 spd->mod_section.registered.crc[1], " Module CRC");
1588 break;
1589 case 0x04: /* LRDIMM */
1590 PRINT_NXS(128, spd->mod_section.loadreduced.mod_height,
1591 "mod_height (Loadreduced) Module Nominal Height");
1592 PRINT_NXS(129, spd->mod_section.loadreduced.mod_thickness,
1593 "mod_thickness (Loadreduced) Module Maximum Thickness");
1594 PRINT_NXS(130, spd->mod_section.loadreduced.ref_raw_card,
1595 "ref_raw_card (Loadreduced) Reference Raw Card Used");
1596 PRINT_NXS(131, spd->mod_section.loadreduced.modu_attr,
1597 "modu_attr (Loadreduced) DIMM Module Attributes");
1598 PRINT_NXS(132, spd->mod_section.loadreduced.thermal,
1599 "thermal (Loadreduced) Thermal Heat Spreader Solution");
1600 PRINT_NXS(133, spd->mod_section.loadreduced.reg_id_lo,
1601 "reg_id_lo (Loadreduced) Register Manufacturer ID Code, LSB");
1602 PRINT_NXS(134, spd->mod_section.loadreduced.reg_id_hi,
1603 "reg_id_hi (Loadreduced) Register Manufacturer ID Code, MSB");
1604 PRINT_NXS(135, spd->mod_section.loadreduced.reg_rev,
1605 "reg_rev (Loadreduced) Register Revision Number");
1606 PRINT_NXS(136, spd->mod_section.loadreduced.reg_map,
1607 "reg_map (Loadreduced) Address mapping");
1608 PRINT_NXS(137, spd->mod_section.loadreduced.reg_drv,
1609 "reg_drv (Loadreduced) Reg output drive strength");
1610 PRINT_NXS(138, spd->mod_section.loadreduced.reg_drv_ck,
1611 "reg_drv_ck (Loadreduced) Reg output drive strength for CK");
1612 PRINT_NXS(139, spd->mod_section.loadreduced.data_buf_rev,
1613 "data_buf_rev (Loadreduced) Data Buffer Revision Numbe");
1614 PRINT_NXS(140, spd->mod_section.loadreduced.vrefqe_r0,
1615 "vrefqe_r0 (Loadreduced) DRAM VrefDQ for Package Rank 0");
1616 PRINT_NXS(141, spd->mod_section.loadreduced.vrefqe_r1,
1617 "vrefqe_r1 (Loadreduced) DRAM VrefDQ for Package Rank 1");
1618 PRINT_NXS(142, spd->mod_section.loadreduced.vrefqe_r2,
1619 "vrefqe_r2 (Loadreduced) DRAM VrefDQ for Package Rank 2");
1620 PRINT_NXS(143, spd->mod_section.loadreduced.vrefqe_r3,
1621 "vrefqe_r3 (Loadreduced) DRAM VrefDQ for Package Rank 3");
1622 PRINT_NXS(144, spd->mod_section.loadreduced.data_intf,
1623 "data_intf (Loadreduced) Data Buffer VrefDQ for DRAM Interface");
1624 PRINT_NXS(145, spd->mod_section.loadreduced.data_drv_1866,
1625 "data_drv_1866 (Loadreduced) Data Buffer MDQ Drive Strength and RTT");
1626 PRINT_NXS(146, spd->mod_section.loadreduced.data_drv_2400,
1627 "data_drv_2400 (Loadreduced) Data Buffer MDQ Drive Strength and RTT");
1628 PRINT_NXS(147, spd->mod_section.loadreduced.data_drv_3200,
1629 "data_drv_3200 (Loadreduced) Data Buffer MDQ Drive Strength and RTT");
1630 PRINT_NXS(148, spd->mod_section.loadreduced.dram_drv,
1631 "dram_drv (Loadreduced) DRAM Drive Strength");
1632 PRINT_NXS(149, spd->mod_section.loadreduced.dram_odt_1866,
1633 "dram_odt_1866 (Loadreduced) DRAM ODT (RTT_WR, RTT_NOM)");
1634 PRINT_NXS(150, spd->mod_section.loadreduced.dram_odt_2400,
1635 "dram_odt_2400 (Loadreduced) DRAM ODT (RTT_WR, RTT_NOM)");
1636 PRINT_NXS(151, spd->mod_section.loadreduced.dram_odt_3200,
1637 "dram_odt_3200 (Loadreduced) DRAM ODT (RTT_WR, RTT_NOM)");
1638 PRINT_NXS(152, spd->mod_section.loadreduced.dram_odt_park_1866,
1639 "dram_odt_park_1866 (Loadreduced) DRAM ODT (RTT_PARK)");
1640 PRINT_NXS(153, spd->mod_section.loadreduced.dram_odt_park_2400,
1641 "dram_odt_park_2400 (Loadreduced) DRAM ODT (RTT_PARK)");
1642 PRINT_NXS(154, spd->mod_section.loadreduced.dram_odt_park_3200,
1643 "dram_odt_park_3200 (Loadreduced) DRAM ODT (RTT_PARK)");
1644 PRINT_NNXXS(254, 255, spd->mod_section.loadreduced.crc[0],
1645 spd->mod_section.loadreduced.crc[1],
1646 " Module CRC");
1647 break;
1648 default:
1649 /* Module-specific Section, Unsupported Module Type */
1650 printf("%-3d-%3d: ", 128, 255);
1651
1652 for (i = 128; i <= 255; i++)
York Sunff5ca8d2014-06-05 12:32:15 -07001653 printf("%02x", spd->mod_section.uc[i - 128]);
York Sun2896cb72014-03-27 17:54:47 -07001654
1655 break;
1656 }
1657
1658 /* Unique Module ID: Bytes 320-383 */
1659 PRINT_NXS(320, spd->mmid_lsb, "Module MfgID Code LSB - JEP-106");
1660 PRINT_NXS(321, spd->mmid_msb, "Module MfgID Code MSB - JEP-106");
1661 PRINT_NXS(322, spd->mloc, "Mfg Location");
1662 PRINT_NNXXS(323, 324, spd->mdate[0], spd->mdate[1], "Mfg Date");
1663
1664 printf("%-3d-%3d: ", 325, 328);
1665
1666 for (i = 325; i <= 328; i++)
1667 printf("%02x ", spd->sernum[i - 325]);
1668 printf(" Module Serial Number\n");
1669
1670 printf("%-3d-%3d: ", 329, 348);
1671 for (i = 329; i <= 348; i++)
1672 printf("%02x ", spd->mpart[i - 329]);
1673 printf(" Mfg's Module Part Number\n");
1674
1675 PRINT_NXS(349, spd->mrev, "Module Revision code");
1676 PRINT_NXS(350, spd->dmid_lsb, "DRAM MfgID Code LSB - JEP-106");
1677 PRINT_NXS(351, spd->dmid_msb, "DRAM MfgID Code MSB - JEP-106");
1678 PRINT_NXS(352, spd->stepping, "DRAM stepping");
1679
1680 printf("%-3d-%3d: ", 353, 381);
1681 for (i = 353; i <= 381; i++)
1682 printf("%02x ", spd->msd[i - 353]);
1683 printf(" Mfg's Specific Data\n");
York Sunbd495cf2011-09-16 13:21:35 -07001684}
1685#endif
1686
1687static inline void generic_spd_dump(const generic_spd_eeprom_t *spd)
1688{
York Sunf0626592013-09-30 09:22:09 -07001689#if defined(CONFIG_SYS_FSL_DDR1)
York Sunbd495cf2011-09-16 13:21:35 -07001690 ddr1_spd_dump(spd);
York Sunf0626592013-09-30 09:22:09 -07001691#elif defined(CONFIG_SYS_FSL_DDR2)
York Sunbd495cf2011-09-16 13:21:35 -07001692 ddr2_spd_dump(spd);
York Sunf0626592013-09-30 09:22:09 -07001693#elif defined(CONFIG_SYS_FSL_DDR3)
York Sunbd495cf2011-09-16 13:21:35 -07001694 ddr3_spd_dump(spd);
York Sun2896cb72014-03-27 17:54:47 -07001695#elif defined(CONFIG_SYS_FSL_DDR4)
1696 ddr4_spd_dump(spd);
York Sunbd495cf2011-09-16 13:21:35 -07001697#endif
1698}
1699
1700static void fsl_ddr_printinfo(const fsl_ddr_info_t *pinfo,
1701 unsigned int ctrl_mask,
1702 unsigned int dimm_mask,
1703 unsigned int do_mask)
1704{
1705 unsigned int i, j, retval;
1706
1707 /* STEP 1: DIMM SPD data */
1708 if (do_mask & STEP_GET_SPD) {
York Sunfe845072016-12-28 08:43:45 -08001709 for (i = 0; i < CONFIG_SYS_NUM_DDR_CTLRS; i++) {
York Sunbd495cf2011-09-16 13:21:35 -07001710 if (!(ctrl_mask & (1 << i)))
1711 continue;
1712
1713 for (j = 0; j < CONFIG_DIMM_SLOTS_PER_CTLR; j++) {
1714 if (!(dimm_mask & (1 << j)))
1715 continue;
1716
1717 printf("SPD info: Controller=%u "
1718 "DIMM=%u\n", i, j);
1719 generic_spd_dump(
1720 &(pinfo->spd_installed_dimms[i][j]));
1721 printf("\n");
1722 }
1723 printf("\n");
1724 }
1725 printf("\n");
1726 }
1727
1728 /* STEP 2: DIMM Parameters */
1729 if (do_mask & STEP_COMPUTE_DIMM_PARMS) {
York Sunfe845072016-12-28 08:43:45 -08001730 for (i = 0; i < CONFIG_SYS_NUM_DDR_CTLRS; i++) {
York Sunbd495cf2011-09-16 13:21:35 -07001731 if (!(ctrl_mask & (1 << i)))
1732 continue;
1733 for (j = 0; j < CONFIG_DIMM_SLOTS_PER_CTLR; j++) {
1734 if (!(dimm_mask & (1 << j)))
1735 continue;
1736 printf("DIMM parameters: Controller=%u "
1737 "DIMM=%u\n", i, j);
1738 print_dimm_parameters(
1739 &(pinfo->dimm_params[i][j]));
1740 printf("\n");
1741 }
1742 printf("\n");
1743 }
1744 printf("\n");
1745 }
1746
1747 /* STEP 3: Common Parameters */
1748 if (do_mask & STEP_COMPUTE_COMMON_PARMS) {
York Sunfe845072016-12-28 08:43:45 -08001749 for (i = 0; i < CONFIG_SYS_NUM_DDR_CTLRS; i++) {
York Sunbd495cf2011-09-16 13:21:35 -07001750 if (!(ctrl_mask & (1 << i)))
1751 continue;
1752 printf("\"lowest common\" DIMM parameters: "
1753 "Controller=%u\n", i);
1754 print_lowest_common_dimm_parameters(
1755 &pinfo->common_timing_params[i]);
1756 printf("\n");
1757 }
1758 printf("\n");
1759 }
1760
1761 /* STEP 4: User Configuration Options */
1762 if (do_mask & STEP_GATHER_OPTS) {
York Sunfe845072016-12-28 08:43:45 -08001763 for (i = 0; i < CONFIG_SYS_NUM_DDR_CTLRS; i++) {
York Sunbd495cf2011-09-16 13:21:35 -07001764 if (!(ctrl_mask & (1 << i)))
1765 continue;
1766 printf("User Config Options: Controller=%u\n", i);
1767 print_memctl_options(&pinfo->memctl_opts[i]);
1768 printf("\n");
1769 }
1770 printf("\n");
1771 }
1772
1773 /* STEP 5: Address assignment */
1774 if (do_mask & STEP_ASSIGN_ADDRESSES) {
York Sunfe845072016-12-28 08:43:45 -08001775 for (i = 0; i < CONFIG_SYS_NUM_DDR_CTLRS; i++) {
York Sunbd495cf2011-09-16 13:21:35 -07001776 if (!(ctrl_mask & (1 << i)))
1777 continue;
1778 for (j = 0; j < CONFIG_DIMM_SLOTS_PER_CTLR; j++) {
1779 printf("Address Assignment: Controller=%u "
1780 "DIMM=%u\n", i, j);
1781 printf("Don't have this functionality yet\n");
1782 }
1783 printf("\n");
1784 }
1785 printf("\n");
1786 }
1787
1788 /* STEP 6: computed controller register values */
1789 if (do_mask & STEP_COMPUTE_REGS) {
York Sunfe845072016-12-28 08:43:45 -08001790 for (i = 0; i < CONFIG_SYS_NUM_DDR_CTLRS; i++) {
York Sunbd495cf2011-09-16 13:21:35 -07001791 if (!(ctrl_mask & (1 << i)))
1792 continue;
1793 printf("Computed Register Values: Controller=%u\n", i);
1794 print_fsl_memctl_config_regs(
1795 &pinfo->fsl_ddr_config_reg[i]);
1796 retval = check_fsl_memctl_config_regs(
1797 &pinfo->fsl_ddr_config_reg[i]);
1798 if (retval) {
1799 printf("check_fsl_memctl_config_regs "
1800 "result = %u\n", retval);
1801 }
1802 printf("\n");
1803 }
1804 printf("\n");
1805 }
1806}
1807
1808struct data_strings {
1809 const char *data_name;
1810 unsigned int step_mask;
1811 unsigned int dimm_number_required;
1812};
1813
1814#define DATA_OPTIONS(name, step, dimm) {#name, step, dimm}
1815
James Yang1a9ea452013-01-04 08:14:00 +00001816static unsigned int fsl_ddr_parse_interactive_cmd(
1817 char **argv,
1818 int argc,
1819 unsigned int *pstep_mask,
1820 unsigned int *pctlr_mask,
1821 unsigned int *pdimm_mask,
1822 unsigned int *pdimm_number_required
1823 ) {
1824
York Sunbd495cf2011-09-16 13:21:35 -07001825 static const struct data_strings options[] = {
1826 DATA_OPTIONS(spd, STEP_GET_SPD, 1),
1827 DATA_OPTIONS(dimmparms, STEP_COMPUTE_DIMM_PARMS, 1),
1828 DATA_OPTIONS(commonparms, STEP_COMPUTE_COMMON_PARMS, 0),
1829 DATA_OPTIONS(opts, STEP_GATHER_OPTS, 0),
1830 DATA_OPTIONS(addresses, STEP_ASSIGN_ADDRESSES, 0),
1831 DATA_OPTIONS(regs, STEP_COMPUTE_REGS, 0),
1832 };
1833 static const unsigned int n_opts = ARRAY_SIZE(options);
James Yang1a9ea452013-01-04 08:14:00 +00001834
1835 unsigned int i, j;
1836 unsigned int error = 0;
James Yang1a9ea452013-01-04 08:14:00 +00001837
1838 for (i = 1; i < argc; i++) {
James Yang6c936cf2013-01-04 08:14:01 +00001839 unsigned int matched = 0;
1840
James Yang1a9ea452013-01-04 08:14:00 +00001841 for (j = 0; j < n_opts; j++) {
1842 if (strcmp(options[j].data_name, argv[i]) != 0)
1843 continue;
1844 *pstep_mask |= options[j].step_mask;
1845 *pdimm_number_required =
1846 options[j].dimm_number_required;
1847 matched = 1;
1848 break;
1849 }
1850
1851 if (matched)
1852 continue;
1853
1854 if (argv[i][0] == 'c') {
1855 char c = argv[i][1];
1856 if (isdigit(c))
1857 *pctlr_mask |= 1 << (c - '0');
1858 continue;
1859 }
1860
1861 if (argv[i][0] == 'd') {
1862 char c = argv[i][1];
1863 if (isdigit(c))
1864 *pdimm_mask |= 1 << (c - '0');
1865 continue;
1866 }
1867
1868 printf("unknown arg %s\n", argv[i]);
1869 *pstep_mask = 0;
1870 error = 1;
1871 break;
1872 }
1873
1874 return error;
1875}
1876
James Yang43794382013-01-07 14:01:03 +00001877int fsl_ddr_interactive_env_var_exists(void)
1878{
1879 char buffer[CONFIG_SYS_CBSIZE];
1880
Simon Glass64b723f2017-08-03 12:22:12 -06001881 if (env_get_f("ddr_interactive", buffer, CONFIG_SYS_CBSIZE) >= 0)
James Yang43794382013-01-07 14:01:03 +00001882 return 1;
1883
1884 return 0;
1885}
1886
1887unsigned long long fsl_ddr_interactive(fsl_ddr_info_t *pinfo, int var_is_set)
James Yang1a9ea452013-01-04 08:14:00 +00001888{
1889 unsigned long long ddrsize;
1890 const char *prompt = "FSL DDR>";
1891 char buffer[CONFIG_SYS_CBSIZE];
James Yang43794382013-01-07 14:01:03 +00001892 char buffer2[CONFIG_SYS_CBSIZE];
1893 char *p = NULL;
James Yang1a9ea452013-01-04 08:14:00 +00001894 char *argv[CONFIG_SYS_MAXARGS + 1]; /* NULL terminated */
1895 int argc;
1896 unsigned int next_step = STEP_GET_SPD;
York Sunbd495cf2011-09-16 13:21:35 -07001897 const char *usage = {
1898 "commands:\n"
1899 "print print SPD and intermediate computed data\n"
1900 "reset reboot machine\n"
1901 "recompute reload SPD and options to default and recompute regs\n"
1902 "edit modify spd, parameter, or option\n"
1903 "compute recompute registers from current next_step to end\n"
James Yang15e172a2013-01-04 08:14:02 +00001904 "copy copy parameters\n"
York Sunbd495cf2011-09-16 13:21:35 -07001905 "next_step shows current next_step\n"
1906 "help this message\n"
1907 "go program the memory controller and continue with u-boot\n"
1908 };
1909
James Yang43794382013-01-07 14:01:03 +00001910 if (var_is_set) {
Simon Glass64b723f2017-08-03 12:22:12 -06001911 if (env_get_f("ddr_interactive", buffer2,
1912 CONFIG_SYS_CBSIZE) > 0)
James Yang43794382013-01-07 14:01:03 +00001913 p = buffer2;
Simon Glass64b723f2017-08-03 12:22:12 -06001914 else
James Yang43794382013-01-07 14:01:03 +00001915 var_is_set = 0;
James Yang43794382013-01-07 14:01:03 +00001916 }
1917
York Sunbd495cf2011-09-16 13:21:35 -07001918 /*
1919 * The strategy for next_step is that it points to the next
1920 * step in the computation process that needs to be done.
1921 */
1922 while (1) {
James Yang43794382013-01-07 14:01:03 +00001923 if (var_is_set) {
1924 char *pend = strchr(p, ';');
1925 if (pend) {
1926 /* found command separator, copy sub-command */
1927 *pend = '\0';
1928 strcpy(buffer, p);
1929 p = pend + 1;
1930 } else {
1931 /* separator not found, copy whole string */
1932 strcpy(buffer, p);
1933 p = NULL;
1934 var_is_set = 0;
1935 }
1936 } else {
1937 /*
1938 * No need to worry for buffer overflow here in
Simon Glassbe6aafc2014-04-10 20:01:27 -06001939 * this function; cli_readline() maxes out at
1940 * CFG_CBSIZE
James Yang43794382013-01-07 14:01:03 +00001941 */
Simon Glassbe6aafc2014-04-10 20:01:27 -06001942 cli_readline_into_buffer(prompt, buffer, 0);
James Yang43794382013-01-07 14:01:03 +00001943 }
Simon Glassbe6aafc2014-04-10 20:01:27 -06001944 argc = cli_simple_parse_line(buffer, argv);
York Sunbd495cf2011-09-16 13:21:35 -07001945 if (argc == 0)
1946 continue;
1947
1948
1949 if (strcmp(argv[0], "help") == 0) {
1950 puts(usage);
1951 continue;
1952 }
1953
1954 if (strcmp(argv[0], "next_step") == 0) {
1955 printf("next_step = 0x%02X (%s)\n",
1956 next_step,
1957 step_to_string(next_step));
1958 continue;
1959 }
1960
James Yang15e172a2013-01-04 08:14:02 +00001961 if (strcmp(argv[0], "copy") == 0) {
1962 unsigned int error = 0;
1963 unsigned int step_mask = 0;
1964 unsigned int src_ctlr_mask = 0;
1965 unsigned int src_dimm_mask = 0;
1966 unsigned int dimm_number_required = 0;
1967 unsigned int src_ctlr_num = 0;
1968 unsigned int src_dimm_num = 0;
1969 unsigned int dst_ctlr_num = -1;
1970 unsigned int dst_dimm_num = -1;
1971 unsigned int i, num_dest_parms;
1972
1973 if (argc == 1) {
1974 printf("copy <src c#> <src d#> <spd|dimmparms|commonparms|opts|addresses|regs> <dst c#> <dst d#>\n");
1975 continue;
1976 }
1977
1978 error = fsl_ddr_parse_interactive_cmd(
1979 argv, argc,
1980 &step_mask,
1981 &src_ctlr_mask,
1982 &src_dimm_mask,
1983 &dimm_number_required
1984 );
1985
1986 /* XXX: only dimm_number_required and step_mask will
1987 be used by this function. Parse the controller and
1988 DIMM number separately because it is easier. */
1989
1990 if (error)
1991 continue;
1992
1993 /* parse source destination controller / DIMM */
1994
1995 num_dest_parms = dimm_number_required ? 2 : 1;
1996
1997 for (i = 0; i < argc; i++) {
1998 if (argv[i][0] == 'c') {
1999 char c = argv[i][1];
2000 if (isdigit(c)) {
2001 src_ctlr_num = (c - '0');
2002 break;
2003 }
2004 }
2005 }
2006
2007 for (i = 0; i < argc; i++) {
2008 if (argv[i][0] == 'd') {
2009 char c = argv[i][1];
2010 if (isdigit(c)) {
2011 src_dimm_num = (c - '0');
2012 break;
2013 }
2014 }
2015 }
2016
2017 /* parse destination controller / DIMM */
2018
2019 for (i = argc - 1; i >= argc - num_dest_parms; i--) {
2020 if (argv[i][0] == 'c') {
2021 char c = argv[i][1];
2022 if (isdigit(c)) {
2023 dst_ctlr_num = (c - '0');
2024 break;
2025 }
2026 }
2027 }
2028
2029 for (i = argc - 1; i >= argc - num_dest_parms; i--) {
2030 if (argv[i][0] == 'd') {
2031 char c = argv[i][1];
2032 if (isdigit(c)) {
2033 dst_dimm_num = (c - '0');
2034 break;
2035 }
2036 }
2037 }
2038
2039 /* TODO: validate inputs */
2040
2041 debug("src_ctlr_num = %u, src_dimm_num = %u, dst_ctlr_num = %u, dst_dimm_num = %u, step_mask = %x\n",
2042 src_ctlr_num, src_dimm_num, dst_ctlr_num, dst_dimm_num, step_mask);
2043
2044
2045 switch (step_mask) {
2046
2047 case STEP_GET_SPD:
2048 memcpy(&(pinfo->spd_installed_dimms[dst_ctlr_num][dst_dimm_num]),
2049 &(pinfo->spd_installed_dimms[src_ctlr_num][src_dimm_num]),
2050 sizeof(pinfo->spd_installed_dimms[0][0]));
2051 break;
2052
2053 case STEP_COMPUTE_DIMM_PARMS:
2054 memcpy(&(pinfo->dimm_params[dst_ctlr_num][dst_dimm_num]),
2055 &(pinfo->dimm_params[src_ctlr_num][src_dimm_num]),
2056 sizeof(pinfo->dimm_params[0][0]));
2057 break;
2058
2059 case STEP_COMPUTE_COMMON_PARMS:
2060 memcpy(&(pinfo->common_timing_params[dst_ctlr_num]),
2061 &(pinfo->common_timing_params[src_ctlr_num]),
2062 sizeof(pinfo->common_timing_params[0]));
2063 break;
2064
2065 case STEP_GATHER_OPTS:
2066 memcpy(&(pinfo->memctl_opts[dst_ctlr_num]),
2067 &(pinfo->memctl_opts[src_ctlr_num]),
2068 sizeof(pinfo->memctl_opts[0]));
2069 break;
2070
2071 /* someday be able to have addresses to copy addresses... */
2072
2073 case STEP_COMPUTE_REGS:
2074 memcpy(&(pinfo->fsl_ddr_config_reg[dst_ctlr_num]),
2075 &(pinfo->fsl_ddr_config_reg[src_ctlr_num]),
2076 sizeof(pinfo->memctl_opts[0]));
2077 break;
2078
2079 default:
2080 printf("unexpected step_mask value\n");
2081 }
2082
2083 continue;
2084
2085 }
2086
York Sunbd495cf2011-09-16 13:21:35 -07002087 if (strcmp(argv[0], "edit") == 0) {
York Sunbd495cf2011-09-16 13:21:35 -07002088 unsigned int error = 0;
2089 unsigned int step_mask = 0;
2090 unsigned int ctlr_mask = 0;
2091 unsigned int dimm_mask = 0;
2092 char *p_element = NULL;
2093 char *p_value = NULL;
2094 unsigned int dimm_number_required = 0;
2095 unsigned int ctrl_num;
2096 unsigned int dimm_num;
York Sunbd495cf2011-09-16 13:21:35 -07002097
2098 if (argc == 1) {
2099 /* Only the element and value must be last */
2100 printf("edit <c#> <d#> "
2101 "<spd|dimmparms|commonparms|opts|"
2102 "addresses|regs> <element> <value>\n");
2103 printf("for spd, specify byte number for "
2104 "element\n");
2105 continue;
2106 }
2107
James Yang1a9ea452013-01-04 08:14:00 +00002108 error = fsl_ddr_parse_interactive_cmd(
2109 argv, argc - 2,
2110 &step_mask,
2111 &ctlr_mask,
2112 &dimm_mask,
2113 &dimm_number_required
2114 );
York Sunbd495cf2011-09-16 13:21:35 -07002115
2116 if (error)
2117 continue;
2118
2119
2120 /* Check arguments */
2121
2122 /* ERROR: If no steps were found */
2123 if (step_mask == 0) {
2124 printf("Error: No valid steps were specified "
2125 "in argument.\n");
2126 continue;
2127 }
2128
2129 /* ERROR: If multiple steps were found */
2130 if (step_mask & (step_mask - 1)) {
2131 printf("Error: Multiple steps specified in "
2132 "argument.\n");
2133 continue;
2134 }
2135
2136 /* ERROR: Controller not specified */
2137 if (ctlr_mask == 0) {
2138 printf("Error: controller number not "
2139 "specified or no element and "
2140 "value specified\n");
2141 continue;
2142 }
2143
2144 if (ctlr_mask & (ctlr_mask - 1)) {
2145 printf("Error: multiple controllers "
2146 "specified, %X\n", ctlr_mask);
2147 continue;
2148 }
2149
2150 /* ERROR: DIMM number not specified */
2151 if (dimm_number_required && dimm_mask == 0) {
2152 printf("Error: DIMM number number not "
2153 "specified or no element and "
2154 "value specified\n");
2155 continue;
2156 }
2157
2158 if (dimm_mask & (dimm_mask - 1)) {
2159 printf("Error: multipled DIMMs specified\n");
2160 continue;
2161 }
2162
2163 p_element = argv[argc - 2];
2164 p_value = argv[argc - 1];
2165
2166 ctrl_num = __ilog2(ctlr_mask);
2167 dimm_num = __ilog2(dimm_mask);
2168
2169 switch (step_mask) {
2170 case STEP_GET_SPD:
2171 {
2172 unsigned int element_num;
2173 unsigned int value;
2174
2175 element_num = simple_strtoul(p_element,
2176 NULL, 0);
2177 value = simple_strtoul(p_value,
2178 NULL, 0);
2179 fsl_ddr_spd_edit(pinfo,
2180 ctrl_num,
2181 dimm_num,
2182 element_num,
2183 value);
2184 next_step = STEP_COMPUTE_DIMM_PARMS;
2185 }
2186 break;
2187
2188 case STEP_COMPUTE_DIMM_PARMS:
2189 fsl_ddr_dimm_parameters_edit(
2190 pinfo, ctrl_num, dimm_num,
2191 p_element, p_value);
2192 next_step = STEP_COMPUTE_COMMON_PARMS;
2193 break;
2194
2195 case STEP_COMPUTE_COMMON_PARMS:
2196 lowest_common_dimm_parameters_edit(pinfo,
2197 ctrl_num, p_element, p_value);
2198 next_step = STEP_GATHER_OPTS;
2199 break;
2200
2201 case STEP_GATHER_OPTS:
2202 fsl_ddr_options_edit(pinfo, ctrl_num,
2203 p_element, p_value);
2204 next_step = STEP_ASSIGN_ADDRESSES;
2205 break;
2206
2207 case STEP_ASSIGN_ADDRESSES:
2208 printf("editing of address assignment "
2209 "not yet implemented\n");
2210 break;
2211
2212 case STEP_COMPUTE_REGS:
2213 {
2214 fsl_ddr_regs_edit(pinfo,
2215 ctrl_num,
2216 p_element,
2217 p_value);
2218 next_step = STEP_PROGRAM_REGS;
2219 }
2220 break;
2221
2222 default:
2223 printf("programming error\n");
2224 while (1)
2225 ;
2226 break;
2227 }
2228 continue;
2229 }
2230
2231 if (strcmp(argv[0], "reset") == 0) {
2232 /*
2233 * Reboot machine.
2234 * Args don't seem to matter because this
2235 * doesn't return
2236 */
2237 do_reset(NULL, 0, 0, NULL);
York Sun7d69ea32012-10-08 07:44:22 +00002238 printf("Reset didn't work\n");
York Sunbd495cf2011-09-16 13:21:35 -07002239 }
2240
2241 if (strcmp(argv[0], "recompute") == 0) {
2242 /*
2243 * Recalculate everything, starting with
2244 * loading SPD EEPROM from DIMMs
2245 */
2246 next_step = STEP_GET_SPD;
2247 ddrsize = fsl_ddr_compute(pinfo, next_step, 0);
2248 continue;
2249 }
2250
2251 if (strcmp(argv[0], "compute") == 0) {
2252 /*
2253 * Compute rest of steps starting at
2254 * the current next_step/
2255 */
2256 ddrsize = fsl_ddr_compute(pinfo, next_step, 0);
2257 continue;
2258 }
2259
2260 if (strcmp(argv[0], "print") == 0) {
York Sunbd495cf2011-09-16 13:21:35 -07002261 unsigned int error = 0;
2262 unsigned int step_mask = 0;
2263 unsigned int ctlr_mask = 0;
2264 unsigned int dimm_mask = 0;
James Yang1a9ea452013-01-04 08:14:00 +00002265 unsigned int dimm_number_required = 0;
York Sunbd495cf2011-09-16 13:21:35 -07002266
2267 if (argc == 1) {
2268 printf("print [c<n>] [d<n>] [spd] [dimmparms] "
2269 "[commonparms] [opts] [addresses] [regs]\n");
2270 continue;
2271 }
2272
James Yang1a9ea452013-01-04 08:14:00 +00002273 error = fsl_ddr_parse_interactive_cmd(
2274 argv, argc,
2275 &step_mask,
2276 &ctlr_mask,
2277 &dimm_mask,
2278 &dimm_number_required
2279 );
York Sunbd495cf2011-09-16 13:21:35 -07002280
2281 if (error)
2282 continue;
2283
2284 /* If no particular controller was found, print all */
2285 if (ctlr_mask == 0)
2286 ctlr_mask = 0xFF;
2287
2288 /* If no particular dimm was found, print all dimms. */
2289 if (dimm_mask == 0)
2290 dimm_mask = 0xFF;
2291
2292 /* If no steps were found, print all steps. */
2293 if (step_mask == 0)
2294 step_mask = STEP_ALL;
2295
2296 fsl_ddr_printinfo(pinfo, ctlr_mask,
2297 dimm_mask, step_mask);
2298 continue;
2299 }
2300
2301 if (strcmp(argv[0], "go") == 0) {
2302 if (next_step)
2303 ddrsize = fsl_ddr_compute(pinfo, next_step, 0);
2304 break;
2305 }
2306
2307 printf("unknown command %s\n", argv[0]);
2308 }
2309
2310 debug("end of memory = %llu\n", (u64)ddrsize);
2311
2312 return ddrsize;
2313}