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
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
|
/*
* This file is part of the coreboot project.
*
* Copyright (C) 2007 Advanced Micro Devices, Inc.
* Copyright (C) 2015 Timothy Pearson <tpearson@raptorengineeringinc.com>, Raptor Engineering
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
/*----------------------------------------------------------------------------
* MODULES USED
*
*----------------------------------------------------------------------------
*/
#undef FILECODE
#define FILECODE 0xF002
#include "h3ncmn.h"
#include "h3finit.h"
#include "h3ffeat.h"
#include "AsPsNb.h"
#include <arch/cpu.h>
#include <device/pci.h>
#include <cpu/amd/msr.h>
#include <device/pci_def.h>
#include <northbridge/amd/amdfam10/raminit.h>
#include <northbridge/amd/amdfam10/amdfam10.h>
/*----------------------------------------------------------------------------
* DEFINITIONS AND MACROS
*
*----------------------------------------------------------------------------
*/
/* CPU Northbridge Functions */
#define CPU_HTNB_FUNC_00 0
#define CPU_HTNB_FUNC_04 4
#define CPU_ADDR_FUNC_01 1
#define CPU_NB_FUNC_03 3
#define CPU_NB_FUNC_05 5
/* Function 0 registers */
#define REG_ROUTE0_0X40 0x40
#define REG_ROUTE1_0X44 0x44
#define REG_NODE_ID_0X60 0x60
#define REG_UNIT_ID_0X64 0x64
#define REG_LINK_TRANS_CONTROL_0X68 0x68
#define REG_LINK_INIT_CONTROL_0X6C 0x6c
#define REG_HT_CAP_BASE_0X80 0x80
#define REG_NORTHBRIDGE_CFG_3X8C 0x8c
#define REG_HT_LINK_RETRY0_0X130 0x130
#define REG_HT_TRAFFIC_DIST_0X164 0x164
#define REG_HT_LINK_EXT_CONTROL0_0X170 0x170
#define HT_CONTROL_CLEAR_CRC (~(3 << 8))
/* Function 1 registers */
#define REG_ADDR_CONFIG_MAP0_1XE0 0xE0
#define CPU_ADDR_NUM_CONFIG_MAPS 4
/* Function 3 registers */
#define REG_NB_SRI_XBAR_BUF_3X70 0x70
#define REG_NB_MCT_XBAR_BUF_3X78 0x78
#define REG_NB_FIFOPTR_3XDC 0xDC
#define REG_NB_CAPABILITY_3XE8 0xE8
#define REG_NB_CPUID_3XFC 0xFC
#define REG_NB_LINK_XCS_TOKEN0_3X148 0x148
#define REG_NB_DOWNCORE_3X190 0x190
#define REG_NB_CAPABILITY_5X84 0x84
/* Function 4 registers */
/*----------------------------------------------------------------------------
* TYPEDEFS AND STRUCTURES
*
*----------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------
* PROTOTYPES OF LOCAL FUNCTIONS
*
*----------------------------------------------------------------------------
*/
/***************************************************************************
*** FAMILY/NORTHBRIDGE SPECIFIC FUNCTIONS ***
***************************************************************************/
inline uint8_t is_gt_rev_d(void)
{
uint8_t fam15h = 0;
uint8_t rev_gte_d = 0;
uint32_t family;
uint32_t model;
family = model = cpuid_eax(0x80000001);
model = ((model & 0xf0000) >> 12) | ((model & 0xf0) >> 4);
family = ((family & 0xf00000) >> 16) | ((family & 0xf00) >> 8);
if (family >= 0x6f)
/* Family 15h or later */
fam15h = 1;
if ((model >= 0x8) || fam15h)
/* Revision D or later */
rev_gte_d = 1;
return rev_gte_d;
}
/***************************************************************************//**
*
* SBDFO
* makeLinkBase(u8 currentNode, u8 currentLink)
*
* Description:
* Private to northbridge implementation. Return the HT Host capability base
* PCI config address for a link.
*
* Parameters:
* @param[in] node = the node this link is on
* @param[in] link = the link
*
*****************************************************************************/
static SBDFO makeLinkBase(u8 node, u8 link)
{
SBDFO linkBase;
/* With rev F can not be called with a 4th link or with the sublinks */
if (link < 4)
linkBase = MAKE_SBDFO(makePCISegmentFromNode(node),
makePCIBusFromNode(node),
makePCIDeviceFromNode(node),
CPU_HTNB_FUNC_00,
REG_HT_CAP_BASE_0X80 + link*HT_HOST_CAP_SIZE);
else
linkBase = MAKE_SBDFO(makePCISegmentFromNode(node),
makePCIBusFromNode(node),
makePCIDeviceFromNode(node),
CPU_HTNB_FUNC_04,
REG_HT_CAP_BASE_0X80 + (link-4)*HT_HOST_CAP_SIZE);
return linkBase;
}
/***************************************************************************//**
*
* void
* setHtControlRegisterBits(SBDFO reg, u8 hiBit, u8 loBit, u32 *pValue)
*
* Description:
* Private to northbridge implementation. Provide a common routine for accessing the
* HT Link Control registers (84, a4, c4, e4), to enforce not clearing the
* HT CRC error bits. Replaces direct use of AmdPCIWriteBits().
* NOTE: This routine is called for IO Devices as well as CPUs!
*
* Parameters:
* @param[in] reg = the PCI config address the control register
* @param[in] hiBit = the high bit number
* @param[in] loBit = the low bit number
* @param[in] pValue = the value to write to that bit range. Bit 0 => loBit.
*
*****************************************************************************/
static void setHtControlRegisterBits(SBDFO reg, u8 hiBit, u8 loBit, u32 *pValue)
{
u32 temp, mask;
ASSERT((hiBit < 32) && (loBit < 32) && (hiBit >= loBit) && ((reg & 0x3) == 0));
ASSERT((hiBit < 8) || (loBit > 9));
/* A 1<<32 == 1<<0 due to x86 SHL instruction, so skip if that is the case */
if ((hiBit-loBit) != 31)
mask = (((u32)1 << (hiBit-loBit+1))-1);
else
mask = (u32)0xFFFFFFFF;
AmdPCIRead(reg, &temp);
temp &= ~(mask << loBit);
temp |= (*pValue & mask) << loBit;
temp &= (u32)HT_CONTROL_CLEAR_CRC;
AmdPCIWrite(reg, &temp);
}
/***************************************************************************//**
*
* static void
* writeRoutingTable(u8 node, u8 target, u8 Link, cNorthBridge *nb)
*
* Description:
* This routine will modify the routing tables on the
* SourceNode to cause it to route both request and response traffic to the
* targetNode through the specified Link.
*
* NOTE: This routine is to be used for early discovery and initialization. The
* final routing tables must be loaded some other way because this
* routine does not address the issue of probes, or independent request
* response paths.
*
* Parameters:
* @param[in] node = the node that will have it's routing tables modified.
* @param[in] target = For routing to node target
* @param[in] link = Link from node to target
* @param[in] *nb = this northbridge
*
*****************************************************************************/
static void writeRoutingTable(u8 node, u8 target, u8 link, cNorthBridge *nb)
{
#ifndef HT_BUILD_NC_ONLY
u32 temp = (nb->selfRouteResponseMask | nb->selfRouteRequestMask) << (link + 1);
ASSERT((node < nb->maxNodes) && (target < nb->maxNodes) && (link < nb->maxLinks));
AmdPCIWrite(MAKE_SBDFO(makePCISegmentFromNode(node),
makePCIBusFromNode(node),
makePCIDeviceFromNode(node),
CPU_HTNB_FUNC_00,
REG_ROUTE0_0X40 + target*4),
&temp);
#else
STOP_HERE;
#endif
}
/***************************************************************************//**
*
* static void
* writeNodeID(u8 node, u8 nodeID, cNorthBridge *nb)
*
* Description:
* Modifies the NodeID register on the target node
*
* Parameters:
* @param[in] node = the node that will have its NodeID altered.
* @param[in] nodeID = the new value for NodeID
* @param[in] *nb = this northbridge
*
*****************************************************************************/
static void writeNodeID(u8 node, u8 nodeID, cNorthBridge *nb)
{
u32 temp;
ASSERT((node < nb->maxNodes) && (nodeID < nb->maxNodes));
if (is_fam15h()) {
temp = 1;
AmdPCIWriteBits(MAKE_SBDFO(makePCISegmentFromNode(node),
makePCIBusFromNode(node),
makePCIDeviceFromNode(node),
CPU_NB_FUNC_03,
REG_NORTHBRIDGE_CFG_3X8C),
22, 22, &temp);
}
temp = nodeID;
AmdPCIWriteBits(MAKE_SBDFO(makePCISegmentFromNode(node),
makePCIBusFromNode(node),
makePCIDeviceFromNode(node),
CPU_HTNB_FUNC_00,
REG_NODE_ID_0X60),
2, 0, &temp);
}
/***************************************************************************//**
*
* static void
* readDefLnk(u8 node, cNorthBridge *nb)
*
* Description:
* Read the DefLnk (the source link of the current packet)
* from node
*
* Parameters:
* @param[in] node = the node that will have its NodeID altered.
* @param[in] *nb = this northbridge
* @return The HyperTransport link where the request to
* read the default link came from. Since this
* code is running on the BSP, this should be the link
* pointing back towards the BSP.
*
*****************************************************************************/
static u8 readDefLnk(u8 node, cNorthBridge *nb)
{
u32 deflink = 0;
SBDFO licr;
u32 temp;
licr = MAKE_SBDFO(makePCISegmentFromNode(node),
makePCIBusFromNode(node),
makePCIDeviceFromNode(node),
CPU_HTNB_FUNC_00,
REG_LINK_INIT_CONTROL_0X6C);
ASSERT((node < nb->maxNodes));
AmdPCIReadBits(licr, 3, 2, &deflink);
AmdPCIReadBits(licr, 8, 8, &temp); /* on rev F, this bit is reserved == 0 */
deflink |= temp << 2;
return (u8)deflink;
}
/***************************************************************************//**
*
* static void
* enableRoutingTables(u8 node, cNorthBridge *nb)
*
* Description:
* Turns routing tables on for a given node
*
* Parameters:
* @param[in] node = the node that will have it's routing tables enabled
* @param[in] *nb = this northbridge
*
*****************************************************************************/
static void enableRoutingTables(u8 node, cNorthBridge *nb)
{
u32 temp = 0;
ASSERT((node < nb->maxNodes));
AmdPCIWriteBits(MAKE_SBDFO(makePCISegmentFromNode(node),
makePCIBusFromNode(node),
makePCIDeviceFromNode(node),
CPU_HTNB_FUNC_00,
REG_LINK_INIT_CONTROL_0X6C),
0, 0, &temp);
}
/***************************************************************************//**
*
* static BOOL
* verifyLinkIsCoherent(u8 node, u8 Link, cNorthBridge *nbk)
*
* Description:
* Verify that the link is coherent, connected, and ready
*
* Parameters:
* @param[in] node = the node that will be examined
* @param[in] link = the link on that Node to examine
* @param[in] *nb = this northbridge
* @return true - The link has the following status
* linkCon = 1, Link is connected
* InitComplete = 1, Link initialization is complete
* NC = 0, Link is coherent
* UniP-cLDT = 0, Link is not Uniprocessor cLDT
* LinkConPend = 0 Link connection is not pending
* false- The link has some other status
*
*****************************************************************************/
static BOOL verifyLinkIsCoherent(u8 node, u8 link, cNorthBridge *nb)
{
#ifndef HT_BUILD_NC_ONLY
u32 linkType;
SBDFO linkBase;
ASSERT((node < nb->maxNodes) && (link < nb->maxLinks));
linkBase = makeLinkBase(node, link);
/* FN0_98/A4/C4 = LDT Type Register */
AmdPCIRead(linkBase + HTHOST_LINK_TYPE_REG, &linkType);
/* Verify LinkCon = 1, InitComplete = 1, NC = 0, UniP-cLDT = 0, LinkConPend = 0 */
return (linkType & HTHOST_TYPE_MASK) == HTHOST_TYPE_COHERENT;
#else
return 0;
#endif /* HT_BUILD_NC_ONLY */
}
/***************************************************************************//**
*
* static bool
* readTrueLinkFailStatus(u8 node, u8 link, sMainData *pDat, cNorthBridge *nb)
*
* Description:
* Return the LinkFailed status AFTER an attempt is made to clear the bit.
* Also, call event notify if a Hardware Fault caused a synch flood on a previous boot.
*
* The table below summarizes correct responses of this routine.
* Family before after unconnected Notify? return
* 0F 0 0 0 No 0
* 0F 1 0 0 Yes 0
* 0F 1 1 X No 1
* 10 0 0 0 No 0
* 10 1 0 0 Yes 0
* 10 1 0 3 No 1
*
* Parameters:
* @param[in] node = the node that will be examined
* @param[in] link = the link on that node to examine
* @param[in] *pDat = access to call back routine
* @param[in] *nb = this northbridge
* @return true - the link is not connected or has hard error
* false- if the link is connected
*
*****************************************************************************/
static BOOL readTrueLinkFailStatus(u8 node, u8 link, sMainData *pDat, cNorthBridge *nb)
{
u32 before, after, unconnected, crc;
SBDFO linkBase;
ASSERT((node < nb->maxNodes) && (link < nb->maxLinks));
linkBase = makeLinkBase(node, link);
/* Save the CRC status before doing anything else.
* Read, Clear, the Re-read the error bits in the Link Control Register
* FN0_84/A4/C4[4] = LinkFail bit
* and the connection status, TransOff and EndOfChain
*/
AmdPCIReadBits(linkBase + HTHOST_LINK_CONTROL_REG, 9, 8, &crc);
AmdPCIReadBits(linkBase + HTHOST_LINK_CONTROL_REG, 4, 4, &before);
setHtControlRegisterBits(linkBase + HTHOST_LINK_CONTROL_REG, 4, 4, &before);
AmdPCIReadBits(linkBase + HTHOST_LINK_CONTROL_REG, 4, 4, &after);
AmdPCIReadBits(linkBase + HTHOST_LINK_CONTROL_REG, 7, 6, &unconnected);
if (before != after)
{
if (!unconnected)
{
if (crc != 0)
{
/* A synch flood occurred due to HT CRC */
if (pDat->HtBlock->AMD_CB_EventNotify)
{
/* Pass the node and link on which the generic synch flood event occurred. */
sHtEventHWHtCrc evt;
evt.eSize = sizeof(sHtEventHWHtCrc);
evt.node = node;
evt.link = link;
evt.laneMask = (uint8)crc;
pDat->HtBlock->AMD_CB_EventNotify(HT_EVENT_CLASS_HW_FAULT,
HT_EVENT_HW_HTCRC,
(u8 *)&evt);
}
}
else
{
/* Some synch flood occurred */
if (pDat->HtBlock->AMD_CB_EventNotify)
{
/* Pass the node and link on which the generic synch flood event occurred. */
sHtEventHWSynchFlood evt;
evt.eSize = sizeof(sHtEventHWSynchFlood);
evt.node = node;
evt.link = link;
pDat->HtBlock->AMD_CB_EventNotify(HT_EVENT_CLASS_HW_FAULT,
HT_EVENT_HW_SYNCHFLOOD,
(u8 *)&evt);
}
}
}
}
return ((after != 0) || unconnected);
}
/***************************************************************************//**
*
* static u8
* readToken(u8 node, cNorthBridge *nb)
*
* Description:
* Read the token stored in the scratchpad register
* NOTE: The location used to store the token is arbitrary. The only
* requirement is that the location warm resets to zero, and that
* using it will have no ill-effects during HyperTransport initialization.
*
* Parameters:
* @param[in] node = the node that will be examined
* @param[in] *nb = this northbridge
* @return the Token read from the node
*
*****************************************************************************/
static u8 readToken(u8 node, cNorthBridge *nb)
{
u32 temp;
ASSERT((node < nb->maxNodes));
/* Use CpuCnt as a scratch register */
/* Limiting use to 4 bits makes code GH to rev F compatible. */
AmdPCIReadBits(MAKE_SBDFO(makePCISegmentFromNode(node),
makePCIBusFromNode(node),
makePCIDeviceFromNode(node),
CPU_HTNB_FUNC_00,
REG_NODE_ID_0X60),
19, 16, &temp);
return (u8)temp;
}
/***************************************************************************//**
*
* static void
* writeToken(u8 node, u8 Value, cNorthBridge *nb)
*
* Description:
* Write the token stored in the scratchpad register
* NOTE: The location used to store the token is arbitrary. The only
* requirement is that the location warm resets to zero, and that
* using it will have no ill-effects during HyperTransport initialization.
* Limiting use to 4 bits makes code GH to rev F compatible.
*
* Parameters:
* @param[in] node = the node that will be examined
* @param value
* @param[in] *nb = this northbridge
*
*****************************************************************************/
static void writeToken(u8 node, u8 value, cNorthBridge *nb)
{
u32 temp = value;
ASSERT((node < nb->maxNodes));
/* Use CpuCnt as a scratch register */
/* Limiting use to 4 bits makes code GH to rev F compatible. */
AmdPCIWriteBits(MAKE_SBDFO(makePCISegmentFromNode(node),
makePCIBusFromNode(node),
makePCIDeviceFromNode(node),
CPU_HTNB_FUNC_00,
REG_NODE_ID_0X60),
19, 16, &temp);
}
/***************************************************************************//**
*
* static u8
* fam0FGetNumCoresOnNode(u8 node, cNorthBridge *nb)
*
* Description:
* Return the number of cores (1 based count) on node.
*
* Parameters:
* @param[in] node = the node that will be examined
* @param[in] *nb = this northbridge
* @return = the number of cores
*
* ---------------------------------------------------------------------------------------
*/
static u8 fam0FGetNumCoresOnNode(u8 node, cNorthBridge *nb)
{
u32 temp;
ASSERT((node < nb->maxNodes));
/* Read CmpCap */
AmdPCIReadBits(MAKE_SBDFO(makePCISegmentFromNode(node),
makePCIBusFromNode(node),
makePCIDeviceFromNode(node),
CPU_NB_FUNC_03,
REG_NB_CAPABILITY_3XE8),
13, 12, &temp);
/* and add one */
return (u8)(temp+1);
}
/***************************************************************************//**
*
* static u8
* fam10GetNumCoresOnNode(u8 node, cNorthBridge *nb)
*
* Description:
* Return the number of cores (1 based count) on node.
*
* Parameters:
* @param[in] node = the node that will be examined
* @param[in] *nb = this northbridge
* @return = the number of cores
*
*
*/
static u8 fam10GetNumCoresOnNode(u8 node, cNorthBridge *nb)
{
u32 temp, leveling, cores;
u8 i;
ASSERT((node < nb->maxNodes));
/* Read CmpCap [2][1:0] */
AmdPCIReadBits(MAKE_SBDFO(makePCISegmentFromNode(node),
makePCIBusFromNode(node),
makePCIDeviceFromNode(node),
CPU_NB_FUNC_03,
REG_NB_CAPABILITY_3XE8),
15, 12, &temp);
/* bits[15,13,12] specify the cores */
temp = ((temp & 8) >> 1) + (temp & 3);
cores = temp + 1;
/* Support Downcoring */
AmdPCIReadBits (MAKE_SBDFO(makePCISegmentFromNode(node),
makePCIBusFromNode(node),
makePCIDeviceFromNode(node),
CPU_NB_FUNC_03,
REG_NB_DOWNCORE_3X190),
3, 0, &leveling);
for (i = 0; i < cores; i++)
{
if (leveling & ((u32) 1 << i))
{
temp--;
}
}
return (u8)(temp+1);
}
/***************************************************************************//**
*
* static u8
* fam15GetNumCoresOnNode(u8 node, cNorthBridge *nb)
*
* Description:
* Return the number of cores (1 based count) on node.
*
* Parameters:
* @param[in] node = the node that will be examined
* @param[in] *nb = this northbridge
* @return = the number of cores
*
*
*/
static u8 fam15GetNumCoresOnNode(u8 node, cNorthBridge *nb)
{
u32 temp, leveling, cores;
u8 i;
ASSERT((node < nb->maxNodes));
/* Read CmpCap [7:0] */
AmdPCIReadBits(MAKE_SBDFO(makePCISegmentFromNode(node),
makePCIBusFromNode(node),
makePCIDeviceFromNode(node),
CPU_NB_FUNC_05,
REG_NB_CAPABILITY_5X84),
7, 0, &temp);
/* bits[7:0] specify the cores */
temp = temp & 0xff;
cores = temp + 1;
/* Support Downcoring */
AmdPCIReadBits (MAKE_SBDFO(makePCISegmentFromNode(node),
makePCIBusFromNode(node),
makePCIDeviceFromNode(node),
CPU_NB_FUNC_03,
REG_NB_DOWNCORE_3X190),
31, 0, &leveling);
for (i = 0; i < cores; i++)
{
if (leveling & ((u32) 1 << i))
{
temp--;
}
}
return (u8)(temp+1);
}
/***************************************************************************//**
*
* static void
* setTotalNodesAndCores(u8 node, u8 totalNodes, u8 totalCores, cNorthBridge *nb)
*
* Description:
* Write the total number of cores and nodes to the node
*
* Parameters:
* @param[in] node = the node that will be examined
* @param[in] totalNodes = the total number of nodes
* @param[in] totalCores = the total number of cores
* @param[in] *nb = this northbridge
*
* ---------------------------------------------------------------------------------------
*/
static void setTotalNodesAndCores(u8 node, u8 totalNodes, u8 totalCores, cNorthBridge *nb)
{
SBDFO nodeIDReg;
u32 temp;
ASSERT((node < nb->maxNodes) && (totalNodes <= nb->maxNodes));
nodeIDReg = MAKE_SBDFO(makePCISegmentFromNode(node),
makePCIBusFromNode(node),
makePCIDeviceFromNode(node),
CPU_HTNB_FUNC_00,
REG_NODE_ID_0X60);
temp = totalCores-1;
/* Rely on max number of nodes:cores for rev F and GH to make
* this code work, even though we write reserved bit 20 on rev F it will be
* zero in that case.
*/
AmdPCIWriteBits(nodeIDReg, 20, 16, &temp);
temp = totalNodes-1;
AmdPCIWriteBits(nodeIDReg, 6, 4, &temp);
}
/***************************************************************************//**
*
* static void
* limitNodes(u8 node, cNorthBridge *nb)
*
* Description:
* Limit coherent config accesses to cpus as indicated by nodecnt.
*
* Parameters:
* @param[in] node = the node that will be examined
* @param[in] *nb = this northbridge
*
* ---------------------------------------------------------------------------------------
*/
static void limitNodes(u8 node, cNorthBridge *nb)
{
u32 temp = 1;
ASSERT((node < nb->maxNodes));
AmdPCIWriteBits(MAKE_SBDFO(makePCISegmentFromNode(node),
makePCIBusFromNode(node),
makePCIDeviceFromNode(node),
CPU_HTNB_FUNC_00,
REG_LINK_TRANS_CONTROL_0X68),
15, 15, &temp);
}
/***************************************************************************//**
*
* static void
* writeFullRoutingTable(u8 node, u8 target, u8 reqLink, u8 rspLink, u32 BClinks, cNorthBridge *nb)
*
* Description:
* Write the routing table entry for node to target, using the request link, response
* link, and broadcast links provided.
*
* Parameters:
* @param[in] node = the node that will be examined
* @param[in] target = the target node for these routes
* @param[in] reqLink = the link for requests to target
* @param[in] rspLink = the link for responses to target
* @param[in] bClinks = the broadcast links
* @param[in] *nb = this northbridge
*
* ---------------------------------------------------------------------------------------
*/
static void writeFullRoutingTable(u8 node, u8 target, u8 reqLink, u8 rspLink, u32 bClinks, cNorthBridge *nb)
{
#ifndef HT_BUILD_NC_ONLY
u32 value = 0;
ASSERT((node < nb->maxNodes) && (target < nb->maxNodes));
if (reqLink == ROUTETOSELF)
value |= nb->selfRouteRequestMask;
else
value |= nb->selfRouteRequestMask << (reqLink+1);
if (rspLink == ROUTETOSELF)
value |= nb->selfRouteResponseMask;
else
value |= nb->selfRouteResponseMask << (rspLink+1);
/* Allow us to accept a Broadcast ourselves, then set broadcasts for routes */
value |= (u32)1 << nb->broadcastSelfBit;
value |= (u32)bClinks << (nb->broadcastSelfBit + 1);
AmdPCIWrite(MAKE_SBDFO(makePCISegmentFromNode(node),
makePCIBusFromNode(node),
makePCIDeviceFromNode(node),
CPU_HTNB_FUNC_00,
REG_ROUTE0_0X40 + target*4), &value);
#else
STOP_HERE;
#endif /* HT_BUILD_NC_ONLY */
}
/***************************************************************************//**
*
* static u32
* makeKey(u8 currentNode)
*
* Description:
* Private routine to northbridge code.
* Determine whether a node is compatible with the discovered configuration so
* far. Currently, that means the family, extended family of the new node are the
* same as the BSP's.
*
* Parameters:
* @param[in] node = the node
* @return = the key value
*
* ---------------------------------------------------------------------------------------
*/
static u32 makeKey(u8 node)
{
u32 extFam, baseFam;
AmdPCIReadBits(MAKE_SBDFO(makePCISegmentFromNode(node),
makePCIBusFromNode(node),
makePCIDeviceFromNode(node),
CPU_NB_FUNC_03,
REG_NB_CPUID_3XFC),
27, 20, &extFam);
AmdPCIReadBits(MAKE_SBDFO(makePCISegmentFromNode(node),
makePCIBusFromNode(node),
makePCIDeviceFromNode(node),
CPU_NB_FUNC_03,
REG_NB_CPUID_3XFC),
11, 8, &baseFam);
return ((u32)(baseFam << 8) | extFam);
}
/***************************************************************************//**
*
* static BOOL
* isCompatible(u8 currentNode, cNorthBridge *nb)
*
* Description:
* Determine whether a node is compatible with the discovered configuration so
* far. Currently, that means the family, extended family of the new node are the
* same as the BSP's.
*
* Parameters:
* @param[in] node = the node
* @param[in] *nb = this northbridge
* @return = true: the new is compatible, false: it is not
*
* ---------------------------------------------------------------------------------------
*/
static BOOL isCompatible(u8 node, cNorthBridge *nb)
{
return (makeKey(node) == nb->compatibleKey);
}
/***************************************************************************//**
*
* static BOOL
* fam0fIsCapable(u8 node, sMainData *pDat, cNorthBridge *nb)
*
* Description:
* Get node capability and update the minimum supported system capability.
* Return whether the current configuration exceeds the capability.
*
* Parameters:
* @param[in] node = the node
* @param[in,out] *pDat = sysMpCap (updated) and NodesDiscovered
* @param[in] *nb = this northbridge
* @return true: system is capable of current config.
* false: system is not capable of current config.
*
* ---------------------------------------------------------------------------------------
*/
static BOOL fam0fIsCapable(u8 node, sMainData *pDat, cNorthBridge *nb)
{
#ifndef HT_BUILD_NC_ONLY
u32 temp;
u8 maxNodes;
ASSERT(node < nb->maxNodes);
AmdPCIReadBits(MAKE_SBDFO(makePCISegmentFromNode(node),
makePCIBusFromNode(node),
makePCIDeviceFromNode(node),
CPU_NB_FUNC_03,
REG_NB_CAPABILITY_3XE8),
2, 1, &temp);
if (temp > 1)
{
maxNodes = 8;
} else {
if (temp == 1)
{
maxNodes = 2;
} else {
maxNodes = 1;
}
}
if (pDat->sysMpCap > maxNodes)
{
pDat->sysMpCap = maxNodes;
}
/* Note since sysMpCap is one based and NodesDiscovered is zero based, equal is false */
return (pDat->sysMpCap > pDat->NodesDiscovered);
#else
return 1;
#endif
}
/***************************************************************************//**
*
* static BOOL
* fam10IsCapable(u8 node, sMainData *pDat, cNorthBridge *nb)
*
* Description:
* Get node capability and update the minimum supported system capability.
* Return whether the current configuration exceeds the capability.
*
* Parameters:
* @param[in] node = the node
* @param[in,out] *pDat = sysMpCap (updated) and NodesDiscovered
* @param[in] *nb = this northbridge
* @return true: system is capable of current config.
* false: system is not capable of current config.
*
* ---------------------------------------------------------------------------------------
*/
static BOOL fam10IsCapable(u8 node, sMainData *pDat, cNorthBridge *nb)
{
#ifndef HT_BUILD_NC_ONLY
u32 temp;
u8 maxNodes;
ASSERT(node < nb->maxNodes);
AmdPCIReadBits(MAKE_SBDFO(makePCISegmentFromNode(node),
makePCIBusFromNode(node),
makePCIDeviceFromNode(node),
CPU_NB_FUNC_03,
REG_NB_CAPABILITY_3XE8),
18, 16, &temp);
if (temp != 0)
{
maxNodes = (1 << (~temp & 0x3)); /* That is, 1, 2, 4, or 8 */
}
else
{
maxNodes = 8;
}
if (pDat->sysMpCap > maxNodes)
{
pDat->sysMpCap = maxNodes;
}
/* Note since sysMpCap is one based and NodesDiscovered is zero based, equal is false */
return (pDat->sysMpCap > pDat->NodesDiscovered);
#else
return 1;
#endif
}
/***************************************************************************//**
*
* static BOOL
* fam15IsCapable(u8 node, sMainData *pDat, cNorthBridge *nb)
*
* Description:
* Get node capability and update the minimum supported system capability.
* Return whether the current configuration exceeds the capability.
*
* Parameters:
* @param[in] node = the node
* @param[in,out] *pDat = sysMpCap (updated) and NodesDiscovered
* @param[in] *nb = this northbridge
* @return true: system is capable of current config.
* false: system is not capable of current config.
*
* ---------------------------------------------------------------------------------------
*/
static BOOL fam15IsCapable(u8 node, sMainData *pDat, cNorthBridge *nb)
{
#ifndef HT_BUILD_NC_ONLY
u32 temp;
u8 maxNodes;
ASSERT(node < nb->maxNodes);
AmdPCIReadBits(MAKE_SBDFO(makePCISegmentFromNode(node),
makePCIBusFromNode(node),
makePCIDeviceFromNode(node),
CPU_NB_FUNC_03,
REG_NB_CAPABILITY_3XE8),
18, 16, &temp);
if (temp != 0)
{
maxNodes = (1 << (~temp & 0x3)); /* That is, 1, 2, 4, or 8 */
}
else
{
/* Check if CPU package is dual node */
AmdPCIReadBits(MAKE_SBDFO(makePCISegmentFromNode(node),
makePCIBusFromNode(node),
makePCIDeviceFromNode(node),
CPU_NB_FUNC_03,
REG_NB_CAPABILITY_3XE8),
29, 29, &temp);
if (temp)
maxNodes = 4;
else
maxNodes = 8;
}
if (pDat->sysMpCap > maxNodes)
{
pDat->sysMpCap = maxNodes;
}
/* Note since sysMpCap is one based and NodesDiscovered is zero based, equal is false */
return (pDat->sysMpCap > pDat->NodesDiscovered);
#else
return 1;
#endif
}
/***************************************************************************//**
*
* static void
* fam0fStopLink(u8 currentNode, u8 currentLink, cNorthBridge *nb)
*
* Description:
* Disable a cHT link on node by setting F0x[E4, C4, A4, 84][TransOff, EndOfChain]=1
*
* Parameters:
* @param[in] node = the node this link is on
* @param[in] link = the link to stop
* @param[in] *nb = this northbridge
*
* ---------------------------------------------------------------------------------------
*/
static void fam0fStopLink(u8 node, u8 link, cNorthBridge *nb)
{
#ifndef HT_BUILD_NC_ONLY
u32 temp;
SBDFO linkBase;
ASSERT((node < nb->maxNodes) && (link < nb->maxLinks));
linkBase = makeLinkBase(node, link);
/* Set TransOff, EndOfChain */
temp = 3;
setHtControlRegisterBits(linkBase + HTHOST_LINK_CONTROL_REG, 7, 6, &temp);
#endif
}
/***************************************************************************//**
*
* static void
* commonVoid()
*
* Description:
* Nothing.
*
* Parameters:
* None.
*
* ---------------------------------------------------------------------------------------
*/
static void commonVoid(void)
{
}
/***************************************************************************//**
*
* static BOOL
* commonReturnFalse()
*
* Description:
* Return False.
*
* Parameters:
* @return = false
*
*/
static BOOL commonReturnFalse(void)
{
return 0;
}
/***************************************************************************
*** Non-coherent init code ***
*** Northbridge access routines ***
***************************************************************************/
/***************************************************************************//**
*
* static u8
* readSbLink(cNorthBridge *nb)
*
* Description:
* Return the link to the Southbridge
*
* Parameters:
* @param[in] *nb = this northbridge
* @return the link to the southbridge
*
* ---------------------------------------------------------------------------------------
*/
static u8 readSbLink(cNorthBridge *nb)
{
u32 temp;
AmdPCIReadBits(MAKE_SBDFO(makePCISegmentFromNode(0),
makePCIBusFromNode(0),
makePCIDeviceFromNode(0),
CPU_HTNB_FUNC_00,
REG_UNIT_ID_0X64),
10, 8, &temp);
return (u8)temp;
}
/***************************************************************************//**
*
* static BOOL
* verifyLinkIsNonCoherent(u8 node, u8 link, cNorthBridge *nb)
*
* Description:
* Verify that the link is non-coherent, connected, and ready
*
* Parameters:
* @param[in] node = the node that will be examined
* @param[in] link = the Link on that node to examine
* @param[in] *nb = this northbridge
* @return = true - The link has the following status
* LinkCon = 1, Link is connected
* InitComplete = 1,Link initialization is complete
* NC = 1, Link is coherent
* UniP-cLDT = 0, Link is not Uniprocessor cLDT
* LinkConPend = 0 Link connection is not pending
* false- The link has some other status
*
* ---------------------------------------------------------------------------------------
*/
static BOOL verifyLinkIsNonCoherent(u8 node, u8 link, cNorthBridge *nb)
{
u32 linkType;
SBDFO linkBase;
ASSERT((node < nb->maxNodes) && (link < nb->maxLinks));
linkBase = makeLinkBase(node, link);
/* FN0_98/A4/C4 = LDT Type Register */
AmdPCIRead(linkBase + HTHOST_LINK_TYPE_REG, &linkType);
/* Verify linkCon = 1, InitComplete = 1, NC = 0, UniP-cLDT = 0, LinkConPend = 0 */
return (linkType & HTHOST_TYPE_MASK) == HTHOST_TYPE_NONCOHERENT;
}
/***************************************************************************//**
*
* static void
* ht3SetCFGAddrMap(u8 cfgMapIndex, u8 secBus, u8 subBus, u8 targetNode, u8 targetLink, sMainData *pDat, cNorthBridge *nb)
*
* Description:
* Configure and enable config access to a non-coherent chain for the given bus range.
*
* Parameters:
* @param[in] cfgMapIndex = the map entry to set
* @param[in] secBus = The secondary bus number to use
* @param[in] subBus = The subordinate bus number to use
* @param[in] targetNode = The node that shall be the recipient of the traffic
* @param[in] targetLink = The link that shall be the recipient of the traffic
* @param[in] pDat = our global state
* @param[in] *nb = this northbridge
*
* ---------------------------------------------------------------------------------------
*/
static void ht3SetCFGAddrMap(u8 cfgMapIndex, u8 secBus, u8 subBus, u8 targetNode, u8 targetLink, sMainData *pDat, cNorthBridge *nb)
{
u8 curNode;
SBDFO linkBase;
u32 temp;
linkBase = makeLinkBase(targetNode, targetLink);
ASSERT(secBus <= subBus);
temp = secBus;
AmdPCIWriteBits(linkBase + HTHOST_ISOC_REG, 15, 8, &temp);
/* For target link, note that rev F uses bits 9:8 and only with GH is bit 10
* set to indicate a sublink. For node, we are currently not supporting Extended
* routing tables.
*/
temp = ((u32)subBus << 24) + ((u32)secBus << 16) + ((u32)targetLink << 8)
+ ((u32)targetNode << 4) + (u32)3;
for (curNode = 0; curNode < pDat->NodesDiscovered+1; curNode++)
AmdPCIWrite(MAKE_SBDFO(makePCISegmentFromNode(curNode),
makePCIBusFromNode(curNode),
makePCIDeviceFromNode(curNode),
CPU_ADDR_FUNC_01,
REG_ADDR_CONFIG_MAP0_1XE0 + 4*cfgMapIndex),
&temp);
}
/***************************************************************************//**
*
* static void
* ht1SetCFGAddrMap(u8 cfgMapIndex, u8 secBus, u8 subBus, u8 targetNode, u8 targetLink, sMainData *pDat, cNorthBridge *nb)
*
* Description:
* Configure and enable config access to a non-coherent chain for the given bus range.
*
* Parameters:
* @param[in] cfgMapIndex = the map entry to set
* @param[in] secBus = The secondary bus number to use
* @param[in] subBus = The subordinate bus number to use
* @param[in] targetNode = The node that shall be the recipient of the traffic
* @param[in] targetLink = The link that shall be the recipient of the traffic
* @param[in] pDat = our global state
* @param[in] *nb = this northbridge
*
******************************************************************************/
static void ht1SetCFGAddrMap(u8 cfgMapIndex, u8 secBus, u8 subBus, u8 targetNode, u8 targetLink, sMainData *pDat, cNorthBridge *nb)
{
u8 curNode;
SBDFO linkBase;
u32 temp;
linkBase = makeLinkBase(targetNode, targetLink);
ASSERT(secBus <= subBus);
temp = secBus;
AmdPCIWriteBits(linkBase + HTHOST_ISOC_REG, 15, 8, &temp);
temp = subBus;
AmdPCIWriteBits(linkBase + HTHOST_ISOC_REG, 23, 16, &temp);
/* For target link, note that rev F uses bits 9:8 and only with GH is bit 10
* set to indicate a sublink. For node, we are currently not supporting Extended
* routing tables.
*/
temp = ((u32)subBus << 24) + ((u32)secBus << 16) + ((u32)targetLink << 8)
+ ((u32)targetNode << 4) + (u32)3;
for (curNode = 0; curNode < pDat->NodesDiscovered+1; curNode++)
AmdPCIWrite(MAKE_SBDFO(makePCISegmentFromNode(curNode),
makePCIBusFromNode(curNode),
makePCIDeviceFromNode(curNode),
CPU_ADDR_FUNC_01,
REG_ADDR_CONFIG_MAP0_1XE0 + 4*cfgMapIndex),
&temp);
}
/***************************************************************************
*** Link Optimization ***
***************************************************************************/
/**
* static u8
* convertBitsToWidth(u8 value, cNorthBridge *nb)
*
* Description:
* Given the bits set in the register field, return the width it represents
*
* Parameters:
* @param[in] value = The bits for the register
* @param[in] *nb = this northbridge
* @return The width
*
******************************************************************************/
static u8 convertBitsToWidth(u8 value, cNorthBridge *nb)
{
switch (value) {
case 1: return 16;
case 0: return 8;
case 5: return 4;
case 4: return 2;
default: STOP_HERE; /* This is an error internal condition */
}
return 0; // shut up GCC.
}
/***************************************************************************//**
*
* static u8
* convertWidthToBits(u8 value, cNorthBridge *nb)
*
* Description:
* Translate a desired width setting to the bits to set in the register field
*
* Parameters:
* @param[in] value = The width
* @param[in] *nb = this northbridge
* @return The bits for the register
*
******************************************************************************/
static u8 convertWidthToBits(u8 value, cNorthBridge *nb)
{
switch (value) {
case 16: return 1;
case 8: return 0;
case 4: return 5;
case 2: return 4;
default: STOP_HERE; /* This is an internal error condition */
}
return 0; // shut up GCC
}
/***************************************************************************//**
*
* static u16
* ht1NorthBridgeFreqMask(u8 NodeID, cNorthBridge *nb)
*
* Description:
* Return a mask that eliminates HT frequencies that cannot be used due to a slow
* northbridge frequency.
*
* Parameters:
* @param[in] node = Result could (later) be for a specific node
* @param[in] *nb = this northbridge
* @return Frequency mask
*
******************************************************************************/
static uint32_t ht1NorthBridgeFreqMask(u8 node, cNorthBridge *nb)
{
/* only up to HT1 speeds */
return (HT_FREQUENCY_LIMIT_HT1_ONLY);
}
/***************************************************************************//**
*
* static u16
* fam10NorthBridgeFreqMask(u8 NodeID, cNorthBridge *nb)
*
* Description:
* Return a mask that eliminates HT frequencies that cannot be used due to a slow
* northbridge frequency.
*
* Parameters:
* @param[in] node = Result could (later) be for a specific node
* @param[in] *nb = this northbridge
* @return = Frequency mask
*
******************************************************************************/
static uint32_t fam10NorthBridgeFreqMask(u8 node, cNorthBridge *nb)
{
u8 nbCOF;
uint32_t supported;
nbCOF = getMinNbCOF();
/*
* nbCOF is minimum northbridge speed in hundreds of MHz.
* HT can not go faster than the minimum speed of the northbridge.
*/
if ((nbCOF >= 6) && (nbCOF < 10))
{
/* Generation 1 HT link frequency */
/* Convert frequency to bit and all less significant bits,
* by setting next power of 2 and subtracting 1.
*/
supported = ((uint32_t)1 << ((nbCOF >> 1) + 2)) - 1;
}
else if ((nbCOF >= 10) && (nbCOF <= 32))
{
/* Generation 3 HT link frequency
* Assume error retry is enabled on all Gen 3 links
*/
if (is_gt_rev_d()) {
nbCOF *= 2;
if (nbCOF > 32)
nbCOF = 32;
}
/* Convert frequency to bit and all less significant bits,
* by setting next power of 2 and subtracting 1.
*/
supported = ((uint32_t)1 << ((nbCOF >> 1) + 2)) - 1;
}
else if (nbCOF > 32)
{
supported = HT_FREQUENCY_LIMIT_3200M;
}
/* unlikely cases, but include as a defensive measure, also avoid trick above */
else if (nbCOF == 4)
{
supported = HT_FREQUENCY_LIMIT_400M;
}
else if (nbCOF == 2)
{
supported = HT_FREQUENCY_LIMIT_200M;
}
else
{
STOP_HERE;
supported = HT_FREQUENCY_LIMIT_200M;
}
return (fixEarlySampleFreqCapability(supported));
}
/***************************************************************************//**
*
* static u16
* fam15NorthBridgeFreqMask(u8 NodeID, cNorthBridge *nb)
*
* Description:
* Return a mask that eliminates HT frequencies that cannot be used due to a slow
* northbridge frequency.
*
* Parameters:
* @param[in] node = Result could (later) be for a specific node
* @param[in] *nb = this northbridge
* @return = Frequency mask
*
******************************************************************************/
static uint32_t fam15NorthBridgeFreqMask(u8 node, cNorthBridge *nb)
{
u8 nbCOF;
uint32_t supported;
nbCOF = getMinNbCOF();
/*
* nbCOF is minimum northbridge speed in hundreds of MHz.
* HT can not go faster than the minimum speed of the northbridge.
*/
if ((nbCOF >= 6) && (nbCOF < 10))
{
/* Generation 1 HT link frequency */
/* Convert frequency to bit and all less significant bits,
* by setting next power of 2 and subtracting 1.
*/
supported = ((uint32_t)1 << ((nbCOF >> 1) + 2)) - 1;
}
else if ((nbCOF >= 10) && (nbCOF <= 32))
{
/* Generation 3 HT link frequency
* Assume error retry is enabled on all Gen 3 links
*/
nbCOF *= 2;
if (nbCOF > 32)
nbCOF = 32;
/* Convert frequency to bit and all less significant bits,
* by setting next power of 2 and subtracting 1.
*/
supported = ((uint32_t)1 << ((nbCOF >> 1) + 2)) - 1;
}
else if (nbCOF > 32)
{
supported = HT_FREQUENCY_LIMIT_3200M;
}
/* unlikely cases, but include as a defensive measure, also avoid trick above */
else if (nbCOF == 4)
{
supported = HT_FREQUENCY_LIMIT_400M;
}
else if (nbCOF == 2)
{
supported = HT_FREQUENCY_LIMIT_200M;
}
else
{
STOP_HERE;
supported = HT_FREQUENCY_LIMIT_200M;
}
return (fixEarlySampleFreqCapability(supported));
}
/***************************************************************************//**
*
* static void
* gatherLinkData(sMainData *pDat, cNorthBridge *nb)
*
* Description:
* For all discovered links, populate the port list with the frequency and width
* capabilities.
*
* Parameters:
* @param[in,out] pDat = our global state, port list
* @param[in] *nb = this northbridge
*
******************************************************************************/
static void gatherLinkData(sMainData *pDat, cNorthBridge *nb)
{
u8 i;
SBDFO linkBase;
u32 temp;
for (i = 0; i < pDat->TotalLinks*2; i++)
{
if (pDat->PortList[i].Type == PORTLIST_TYPE_CPU)
{
linkBase = makeLinkBase(pDat->PortList[i].NodeID, pDat->PortList[i].Link);
pDat->PortList[i].Pointer = linkBase;
AmdPCIReadBits(linkBase + HTHOST_LINK_CONTROL_REG, 22, 20, &temp);
pDat->PortList[i].PrvWidthOutCap = convertBitsToWidth((u8)temp, pDat->nb);
AmdPCIReadBits(linkBase + HTHOST_LINK_CONTROL_REG, 18, 16, &temp);
pDat->PortList[i].PrvWidthInCap = convertBitsToWidth((u8)temp, pDat->nb);
AmdPCIReadBits(linkBase + HTHOST_FREQ_REV_REG, 31, 16, &temp);
pDat->PortList[i].PrvFrequencyCap = temp & 0x7FFF /* Mask off bit 15, reserved value */
& nb->northBridgeFreqMask(pDat->PortList[i].NodeID, pDat->nb);
if (is_gt_rev_d()) {
AmdPCIReadBits(linkBase + HTHOST_FREQ_REV_REG_2, 15, 1, &temp);
temp &= 0x7; /* Mask off reserved values */
pDat->PortList[i].PrvFrequencyCap |= (temp << 17);
}
AmdPCIReadBits(linkBase + HTHOST_FEATURE_CAP_REG, 9, 0, &temp);
pDat->PortList[i].PrvFeatureCap = (u16)temp;
}
else
{
linkBase = pDat->PortList[i].Pointer;
if (pDat->PortList[i].Link == 1)
linkBase += HTSLAVE_LINK01_OFFSET;
AmdPCIReadBits(linkBase + HTSLAVE_LINK_CONTROL_0_REG, 22, 20, &temp);
pDat->PortList[i].PrvWidthOutCap = convertBitsToWidth((u8)temp, pDat->nb);
AmdPCIReadBits(linkBase + HTSLAVE_LINK_CONTROL_0_REG, 18, 16, &temp);
pDat->PortList[i].PrvWidthInCap = convertBitsToWidth((u8)temp, pDat->nb);
AmdPCIReadBits(linkBase + HTSLAVE_FREQ_REV_0_REG, 31, 16, &temp);
pDat->PortList[i].PrvFrequencyCap = (u16)temp;
AmdPCIReadBits(linkBase + HTSLAVE_FEATURE_CAP_REG, 7, 0, &temp);
pDat->PortList[i].PrvFeatureCap = (u16)temp;
if (pDat->HtBlock->AMD_CB_DeviceCapOverride)
{
linkBase &= 0xFFFFF000;
AmdPCIRead(linkBase, &temp);
pDat->HtBlock->AMD_CB_DeviceCapOverride(
pDat->PortList[i].NodeID,
pDat->PortList[i].HostLink,
pDat->PortList[i].HostDepth,
(u8)SBDFO_SEG(pDat->PortList[i].Pointer),
(u8)SBDFO_BUS(pDat->PortList[i].Pointer),
(u8)SBDFO_DEV(pDat->PortList[i].Pointer),
temp,
pDat->PortList[i].Link,
&(pDat->PortList[i].PrvWidthInCap),
&(pDat->PortList[i].PrvWidthOutCap),
&(pDat->PortList[i].PrvFrequencyCap),
&(pDat->PortList[i].PrvFeatureCap));
}
}
}
}
/***************************************************************************//**
*
* static void
* setLinkData(sMainData *pDat, cNorthBridge *nb)
*
* Description:
* Change the hardware state for all links according to the now optimized data in the
* port list data structure.
*
* Parameters:
* @param[in] pDat = our global state, port list
* @param[in] *nb = this northbridge
*
******************************************************************************/
static void setLinkData(sMainData *pDat, cNorthBridge *nb)
{
u8 i;
SBDFO linkBase;
u32 temp, temp2, frequency_index, widthin, widthout, bits;
for (i = 0; i < pDat->TotalLinks*2; i++)
{
ASSERT(pDat->PortList[i&0xFE].SelWidthOut == pDat->PortList[(i&0xFE)+1].SelWidthIn);
ASSERT(pDat->PortList[i&0xFE].SelWidthIn == pDat->PortList[(i&0xFE)+1].SelWidthOut);
ASSERT(pDat->PortList[i&0xFE].SelFrequency == pDat->PortList[(i&0xFE)+1].SelFrequency);
if (pDat->PortList[i].SelRegang)
{
ASSERT(pDat->PortList[i].Type == PORTLIST_TYPE_CPU);
ASSERT(pDat->PortList[i].Link < 4);
temp = 1;
AmdPCIWriteBits(MAKE_SBDFO(makePCISegmentFromNode(pDat->PortList[i].NodeID),
makePCIBusFromNode(pDat->PortList[i].NodeID),
makePCIDeviceFromNode(pDat->PortList[i].NodeID),
CPU_HTNB_FUNC_00,
REG_HT_LINK_EXT_CONTROL0_0X170 + 4*pDat->PortList[i].Link),
0, 0, &temp);
}
if (pDat->PortList[i].Type == PORTLIST_TYPE_CPU)
{
if (pDat->HtBlock->AMD_CB_OverrideCpuPort)
pDat->HtBlock->AMD_CB_OverrideCpuPort(pDat->PortList[i].NodeID,
pDat->PortList[i].Link,
&(pDat->PortList[i].SelWidthIn),
&(pDat->PortList[i].SelWidthOut),
&(pDat->PortList[i].SelFrequency));
}
else
{
if (pDat->HtBlock->AMD_CB_OverrideDevicePort)
pDat->HtBlock->AMD_CB_OverrideDevicePort(pDat->PortList[i].NodeID,
pDat->PortList[i].HostLink,
pDat->PortList[i].HostDepth,
pDat->PortList[i].Link,
&(pDat->PortList[i].SelWidthIn),
&(pDat->PortList[i].SelWidthOut),
&(pDat->PortList[i].SelFrequency));
}
linkBase = pDat->PortList[i].Pointer;
if ((pDat->PortList[i].Type == PORTLIST_TYPE_IO) && (pDat->PortList[i].Link == 1))
linkBase += HTSLAVE_LINK01_OFFSET;
/* Some IO devices don't work properly when setting widths, so write them in a single operation,
* rather than individually.
*/
widthout = convertWidthToBits(pDat->PortList[i].SelWidthOut, pDat->nb);
ASSERT(widthout == 1 || widthout == 0 || widthout == 5 || widthout == 4);
widthin = convertWidthToBits(pDat->PortList[i].SelWidthIn, pDat->nb);
ASSERT(widthin == 1 || widthin == 0 || widthin == 5 || widthin == 4);
temp = (widthin & 7) | ((widthout & 7) << 4);
setHtControlRegisterBits(linkBase + HTHOST_LINK_CONTROL_REG, 31, 24, &temp);
temp = pDat->PortList[i].SelFrequency;
if (pDat->PortList[i].Type == PORTLIST_TYPE_CPU)
{
ASSERT((temp >= HT_FREQUENCY_600M && temp <= HT_FREQUENCY_3200M)
|| (temp == HT_FREQUENCY_200M) || (temp == HT_FREQUENCY_400M));
frequency_index = temp;
if (temp > 0xf) {
temp2 = (temp >> 4) & 0x1;
temp &= 0xf;
} else {
temp2 = 0x0;
}
/* NOTE
* The Family 15h BKDG Rev. 3.14 is wrong
* Freq[4] must be set before Freq[3:0], otherwise the register writes will be ignored!
*/
if (is_gt_rev_d())
AmdPCIWriteBits(linkBase + HTHOST_FREQ_REV_REG_2, 0, 0, &temp2);
AmdPCIWriteBits(linkBase + HTHOST_FREQ_REV_REG, 11, 8, &temp);
/* Enable isochronous flow control mode if supported by chipset */
if (is_fam15h()) {
if (pDat->PortList[i].enable_isochronous_mode)
temp = 1;
else
temp = 0;
setHtControlRegisterBits(linkBase + HTHOST_LINK_CONTROL_REG, 12, 12, &temp);
}
if (frequency_index > HT_FREQUENCY_1000M) /* Gen1 = 200MHz -> 1000MHz, Gen3 = 1200MHz -> 3200MHz */
{
/* Enable for Gen3 frequencies */
temp = 1;
}
else
{
/* Disable for Gen1 frequencies */
temp = 0;
}
/* HT3 retry mode enable / disable */
AmdPCIWriteBits(MAKE_SBDFO(makePCISegmentFromNode(pDat->PortList[i].NodeID),
makePCIBusFromNode(pDat->PortList[i].NodeID),
makePCIDeviceFromNode(pDat->PortList[i].NodeID),
CPU_HTNB_FUNC_00,
REG_HT_LINK_RETRY0_0X130 + 4*pDat->PortList[i].Link),
0, 0, &temp);
/* and Scrambling enable / disable */
AmdPCIWriteBits(MAKE_SBDFO(makePCISegmentFromNode(pDat->PortList[i].NodeID),
makePCIBusFromNode(pDat->PortList[i].NodeID),
makePCIDeviceFromNode(pDat->PortList[i].NodeID),
CPU_HTNB_FUNC_00,
REG_HT_LINK_EXT_CONTROL0_0X170 + 4*pDat->PortList[i].Link),
3, 3, &temp);
}
else
{
SBDFO currentPtr;
BOOL isFound;
ASSERT(temp <= HT_FREQUENCY_3200M);
/* Write the frequency setting */
AmdPCIWriteBits(linkBase + HTSLAVE_FREQ_REV_0_REG, 11, 8, &temp);
/* Handle additional HT3 frequency requirements, if needed,
* or clear them if switching down to ht1 on a warm reset.
* Gen1 = 200MHz -> 1000MHz, Gen3 = 1200MHz -> 2600MHz
*
* Even though we assert if debugging, we need to check that the capability was found
* always, since this is an unknown hardware device, also we are taking
* unqualified frequency from the call backs
* (could be trying to do ht3 on an ht1 IO device).
*/
if (temp > HT_FREQUENCY_1000M)
{
/* Enabling features if gen 3 */
bits = 1;
}
else
{
/* Disabling features if gen 1 */
bits = 0;
}
/* Enable isochronous flow control mode if supported by chipset */
if (is_fam15h()) {
if (pDat->PortList[i].enable_isochronous_mode)
temp = 1;
else
temp = 0;
}
/* Retry Enable */
isFound = FALSE;
currentPtr = linkBase & (u32)0xFFFFF000; /* Set PCI Offset to 0 */
do
{
AmdPCIFindNextCap(¤tPtr);
if (currentPtr != ILLEGAL_SBDFO)
{
AmdPCIRead(currentPtr, &temp);
/* HyperTransport Retry Capability? */
if (IS_HT_RETRY_CAPABILITY(temp))
{
ASSERT(pDat->PortList[i].Link < 2);
AmdPCIWriteBits(currentPtr + HTRETRY_CONTROL_REG,
pDat->PortList[i].Link*16,
pDat->PortList[i].Link*16,
&bits);
isFound = TRUE;
}
/* Some other capability, keep looking */
}
else
{
/* If we are turning it off, that may mean the device was only ht1 capable,
* so don't complain that we can't do it.
*/
if (bits != 0)
{
if (pDat->HtBlock->AMD_CB_EventNotify)
{
sHtEventOptRequiredCap evt;
evt.eSize = sizeof(sHtEventOptRequiredCap);
evt.node = pDat->PortList[i].NodeID;
evt.link = pDat->PortList[i].HostLink;
evt.depth = pDat->PortList[i].HostDepth;
pDat->HtBlock->AMD_CB_EventNotify(HT_EVENT_CLASS_WARNING,
HT_EVENT_OPT_REQUIRED_CAP_RETRY,
(u8 *)&evt);
}
STOP_HERE;
}
isFound = TRUE;
}
} while (!isFound);
/* Scrambling enable */
isFound = FALSE;
currentPtr = linkBase & (u32)0xFFFFF000; /* Set PCI Offset to 0 */
do
{
AmdPCIFindNextCap(¤tPtr);
if (currentPtr != ILLEGAL_SBDFO)
{
AmdPCIRead(currentPtr, &temp);
/* HyperTransport Gen3 Capability? */
if (IS_HT_GEN3_CAPABILITY(temp))
{
ASSERT(pDat->PortList[i].Link < 2);
AmdPCIWriteBits((currentPtr +
HTGEN3_LINK_TRAINING_0_REG +
pDat->PortList[i].Link*HTGEN3_LINK01_OFFSET),
3, 3, &bits);
isFound = TRUE;
}
/* Some other capability, keep looking */
}
else
{
/* If we are turning it off, that may mean the device was only ht1 capable,
* so don't complain that we can't do it.
*/
if (bits != 0)
{
if (pDat->HtBlock->AMD_CB_EventNotify)
{
sHtEventOptRequiredCap evt;
evt.eSize = sizeof(sHtEventOptRequiredCap);
evt.node = pDat->PortList[i].NodeID;
evt.link = pDat->PortList[i].HostLink;
evt.depth = pDat->PortList[i].HostDepth;
pDat->HtBlock->AMD_CB_EventNotify(HT_EVENT_CLASS_WARNING,
HT_EVENT_OPT_REQUIRED_CAP_GEN3,
(u8 *)&evt);
}
STOP_HERE;
}
isFound = TRUE;
}
} while (!isFound);
}
}
}
/***************************************************************************//**
*
* void
* fam0fWriteHTLinkCmdBufferAlloc(u8 node, u8 link, u8 req, u8 preq, u8 rsp, u8 prb)
*
* Description:
* Set the command buffer allocations in the buffer count register for the node and link.
* The command buffer settings in the low 16 bits are the same on both
* family 10h and family 0fh northbridges.
*
* Parameters:
* @param[in] node = The node to set allocations on
* @param[in] link = the link to set allocations on
* @param[in] req = non-posted Request Command Buffers
* @param[in] preq = Posted Request Command Buffers
* @param[in] rsp = Response Command Buffers
* @param[in] prb = Probe Command Buffers
*
******************************************************************************/
#ifndef HT_BUILD_NC_ONLY
static void fam0fWriteHTLinkCmdBufferAlloc(u8 node, u8 link, u8 req, u8 preq, u8 rsp, u8 prb)
{
u32 temp;
SBDFO currentPtr;
currentPtr = makeLinkBase(node, link);
currentPtr += HTHOST_BUFFER_COUNT_REG;
/* non-posted Request Command Buffers */
temp = req;
AmdPCIWriteBits(currentPtr, 3, 0, &temp);
/* Posted Request Command Buffers */
temp = preq;
AmdPCIWriteBits(currentPtr, 7, 4, &temp);
/* Response Command Buffers */
temp = rsp;
AmdPCIWriteBits(currentPtr, 11, 8, &temp);
/* Probe Command Buffers */
temp = prb;
AmdPCIWriteBits(currentPtr, 15, 12, &temp);
/* LockBc */
temp = 1;
AmdPCIWriteBits(currentPtr, 31, 31, &temp);
}
#endif /* HT_BUILD_NC_ONLY */
/***************************************************************************//**
*
* void
* fam0fWriteHTLinkDatBufferAlloc(u8 node, u8 link, u8 reqD, u8 preqD, u8 rspD)
*
* Description:
* Set the data buffer allocations in the buffer count register for the node and link.
* The command buffer settings in the high 16 bits are not the same on both
* family 10h and family 0fh northbridges.
*
* Parameters:
* @param[in] node = The node to set allocations on
* @param[in] link = the link to set allocations on
* @param[in] reqD = non-posted Request Data Buffers
* @param[in] preqD = Posted Request Data Buffers
* @param[in] rspD = Response Data Buffers
*
******************************************************************************/
#ifndef HT_BUILD_NC_ONLY
static void fam0fWriteHTLinkDatBufferAlloc(u8 node, u8 link, u8 reqD, u8 preqD, u8 rspD)
{
u32 temp;
SBDFO currentPtr;
currentPtr = makeLinkBase(node, link);
currentPtr += HTHOST_BUFFER_COUNT_REG;
/* Request Data Buffers */
temp = reqD;
AmdPCIWriteBits(currentPtr, 18, 16, &temp);
/* Posted Request Data Buffers */
temp = preqD;
AmdPCIWriteBits(currentPtr, 22, 20, &temp);
/* Response Data Buffers */
temp = rspD;
AmdPCIWriteBits(currentPtr, 26, 24, &temp);
}
#endif /* HT_BUILD_NC_ONLY */
/***************************************************************************//**
*
* static void
* ht3WriteTrafficDistribution(u32 links01, u32 links10, cNorthBridge *nb)
*
* Description:
* Set the traffic distribution register for the links provided.
*
* Parameters:
* @param[in] links01 = coherent links from node 0 to 1
* @param[in] links10 = coherent links from node 1 to 0
* @param[in] nb = this northbridge
*
******************************************************************************/
static void ht3WriteTrafficDistribution(u32 links01, u32 links10, cNorthBridge *nb)
{
#ifndef HT_BUILD_NC_ONLY
u32 temp;
/* Node 0 */
/* DstLnk */
AmdPCIWriteBits(MAKE_SBDFO(makePCISegmentFromNode(0),
makePCIBusFromNode(0),
makePCIDeviceFromNode(0),
CPU_HTNB_FUNC_00,
REG_HT_TRAFFIC_DIST_0X164),
23, 16, &links01);
/* DstNode = 1, cHTPrbDistEn = 1, cHTRspDistEn = 1, cHTReqDistEn = 1 */
temp = 0x0107;
AmdPCIWriteBits(MAKE_SBDFO(makePCISegmentFromNode(0),
makePCIBusFromNode(0),
makePCIDeviceFromNode(0),
CPU_HTNB_FUNC_00,
REG_HT_TRAFFIC_DIST_0X164),
15, 0, &temp);
/* Node 1 */
/* DstLnk */
AmdPCIWriteBits(MAKE_SBDFO(makePCISegmentFromNode(1),
makePCIBusFromNode(1),
makePCIDeviceFromNode(1),
CPU_HTNB_FUNC_00,
REG_HT_TRAFFIC_DIST_0X164),
23, 16, &links10);
/* DstNode = 0, cHTPrbDistEn = 1, cHTRspDistEn = 1, cHTReqDistEn = 1 */
temp = 0x0007;
AmdPCIWriteBits(MAKE_SBDFO(makePCISegmentFromNode(1),
makePCIBusFromNode(1),
makePCIDeviceFromNode(1),
CPU_HTNB_FUNC_00,
REG_HT_TRAFFIC_DIST_0X164),
15, 0, &temp);
#endif /* HT_BUILD_NC_ONLY */
}
/***************************************************************************//**
*
* static void
* ht1WriteTrafficDistribution(u32 links01, u32 links10, cNorthBridge *nb)
*
* Description:
* Traffic distribution is more complex in this case as the routing table must be
* adjusted to use one link for requests and the other for responses. Also,
* perform the buffer tunings on the links required for this config.
*
* Parameters:
* @param[in] links01 = coherent links from node 0 to 1
* @param[in] links10 = coherent links from node 1 to 0
* @param[in] nb = this northbridge
*
******************************************************************************/
static void ht1WriteTrafficDistribution(u32 links01, u32 links10, cNorthBridge *nb)
{
#ifndef HT_BUILD_NC_ONLY
u32 route01, route10;
u8 req0, req1, rsp0, rsp1, nclink;
/*
* Get the current request route for 0->1 and 1->0. This will indicate which of the links
* in links01 are connected to which links in links10. Since we have to route to distribute
* traffic, we need to know that. The link used by htinit will become the request, probe link.
* the other link will be used for responses.
*/
/* Get the routes, and hang on to them, we will write them back updated. */
AmdPCIRead(MAKE_SBDFO(makePCISegmentFromNode(0),
makePCIBusFromNode(0),
makePCIDeviceFromNode(0),
CPU_HTNB_FUNC_00,
REG_ROUTE1_0X44),
&route01);
AmdPCIRead(MAKE_SBDFO(makePCISegmentFromNode(1),
makePCIBusFromNode(1),
makePCIDeviceFromNode(1),
CPU_HTNB_FUNC_00,
REG_ROUTE0_0X40),
&route10);
/* Convert the request routes to a link number. Note "0xE" is ht1 nb specific.
* Find the response link numbers.
*/
ASSERT((route01 & 0xE) && (route10 & 0xE)); /* no route! error! */
req0 = (u8)AmdBitScanReverse((route01 & 0xE)) - 1;
req1 = (u8)AmdBitScanReverse((route10 & 0xE)) - 1;
/* Now, find the other link for the responses */
rsp0 = (u8)AmdBitScanReverse((links01 & ~((u32)1 << req0)));
rsp1 = (u8)AmdBitScanReverse((links10 & ~((u32)1 << req1)));
/* ht1 nb restriction, must have exactly two links */
ASSERT(((((links01 & ~((u32)1 << req0)) & ~((u32)1 << rsp0))) == 0)
&& ((((links10 & ~((u32)1 << req1)) & ~((u32)1 << rsp1))) == 0));
route01 = (route01 & ~0x0E00) | ((u32)0x0100<<(rsp0 + 1));
route10 = (route10 & ~0x0E00) | ((u32)0x0100<<(rsp1 + 1));
AmdPCIWrite(MAKE_SBDFO(makePCISegmentFromNode(0),
makePCIBusFromNode(0),
makePCIDeviceFromNode(0),
CPU_HTNB_FUNC_00,
REG_ROUTE1_0X44),
&route01);
AmdPCIWrite(MAKE_SBDFO(makePCISegmentFromNode(1),
makePCIBusFromNode(1),
makePCIDeviceFromNode(1),
CPU_HTNB_FUNC_00,
REG_ROUTE0_0X40),
&route10);
/* While we otherwise do buffer tunings elsewhere, for the dual cHT DP case with
* ht1 northbridges like family 0Fh, do the tunings here where we have all the
* link and route info at hand and don't need to recalculate it.
*/
/* Node 0, Request / Probe Link (note family F only has links < 4) */
fam0fWriteHTLinkCmdBufferAlloc(0, req0, 6, 3, 1, 6);
fam0fWriteHTLinkDatBufferAlloc(0, req0, 4, 3, 1);
/* Node 0, Response Link (note family F only has links < 4) */
fam0fWriteHTLinkCmdBufferAlloc(0, rsp0, 1, 0, 15, 0);
fam0fWriteHTLinkDatBufferAlloc(0, rsp0, 1, 1, 6);
/* Node 1, Request / Probe Link (note family F only has links < 4) */
fam0fWriteHTLinkCmdBufferAlloc(1, req1, 6, 3, 1, 6);
fam0fWriteHTLinkDatBufferAlloc(1, req1, 4, 3, 1);
/* Node 1, Response Link (note family F only has links < 4) */
fam0fWriteHTLinkCmdBufferAlloc(1, rsp1, 1, 0, 15, 0);
fam0fWriteHTLinkDatBufferAlloc(1, rsp1, 1, 1, 6);
/* Node 0, is the third link non-coherent? */
nclink = (u8)AmdBitScanReverse(((u8)0x07 & ~((u32)1 << req0) & ~((u32)1 << rsp0)));
if (nb->verifyLinkIsNonCoherent(0, nclink, nb))
{
fam0fWriteHTLinkCmdBufferAlloc(0, nclink, 6, 5, 2, 0);
}
/* Node 1, is the third link non-coherent? */
nclink = (u8)AmdBitScanReverse(((u8)0x07 & ~((u32)1 << req1) & ~((u32)1 << rsp1)));
if (nb->verifyLinkIsNonCoherent(1, nclink, nb))
{
fam0fWriteHTLinkCmdBufferAlloc(1, nclink, 6, 5, 2, 0);
}
#endif /* HT_BUILD_NC_ONLY */
}
/***************************************************************************//**
*
* static void
* fam0fBufferOptimizations(u8 node, sMainData *pDat, cNorthBridge *nb)
*
* Description:
* Buffer tunings are inherently northbridge specific. Check for specific configs
* which require adjustments and apply any standard workarounds to this node.
*
* Parameters:
* @param[in] node = the node to
* @param[in] *pDat = coherent links from node 0 to 1
* @param[in] nb = this northbridge
*
******************************************************************************/
static void fam0fBufferOptimizations(u8 node, sMainData *pDat, cNorthBridge *nb)
{
#ifndef HT_BUILD_NC_ONLY
u8 i;
u32 temp;
SBDFO currentPtr;
ASSERT(node < nb->maxNodes);
/* Fix the FIFO pointer register before changing speeds */
currentPtr = MAKE_SBDFO(makePCISegmentFromNode(node),
makePCIBusFromNode(node),
makePCIDeviceFromNode(node),
CPU_NB_FUNC_03,
REG_NB_FIFOPTR_3XDC);
for (i = 0; i < nb->maxLinks; i++)
{
temp = 0;
if (nb->verifyLinkIsCoherent(node, i, nb))
{
temp = 0x26;
ASSERT(i < 3);
AmdPCIWriteBits(currentPtr, 8*i + 5, 8*i, &temp);
}
else
{
if (nb->verifyLinkIsNonCoherent(node, i, nb))
{
temp = 0x25;
ASSERT(i < 3);
AmdPCIWriteBits(currentPtr, 8*i + 5, 8*i, &temp);
}
}
}
/*
* 8P Buffer tuning.
* Either apply the BKDG tunings or, if applicable, apply the more restrictive errata 153
* workaround.
* If 8 nodes, Check this node for 'inner' or 'outer'.
* Tune each link based on coherent or non-coherent
*/
if (pDat->NodesDiscovered >= 6)
{
u8 j;
BOOL isOuter;
BOOL isErrata153;
/* This is for family 0Fh, so assuming dual core max then 7 or 8 nodes are required
* to be in the situation of 14 or more cores. We checked nodes above, cross check
* that the number of cores is 14 or more. We want both 14 cores with at least 7 or 8 nodes
* not one condition alone, to apply the errata 153 workaround. Otherwise, 7 or 8 rev F
* nodes use the BKDG tuning.
*/
isErrata153 = 0;
AmdPCIReadBits (MAKE_SBDFO(makePCISegmentFromNode(0),
makePCIBusFromNode(0),
makePCIDeviceFromNode(0),
CPU_HTNB_FUNC_00,
REG_NODE_ID_0X60),
19, 16, &temp);
if (temp >= 14)
{
/* Check whether we need to do errata 153 tuning or BKDG tuning.
* Errata 153 applies to JH-1, JH-2 and older. It is fixed in JH-3
* (and, one assumes, from there on).
*/
for (i = 0; i < (pDat->NodesDiscovered +1); i++)
{
AmdPCIReadBits(MAKE_SBDFO(makePCISegmentFromNode(i),
makePCIBusFromNode(i),
makePCIDeviceFromNode(i),
CPU_NB_FUNC_03,
REG_NB_CPUID_3XFC),
7, 0, &temp);
if (((u8)temp & ~0x40) < 0x13)
{
isErrata153 = 1;
break;
}
}
}
for (i = 0; i < CPU_ADDR_NUM_CONFIG_MAPS; i++)
{
isOuter = FALSE;
/* Check for outer node by scanning the config maps on node 0 for one
* which is assigned to this node.
*/
currentPtr = MAKE_SBDFO(makePCISegmentFromNode(0),
makePCIBusFromNode(0),
makePCIDeviceFromNode(0),
CPU_ADDR_FUNC_01,
REG_ADDR_CONFIG_MAP0_1XE0 + (4 * i));
AmdPCIReadBits (currentPtr, 1, 0, &temp);
/* Make sure this config map is valid, if it is it will be enabled for read/write */
if (temp == 3)
{
/* It's valid, get the node (that node is an outer node) */
AmdPCIReadBits (currentPtr, 6, 4, &temp);
/* Is the node we're working on now? */
if (node == (u8)temp)
{
/* This is an outer node. Tune it appropriately. */
for (j = 0; j < nb->maxLinks; j++)
{
if (isErrata153)
{
if (nb->verifyLinkIsCoherent(node, j, nb))
{
fam0fWriteHTLinkCmdBufferAlloc(node, j, 1, 1, 6, 4);
}
else
{
if (nb->verifyLinkIsNonCoherent(node, j, nb))
{
fam0fWriteHTLinkCmdBufferAlloc(node, j, 5, 4, 1, 0);
}
}
}
else
{
if (nb->verifyLinkIsCoherent(node, j, nb))
{
fam0fWriteHTLinkCmdBufferAlloc(node, j, 1, 1, 8, 5);
}
}
}
/*
* SRI to XBAR Buffer Counts are correct for outer node at power on defaults.
*/
isOuter = TRUE;
break;
}
}
/* We fill config maps in ascending order, so if we didn't use this one, we're done. */
else break;
}
if (!isOuter)
{
if (isErrata153)
{
/* Tuning for inner node coherent links */
for (j = 0; j < nb->maxLinks; j++)
{
if (nb->verifyLinkIsCoherent(node, j, nb))
{
fam0fWriteHTLinkCmdBufferAlloc(node, j, 2, 1, 5, 4);
}
}
/* SRI to XBAR Buffer Count for inner nodes, zero DReq and DPReq */
temp = 0;
AmdPCIWriteBits (MAKE_SBDFO(makePCISegmentFromNode(node),
makePCIBusFromNode(node),
makePCIDeviceFromNode(node),
CPU_NB_FUNC_03,
REG_NB_SRI_XBAR_BUF_3X70),
31, 28, &temp);
}
}
/*
* Tune MCT to XBAR Buffer Count the same an all nodes, 2 Probes, 5 Response
*/
if (isErrata153)
{
temp = 0x25;
AmdPCIWriteBits (MAKE_SBDFO(makePCISegmentFromNode(node),
makePCIBusFromNode(node),
makePCIDeviceFromNode(node),
CPU_NB_FUNC_03,
REG_NB_MCT_XBAR_BUF_3X78),
14, 8, &temp);
}
}
#endif /* HT_BUILD_NC_ONLY */
}
/***************************************************************************//**
*
* static void
* fam10BufferOptimizations(u8 node, sMainData *pDat, cNorthBridge *nb)
*
* Description:
* Buffer tunings are inherently northbridge specific. Check for specific configs
* which require adjustments and apply any standard workarounds to this node.
*
* Parameters:
* @param[in] node = the node to tune
* @param[in] *pDat = global state
* @param[in] nb = this northbridge
*
******************************************************************************/
static void fam10BufferOptimizations(u8 node, sMainData *pDat, cNorthBridge *nb)
{
u32 temp;
SBDFO currentPtr;
u8 i;
ASSERT(node < nb->maxNodes);
/*
* Link to XCS Token Count Tuning
*
* For each active link that we reganged (so this unfortunately can't go into the PCI reg
* table), we have to switch the Link to XCS Token Counts to the ganged state.
* We do this here for the non-uma case, which is to write the values that would have
* been power on defaults if the link was ganged at cold reset.
*/
for (i = 0; i < pDat->TotalLinks*2; i++)
{
if ((pDat->PortList[i].NodeID == node) && (pDat->PortList[i].Type == PORTLIST_TYPE_CPU))
{
/* If the link is greater than 4, this is a sublink 1, so it is not reganged. */
if (pDat->PortList[i].Link < 4)
{
currentPtr = MAKE_SBDFO(makePCISegmentFromNode(node),
makePCIBusFromNode(node),
makePCIDeviceFromNode(node),
CPU_NB_FUNC_03,
REG_NB_LINK_XCS_TOKEN0_3X148 + 4*pDat->PortList[i].Link);
if (pDat->PortList[i].SelRegang)
{
/* Handle all the regang Token count adjustments */
/* Sublink 0: [Probe0tok] = 2 [Rsp0tok] = 2 [PReq0tok] = 2 [Req0tok] = 2 */
temp = 0xAA;
AmdPCIWriteBits(currentPtr, 7, 0, &temp);
/* Sublink 1: [Probe1tok] = 0 [Rsp1tok] = 0 [PReq1tok] = 0 [Req1tok] = 0 */
temp = 0;
AmdPCIWriteBits(currentPtr, 23, 16, &temp);
/* [FreeTok] = 3 */
temp = 3;
AmdPCIWriteBits(currentPtr, 15, 14, &temp);
}
else
{
/* Read the regang bit in hardware */
AmdPCIReadBits(MAKE_SBDFO(makePCISegmentFromNode(pDat->PortList[i].NodeID),
makePCIBusFromNode(pDat->PortList[i].NodeID),
makePCIDeviceFromNode(pDat->PortList[i].NodeID),
CPU_HTNB_FUNC_00,
REG_HT_LINK_EXT_CONTROL0_0X170 + 4*pDat->PortList[i].Link),
0, 0, &temp);
if (temp == 1)
{
/* handle a minor adjustment for stapped ganged links. If SelRegang is false we
* didn't do the regang, so if the bit is on then it's hardware strapped.
*/
/* [FreeTok] = 3 */
temp = 3;
AmdPCIWriteBits(currentPtr, 15, 14, &temp);
}
}
}
}
}
}
/***************************************************************************//**
*
* static void
* fam15BufferOptimizations(u8 node, sMainData *pDat, cNorthBridge *nb)
*
* Description:
* Buffer tunings are inherently northbridge specific. Check for specific configs
* which require adjustments and apply any standard workarounds to this node.
*
* Parameters:
* @param[in] node = the node to tune
* @param[in] *pDat = global state
* @param[in] nb = this northbridge
*
******************************************************************************/
static void fam15BufferOptimizations(u8 node, sMainData *pDat, cNorthBridge *nb)
{
/* Buffer count setup on Family 15h is currently handled in cpuSetAMDPCI */
}
/*
* North Bridge 'constructor'.
*
*/
/***************************************************************************//**
*
* void
* newNorthBridge(u8 node, cNorthBridge *nb)
*
* Description:
* Construct a new northbridge. This routine encapsulates knowledge of how to tell
* significant differences between families of supported northbridges and what routines
* can be used in common and which are unique. A fully populated northbridge interface
* is provided by nb.
*
* Parameters:
* @param node
* @param[out] nb = the caller's northbridge structure to initialize.
*
******************************************************************************/
void newNorthBridge(u8 node, cNorthBridge *nb)
{
u32 match;
u32 extFam, baseFam, model;
cNorthBridge fam15 =
{
#ifdef HT_BUILD_NC_ONLY
8,
1,
12,
#else
8,
8,
64,
#endif /* HT_BUILD_NC_ONLY*/
writeRoutingTable,
writeNodeID,
readDefLnk,
enableRoutingTables,
verifyLinkIsCoherent,
readTrueLinkFailStatus,
readToken,
writeToken,
fam15GetNumCoresOnNode,
setTotalNodesAndCores,
limitNodes,
writeFullRoutingTable,
isCompatible,
fam15IsCapable,
(void (*)(u8, u8, cNorthBridge*))commonVoid,
(BOOL (*)(u8, u8, sMainData*, cNorthBridge*))commonReturnFalse,
readSbLink,
verifyLinkIsNonCoherent,
ht3SetCFGAddrMap,
convertBitsToWidth,
convertWidthToBits,
fam15NorthBridgeFreqMask,
gatherLinkData,
setLinkData,
ht3WriteTrafficDistribution,
fam15BufferOptimizations,
0x00000001,
0x00000200,
18,
0x00000f06
};
cNorthBridge fam10 =
{
#ifdef HT_BUILD_NC_ONLY
8,
1,
12,
#else
8,
8,
64,
#endif /* HT_BUILD_NC_ONLY*/
writeRoutingTable,
writeNodeID,
readDefLnk,
enableRoutingTables,
verifyLinkIsCoherent,
readTrueLinkFailStatus,
readToken,
writeToken,
fam10GetNumCoresOnNode,
setTotalNodesAndCores,
limitNodes,
writeFullRoutingTable,
isCompatible,
fam10IsCapable,
(void (*)(u8, u8, cNorthBridge*))commonVoid,
(BOOL (*)(u8, u8, sMainData*, cNorthBridge*))commonReturnFalse,
readSbLink,
verifyLinkIsNonCoherent,
ht3SetCFGAddrMap,
convertBitsToWidth,
convertWidthToBits,
fam10NorthBridgeFreqMask,
gatherLinkData,
setLinkData,
ht3WriteTrafficDistribution,
fam10BufferOptimizations,
0x00000001,
0x00000200,
18,
0x00000f01
};
cNorthBridge fam0f =
{
#ifdef HT_BUILD_NC_ONLY
3,
1,
12,
#else
3,
8,
32,
#endif /* HT_BUILD_NC_ONLY*/
writeRoutingTable,
writeNodeID,
readDefLnk,
enableRoutingTables,
verifyLinkIsCoherent,
readTrueLinkFailStatus,
readToken,
writeToken,
fam0FGetNumCoresOnNode,
setTotalNodesAndCores,
limitNodes,
writeFullRoutingTable,
isCompatible,
fam0fIsCapable,
fam0fStopLink,
(BOOL (*)(u8, u8, sMainData*, cNorthBridge*))commonReturnFalse,
readSbLink,
verifyLinkIsNonCoherent,
ht1SetCFGAddrMap,
convertBitsToWidth,
convertWidthToBits,
ht1NorthBridgeFreqMask,
gatherLinkData,
setLinkData,
ht1WriteTrafficDistribution,
fam0fBufferOptimizations,
0x00000001,
0x00000100,
16,
0x00000f00
};
/* Start with enough of the key to identify the northbridge interface */
AmdPCIReadBits(MAKE_SBDFO(makePCISegmentFromNode(node),
makePCIBusFromNode(node),
makePCIDeviceFromNode(node),
CPU_NB_FUNC_03,
REG_NB_CPUID_3XFC),
27, 20, &extFam);
AmdPCIReadBits(MAKE_SBDFO(makePCISegmentFromNode(node),
makePCIBusFromNode(node),
makePCIDeviceFromNode(node),
CPU_NB_FUNC_03,
REG_NB_CPUID_3XFC),
11, 8, &baseFam);
AmdPCIReadBits(MAKE_SBDFO(makePCISegmentFromNode(node),
makePCIBusFromNode(node),
makePCIDeviceFromNode(node),
CPU_NB_FUNC_03,
REG_NB_CPUID_3XFC),
7, 4, &model);
match = (u32)((baseFam << 8) | extFam);
/* Test each in turn looking for a match.
* Initialize the struct if found.
*/
if (match == fam15.compatibleKey)
{
Amdmemcpy((void *)nb, (const void *)&fam15, (u32) sizeof(cNorthBridge));
}
else if (match == fam10.compatibleKey)
{
Amdmemcpy((void *)nb, (const void *)&fam10, (u32) sizeof(cNorthBridge));
}
else
{
if (match == fam0f.compatibleKey)
{
Amdmemcpy((void *)nb, (const void *)&fam0f, (u32) sizeof(cNorthBridge));
}
else
{
STOP_HERE;
}
}
/* Update the initial limited key to the real one, which may include other matching info */
nb->compatibleKey = makeKey(node);
}
|