blob: de70e6d29431801a331920e7ddaa051d637d7952 [file] [log] [blame]
Stefan Reinauer23190272008-08-20 13:41:24 +00001/*
2 * inteltool - dump all registers on an Intel CPU + chipset based system.
3 *
Stefan Reinauer14e22772010-04-27 06:56:47 +00004 * Copyright (C) 2008-2010 by coresystems GmbH
Anton Kochkovc7fc4422012-07-21 06:36:47 +04005 * Copyright (C) 2012 Anton Kochkov
Stefan Reinauer14e22772010-04-27 06:56:47 +00006 *
Stefan Reinauer23190272008-08-20 13:41:24 +00007 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
Stefan Reinauer23190272008-08-20 13:41:24 +000015 */
16
17#include <stdio.h>
18#include <stdlib.h>
Stefan Reinauera7b296d2011-11-14 12:40:34 -080019#include <inttypes.h>
Stefan Reinauer23190272008-08-20 13:41:24 +000020#include "inteltool.h"
21
Stefan Taunerdbc6fcd2013-06-20 18:05:06 +020022/* 320766 */
23static const io_register_t nehalem_dmi_registers[] = {
24 { 0x00, 4, "DMIVCH" }, // DMI Virtual Channel Capability Header
25 { 0x04, 4, "DMIVCCAP1" }, // DMI Port VC Capability Register 1
26 { 0x08, 4, "DMIVCCAP2" }, // DMI Port VC Capability Register 2
27 { 0x0C, 4, "DMIVCCTL" }, // DMI Port VC Control
28 { 0x10, 4, "DMIVC0RCAP" }, // DMI VC0 Resource Capability
29 { 0x14, 4, "DMIVC0RCTL" }, // DMI VC0 Resource Control
30/* { 0x18, 2, "RSVD" }, // Reserved */
31 { 0x1A, 2, "DMIVC0RSTS" }, // DMI VC0 Resource Status
32 { 0x1C, 4, "DMIVC1RCAP" }, // DMI VC1 Resource Capability
33 { 0x20, 4, "DMIVC1RCTL" }, // DMI VC1 Resource Control
34/* { 0x24, 2, "RSVD" }, // Reserved */
35 { 0x26, 2, "DMIVC1RSTS" }, // DMI VC1 Resource Status
36/* ... - Reserved */
37 { 0x84, 4, "DMILCAP" }, // DMI Link Capabilities
38 { 0x88, 2, "DMILCTL" }, // DMI Link Control
39 { 0x8A, 2, "DMILSTS" }, // DMI Link Status
40/* ... - Reserved */
41};
42
43/* 322812 */
44static const io_register_t westmere_dmi_registers[] = {
45 { 0x00, 4, "DMIVCECH" }, // DMI Virtual Channel Enhanced Capability
46 { 0x04, 4, "DMIPVCCAP1" }, // DMI Port VC Capability Register 1
47 { 0x08, 4, "DMIPVCCAP2" }, // DMI Port VC Capability Register 2
48 { 0x0C, 2, "DMIPVCCTL" }, // DMI Port VC Control
49/* { 0x0E, 2, "RSVD" }, // Reserved */
50 { 0x10, 4, "DMIVC0RCAP" }, // DMI VC0 Resource Capability
51 { 0x14, 4, "DMIVC0RCTL" }, // DMI VC0 Resource Control
52/* { 0x18, 2, "RSVD" }, // Reserved */
53 { 0x1A, 2, "DMIVC0RSTS" }, // DMI VC0 Resource Status
54 { 0x1C, 4, "DMIVC1RCAP" }, // DMI VC1 Resource Capability
55 { 0x20, 4, "DMIVC1RCTL1" }, // DMI VC1 Resource Control
56/* { 0x24, 2, "RSVD" }, // Reserved */
57 { 0x26, 2, "DMIC1RSTS" }, // DMI VC1 Resource Status
58/* ... - Reserved */
59 { 0x84, 4, "DMILCAP" }, // DMI Link Capabilities
60 { 0x88, 2, "DMILCTL" }, // DMI Link Control
61 { 0x8A, 2, "DMILSTS" }, // DMI Link Status
62/* ... - Reserved */
63};
64
Anton Kochkovc7fc4422012-07-21 06:36:47 +040065static const io_register_t sandybridge_dmi_registers[] = {
66 { 0x00, 4, "DMI VCECH" }, // DMI Virtual Channel Enhanced Capability
67 { 0x04, 4, "DMI PVCCAP1" }, // DMI Port VC Capability Register 1
68 { 0x08, 4, "DMI PVVAP2" }, // DMI Port VC Capability Register 2
69 { 0x0C, 2, "DMI PVCCTL" }, // DMI Port VC Control
70/* { 0x0E, 2, "RSVD" }, // Reserved */
71 { 0x10, 4, "DMI VC0RCAP" }, // DMI VC0 Resource Capability
72 { 0x14, 4, "DMI VC0RCTL" }, // DMI VC0 Resource Control
73/* { 0x18, 2, "RSVD" }, // Reserved */
74 { 0x1A, 2, "DMI VC0RSTS" }, // DMI VC0 Resource Status
75 { 0x1C, 4, "DMI VC1RCAP" }, // DMI VC1 Resource Capability
76 { 0x20, 4, "DMI VC1RCTL" }, // DMI VC1 Resource Control
77/* { 0x24, 2, "RSVD" }, // Reserved */
78 { 0x26, 2, "DMI VC1RSTS" }, // DMI VC1 Resource Status
79 { 0x28, 4, "DMI VCPRCAP" }, // DMI VCp Resource Capability
80 { 0x2C, 4, "DMI VCPRCTL" }, // DMI VCp Resource Control
81/* { 0x30, 2, "RSVD" }, // Reserved */
82 { 0x32, 2, "DMI VCPRSTS" }, // DMI VCp Resource Status
83 { 0x34, 4, "DMI VCMRCAP" }, // DMI VCm Resource Capability
84 { 0x38, 4, "DMI VCMRCTL" }, // DMI VCm Resource Control
85/* { 0x3C, 2, "RSVD" }, // Reserved */
86 { 0x3E, 2, "DMI VCMRSTS" }, // DMI VCm Resource Status
87/* { 0x40, 4, "RSVD" }, // Reserved */
88 { 0x44, 4, "DMI ESC" }, // DMI Element Self Description
89/* { 0x48, 8, "RSVD" }, // Reserved */
90 { 0x50, 4, "DMI LE1D" }, // DMI Link Entry 1 Description
91/* { 0x54, 4, "RSVD" }, // Reserved */
92 { 0x58, 4, "DMI LE1A" }, // DMI Link Entry 1 Address
93 { 0x5C, 4, "DMI LUE1A" }, // DMI Link Upper Entry 1 Address
94 { 0x60, 4, "DMI LE2D" }, // DMI Link Entry 2 Description
95/* { 0x64, 4, "RSVD" }, // Reserved */
96 { 0x68, 4, "DMI LE2A" }, // DMI Link Entry 2 Address
97/* { 0x6C, 4, "RSVD" }, // Reserved
98 { 0x70, 8, "RSVD" }, // Reserved
99 { 0x78, 8, "RSVD" }, // Reserved
100 { 0x80, 4, "RSVD" }, // Reserved */
101 { 0x84, 4, "LCAP" }, // Link Capabilities
102 { 0x88, 2, "LCTL" }, // Link Control
103 { 0x8A, 2, "LSTS" }, // Link Status
104/* { 0x8C, 4, "RSVD" }, // Reserved
105 { 0x90, 4, "RSVD" }, // Reserved
106 { 0x94, 4, "RSVD" }, // Reserved */
107 { 0x98, 2, "LCTL2" }, // Link Control 2
108 { 0x9A, 2, "LSTS2" }, // Link Status 2
109/* ... - Reserved */
110 { 0xBC0, 4, "AFE_BMUF0" }, // AFE BMU Configuration Function 0
111 { 0xBC4, 4, "RSVD" }, // Reserved
112 { 0xBC8, 4, "RSVD" }, // Reserved
113 { 0xBCC, 4, "AFE_BMUT0" }, // AFE BMU Configuration Test 0
114/* ... - Reserved */
115};
116
Stefan Reinauer23190272008-08-20 13:41:24 +0000117/*
Dennis Wassenbergae6685f2014-10-30 10:30:40 +0100118 * All Haswell DMI Registers per
119 *
120 * Mobile 4th Generation Intel Core TM Processor Family, Mobile Intel Pentium Processor Family,
121 * and Mobile Intel Celeron Processor Family
122 * Datasheet Volume 2
123 * 329002-002
124 */
125static const io_register_t haswell_ult_dmi_registers[] = {
126 { 0x00, 4, "DMIVCECH" }, // DMI Virtual Channel Enhanced Capability
127 { 0x04, 4, "DMIPVCCAP1" }, // DMI Port VC Capability Register 1
128 { 0x08, 4, "DMIPVCCAP2" }, // DMI Port VC Capability Register 2
129 { 0x0C, 2, "DMI PVCCTL" }, // DMI Port VC Control
130/* { 0x0E, 2, "RSVD" }, // Reserved */
131 { 0x10, 4, "DMIVC0RCAP" }, // DMI VC0 Resource Capability
132 { 0x14, 4, "DMIVC0RCTL" }, // DMI VC0 Resource Control
133/* { 0x18, 2, "RSVD" }, // Reserved */
134 { 0x1A, 2, "DMIVC0RSTS" }, // DMI VC0 Resource Status
135 { 0x1C, 4, "DMIVC1RCAP" }, // DMI VC1 Resource Capability
136 { 0x20, 4, "DMIVC1RCTL" }, // DMI VC1 Resource Control
137/* { 0x24, 2, "RSVD" }, // Reserved */
138 { 0x26, 2, "DMIVC1RSTS" }, // DMI VC1 Resource Status
139 { 0x28, 4, "DMIVCPRCAP" }, // DMI VCp Resource Capability
140 { 0x2C, 4, "DMIVCPRCTL" }, // DMI VCp Resource Control
141/* { 0x30, 2, "RSVD" }, // Reserved */
142 { 0x32, 2, "DMIVCPRSTS" }, // DMI VCp Resource Status
143 { 0x34, 4, "DMIVCMRCAP" }, // DMI VCm Resource Capability
144 { 0x38, 4, "DMIVCMRCTL" }, // DMI VCm Resource Control
145/* { 0x3C, 2, "RSVD" }, // Reserved */
146 { 0x3E, 2, "DMIVCMRSTS" }, // DMI VCm Resource Status
147 { 0x40, 4, "DMIRCLDECH" }, // DMI Root Complex Link Declaration */
148 { 0x44, 4, "DMIESD" }, // DMI Element Self Description
149/* { 0x48, 4, "RSVD" }, // Reserved */
150/* { 0x4C, 4, "RSVD" }, // Reserved */
151 { 0x50, 4, "DMILE1D" }, // DMI Link Entry 1 Description
152/* { 0x54, 4, "RSVD" }, // Reserved */
153 { 0x58, 4, "DMILE1A" }, // DMI Link Entry 1 Address
154 { 0x5C, 4, "DMILUE1A" }, // DMI Link Upper Entry 1 Address
155 { 0x60, 4, "DMILE2D" }, // DMI Link Entry 2 Description
156/* { 0x64, 4, "RSVD" }, // Reserved */
157 { 0x68, 4, "DMILE2A" }, // DMI Link Entry 2 Address
158/* { 0x6C, 4, "RSVD" }, // Reserved */
159/* { 0x70, 4, "RSVD" }, // Reserved */
160/* { 0x74, 4, "RSVD" }, // Reserved */
161/* { 0x78, 4, "RSVD" }, // Reserved */
162/* { 0x7C, 4, "RSVD" }, // Reserved */
163/* { 0x80, 4, "RSVD" }, // Reserved */
164/* { 0x84, 4, "RSVD" }, // Reserved */
165 { 0x88, 2, "LCTL" }, // Link Control
166 /* ... - Reserved */
167 { 0x1C4, 4, "DMIUESTS" }, // DMI Uncorrectable Error Status
168 { 0x1C8, 4, "DMIUEMSK" }, // DMI Uncorrectable Error Mask
169 { 0x1D0, 4, "DMICESTS" }, // DMI Correctable Error Status
170 { 0x1D4, 4, "DMICEMSK" }, // DMI Correctable Error Mask
171/* ... - Reserved */
172};
173
174/*
Stefan Reinauer23190272008-08-20 13:41:24 +0000175 * Egress Port Root Complex MMIO configuration space
176 */
177int print_epbar(struct pci_dev *nb)
178{
179 int i, size = (4 * 1024);
180 volatile uint8_t *epbar;
Stefan Reinauer1162f252008-12-04 15:18:20 +0000181 uint64_t epbar_phys;
Stefan Reinauer23190272008-08-20 13:41:24 +0000182
183 printf("\n============= EPBAR =============\n\n");
184
185 switch (nb->device_id) {
Pat Erleyca3548e2010-04-21 06:23:19 +0000186 case PCI_DEVICE_ID_INTEL_82915:
Stefan Reinauer23190272008-08-20 13:41:24 +0000187 case PCI_DEVICE_ID_INTEL_82945GM:
Björn Busse2d33dc42010-08-01 15:33:30 +0000188 case PCI_DEVICE_ID_INTEL_82945GSE:
Stefan Reinauer3d9a12f2008-11-02 11:11:40 +0000189 case PCI_DEVICE_ID_INTEL_82945P:
Stefan Tauner1a00cf02012-10-13 06:23:52 +0200190 case PCI_DEVICE_ID_INTEL_82946:
Stefan Reinauer1162f252008-12-04 15:18:20 +0000191 case PCI_DEVICE_ID_INTEL_82975X:
Stefan Reinauer23190272008-08-20 13:41:24 +0000192 epbar_phys = pci_read_long(nb, 0x40) & 0xfffffffe;
193 break;
Stefan Tauner04c06002012-10-13 02:19:30 +0200194 case PCI_DEVICE_ID_INTEL_82965PM:
195 case PCI_DEVICE_ID_INTEL_82Q965:
196 case PCI_DEVICE_ID_INTEL_82Q35:
197 case PCI_DEVICE_ID_INTEL_82G33:
198 case PCI_DEVICE_ID_INTEL_82Q33:
199 case PCI_DEVICE_ID_INTEL_82X38:
Ruud Schrampbb41f502011-04-04 07:53:19 +0200200 case PCI_DEVICE_ID_INTEL_32X0:
Damien Zammit9c986642015-08-17 21:04:41 +1000201 case PCI_DEVICE_ID_INTEL_82XX4X:
202 case PCI_DEVICE_ID_INTEL_82Q45:
203 case PCI_DEVICE_ID_INTEL_82G45:
204 case PCI_DEVICE_ID_INTEL_82G41:
205 case PCI_DEVICE_ID_INTEL_82B43:
206 case PCI_DEVICE_ID_INTEL_82B43_2:
Corey Osgood23d98c72010-07-29 19:25:31 +0000207 case PCI_DEVICE_ID_INTEL_ATOM_DXXX:
208 case PCI_DEVICE_ID_INTEL_ATOM_NXXX:
Felix Heldfac95e32014-11-09 00:11:28 +0100209 case PCI_DEVICE_ID_INTEL_CORE_2ND_GEN_D:
210 case PCI_DEVICE_ID_INTEL_CORE_2ND_GEN_M:
211 case PCI_DEVICE_ID_INTEL_CORE_2ND_GEN_E3:
212 case PCI_DEVICE_ID_INTEL_CORE_3RD_GEN_D:
213 case PCI_DEVICE_ID_INTEL_CORE_3RD_GEN_M:
214 case PCI_DEVICE_ID_INTEL_CORE_3RD_GEN_E3:
215 case PCI_DEVICE_ID_INTEL_CORE_3RD_GEN_015c:
216 case PCI_DEVICE_ID_INTEL_CORE_4TH_GEN_D:
217 case PCI_DEVICE_ID_INTEL_CORE_4TH_GEN_M:
218 case PCI_DEVICE_ID_INTEL_CORE_4TH_GEN_E3:
Dennis Wassenbergae6685f2014-10-30 10:30:40 +0100219 case PCI_DEVICE_ID_INTEL_CORE_4TH_GEN_U:
Matt DeVillier5b667df2015-05-14 21:58:33 -0500220 case PCI_DEVICE_ID_INTEL_CORE_5TH_GEN_U:
Stefan Tauner04c06002012-10-13 02:19:30 +0200221 epbar_phys = pci_read_long(nb, 0x40) & 0xfffffffe;
222 epbar_phys |= ((uint64_t)pci_read_long(nb, 0x44)) << 32;
223 break;
Stefan Reinauerb2aedb12009-08-29 15:45:43 +0000224 case PCI_DEVICE_ID_INTEL_82810:
Stefan Tauner04c06002012-10-13 02:19:30 +0200225 case PCI_DEVICE_ID_INTEL_82810_DC:
226 case PCI_DEVICE_ID_INTEL_82810E_DC:
Stefan Reinauer04844812010-02-22 11:26:06 +0000227 case PCI_DEVICE_ID_INTEL_82830M:
Idwer Vollering312fc962010-12-17 22:34:58 +0000228 case PCI_DEVICE_ID_INTEL_82865:
229 printf("This northbridge does not have EPBAR.\n");
Stefan Reinauer23190272008-08-20 13:41:24 +0000230 return 1;
231 default:
232 printf("Error: Dumping EPBAR on this northbridge is not (yet) supported.\n");
233 return 1;
234 }
235
Stefan Reinauer1162f252008-12-04 15:18:20 +0000236 epbar = map_physical(epbar_phys, size);
Stefan Reinauer14e22772010-04-27 06:56:47 +0000237
Stefan Reinauer1162f252008-12-04 15:18:20 +0000238 if (epbar == NULL) {
Stefan Reinauer23190272008-08-20 13:41:24 +0000239 perror("Error mapping EPBAR");
240 exit(1);
241 }
242
Stefan Reinauera7b296d2011-11-14 12:40:34 -0800243 printf("EPBAR = 0x%08" PRIx64 " (MEM)\n\n", epbar_phys);
Stefan Reinauer23190272008-08-20 13:41:24 +0000244 for (i = 0; i < size; i += 4) {
245 if (*(uint32_t *)(epbar + i))
246 printf("0x%04x: 0x%08x\n", i, *(uint32_t *)(epbar+i));
247 }
248
Stefan Reinauer1162f252008-12-04 15:18:20 +0000249 unmap_physical((void *)epbar, size);
Stefan Reinauer23190272008-08-20 13:41:24 +0000250 return 0;
251}
252
253/*
254 * MCH-ICH Serial Interconnect Ingress Root Complex MMIO configuration space
255 */
256int print_dmibar(struct pci_dev *nb)
257{
258 int i, size = (4 * 1024);
259 volatile uint8_t *dmibar;
Stefan Reinauer1162f252008-12-04 15:18:20 +0000260 uint64_t dmibar_phys;
Anton Kochkovc7fc4422012-07-21 06:36:47 +0400261 const io_register_t *dmi_registers = NULL;
Stefan Reinauer23190272008-08-20 13:41:24 +0000262
263 printf("\n============= DMIBAR ============\n\n");
264
265 switch (nb->device_id) {
Pat Erleyca3548e2010-04-21 06:23:19 +0000266 case PCI_DEVICE_ID_INTEL_82915:
Stefan Reinauer23190272008-08-20 13:41:24 +0000267 case PCI_DEVICE_ID_INTEL_82945GM:
Björn Busse2d33dc42010-08-01 15:33:30 +0000268 case PCI_DEVICE_ID_INTEL_82945GSE:
Stefan Reinauer3d9a12f2008-11-02 11:11:40 +0000269 case PCI_DEVICE_ID_INTEL_82945P:
Stefan Reinauer1162f252008-12-04 15:18:20 +0000270 case PCI_DEVICE_ID_INTEL_82975X:
Stefan Reinauer23190272008-08-20 13:41:24 +0000271 dmibar_phys = pci_read_long(nb, 0x4c) & 0xfffffffe;
272 break;
Stefan Tauner1a00cf02012-10-13 06:23:52 +0200273 case PCI_DEVICE_ID_INTEL_82946:
Stefan Tauner04c06002012-10-13 02:19:30 +0200274 case PCI_DEVICE_ID_INTEL_82965PM:
275 case PCI_DEVICE_ID_INTEL_82Q965:
Warren Turkal53291952010-09-03 09:32:17 +0000276 case PCI_DEVICE_ID_INTEL_82Q35:
277 case PCI_DEVICE_ID_INTEL_82G33:
278 case PCI_DEVICE_ID_INTEL_82Q33:
Stefan Tauner04c06002012-10-13 02:19:30 +0200279 case PCI_DEVICE_ID_INTEL_82X38:
Ruud Schrampbb41f502011-04-04 07:53:19 +0200280 case PCI_DEVICE_ID_INTEL_32X0:
Damien Zammit9c986642015-08-17 21:04:41 +1000281 case PCI_DEVICE_ID_INTEL_82XX4X:
282 case PCI_DEVICE_ID_INTEL_82Q45:
283 case PCI_DEVICE_ID_INTEL_82G45:
284 case PCI_DEVICE_ID_INTEL_82G41:
285 case PCI_DEVICE_ID_INTEL_82B43:
286 case PCI_DEVICE_ID_INTEL_82B43_2:
Corey Osgood23d98c72010-07-29 19:25:31 +0000287 case PCI_DEVICE_ID_INTEL_ATOM_DXXX:
288 case PCI_DEVICE_ID_INTEL_ATOM_NXXX:
Warren Turkal53291952010-09-03 09:32:17 +0000289 dmibar_phys = pci_read_long(nb, 0x68) & 0xfffffffe;
290 dmibar_phys |= ((uint64_t)pci_read_long(nb, 0x6c)) << 32;
291 break;
Stefan Reinauerb2aedb12009-08-29 15:45:43 +0000292 case PCI_DEVICE_ID_INTEL_82810:
Stefan Tauner04c06002012-10-13 02:19:30 +0200293 case PCI_DEVICE_ID_INTEL_82810_DC:
294 case PCI_DEVICE_ID_INTEL_82810E_DC:
Idwer Vollering312fc962010-12-17 22:34:58 +0000295 case PCI_DEVICE_ID_INTEL_82865:
296 printf("This northbridge does not have DMIBAR.\n");
Stefan Reinauer23190272008-08-20 13:41:24 +0000297 return 1;
Stefan Tauner04c06002012-10-13 02:19:30 +0200298 case PCI_DEVICE_ID_INTEL_82X58:
Warren Turkal3235eea2010-09-03 09:31:13 +0000299 dmibar_phys = pci_read_long(nb, 0x50) & 0xfffff000;
300 break;
Stefan Taunerdbc6fcd2013-06-20 18:05:06 +0200301 case PCI_DEVICE_ID_INTEL_CORE_0TH_GEN:
302 /* DMIBAR is called DMIRCBAR in Nehalem */
303 dmibar_phys = pci_read_long(nb, 0x50) & 0xfffff000; /* 31:12 */
304 dmi_registers = nehalem_dmi_registers;
305 size = ARRAY_SIZE(nehalem_dmi_registers);
306 break;
Stefan Tauner04c06002012-10-13 02:19:30 +0200307 case PCI_DEVICE_ID_INTEL_CORE_1ST_GEN:
308 dmibar_phys = pci_read_long(nb, 0x68);
309 dmibar_phys |= ((uint64_t)pci_read_long(nb, 0x6c)) << 32;
310 dmibar_phys &= 0x0000000ffffff000UL; /* 35:12 */
Stefan Taunerdbc6fcd2013-06-20 18:05:06 +0200311 dmi_registers = westmere_dmi_registers;
312 size = ARRAY_SIZE(westmere_dmi_registers);
Stefan Tauner04c06002012-10-13 02:19:30 +0200313 break;
Felix Held0cc8f292014-11-05 03:18:44 +0100314 case PCI_DEVICE_ID_INTEL_CORE_2ND_GEN_D:
315 case PCI_DEVICE_ID_INTEL_CORE_2ND_GEN_M:
Felix Heldfac95e32014-11-09 00:11:28 +0100316 case PCI_DEVICE_ID_INTEL_CORE_2ND_GEN_E3:
Anton Kochkovc7fc4422012-07-21 06:36:47 +0400317 dmi_registers = sandybridge_dmi_registers;
318 size = ARRAY_SIZE(sandybridge_dmi_registers);
Felix Heldfac95e32014-11-09 00:11:28 +0100319 case PCI_DEVICE_ID_INTEL_CORE_3RD_GEN_D: /* pretty printing not implemented yet */
320 case PCI_DEVICE_ID_INTEL_CORE_3RD_GEN_M:
321 case PCI_DEVICE_ID_INTEL_CORE_3RD_GEN_E3:
322 case PCI_DEVICE_ID_INTEL_CORE_3RD_GEN_015c:
323 case PCI_DEVICE_ID_INTEL_CORE_4TH_GEN_D:
324 case PCI_DEVICE_ID_INTEL_CORE_4TH_GEN_M:
325 case PCI_DEVICE_ID_INTEL_CORE_4TH_GEN_E3:
Stefan Tauner04c06002012-10-13 02:19:30 +0200326 dmibar_phys = pci_read_long(nb, 0x68);
327 dmibar_phys |= ((uint64_t)pci_read_long(nb, 0x6c)) << 32;
328 dmibar_phys &= 0x0000007ffffff000UL; /* 38:12 */
Anton Kochkovc7fc4422012-07-21 06:36:47 +0400329 break;
Dennis Wassenbergae6685f2014-10-30 10:30:40 +0100330 case PCI_DEVICE_ID_INTEL_CORE_4TH_GEN_U:
Matt DeVillier5b667df2015-05-14 21:58:33 -0500331 case PCI_DEVICE_ID_INTEL_CORE_5TH_GEN_U:
Dennis Wassenbergae6685f2014-10-30 10:30:40 +0100332 dmi_registers = haswell_ult_dmi_registers;
333 size = ARRAY_SIZE(haswell_ult_dmi_registers);
334 dmibar_phys = pci_read_long(nb, 0x68);
335 dmibar_phys |= ((uint64_t)pci_read_long(nb, 0x6c)) << 32;
336 dmibar_phys &= 0x0000007ffffff000UL; /* 38:12 */
337 break;
338
Stefan Reinauer23190272008-08-20 13:41:24 +0000339 default:
340 printf("Error: Dumping DMIBAR on this northbridge is not (yet) supported.\n");
341 return 1;
342 }
343
Stefan Reinauer1162f252008-12-04 15:18:20 +0000344 dmibar = map_physical(dmibar_phys, size);
Stefan Reinauer14e22772010-04-27 06:56:47 +0000345
Stefan Reinauer1162f252008-12-04 15:18:20 +0000346 if (dmibar == NULL) {
Stefan Reinauer23190272008-08-20 13:41:24 +0000347 perror("Error mapping DMIBAR");
348 exit(1);
349 }
350
Stefan Reinauera7b296d2011-11-14 12:40:34 -0800351 printf("DMIBAR = 0x%08" PRIx64 " (MEM)\n\n", dmibar_phys);
Anton Kochkovc7fc4422012-07-21 06:36:47 +0400352 if (dmi_registers != NULL) {
353 for (i = 0; i < size; i++) {
354 switch (dmi_registers[i].size) {
355 case 4:
356 printf("dmibase+0x%04x: 0x%08x (%s)\n",
357 dmi_registers[i].addr,
358 *(uint32_t *)(dmibar+dmi_registers[i].addr),
359 dmi_registers[i].name);
360 break;
361 case 2:
362 printf("dmibase+0x%04x: 0x%04x (%s)\n",
363 dmi_registers[i].addr,
364 *(uint16_t *)(dmibar+dmi_registers[i].addr),
365 dmi_registers[i].name);
366 break;
367 case 1:
368 printf("dmibase+0x%04x: 0x%02x (%s)\n",
369 dmi_registers[i].addr,
370 *(uint8_t *)(dmibar+dmi_registers[i].addr),
371 dmi_registers[i].name);
372 break;
373 }
374 }
375 } else {
376 for (i = 0; i < size; i += 4) {
377 if (*(uint32_t *)(dmibar + i))
378 printf("0x%04x: 0x%08x\n", i, *(uint32_t *)(dmibar+i));
379 }
Stefan Reinauer23190272008-08-20 13:41:24 +0000380 }
381
Stefan Reinauer1162f252008-12-04 15:18:20 +0000382 unmap_physical((void *)dmibar, size);
Stefan Reinauer23190272008-08-20 13:41:24 +0000383 return 0;
384}
385
386/*
387 * PCIe MMIO configuration space
388 */
389int print_pciexbar(struct pci_dev *nb)
390{
Stefan Reinauer1162f252008-12-04 15:18:20 +0000391 uint64_t pciexbar_reg;
392 uint64_t pciexbar_phys;
Stefan Reinauer23190272008-08-20 13:41:24 +0000393 volatile uint8_t *pciexbar;
394 int max_busses, devbase, i;
395 int bus, dev, fn;
396
397 printf("========= PCIEXBAR ========\n\n");
398
399 switch (nb->device_id) {
Pat Erleyca3548e2010-04-21 06:23:19 +0000400 case PCI_DEVICE_ID_INTEL_82915:
Stefan Reinauer23190272008-08-20 13:41:24 +0000401 case PCI_DEVICE_ID_INTEL_82945GM:
Björn Busse2d33dc42010-08-01 15:33:30 +0000402 case PCI_DEVICE_ID_INTEL_82945GSE:
Stefan Reinauer3d9a12f2008-11-02 11:11:40 +0000403 case PCI_DEVICE_ID_INTEL_82945P:
Stefan Reinauer1162f252008-12-04 15:18:20 +0000404 case PCI_DEVICE_ID_INTEL_82975X:
Stefan Reinauer23190272008-08-20 13:41:24 +0000405 pciexbar_reg = pci_read_long(nb, 0x48);
406 break;
Stefan Tauner1a00cf02012-10-13 06:23:52 +0200407 case PCI_DEVICE_ID_INTEL_82946:
Stefan Tauner04c06002012-10-13 02:19:30 +0200408 case PCI_DEVICE_ID_INTEL_82965PM:
409 case PCI_DEVICE_ID_INTEL_82Q965:
410 case PCI_DEVICE_ID_INTEL_82Q35:
411 case PCI_DEVICE_ID_INTEL_82G33:
412 case PCI_DEVICE_ID_INTEL_82Q33:
413 case PCI_DEVICE_ID_INTEL_82X38:
Ruud Schrampbb41f502011-04-04 07:53:19 +0200414 case PCI_DEVICE_ID_INTEL_32X0:
Damien Zammit9c986642015-08-17 21:04:41 +1000415 case PCI_DEVICE_ID_INTEL_82XX4X:
416 case PCI_DEVICE_ID_INTEL_82Q45:
417 case PCI_DEVICE_ID_INTEL_82G45:
418 case PCI_DEVICE_ID_INTEL_82G41:
419 case PCI_DEVICE_ID_INTEL_82B43:
420 case PCI_DEVICE_ID_INTEL_82B43_2:
Corey Osgood23d98c72010-07-29 19:25:31 +0000421 case PCI_DEVICE_ID_INTEL_ATOM_DXXX:
422 case PCI_DEVICE_ID_INTEL_ATOM_NXXX:
Felix Heldfac95e32014-11-09 00:11:28 +0100423 case PCI_DEVICE_ID_INTEL_CORE_2ND_GEN_D:
424 case PCI_DEVICE_ID_INTEL_CORE_2ND_GEN_M:
425 case PCI_DEVICE_ID_INTEL_CORE_2ND_GEN_E3:
426 case PCI_DEVICE_ID_INTEL_CORE_3RD_GEN_D:
427 case PCI_DEVICE_ID_INTEL_CORE_3RD_GEN_M:
428 case PCI_DEVICE_ID_INTEL_CORE_3RD_GEN_E3:
429 case PCI_DEVICE_ID_INTEL_CORE_3RD_GEN_015c:
430 case PCI_DEVICE_ID_INTEL_CORE_4TH_GEN_D:
431 case PCI_DEVICE_ID_INTEL_CORE_4TH_GEN_M:
432 case PCI_DEVICE_ID_INTEL_CORE_4TH_GEN_E3:
Dennis Wassenbergae6685f2014-10-30 10:30:40 +0100433 case PCI_DEVICE_ID_INTEL_CORE_4TH_GEN_U:
Matt DeVillier5b667df2015-05-14 21:58:33 -0500434 case PCI_DEVICE_ID_INTEL_CORE_5TH_GEN_U:
Stefan Tauner04c06002012-10-13 02:19:30 +0200435 pciexbar_reg = pci_read_long(nb, 0x60);
436 pciexbar_reg |= ((uint64_t)pci_read_long(nb, 0x64)) << 32;
437 break;
Stefan Reinauerb2aedb12009-08-29 15:45:43 +0000438 case PCI_DEVICE_ID_INTEL_82810:
Stefan Tauner04c06002012-10-13 02:19:30 +0200439 case PCI_DEVICE_ID_INTEL_82810_DC:
440 case PCI_DEVICE_ID_INTEL_82810E_DC:
Idwer Vollering312fc962010-12-17 22:34:58 +0000441 case PCI_DEVICE_ID_INTEL_82865:
442 printf("Error: This northbridge does not have PCIEXBAR.\n");
Stefan Reinauer23190272008-08-20 13:41:24 +0000443 return 1;
444 default:
445 printf("Error: Dumping PCIEXBAR on this northbridge is not (yet) supported.\n");
446 return 1;
447 }
448
449 if (!(pciexbar_reg & (1 << 0))) {
450 printf("PCIEXBAR register is disabled.\n");
451 return 0;
452 }
453
454 switch ((pciexbar_reg >> 1) & 3) {
455 case 0: // 256MB
Paul Menzel17c05f22013-04-03 10:00:33 +0200456 pciexbar_phys = pciexbar_reg & (0xffULL << 28);
Stefan Reinauer23190272008-08-20 13:41:24 +0000457 max_busses = 256;
458 break;
459 case 1: // 128M
Paul Menzel17c05f22013-04-03 10:00:33 +0200460 pciexbar_phys = pciexbar_reg & (0x1ffULL << 27);
Stefan Reinauer23190272008-08-20 13:41:24 +0000461 max_busses = 128;
462 break;
463 case 2: // 64M
Paul Menzel17c05f22013-04-03 10:00:33 +0200464 pciexbar_phys = pciexbar_reg & (0x3ffULL << 26);
Stefan Reinauer23190272008-08-20 13:41:24 +0000465 max_busses = 64;
466 break;
467 default: // RSVD
468 printf("Undefined address base. Bailing out.\n");
469 return 1;
Stefan Reinauer14e22772010-04-27 06:56:47 +0000470 }
Stefan Reinauer23190272008-08-20 13:41:24 +0000471
Stefan Reinauera7b296d2011-11-14 12:40:34 -0800472 printf("PCIEXBAR: 0x%08" PRIx64 "\n", pciexbar_phys);
Stefan Reinauer23190272008-08-20 13:41:24 +0000473
Stefan Reinauer1162f252008-12-04 15:18:20 +0000474 pciexbar = map_physical(pciexbar_phys, (max_busses * 1024 * 1024));
Stefan Reinauer14e22772010-04-27 06:56:47 +0000475
Stefan Reinauer1162f252008-12-04 15:18:20 +0000476 if (pciexbar == NULL) {
Stefan Reinauer23190272008-08-20 13:41:24 +0000477 perror("Error mapping PCIEXBAR");
478 exit(1);
479 }
Stefan Reinauer14e22772010-04-27 06:56:47 +0000480
Stefan Reinauer23190272008-08-20 13:41:24 +0000481 for (bus = 0; bus < max_busses; bus++) {
482 for (dev = 0; dev < 32; dev++) {
483 for (fn = 0; fn < 8; fn++) {
484 devbase = (bus * 1024 * 1024) + (dev * 32 * 1024) + (fn * 4 * 1024);
485
486 if (*(uint16_t *)(pciexbar + devbase) == 0xffff)
487 continue;
Stefan Reinauer14e22772010-04-27 06:56:47 +0000488
Stefan Reinauer23190272008-08-20 13:41:24 +0000489 /* This is a heuristics. Anyone got a better check? */
490 if( (*(uint32_t *)(pciexbar + devbase + 256) == 0xffffffff) &&
491 (*(uint32_t *)(pciexbar + devbase + 512) == 0xffffffff) ) {
492#if DEBUG
493 printf("Skipped non-PCIe device %02x:%02x.%01x\n", bus, dev, fn);
494#endif
495 continue;
496 }
497
498 printf("\nPCIe %02x:%02x.%01x extended config space:", bus, dev, fn);
499 for (i = 0; i < 4096; i++) {
500 if((i % 0x10) == 0)
501 printf("\n%04x:", i);
502 printf(" %02x", *(pciexbar+devbase+i));
503 }
504 printf("\n");
505 }
506 }
507 }
508
Stefan Reinauer1162f252008-12-04 15:18:20 +0000509 unmap_physical((void *)pciexbar, (max_busses * 1024 * 1024));
Stefan Reinauer23190272008-08-20 13:41:24 +0000510
511 return 0;
512}