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!!!! */
30 [0xf1] = "pc8374 (winbond, was NS)"
33 /* eventually, if you care, break this out into a file. For now, I don't know
37 unsigned char regval(unsigned short port, unsigned char reg) {
42 void regwrite(unsigned short port, unsigned char reg, unsigned char val) {
48 dump_ns8374(unsigned short port) {
49 printf("Enables: 21=%02x, 22=%02x, 23=%02x, 24=%02x, 26=%02x\n",
50 regval(port, 0x21), regval(port, 0x22), regval(port, 0x23),
51 regval(port, 0x24), regval(port, 0x26));
52 printf("SMBUS at %02x\n", regval(port, 0x2a));
53 /* check COM1. This is all we care about at present. */
54 printf("COM 1 is Globally %s\n", regval(port, 0x26) & 8 ? "disabled" : "enabled");
56 regwrite(port, 0x07, 0x03);
57 printf("COM 1 is locally %s\n", regval(port, 0x30) & 1 ? "enabled" : "disabled");
58 printf("COM1 60=%02x, 61=%02x, 70=%02x, 71=%02x, 74=%02x, 75=%02x, f0=%02x\n",
59 regval(port, 0x60), regval(port, 0x61), regval(port, 0x70), regval(port, 0x71),
60 regval(port, 0x74), regval(port, 0x75), regval(port, 0xf0));
62 regwrite(port, 0x07, 0x07);
63 printf("GPIO is %s\n", regval(port, 0x30) & 1 ? "enabled" : "disabled");
64 printf("GPIO 60=%02x, 61=%02x, 70=%02x, 71=%02x, 74=%02x, 75=%02x, f0=%02x\n",
65 regval(port, 0x60), regval(port, 0x61), regval(port, 0x70), regval(port, 0x71),
66 regval(port, 0x74), regval(port, 0x75), regval(port, 0xf0));
71 dump_fintek(unsigned short port, unsigned int did)
75 printf ("Fintek F71805\n");
78 printf ("Fintek F71872\n");
81 printf ("Unknown Fintek SuperI/O: did=0x%04x\n", did);
85 printf("Flash write is %s.\n", regval(port, 0x28) & 0x80 ? "enabled" : "disabled");
86 printf("Flash control is 0x%04x.\n", regval(port, 0x28));
87 printf("27=%02x\n", regval(port, 0x27));
88 printf("29=%02x\n", regval(port, 0x29));
89 printf("2a=%02x\n", regval(port, 0x2a));
90 printf("2b=%02x\n", regval(port, 0x2b));
93 regwrite(port, 0x07, 0x01);
94 printf("UART1 is %s\n", regval(port, 0x30) & 1 ? "enabled" : "disabled");
95 printf("UART1 base=%02x%02x, irq=%02x, mode=%s\n",
96 regval(port, 0x60), regval(port, 0x61), regval(port, 0x70) & 0x0f,
97 regval(port, 0xf0) & 0x10 ? "RS485":"RS232");
100 regwrite(port, 0x07, 0x02);
101 printf("UART2 is %s\n", regval(port, 0x30) & 1 ? "enabled" : "disabled");
102 printf("UART2 base=%02x%02x, irq=%02x, mode=%s\n",
103 regval(port, 0x60), regval(port, 0x61), regval(port, 0x70) & 0x0f,
104 regval(port, 0xf0) & 0x10 ? "RS485":"RS232");
107 regwrite(port, 0x07, 0x03);
108 printf("PARPORT is %s\n", regval(port, 0x30) & 1 ? "enabled" : "disabled");
109 printf("PARPORT base=%02x%02x, irq=%02x\n",
110 regval(port, 0x60), regval(port, 0x61), regval(port, 0x70) & 0x0f);
112 /* select hw monitor */
113 regwrite(port, 0x07, 0x04);
114 printf("HW monitor is %s\n", regval(port, 0x30) & 1 ? "enabled" : "disabled");
115 printf("HW monitor base=%02x%02x, irq=%02x\n",
116 regval(port, 0x60), regval(port, 0x61), regval(port, 0x70) & 0x0f);
119 regwrite(port, 0x07, 0x05);
120 printf("GPIO is %s\n", regval(port, 0x30) & 1 ? "enabled" : "disabled");
121 printf("GPIO 70=%02x, e0=%02x, e1=%02x, e2=%02x, e3=%02x, e4=%02x, e5=%02x\n",
122 regval(port, 0x70), regval(port, 0xe0), regval(port, 0xe1), regval(port, 0xe2),
123 regval(port, 0xe3), regval(port, 0xe4), regval(port, 0xe5));
124 printf("GPIO e6=%02x, e7=%02x, e8=%02x, e9=%02x, f0=%02x, f1=%02x, f3=%02x, f4=%02x\n",
125 regval(port, 0xe6), regval(port, 0xe7), regval(port, 0xe8), regval(port, 0xe9),
126 regval(port, 0xf0), regval(port, 0xf1), regval(port, 0xf3), regval(port, 0xf4));
127 printf("GPIO f5=%02x, f6=%02x, f7=%02x, f8=%02x\n",
128 regval(port, 0xf5), regval(port, 0xf6), regval(port, 0xf7), regval(port, 0xf8));
139 /* Maximum Name Length */
140 #define MAXNAMELEN 20
143 /* biggestLDN + 0 + NOLDN + EOT */
144 #define LDNSIZE MAXLDN + 3
145 /* MAXimum NUMber of Indexes */
147 #define IDXSIZE MAXNUMIDX + 1
149 const static struct ite_registers {
150 /* yes, superio_id should be unsigned, but EOT has to be negative */
151 signed short superio_id;
152 char name[MAXNAMELEN];
155 signed short idx[IDXSIZE];
156 signed short def[IDXSIZE];
158 } ite_reg_table[] = {
161 {0x8705, "IT8705 or IT8700", {
165 {0x07,0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,
166 0x29,0x2a,0x2e,0x2f,EOT},
167 {NANA,0x87,0x08,0x00,0x00,NANA,0x3f,0x00,0xff,0xff,
168 0xff,0xff,0x00,0x00,EOT}},
170 {0x30,0x60,0x61,0x70,0x74,0xf0,0xf1,EOT},
171 {0x00,0x03,0xf0,0x06,0x02,0x00,0x00,EOT}},
173 {0x30,0x60,0x61,0x70,0xf0,EOT},
174 {0x00,0x03,0xf8,0x04,0x00,EOT}},
176 {0x30,0x60,0x61,0x70,0xf0,0xf1,0xf2,0xf3,EOT},
177 {0x00,0x02,0xf8,0x03,0x00,0x50,0x00,0x7f,EOT}},
179 {0x30,0x60,0x61,0x62,0x63,0x64,0x65,0x70,0x74,
181 {0x00,0x03,0x78,0x07,0x78,0x00,0x80,0x07,0x03,
184 {0xe0,0xe1,0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,
185 0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,EOT},
186 {NANA,NANA,0x00,0x00,0x00,0x00,0x00,0x00,
187 0x00,0x00,0x00,0x00,0x00,NANA,NANA,EOT}},
188 {0x5, /* Note: 0x30 can actually be 0x00 _or_ 0x01. */
189 {0x30,0x60,0x61,0x62,0x63,0x70,0x71,0xf0,EOT},
190 {0x01,0x00,0x60,0x00,0x64,0x01,0x02,0x00,EOT}},
192 {0x30,0x70,0x71,0xf0,EOT},
193 {0x00,0x0c,0x02,0x00,EOT}},
195 {0x70,0xb0,0xb1,0xb2,0xb3,0xb4,0xb5,0xb8,0xb9,0xba,
196 0xbb,0xbc,0xbd,0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc8,
197 0xc9,0xca,0xcb,0xcc,0xcd,0xd0,0xd1,0xd2,0xd3,0xd4,
198 0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xdb,0xdc,0xf0,0xf1,
199 0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa,0xfb,
201 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
202 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
203 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
204 0x00,0x00,NANA,NANA,NANA,NANA,NANA,NANA,0x00,0x00,
205 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,NANA,
208 {0x30,0x60,0x61,EOT},
209 {0x00,0x02,0x01,EOT}},
211 {0x30,0x60,0x61,0x70,0xf0,EOT},
212 {0x00,0x03,0x10,0x0b,0x00,EOT}},
214 {0x30,0x60,0x61,0x70,0xf0,EOT},
215 {0x00,0x03,0x00,0x0a,0x00,EOT}},
221 {0x07,0x20,0x21,0x22,0x23,0x24,0x2b,EOT},
222 {NANA,0x87,0x12,0x08,0x00,0x00,0x00,EOT}},
224 {0x30,0x60,0x61,0x70,0x74,0xf0,0xf1,EOT},
225 {0x00,0x03,0xf0,0x06,0x02,0x00,0x00,EOT}},
227 {0x30,0x60,0x61,0x70,0xf0,0xf1,0xf2,0xf3,EOT},
228 {0x00,0x03,0xf8,0x04,0x00,0x50,0x00,0x7f,EOT}},
230 {0x30,0x60,0x61,0x70,0xf0,0xf1,0xf2,0xf3,EOT},
231 {0x00,0x02,0xf8,0x03,0x00,0x50,0x00,0x7f,EOT}},
233 {0x30,0x60,0x61,0x62,0x63,0x70,0x74,0xf0,EOT},
234 {0x00,0x03,0x78,0x07,0x78,0x07,0x03,0x03,EOT}},
236 {0x30,0x60,0x61,0x62,0x63,0x70,0xf0,0xf1,0xf2,0xf3,
238 {0x00,0x02,0x90,0x02,0x30,0x09,0x00,0x00,0x00,0x00,
239 0x00,NANA,NANA,EOT}},
241 {0x30,0x60,0x61,0x62,0x63,0x70,0x71,0xf0,EOT},
242 {0x01,0x00,0x60,0x00,0x64,0x01,0x02,0x08,EOT}},
244 {0x30,0x70,0x71,0xf0,EOT},
245 {0x00,0x0c,0x02,0x00,EOT}},
247 {0x25,0x26,0x27,0x28,0x29,0x2a,0x2c,0x60,0x61,0x62,
248 0x63,0x64,0x65,0x70,0x71,0x72,0x73,0x74,0xb0,0xb1,
249 0xb2,0xb3,0xb4,0xb5,0xb8,0xb9,0xba,0xbb,0xbc,0xbd,
250 0xc0,0xc1,0xc2,0xc3,0xc4,0xc8,0xc9,0xca,0xcb,0xcc,
251 0xe0,0xe1,0xe2,0xe3,0xe4,0xf0,0xf1,0xf2,0xf3,0xf4,
252 0xf5,0xf6,0xf7,0xf8,0xf9,0xfa,0xfb,0xfc,0xfd,EOT},
253 {0x01,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,
254 0x00,0x00,0x00,0x00,0x00,0x30,0x38,0x00,0x00,0x00,
255 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
256 0x01,0x00,0x00,0x40,0x00,0x01,0x00,0x00,0x40,0x00,
257 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
258 0x00,0x00,0x00,0x00,0x00,0x00,0x00,NANA,0x00,EOT}},
260 {0x30,0x60,0x61,0x70,0xf0,EOT},
261 {0x00,0x03,0x00,0x0a,0x00,EOT}},
263 {0x30,0x60,0x61,EOT},
264 {0x00,0x02,0x01,EOT}},
266 {0x30,0x60,0x61,0x70,0xf0,EOT},
267 {0x00,0x03,0x10,0x0b,0x00,EOT}},
277 dump_ite(unsigned short port, unsigned short id)
285 unknown -> IT8711 (no datasheet)
286 unknown -> IT8722 (no datasheet)
288 0x8705 -> IT8700 or IT8705
294 0x8726 -> IT8726 (datasheet wrongly says 0x8716)
305 if (ite_reg_table[i].superio_id == EOT)
307 if ((unsigned short)ite_reg_table[i].superio_id != id)
309 printf ("%s\n", ite_reg_table[i].name);
311 if (ite_reg_table[i].ldn[j].ldn == EOT)
313 if (ite_reg_table[i].ldn[j].ldn != NOLDN) {
314 printf("switching to LDN 0x%01x\n",
315 ite_reg_table[i].ldn[j].ldn);
317 ite_reg_table[i].ldn[j].ldn);
319 idx = ite_reg_table[i].ldn[j].idx;
324 printf("%02x ", idx[k]);
330 printf("%02x ", regval(port, idx[k]));
333 idx = ite_reg_table[i].ldn[j].def;
340 printf("%02x ", idx[k]);
348 printf ("unknown ITE chip, id=%04x\n", id);
349 for (i=0x20; i<=0x24; i++)
350 printf("index %02x=%02x\n", i, regval(port, i));
356 probe_idregs_simple(unsigned short port){
359 if (inb(port) != 0x20) {
360 if (inb(port) == 0xff )
361 printf ("No SuperI/O chip found at 0x%04x\n", port);
363 printf("probing 0x%04x, failed (0x%02x), data returns 0x%02x\n",
364 port, inb(port), inb(port + 1));
369 printf("SuperI/O found at 0x%02x: id = 0x%02x\n", port, id);
374 printf("%s\n", familyid[id]);
376 printf("<unknown>\n");
383 printf("no dump for 0x%02x\n", id);
390 probe_idregs_fintek(unsigned short port){
391 unsigned int vid, did, success = 0;
393 /* Enable configuration sequence (Fintek uses this for example)
394 Older ITE chips have the same enable sequence */
399 if (inb(port) != 0x20) {
400 if (inb(port) == 0xff )
401 printf ("No SuperIO chip found at 0x%04x\n", port);
403 printf("probing 0x%04x, failed (0x%02x), data returns 0x%02x\n",
404 port, inb(port), inb(port + 1));
409 did |= (regval(port, 0x21)<<8);
411 vid = regval(port, 0x23);
412 vid |= (regval(port, 0x24)<<8);
414 printf("SuperIO found at 0x%02x: vid=0x%04x/did=0x%04x\n", port, vid, did);
416 if (vid == 0xff || vid == 0xffff)
419 /* printf("%s\n", familyid[id]); */
421 case 0x0887: /* pseudoreversed for ITE8708 */
422 case 0x1087: /* pseudoreversed for ITE8710 */
424 dump_ite(port, ((did & 0xff) << 8) | ((did & 0xff00) >> 8));
425 /* disable configuration */
426 regwrite(port, 0x02, 0x02);
434 dump_fintek(port, did);
440 printf("no dump for vid 0x%04x, did 0x%04x\n", vid, did);
442 /* disable configuration (for Fintek, doesn't hurt ITE) */
447 probe_idregs_ite(unsigned short port){
448 unsigned int id, chipver;
450 /* Enable configuration sequence (ITE uses this for newer IT87[012]x)
451 IT871[01] uses 0x87, 0x87 -> fintek detection should handle it
452 IT8708 uses 0x87, 0x87 -> fintek detection should handle it
453 IT8761 uses 0x87, 0x61, 0x55, 0x55/0xaa
454 IT86xx series uses different ports
455 IT8661 uses 0x86, 0x61, 0x55/0xaa, 0x55/0xaa and 32 more writes
456 IT8673 uses 0x86, 0x80, 0x55/0xaa, 0x55/0xaa and 32 more writes */
465 /* Read Chip ID Byte 1 */
466 id = regval(port, 0x20);
468 if (inb(port) == 0xff )
469 printf ("No SuperIO chip found at 0x%04x\n", port);
471 printf("probing 0x%04x, failed (0x%02x), data returns 0x%02x\n",
472 port, inb(port), inb(port + 1));
478 /* Read Chip ID Byte 2 */
479 id |= regval(port, 0x21);
481 /* Read Chip Version, only bit 3..0 for all IT87xx */
482 chipver = regval(port, 0x22) & 0x0f;
485 unknown -> IT8711 (no datasheet)
486 unknown -> IT8722 (no datasheet)
488 0x8705 -> IT8700 or IT8705
494 0x8726 -> IT8726 (datasheet wrongly says 0x8716)
496 printf("SuperI/O found at 0x%02x: id=0x%04x, chipver=0x%01x\n",
510 printf("no dump for id 0x%04x\n", id);
513 /* disable configuration */
514 regwrite(port, 0x02, 0x02);
518 probe_superio(unsigned short port) {
519 probe_idregs_simple(port);
520 probe_idregs_fintek(port);
521 probe_idregs_ite(port);
525 main(int argc, char *argv[])