blob: 9bb23c9c07202fc465bf052c0becb9fb7f72a83b [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 by coresystems GmbH
5 *
Stefan Reinauer23190272008-08-20 13:41:24 +00006 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20#include <stdio.h>
Stefan Reinauer23190272008-08-20 13:41:24 +000021#include "inteltool.h"
22
23static const io_register_t ich0_gpio_registers[] = {
24 { 0x00, 4, "GPIO_USE_SEL" },
25 { 0x04, 4, "GP_IO_SEL" },
26 { 0x08, 4, "RESERVED" },
27 { 0x0c, 4, "GP_LVL" },
28 { 0x10, 4, "RESERVED" },
29 { 0x14, 4, "GPO_TTL" },
30 { 0x18, 4, "GPO_BLINK" },
31 { 0x1c, 4, "RESERVED" },
32 { 0x20, 4, "RESERVED" },
33 { 0x24, 4, "RESERVED" },
34 { 0x28, 4, "RESERVED" },
35 { 0x2c, 4, "GPI_INV" },
36 { 0x30, 4, "RESERVED" },
37 { 0x34, 4, "RESERVED" },
38 { 0x38, 4, "RESERVED" },
39 { 0x3C, 4, "RESERVED" }
40};
41
Joseph Smithe10757e2010-06-16 22:21:19 +000042static const io_register_t ich2_gpio_registers[] = {
43 { 0x00, 4, "GPIO_USE_SEL" },
44 { 0x04, 4, "GP_IO_SEL" },
45 { 0x08, 4, "RESERVED" },
46 { 0x0c, 4, "GP_LVL" },
47 { 0x10, 4, "RESERVED" },
48 { 0x14, 4, "GPO_TTL" },
49 { 0x18, 4, "GPO_BLINK" },
50 { 0x1c, 4, "RESERVED" },
51 { 0x20, 4, "RESERVED" },
52 { 0x24, 4, "RESERVED" },
53 { 0x28, 4, "RESERVED" },
54 { 0x2c, 4, "GPI_INV" },
55 { 0x30, 4, "RESERVED" },
56 { 0x34, 4, "RESERVED" },
57 { 0x38, 4, "RESERVED" },
58 { 0x3C, 4, "RESERVED" }
59};
60
Stefan Reinauer23190272008-08-20 13:41:24 +000061static const io_register_t ich4_gpio_registers[] = {
62 { 0x00, 4, "GPIO_USE_SEL" },
63 { 0x04, 4, "GP_IO_SEL" },
64 { 0x08, 4, "RESERVED" },
65 { 0x0c, 4, "GP_LVL" },
66 { 0x10, 4, "RESERVED" },
67 { 0x14, 4, "GPO_TTL" },
68 { 0x18, 4, "GPO_BLINK" },
69 { 0x1c, 4, "RESERVED" },
70 { 0x20, 4, "RESERVED" },
71 { 0x24, 4, "RESERVED" },
72 { 0x28, 4, "RESERVED" },
73 { 0x2c, 4, "GPI_INV" },
74 { 0x30, 4, "GPIO_USE_SEL2" },
75 { 0x34, 4, "GP_IO_SEL2" },
76 { 0x38, 4, "GP_LVL2" },
77 { 0x3C, 4, "RESERVED" }
78};
79
Pat Erleyca3548e2010-04-21 06:23:19 +000080static const io_register_t ich6_gpio_registers[] = {
81 { 0x00, 4, "GPIO_USE_SEL" },
82 { 0x08, 4, "RESERVED" },
83 { 0x0c, 4, "GP_LVL" },
84 { 0x10, 4, "RESERVED" },
85 { 0x14, 4, "RESERVED" },
86 { 0x18, 4, "GPO_BLINK" },
87 { 0x1c, 4, "RESERVED" },
88 { 0x20, 4, "RESERVED" },
89 { 0x24, 4, "RESERVED" },
90 { 0x28, 4, "RESERVED" },
91 { 0x2c, 4, "GPI_INV" },
92 { 0x30, 4, "GPIO_USE_SEL2" },
93 { 0x34, 4, "GP_IO_SEL2" },
94 { 0x38, 4, "GP_LVL2" },
95 { 0x04, 4, "GP_IO_SEL" },
96};
97
Stefan Reinauer23190272008-08-20 13:41:24 +000098static const io_register_t ich7_gpio_registers[] = {
99 { 0x00, 4, "GPIO_USE_SEL" },
100 { 0x04, 4, "GP_IO_SEL" },
101 { 0x08, 4, "RESERVED" },
102 { 0x0c, 4, "GP_LVL" },
103 { 0x10, 4, "RESERVED" },
104 { 0x14, 4, "RESERVED" },
105 { 0x18, 4, "GPO_BLINK" },
106 { 0x1c, 4, "RESERVED" },
107 { 0x20, 4, "RESERVED" },
108 { 0x24, 4, "RESERVED" },
109 { 0x28, 4, "RESERVED" },
110 { 0x2c, 4, "GPI_INV" },
111 { 0x30, 4, "GPIO_USE_SEL2" },
112 { 0x34, 4, "GP_IO_SEL2" },
113 { 0x38, 4, "GP_LVL2" },
114 { 0x3C, 4, "RESERVED" }
115};
116
Stefan Reinauer1162f252008-12-04 15:18:20 +0000117static const io_register_t ich8_gpio_registers[] = {
118 { 0x00, 4, "GPIO_USE_SEL" },
119 { 0x04, 4, "GP_IO_SEL" },
120 { 0x08, 4, "RESERVED" },
121 { 0x0c, 4, "GP_LVL" },
122 { 0x10, 4, "GPIO_USE_SEL Override (LOW)" },
123 { 0x14, 4, "RESERVED" },
124 { 0x18, 4, "GPO_BLINK" },
125 { 0x1c, 4, "GP_SER_BLINK" },
126 { 0x20, 4, "GP_SB_CMDSTS" },
127 { 0x24, 4, "GP_SB_DATA" },
128 { 0x28, 4, "RESERVED" },
129 { 0x2c, 4, "GPI_INV" },
130 { 0x30, 4, "GPIO_USE_SEL2" },
131 { 0x34, 4, "GP_IO_SEL2" },
132 { 0x38, 4, "GP_LVL2" },
133 { 0x3C, 4, "GPIO_USE_SEL Override (HIGH)" }
134};
135
Anton Kochkovda0b4562010-05-30 12:33:12 +0000136static const io_register_t ich9_gpio_registers[] = {
137 { 0x00, 4, "GPIO_USE_SEL" },
138 { 0x04, 4, "GP_IO_SEL" },
139 { 0x08, 4, "RESERVED" },
140 { 0x0c, 4, "GP_LVL" },
141 { 0x10, 4, "RESERVED" },
142 { 0x14, 4, "RESERVED" },
143 { 0x18, 4, "GPO_BLINK" },
144 { 0x1c, 4, "GP_SER_BLINK" },
145 { 0x20, 4, "GP_SB_CMDSTS" },
146 { 0x24, 4, "GP_SB_DATA" },
147 { 0x28, 4, "RESERVED" },
148 { 0x2c, 4, "GPI_INV" },
149 { 0x30, 4, "GPIO_USE_SEL2" },
150 { 0x34, 4, "GP_IO_SEL2" },
151 { 0x38, 4, "GP_LVL2" },
152 { 0x3C, 4, "RESERVED" }
153};
Stefan Reinauer1162f252008-12-04 15:18:20 +0000154
Warren Turkala7f2b0e2010-09-01 03:40:57 +0000155static const io_register_t ich10_gpio_registers[] = {
156 { 0x00, 4, "GPIO_USE_SEL" },
157 { 0x04, 4, "GP_IO_SEL" },
158 { 0x08, 4, "RESERVED" },
159 { 0x0c, 4, "GP_LVL" },
160 { 0x10, 4, "RESERVED" },
161 { 0x14, 4, "RESERVED" },
162 { 0x18, 4, "GPO_BLINK" },
163 { 0x1c, 4, "GP_SER_BLINK" },
164 { 0x20, 4, "GP_SB_CMDSTS" },
165 { 0x24, 4, "GP_SB_DATA" },
166 { 0x28, 4, "RESERVED" },
167 { 0x2c, 4, "GPI_INV" },
168 { 0x30, 4, "GPIO_USE_SEL2" },
169 { 0x34, 4, "GP_IO_SEL2" },
170 { 0x38, 4, "GP_LVL2" },
171 { 0x3C, 4, "RESERVED" },
172 { 0x40, 4, "GPIO_USE_SEL3" },
173 { 0x44, 4, "GPIO_SEL3" },
174 { 0x48, 4, "GPIO_LVL3" },
175 { 0x4c, 4, "RESERVED" },
176 { 0x50, 4, "RESERVED" },
177 { 0x54, 4, "RESERVED" },
178 { 0x58, 4, "RESERVED" },
179 { 0x5c, 4, "RESERVED" },
180 { 0x60, 4, "GP_RST_SEL" },
181 { 0x64, 4, "RESERVED" },
182 { 0x68, 4, "RESERVED" },
183 { 0x6c, 4, "RESERVED" },
184 { 0x70, 4, "RESERVED" },
185 { 0x74, 4, "RESERVED" },
186 { 0x78, 4, "RESERVED" },
187 { 0x7c, 4, "RESERVED" },
188};
189
Stefan Reinauer23190272008-08-20 13:41:24 +0000190int print_gpios(struct pci_dev *sb)
191{
192 int i, size;
193 uint16_t gpiobase;
194 const io_register_t *gpio_registers;
195
196 printf("\n============= GPIOS =============\n\n");
197
198 switch (sb->device_id) {
Warren Turkala7f2b0e2010-09-01 03:40:57 +0000199 case PCI_DEVICE_ID_INTEL_ICH10R:
200 gpiobase = pci_read_word(sb, 0x48) & 0xfffc;
201 gpio_registers = ich10_gpio_registers;
202 size = ARRAY_SIZE(ich10_gpio_registers);
203 break;
Anton Kochkovda0b4562010-05-30 12:33:12 +0000204 case PCI_DEVICE_ID_INTEL_ICH9DH:
205 case PCI_DEVICE_ID_INTEL_ICH9DO:
206 case PCI_DEVICE_ID_INTEL_ICH9R:
207 case PCI_DEVICE_ID_INTEL_ICH9:
208 case PCI_DEVICE_ID_INTEL_ICH9M:
209 case PCI_DEVICE_ID_INTEL_ICH9ME:
210 gpiobase = pci_read_word(sb, 0x48) & 0xfffc;
211 gpio_registers = ich9_gpio_registers;
212 size = ARRAY_SIZE(ich9_gpio_registers);
213 break;
Corey Osgoodf366ce02010-08-17 08:33:44 +0000214 case PCI_DEVICE_ID_INTEL_ICH8:
Stefan Reinauer1162f252008-12-04 15:18:20 +0000215 case PCI_DEVICE_ID_INTEL_ICH8M:
216 gpiobase = pci_read_word(sb, 0x48) & 0xfffc;
217 gpio_registers = ich8_gpio_registers;
218 size = ARRAY_SIZE(ich8_gpio_registers);
219 break;
Stefan Reinauer23190272008-08-20 13:41:24 +0000220 case PCI_DEVICE_ID_INTEL_ICH7:
221 case PCI_DEVICE_ID_INTEL_ICH7M:
222 case PCI_DEVICE_ID_INTEL_ICH7DH:
223 case PCI_DEVICE_ID_INTEL_ICH7MDH:
Corey Osgoodf366ce02010-08-17 08:33:44 +0000224 case PCI_DEVICE_ID_INTEL_NM10:
Stefan Reinauer23190272008-08-20 13:41:24 +0000225 gpiobase = pci_read_word(sb, 0x48) & 0xfffc;
226 gpio_registers = ich7_gpio_registers;
227 size = ARRAY_SIZE(ich7_gpio_registers);
228 break;
Pat Erleyca3548e2010-04-21 06:23:19 +0000229 case PCI_DEVICE_ID_INTEL_ICH6:
230 gpiobase = pci_read_word(sb, 0x48) & 0xfffc;
231 gpio_registers = ich6_gpio_registers;
232 size = ARRAY_SIZE(ich6_gpio_registers);
233 break;
Stefan Reinauer23190272008-08-20 13:41:24 +0000234 case PCI_DEVICE_ID_INTEL_ICH4:
235 case PCI_DEVICE_ID_INTEL_ICH4M:
236 gpiobase = pci_read_word(sb, 0x58) & 0xfffc;
237 gpio_registers = ich4_gpio_registers;
238 size = ARRAY_SIZE(ich4_gpio_registers);
239 break;
Joseph Smithe10757e2010-06-16 22:21:19 +0000240 case PCI_DEVICE_ID_INTEL_ICH2:
241 gpiobase = pci_read_word(sb, 0x58) & 0xfffc;
242 gpio_registers = ich2_gpio_registers;
243 size = ARRAY_SIZE(ich2_gpio_registers);
244 break;
Stefan Reinauer23190272008-08-20 13:41:24 +0000245 case PCI_DEVICE_ID_INTEL_ICH:
246 case PCI_DEVICE_ID_INTEL_ICH0:
247 gpiobase = pci_read_word(sb, 0x58) & 0xfffc;
248 gpio_registers = ich0_gpio_registers;
249 size = ARRAY_SIZE(ich0_gpio_registers);
250 break;
Maciej Pijanka90d17402009-09-30 17:05:46 +0000251 case PCI_DEVICE_ID_INTEL_82371XX:
252 printf("This southbridge has GPIOs in the PM unit.\n");
253 return 1;
Stefan Reinauer23190272008-08-20 13:41:24 +0000254 case 0x1234: // Dummy for non-existent functionality
255 printf("This southbridge does not have GPIOBASE.\n");
256 return 1;
257 default:
258 printf("Error: Dumping GPIOs on this southbridge is not (yet) supported.\n");
259 return 1;
260 }
261
262 printf("GPIOBASE = 0x%04x (IO)\n\n", gpiobase);
263
264 for (i = 0; i < size; i++) {
265 switch (gpio_registers[i].size) {
266 case 4:
267 printf("gpiobase+0x%04x: 0x%08x (%s)\n",
268 gpio_registers[i].addr,
269 inl(gpiobase+gpio_registers[i].addr),
270 gpio_registers[i].name);
271 break;
272 case 2:
273 printf("gpiobase+0x%04x: 0x%04x (%s)\n",
274 gpio_registers[i].addr,
275 inw(gpiobase+gpio_registers[i].addr),
276 gpio_registers[i].name);
277 break;
278 case 1:
279 printf("gpiobase+0x%04x: 0x%02x (%s)\n",
280 gpio_registers[i].addr,
281 inb(gpiobase+gpio_registers[i].addr),
282 gpio_registers[i].name);
283 break;
284 }
285 }
286
287 return 0;
288}
289