blob: d479bfdc06e401807e3d0d854bd760151348d699 [file] [log] [blame]
Stefan Reinauer23190272008-08-20 13:41:24 +00001/*
2 * inteltool - dump all registers on an Intel CPU + chipset based system.
3 *
4 * Copyright (C) 2008 by coresystems GmbH
5 * written by Stefan Reinauer <stepan@coresystems.de>
6 *
7 * 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.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21#include <stdio.h>
Stefan Reinauer23190272008-08-20 13:41:24 +000022#include "inteltool.h"
23
Stefan Reinauer1162f252008-12-04 15:18:20 +000024static const io_register_t ich7_pm_registers[] = {
25 { 0x00, 2, "PM1_STS" },
26 { 0x02, 2, "PM1_EN" },
27 { 0x04, 4, "PM1_CNT" },
28 { 0x08, 4, "PM1_TMR" },
29 { 0x0c, 4, "RESERVED" },
30 { 0x10, 4, "PROC_CNT" },
31#if DANGEROUS_REGISTERS
32 /* These registers return 0 on read, but reading them may cause
33 * the system to enter C2/C3/C4 state, which might hang the system.
34 */
35 { 0x14, 1, "LV2 (Mobile/Ultra Mobile)" },
36 { 0x15, 1, "LV3 (Mobile/Ultra Mobile)" },
37 { 0x16, 1, "LV4 (Mobile/Ultra Mobile)" },
38#endif
39 { 0x17, 1, "RESERVED" },
40 { 0x18, 4, "RESERVED" },
41 { 0x1c, 4, "RESERVED" },
42 { 0x20, 1, "PM2_CNT (Mobile/Ultra Mobile)" },
43 { 0x21, 1, "RESERVED" },
44 { 0x22, 2, "RESERVED" },
45 { 0x24, 4, "RESERVED" },
46 { 0x28, 4, "GPE0_STS" },
47 { 0x2C, 4, "GPE0_EN" },
48 { 0x30, 4, "SMI_EN" },
49 { 0x34, 4, "SMI_STS" },
50 { 0x38, 2, "ALT_GP_SMI_EN" },
51 { 0x3a, 2, "ALT_GP_SMI_STS" },
52 { 0x3c, 4, "RESERVED" },
53 { 0x40, 2, "RESERVED" },
54 { 0x42, 1, "GPE_CNTL" },
55 { 0x43, 1, "RESERVED" },
56 { 0x44, 2, "DEVACT_STS" },
57 { 0x46, 2, "RESERVED" },
58 { 0x48, 4, "RESERVED" },
59 { 0x4c, 4, "RESERVED" },
60 { 0x50, 1, "SS_CNT (Mobile/Ultra Mobile)" },
61 { 0x51, 1, "RESERVED" },
62 { 0x52, 2, "RESERVED" },
63 { 0x54, 4, "C3_RES (Mobile/Ultra Mobile)" },
64 { 0x58, 4, "RESERVED" },
65 { 0x5c, 4, "RESERVED" },
66 /* Here start the TCO registers */
67 { 0x60, 2, "TCO_RLD" },
68 { 0x62, 1, "TCO_DAT_IN" },
69 { 0x63, 1, "TCO_DAT_OUT" },
70 { 0x64, 2, "TCO1_STS" },
71 { 0x66, 2, "TCO2_STS" },
72 { 0x68, 2, "TCO1_CNT" },
73 { 0x6a, 2, "TCO2_CNT" },
74 { 0x6c, 2, "TCO_MESSAGE" },
75 { 0x6e, 1, "TCO_WDCNT" },
76 { 0x6f, 1, "RESERVED" },
77 { 0x70, 1, "SW_IRQ_GEN" },
78 { 0x71, 1, "RESERVED" },
79 { 0x72, 2, "TCO_TMR" },
80 { 0x74, 4, "RESERVED" },
81 { 0x78, 4, "RESERVED" },
82 { 0x7c, 4, "RESERVED" },
83};
84
85static const io_register_t ich8_pm_registers[] = {
86 { 0x00, 2, "PM1_STS" },
87 { 0x02, 2, "PM1_EN" },
88 { 0x04, 4, "PM1_CNT" },
89 { 0x08, 4, "PM1_TMR" },
90 { 0x0c, 4, "RESERVED" },
91 { 0x10, 4, "PROC_CNT" },
92#if DANGEROUS_REGISTERS
93 /* These registers return 0 on read, but reading them may cause
94 * the system to enter Cx states, which might hang the system.
95 */
96 { 0x14, 1, "LV2 (Mobile)" },
97 { 0x15, 1, "LV3 (Mobile)" },
98 { 0x16, 1, "LV4 (Mobile)" },
99 { 0x17, 1, "LV5 (Mobile)" },
100 { 0x18, 1, "LV6 (Mobile)" },
101#endif
102 { 0x19, 1, "RESERVED" },
103 { 0x1a, 2, "RESERVED" },
104 { 0x1c, 4, "RESERVED" },
105 { 0x20, 1, "PM2_CNT (Mobile)" },
106 { 0x21, 1, "RESERVED" },
107 { 0x22, 2, "RESERVED" },
108 { 0x24, 4, "RESERVED" },
109 { 0x28, 4, "GPE0_STS" },
110 { 0x2C, 4, "GPE0_EN" },
111 { 0x30, 4, "SMI_EN" },
112 { 0x34, 4, "SMI_STS" },
113 { 0x38, 2, "ALT_GP_SMI_EN" },
114 { 0x3a, 2, "ALT_GP_SMI_STS" },
115 { 0x3c, 4, "RESERVED" },
116 { 0x40, 2, "RESERVED" },
117 { 0x42, 1, "GPE_CNTL" },
118 { 0x43, 1, "RESERVED" },
119 { 0x44, 2, "DEVACT_STS" },
120 { 0x46, 2, "RESERVED" },
121 { 0x48, 4, "RESERVED" },
122 { 0x4c, 4, "RESERVED" },
123 { 0x50, 1, "SS_CNT (Mobile)" },
124 { 0x51, 1, "RESERVED" },
125 { 0x52, 2, "RESERVED" },
126 { 0x54, 4, "C3_RES (Mobile)" },
127 { 0x58, 4, "C5_RES (Mobile)" },
128 { 0x5c, 4, "RESERVED" },
129 /* Here start the TCO registers */
130 { 0x60, 2, "TCO_RLD" },
131 { 0x62, 1, "TCO_DAT_IN" },
132 { 0x63, 1, "TCO_DAT_OUT" },
133 { 0x64, 2, "TCO1_STS" },
134 { 0x66, 2, "TCO2_STS" },
135 { 0x68, 2, "TCO1_CNT" },
136 { 0x6a, 2, "TCO2_CNT" },
137 { 0x6c, 2, "TCO_MESSAGE" },
138 { 0x6e, 1, "TCO_WDCNT" },
139 { 0x6f, 1, "RESERVED" },
140 { 0x70, 1, "SW_IRQ_GEN" },
141 { 0x71, 1, "RESERVED" },
142 { 0x72, 2, "TCO_TMR" },
143 { 0x74, 4, "RESERVED" },
144 { 0x78, 4, "RESERVED" },
145 { 0x7c, 4, "RESERVED" },
146};
147
Stefan Reinauerb2aedb12009-08-29 15:45:43 +0000148static const io_register_t ich0_pm_registers[] = {
149 { 0x00, 2, "PM1_STS" },
150 { 0x02, 2, "PM1_EN" },
151 { 0x04, 4, "PM1_CNT" },
152 { 0x08, 4, "PM1_TMR" },
153 { 0x0c, 4, "RESERVED" },
154 { 0x10, 4, "PROC_CNT" },
155#if DANGEROUS_REGISTERS
156 /* This register returns 0 on read, but reading it may cause
157 * the system to enter C2 state, which might hang the system.
158 */
159 { 0x14, 1, "LV2" },
160 { 0x15, 1, "RESERVED" },
161 { 0x16, 2, "RESERVED" },
162#endif
163 { 0x18, 4, "RESERVED" },
164 { 0x1c, 4, "RESERVED" },
165 { 0x20, 4, "RESERVED" },
166 { 0x24, 4, "RESERVED" },
167 { 0x28, 4, "GPE0_STS" },
168 { 0x2C, 4, "GPE0_EN" },
169 { 0x30, 2, "SMI_EN" },
170 { 0x32, 2, "RESERVED" },
171 { 0x34, 2, "SMI_STS" },
172 { 0x36, 2, "RESERVED" },
173 { 0x38, 4, "RESERVED" },
174 { 0x3c, 4, "RESERVED" },
175 { 0x40, 2, "IOMON_STS_EN" },
176 { 0x42, 2, "RESERVED" },
177 { 0x44, 2, "DEVACT_STS" },
178 { 0x46, 2, "RESERVED" },
179 { 0x48, 4, "RESERVED" },
180 { 0x4c, 2, "BUS_ADDR_TRACK" },
181 { 0x4e, 1, "BUS_CYC_TRACK" },
182 { 0x4f, 1, "RESERVED" },
183 { 0x50, 4, "RESERVED" },
184 { 0x54, 4, "RESERVED" },
185 { 0x58, 4, "RESERVED" },
186 { 0x5c, 4, "RESERVED" },
187 /* Here start the TCO registers */
188 { 0x60, 1, "TCO_RLD" },
189 { 0x61, 1, "TCO_TMR" },
190 { 0x62, 1, "TCO_DAT_IN" },
191 { 0x63, 1, "TCO_DAT_OUT" },
192 { 0x64, 2, "TCO1_STS" },
193 { 0x66, 2, "TCO2_STS" },
194 { 0x68, 2, "TCO1_CNT" },
195 { 0x6a, 2, "TCO2_CNT" },
196 { 0x6c, 1, "TCO_MESSAGE1" },
197 { 0x6d, 1, "TCO_MESSAGE2" },
198 { 0x6e, 1, "TCO_WDSTATUS" },
199 { 0x6f, 1, "RESERVED" },
200 { 0x70, 4, "RESERVED" },
201 { 0x74, 4, "RESERVED" },
202 { 0x78, 4, "RESERVED" },
203 { 0x7c, 4, "RESERVED" },
204};
205
Maciej Pijanka90d17402009-09-30 17:05:46 +0000206static const io_register_t i82371xx_pm_registers[] = {
207 { 0x00, 2, "PMSTS" },
208 { 0x02, 2, "PMEN" },
209 { 0x04, 2, "PMCNTRL" },
210 { 0x06, 2, "RESERVED" },
211 { 0x08, 1, "PMTMR" },
212 { 0x09, 1, "RESERVED" },
213 { 0x0A, 1, "RESERVED" },
214 { 0x0B, 1, "RESERVED" },
215 { 0x0C, 2, "GPSTS" },
216 { 0x0E, 2, "GPEN" },
217 { 0x10, 4, "PCNTRL" },
218#if DANGEROUS_REGISTERS
219 /*
220 * This register returns 0 on read, but reading it may cause
221 * the system to enter C2 state, which might hang the system.
222 */
223 { 0x14, 1, "PLVL2" },
224 { 0x15, 1, "PLVL3" },
225 { 0x16, 2, "RESERVED" },
226#endif
227 { 0x18, 2, "GLBSTS" },
228 { 0x1A, 2, "RESERVED" },
229 { 0x1c, 4, "DEVSTS" },
230 { 0x20, 2, "GLBEN" },
231 { 0x22, 1, "RESERVED" },
232 { 0x23, 1, "RESERVED" },
233 { 0x24, 1, "RESERVED" },
234 { 0x25, 1, "RESERVED" },
235 { 0x26, 1, "RESERVED" },
236 { 0x27, 1, "RESERVED" },
237 { 0x28, 4, "GLBCTL" },
238 { 0x2C, 4, "DEVCTL" },
239 /* The registers 0x30-0x33 and 0x34-0x37 allow byte-wise reads only. */
240 { 0x30, 1, "GPIREG 0" },
241 { 0x31, 1, "GPIREG 1" },
242 { 0x32, 1, "GPIREG 2" },
243 { 0x33, 1, "GPIREG 3" },
244 { 0x34, 1, "GPOREG 0" },
245 { 0x35, 1, "GPOREG 1" },
246 { 0x36, 1, "GPOREG 2" },
247 { 0x37, 1, "GPOREG 3" },
248};
249
Stefan Reinauer23190272008-08-20 13:41:24 +0000250int print_pmbase(struct pci_dev *sb)
251{
Stefan Reinauer1162f252008-12-04 15:18:20 +0000252 int i, size;
Stefan Reinauer23190272008-08-20 13:41:24 +0000253 uint16_t pmbase;
Stefan Reinauer1162f252008-12-04 15:18:20 +0000254 const io_register_t *pm_registers;
Stefan Reinauer23190272008-08-20 13:41:24 +0000255
256 printf("\n============= PMBASE ============\n\n");
257
258 switch (sb->device_id) {
259 case PCI_DEVICE_ID_INTEL_ICH7:
260 case PCI_DEVICE_ID_INTEL_ICH7M:
261 case PCI_DEVICE_ID_INTEL_ICH7DH:
262 case PCI_DEVICE_ID_INTEL_ICH7MDH:
263 pmbase = pci_read_word(sb, 0x40) & 0xfffc;
Stefan Reinauer1162f252008-12-04 15:18:20 +0000264 pm_registers = ich7_pm_registers;
265 size = ARRAY_SIZE(ich7_pm_registers);
266 break;
267 case PCI_DEVICE_ID_INTEL_ICH8M:
268 pmbase = pci_read_word(sb, 0x40) & 0xfffc;
269 pm_registers = ich8_pm_registers;
270 size = ARRAY_SIZE(ich8_pm_registers);
Stefan Reinauer23190272008-08-20 13:41:24 +0000271 break;
Stefan Reinauerb2aedb12009-08-29 15:45:43 +0000272 case PCI_DEVICE_ID_INTEL_ICH0:
273 pmbase = pci_read_word(sb, 0x40) & 0xfffc;
274 pm_registers = ich0_pm_registers;
275 size = ARRAY_SIZE(ich0_pm_registers);
276 break;
Maciej Pijanka90d17402009-09-30 17:05:46 +0000277 case PCI_DEVICE_ID_INTEL_82371XX:
278 pmbase = pci_read_word(sb, 0x40) & 0xfffc;
279 pm_registers = i82371xx_pm_registers;
280 size = ARRAY_SIZE(i82371xx_pm_registers);
281 break;
Stefan Reinauer23190272008-08-20 13:41:24 +0000282 case 0x1234: // Dummy for non-existent functionality
283 printf("This southbridge does not have PMBASE.\n");
284 return 1;
285 default:
286 printf("Error: Dumping PMBASE on this southbridge is not (yet) supported.\n");
287 return 1;
288 }
289
290 printf("PMBASE = 0x%04x (IO)\n\n", pmbase);
291
Stefan Reinauer1162f252008-12-04 15:18:20 +0000292 for (i = 0; i < size; i++) {
293 switch (pm_registers[i].size) {
294 case 4:
295 printf("pmbase+0x%04x: 0x%08x (%s)\n",
296 pm_registers[i].addr,
297 inl(pmbase+pm_registers[i].addr),
298 pm_registers[i].name);
299 break;
300 case 2:
301 printf("pmbase+0x%04x: 0x%04x (%s)\n",
302 pm_registers[i].addr,
303 inw(pmbase+pm_registers[i].addr),
304 pm_registers[i].name);
305 break;
306 case 1:
307 printf("pmbase+0x%04x: 0x%02x (%s)\n",
308 pm_registers[i].addr,
309 inb(pmbase+pm_registers[i].addr),
310 pm_registers[i].name);
311 break;
312 }
Stefan Reinauer23190272008-08-20 13:41:24 +0000313 }
314
315 return 0;
316}
317