2 * This file is part of the LinuxBIOS project.
4 * Copyright (C) 2006 Ronald Minnich <rminnich@gmail.com>
5 * Copyright (C) 2006 coresystems GmbH <info@coresystems.de>
6 * Copyright (C) 2007 Carl-Daniel Hailfinger
7 * Copyright (C) 2007 Uwe Hermann <uwe@hermann-uwe.de>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 /* Well, they really thought this through, eh? Family is 8 bits! */
29 static const char *familyid[] = {
30 [0xf1] = "PC8374 (Winbond/NatSemi)"
33 unsigned char regval(unsigned short port, unsigned char reg)
39 void regwrite(unsigned short port, unsigned char reg, unsigned char val)
45 void dump_ns8374(unsigned short port)
47 printf("Enables: 21=%02x, 22=%02x, 23=%02x, 24=%02x, 26=%02x\n",
48 regval(port, 0x21), regval(port, 0x22), regval(port, 0x23),
49 regval(port, 0x24), regval(port, 0x26));
50 printf("SMBUS at %02x\n", regval(port, 0x2a));
52 /* Check COM1. This is all we care about at present. */
53 printf("COM 1 is globally %s\n",
54 regval(port, 0x26) & 8 ? "disabled" : "enabled");
57 regwrite(port, 0x07, 0x03);
58 printf("COM 1 is locally %s\n",
59 regval(port, 0x30) & 1 ? "enabled" : "disabled");
61 ("COM1 60=%02x, 61=%02x, 70=%02x, 71=%02x, 74=%02x, 75=%02x, f0=%02x\n",
62 regval(port, 0x60), regval(port, 0x61), regval(port, 0x70),
63 regval(port, 0x71), regval(port, 0x74), regval(port, 0x75),
67 regwrite(port, 0x07, 0x07);
68 printf("GPIO is %s\n", regval(port, 0x30) & 1 ? "enabled" : "disabled");
70 ("GPIO 60=%02x, 61=%02x, 70=%02x, 71=%02x, 74=%02x, 75=%02x, f0=%02x\n",
71 regval(port, 0x60), regval(port, 0x61), regval(port, 0x70),
72 regval(port, 0x71), regval(port, 0x74), regval(port, 0x75),
76 void dump_fintek(unsigned short port, unsigned int did)
80 printf("Fintek F71805\n");
83 printf("Fintek F71872\n");
86 printf("Unknown Fintek Super I/O: did=0x%04x\n", did);
90 printf("Flash write is %s.\n",
91 regval(port, 0x28) & 0x80 ? "enabled" : "disabled");
92 printf("Flash control is 0x%04x.\n", regval(port, 0x28));
93 printf("27=%02x\n", regval(port, 0x27));
94 printf("29=%02x\n", regval(port, 0x29));
95 printf("2a=%02x\n", regval(port, 0x2a));
96 printf("2b=%02x\n", regval(port, 0x2b));
99 regwrite(port, 0x07, 0x01);
100 printf("UART1 is %s\n",
101 regval(port, 0x30) & 1 ? "enabled" : "disabled");
102 printf("UART1 base=%02x%02x, irq=%02x, mode=%s\n", regval(port, 0x60),
103 regval(port, 0x61), regval(port, 0x70) & 0x0f,
104 regval(port, 0xf0) & 0x10 ? "RS485" : "RS232");
107 regwrite(port, 0x07, 0x02);
108 printf("UART2 is %s\n",
109 regval(port, 0x30) & 1 ? "enabled" : "disabled");
110 printf("UART2 base=%02x%02x, irq=%02x, mode=%s\n", regval(port, 0x60),
111 regval(port, 0x61), regval(port, 0x70) & 0x0f,
112 regval(port, 0xf0) & 0x10 ? "RS485" : "RS232");
114 /* Select parallel port. */
115 regwrite(port, 0x07, 0x03);
116 printf("PARPORT is %s\n",
117 regval(port, 0x30) & 1 ? "enabled" : "disabled");
118 printf("PARPORT base=%02x%02x, irq=%02x\n", regval(port, 0x60),
119 regval(port, 0x61), regval(port, 0x70) & 0x0f);
121 /* Select HW monitor. */
122 regwrite(port, 0x07, 0x04);
123 printf("HW monitor is %s\n",
124 regval(port, 0x30) & 1 ? "enabled" : "disabled");
125 printf("HW monitor base=%02x%02x, irq=%02x\n", regval(port, 0x60),
126 regval(port, 0x61), regval(port, 0x70) & 0x0f);
129 regwrite(port, 0x07, 0x05);
130 printf("GPIO is %s\n", regval(port, 0x30) & 1 ? "enabled" : "disabled");
132 ("GPIO 70=%02x, e0=%02x, e1=%02x, e2=%02x, e3=%02x, e4=%02x, e5=%02x\n",
133 regval(port, 0x70), regval(port, 0xe0), regval(port, 0xe1),
134 regval(port, 0xe2), regval(port, 0xe3), regval(port, 0xe4),
137 ("GPIO e6=%02x, e7=%02x, e8=%02x, e9=%02x, f0=%02x, f1=%02x, f3=%02x, f4=%02x\n",
138 regval(port, 0xe6), regval(port, 0xe7), regval(port, 0xe8),
139 regval(port, 0xe9), regval(port, 0xf0), regval(port, 0xf1),
140 regval(port, 0xf3), regval(port, 0xf4));
141 printf("GPIO f5=%02x, f6=%02x, f7=%02x, f8=%02x\n", regval(port, 0xf5),
142 regval(port, 0xf6), regval(port, 0xf7), regval(port, 0xf8));
145 #define EOT -1 /* End Of Table */
146 #define NOLDN -2 /* NO LDN needed */
147 #define NANA -3 /* Not Available */
148 #define MAXNAMELEN 20 /* Maximum Name Length */
149 #define MAXLDN 0xa /* Biggest LDN */
150 #define LDNSIZE (MAXLDN + 3) /* Biggest LDN + 0 + NOLDN + EOT */
151 #define MAXNUMIDX 70 /* Maximum number of indexes */
152 #define IDXSIZE (MAXNUMIDX + 1)
154 const static struct ite_registers {
155 /* Yes, superio_id should be unsigned, but EOT has to be negative. */
156 signed short superio_id;
157 const char name[MAXNAMELEN];
160 signed short idx[IDXSIZE];
161 signed short def[IDXSIZE];
163 } ite_reg_table[] = {
166 {0x8705, "IT8705 or IT8700", {
170 {0x07,0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,
171 0x29,0x2a,0x2e,0x2f,EOT},
172 {NANA,0x87,0x08,0x00,0x00,NANA,0x3f,0x00,0xff,0xff,
173 0xff,0xff,0x00,0x00,EOT}},
175 {0x30,0x60,0x61,0x70,0x74,0xf0,0xf1,EOT},
176 {0x00,0x03,0xf0,0x06,0x02,0x00,0x00,EOT}},
178 {0x30,0x60,0x61,0x70,0xf0,EOT},
179 {0x00,0x03,0xf8,0x04,0x00,EOT}},
181 {0x30,0x60,0x61,0x70,0xf0,0xf1,0xf2,0xf3,EOT},
182 {0x00,0x02,0xf8,0x03,0x00,0x50,0x00,0x7f,EOT}},
184 {0x30,0x60,0x61,0x62,0x63,0x64,0x65,0x70,0x74,
186 {0x00,0x03,0x78,0x07,0x78,0x00,0x80,0x07,0x03,
189 {0xe0,0xe1,0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,
190 0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,EOT},
191 {NANA,NANA,0x00,0x00,0x00,0x00,0x00,0x00,
192 0x00,0x00,0x00,0x00,0x00,NANA,NANA,EOT}},
193 {0x5, /* Note: 0x30 can actually be 0x00 _or_ 0x01. */
194 {0x30,0x60,0x61,0x62,0x63,0x70,0x71,0xf0,EOT},
195 {0x01,0x00,0x60,0x00,0x64,0x01,0x02,0x00,EOT}},
197 {0x30,0x70,0x71,0xf0,EOT},
198 {0x00,0x0c,0x02,0x00,EOT}},
200 {0x70,0xb0,0xb1,0xb2,0xb3,0xb4,0xb5,0xb8,0xb9,0xba,
201 0xbb,0xbc,0xbd,0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc8,
202 0xc9,0xca,0xcb,0xcc,0xcd,0xd0,0xd1,0xd2,0xd3,0xd4,
203 0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xdb,0xdc,0xf0,0xf1,
204 0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa,0xfb,
206 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
207 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
208 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
209 0x00,0x00,NANA,NANA,NANA,NANA,NANA,NANA,0x00,0x00,
210 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,NANA,
213 {0x30,0x60,0x61,EOT},
214 {0x00,0x02,0x01,EOT}},
216 {0x30,0x60,0x61,0x70,0xf0,EOT},
217 {0x00,0x03,0x10,0x0b,0x00,EOT}},
219 {0x30,0x60,0x61,0x70,0xf0,EOT},
220 {0x00,0x03,0x00,0x0a,0x00,EOT}},
226 {0x07,0x20,0x21,0x22,0x23,0x24,0x2b,EOT},
227 {NANA,0x87,0x12,0x08,0x00,0x00,0x00,EOT}},
229 {0x30,0x60,0x61,0x70,0x74,0xf0,0xf1,EOT},
230 {0x00,0x03,0xf0,0x06,0x02,0x00,0x00,EOT}},
232 {0x30,0x60,0x61,0x70,0xf0,0xf1,0xf2,0xf3,EOT},
233 {0x00,0x03,0xf8,0x04,0x00,0x50,0x00,0x7f,EOT}},
235 {0x30,0x60,0x61,0x70,0xf0,0xf1,0xf2,0xf3,EOT},
236 {0x00,0x02,0xf8,0x03,0x00,0x50,0x00,0x7f,EOT}},
238 {0x30,0x60,0x61,0x62,0x63,0x70,0x74,0xf0,EOT},
239 {0x00,0x03,0x78,0x07,0x78,0x07,0x03,0x03,EOT}},
241 {0x30,0x60,0x61,0x62,0x63,0x70,0xf0,0xf1,0xf2,0xf3,
243 {0x00,0x02,0x90,0x02,0x30,0x09,0x00,0x00,0x00,0x00,
244 0x00,NANA,NANA,EOT}},
246 {0x30,0x60,0x61,0x62,0x63,0x70,0x71,0xf0,EOT},
247 {0x01,0x00,0x60,0x00,0x64,0x01,0x02,0x08,EOT}},
249 {0x30,0x70,0x71,0xf0,EOT},
250 {0x00,0x0c,0x02,0x00,EOT}},
252 {0x25,0x26,0x27,0x28,0x29,0x2a,0x2c,0x60,0x61,0x62,
253 0x63,0x64,0x65,0x70,0x71,0x72,0x73,0x74,0xb0,0xb1,
254 0xb2,0xb3,0xb4,0xb5,0xb8,0xb9,0xba,0xbb,0xbc,0xbd,
255 0xc0,0xc1,0xc2,0xc3,0xc4,0xc8,0xc9,0xca,0xcb,0xcc,
256 0xe0,0xe1,0xe2,0xe3,0xe4,0xf0,0xf1,0xf2,0xf3,0xf4,
257 0xf5,0xf6,0xf7,0xf8,0xf9,0xfa,0xfb,0xfc,0xfd,EOT},
258 {0x01,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,
259 0x00,0x00,0x00,0x00,0x00,0x30,0x38,0x00,0x00,0x00,
260 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
261 0x01,0x00,0x00,0x40,0x00,0x01,0x00,0x00,0x40,0x00,
262 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
263 0x00,0x00,0x00,0x00,0x00,0x00,0x00,NANA,0x00,EOT}},
265 {0x30,0x60,0x61,0x70,0xf0,EOT},
266 {0x00,0x03,0x00,0x0a,0x00,EOT}},
268 {0x30,0x60,0x61,EOT},
269 {0x00,0x02,0x01,EOT}},
271 {0x30,0x60,0x61,0x70,0xf0,EOT},
272 {0x00,0x03,0x10,0x0b,0x00,EOT}},
276 {0x07,0x20,0x21,0x22,0x23,0x24,0x2b,EOT},
277 {NANA,0x87,0x16,0x01,0x00,0x00,0x00,EOT}},
279 {0x30,0x60,0x61,0x70,0x74,0xf0,0xf1,EOT},
280 {0x00,0x03,0xf0,0x06,0x02,0x00,0x00,EOT}},
282 {0x30,0x60,0x61,0x70,0xf0,0xf1,0xf2,0xf3,EOT},
283 {0x00,0x03,0xf8,0x04,0x00,0x50,0x00,0x7f,EOT}},
285 {0x30,0x60,0x61,0x70,0xf0,0xf1,0xf2,0xf3,EOT},
286 {0x00,0x02,0xf8,0x03,0x00,0x50,0x00,0x7f,EOT}},
288 {0x30,0x60,0x61,0x62,0x63,0x70,0x74,0xf0,EOT},
289 {0x00,0x03,0x78,0x07,0x78,0x07,0x03,0x03,EOT}},
291 {0x30,0x60,0x61,0x62,0x63,0x70,0xf0,0xf1,0xf2,0xf3,
293 {0x00,0x02,0x90,0x02,0x30,0x09,0x00,0x00,0x00,0x00,
294 0x00,NANA,NANA,EOT}},
296 {0x30,0x60,0x61,0x62,0x63,0x70,0x71,0xf0,EOT},
297 {0x01,0x00,0x60,0x00,0x64,0x01,0x02,0x00,EOT}},
299 {0x30,0x70,0x71,0xf0,EOT},
300 {0x00,0x0c,0x02,0x00,EOT}},
302 {0x25,0x26,0x27,0x28,0x29,0x2a,0x2c,0x60,0x61,0x62,
303 0x63,0x64,0x65,0x70,0x71,0x72,0x73,0x74,0xb0,0xb1,
304 0xb2,0xb3,0xb4,0xb5,0xb8,0xb9,0xba,0xbb,0xbc,0xbd,
305 0xc0,0xc1,0xc2,0xc3,0xc4,0xc8,0xc9,0xca,0xcb,0xcc,
306 0xe0,0xe1,0xe2,0xe3,0xe4,0xf0,0xf1,0xf2,0xf3,0xf4,
307 0xf5,0xf6,0xf7,0xf8,0xf9,0xfa,0xfb,0xfc,0xfd,EOT},
308 {0x01,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,
309 0x00,0x00,0x00,0x00,0x00,0x20,0x38,0x00,0x00,0x00,
310 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
311 0x01,0x00,0x00,0x40,0x00,0x01,0x00,0x00,0x40,0x00,
312 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
313 0x00,0x00,0x00,0x00,0x00,0x00,0x00,NANA,0x00,EOT}},
315 {0x30,0x60,0x61,0x70,0xf0,EOT},
316 {0x00,0x03,0x00,0x0a,0x00,EOT}},
318 {0x30,0x60,0x61,EOT},
319 {0x00,0x02,0x01,EOT}},
321 {0x30,0x60,0x61,0x70,0xf0,EOT},
322 {0x00,0x03,0x10,0x0b,0x00,EOT}},
329 void dump_ite(unsigned short port, unsigned short id)
336 unknown -> IT8711 (no datasheet)
337 unknown -> IT8722 (no datasheet)
339 0x8705 -> IT8700 or IT8705
345 0x8726 -> IT8726 (datasheet wrongly says 0x8716)
356 if (ite_reg_table[i].superio_id == EOT)
358 if ((unsigned short)ite_reg_table[i].superio_id != id)
360 printf("%s\n", ite_reg_table[i].name);
362 if (ite_reg_table[i].ldn[j].ldn == EOT)
364 if (ite_reg_table[i].ldn[j].ldn != NOLDN) {
365 printf("Switching to LDN 0x%01x\n",
366 ite_reg_table[i].ldn[j].ldn);
368 ite_reg_table[i].ldn[j].ldn);
370 idx = ite_reg_table[i].ldn[j].idx;
375 printf("%02x ", idx[k]);
381 printf("%02x ", regval(port, idx[k]));
384 idx = ite_reg_table[i].ldn[j].def;
391 printf("%02x ", idx[k]);
398 printf("Unknown ITE chip, id=%04x\n", id);
399 for (i = 0x20; i <= 0x24; i++)
400 printf("index %02x=%02x\n", i, regval(port, i));
405 void probe_idregs_simple(unsigned short port)
409 if (inb(port) != 0x20) {
410 if (inb(port) == 0xff)
411 printf("No SuperI/O chip found at 0x%04x\n", port);
413 printf("probing 0x%04x, failed (0x%02x), data returns 0x%02x\n", port, inb(port), inb(port + 1));
418 printf("SuperI/O found at 0x%02x: id = 0x%02x\n", port, id);
423 printf("%s\n", familyid[id]);
425 printf("<unknown>\n");
432 printf("no dump for 0x%02x\n", id);
437 void probe_idregs_fintek(unsigned short port)
439 unsigned int vid, did, success = 0;
441 /* Enable configuration sequence (Fintek uses this for example)
442 * Older ITE chips have the same enable sequence.
448 if (inb(port) != 0x20) {
449 if (inb(port) == 0xff)
450 printf("No SuperIO chip found at 0x%04x\n", port);
452 printf("probing 0x%04x, failed (0x%02x), data returns 0x%02x\n", port, inb(port), inb(port + 1));
456 did |= (regval(port, 0x21) << 8);
458 vid = regval(port, 0x23);
459 vid |= (regval(port, 0x24) << 8);
461 printf("Super I/O found at 0x%02x: vid=0x%04x/did=0x%04x\n",
464 if (vid == 0xff || vid == 0xffff)
467 /* printf("%s\n", familyid[id]); */
469 case 0x0887: /* Pseudoreversed for ITE8708 */
470 case 0x1087: /* Pseudoreversed for ITE8710 */
472 dump_ite(port, ((did & 0xff) << 8) | ((did & 0xff00) >> 8));
473 regwrite(port, 0x02, 0x02); /* Exit MB PnP mode. */
482 dump_fintek(port, did);
489 printf("No dump for vid 0x%04x, did 0x%04x\n", vid, did);
491 /* Exit MB PnP mode (for Fintek, doesn't hurt ITE). */
495 void probe_idregs_ite(unsigned short port)
497 unsigned int id, chipver;
499 /* Enable configuration sequence (ITE uses this for newer IT87[012]x)
500 * IT871[01] uses 0x87, 0x87 -> fintek detection should handle it
501 * IT8708 uses 0x87, 0x87 -> fintek detection should handle it
502 * IT8761 uses 0x87, 0x61, 0x55, 0x55/0xaa
503 * IT86xx series uses different ports
504 * IT8661 uses 0x86, 0x61, 0x55/0xaa, 0x55/0xaa and 32 more writes
505 * IT8673 uses 0x86, 0x80, 0x55/0xaa, 0x55/0xaa and 32 more writes
515 /* Read Chip ID Byte 1. */
516 id = regval(port, 0x20);
518 if (inb(port) == 0xff)
519 printf("No Super-I/O chip found at 0x%04x\n", port);
521 printf("probing 0x%04x, failed (0x%02x), data returns 0x%02x\n", port, inb(port), inb(port + 1));
527 /* Read Chip ID Byte 2. */
528 id |= regval(port, 0x21);
530 /* Read chip version, only bits 3..0 for all IT87xx. */
531 chipver = regval(port, 0x22) & 0x0f;
534 * unknown -> IT8711 (no datasheet)
535 * unknown -> IT8722 (no datasheet)
537 * 0x8705 -> IT8700 or IT8705
543 * 0x8726 -> IT8726 (datasheet wrongly says 0x8716)
545 printf("Super I/O found at 0x%02x: id=0x%04x, chipver=0x%01x\n",
559 printf("No dump for id 0x%04x\n", id);
562 regwrite(port, 0x02, 0x02); /* Exit MB PnP mode. */
565 void probe_superio(unsigned short port)
567 probe_idregs_simple(port);
568 probe_idregs_fintek(port);
569 probe_idregs_ite(port);
572 int main(int argc, char *argv[])
579 probe_superio(0x2e); /* Try 0x2e. */
580 probe_superio(0x4e); /* Try 0x4e. */