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