Add/fix some LDN descriptions (trivial).
[coreboot.git] / util / superiotool / nsc.c
1 /*
2  * This file is part of the superiotool project.
3  *
4  * Copyright (C) 2006 Ronald Minnich <rminnich@gmail.com>
5  * Copyright (C) 2007 Uwe Hermann <uwe@hermann-uwe.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; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
20  */
21
22 #include "superiotool.h"
23
24 #define CHIP_ID_REG     0x20    /* Super I/O ID (SID) / family */
25 #define CHIP_REV_REG    0x27    /* Super I/O revision ID (SRID) */
26
27 static const struct superio_registers reg_table[] = {
28         {0xd0, "PC87317", {
29                 {EOT}}},
30         {0xdf, "PC97317", {
31                 {EOT}}},
32         {0xe1, "PC87360", {
33                 {NOLDN, NULL,
34                         {0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x2a,
35                          0x2b,0x2c,0x2d,0x2e,EOT},
36                         {0xe1,0x11,0x00,0x03,0x00,0x00,0x00,NANA,0x00,MISC,
37                          0x00,0x00,0x00,RSVD,EOT}},
38                 {0x0, "Floppy",
39                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,0xf1,EOT},
40                         {0x00,0x03,0xf2,0x06,0x03,0x02,0x04,0x24,0x00,EOT}},
41                 {0x1, "Parallel port",
42                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
43                         {0x00,0x02,0x78,0x07,0x02,0x04,0x04,0xf2,EOT}},
44                 {0x2, "COM2",
45                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
46                         {0x00,0x02,0xf8,0x03,0x03,0x04,0x04,0x02,EOT}},
47                 {0x3, "COM1",
48                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
49                         {0x00,0x03,0xf8,0x04,0x03,0x04,0x04,0x02,EOT}},
50                 {0x4, "System wake-up control (SWC)",
51                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,EOT},
52                         {0x00,0x00,0x00,0x00,0x03,0x04,0x04,EOT}},
53                 {0x5, "Mouse",
54                         {0x30,0x70,0x71,0x74,0x75,EOT},
55                         {0x00,0x0c,0x02,0x04,0x04,EOT}},
56                 {0x6, "Keyboard",
57                         {0x30,0x60,0x61,0x62,0x63,0x70,0x71,0x74,0x75,0xf0,
58                          EOT},
59                         {0x01,0x00,0x60,0x00,0x64,0x01,0x02,0x04,0x04,0x40,
60                          EOT}},
61                 {0x7, "GPIO",
62                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,0xf1,0xf2,
63                          EOT},
64                         {0x00,0x00,0x00,0x00,0x03,0x04,0x04,0x00,0x00,0x00,
65                          EOT}},
66                 {0x8, "ACCESS.bus (ACB)",
67                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
68                         {0x00,0x00,0x00,0x00,0x03,0x04,0x04,0x00,EOT}},
69                 {0x9, "Fan speed control and monitor (FSCM)",
70                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
71                         {0x00,0x00,0x00,0x00,0x03,0x04,0x04,0x00,EOT}},
72                 {0xa, "Watchdog timer",
73                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
74                         {0x00,0x00,0x00,0x00,0x03,0x04,0x04,0x02,EOT}},
75                 {EOT}}},
76         {0xe2, "PC87351", {
77                 {NOLDN, NULL,
78                         {0x20,0x21,0x22,0x23,0x24,0x27,0x2e,EOT},
79                         {0xe2,0x11,0xa1,0x00,MISC,NANA,RSVD,EOT}},
80                 {0x0, "Floppy",
81                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,0xf1,EOT},
82                         {0x00,0x03,0xf2,0x06,0x03,0x02,0x04,0x24,0x00,EOT}},
83                 {0x1, "Parallel port",
84                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
85                         {0x00,0x02,0x78,0x07,0x02,0x04,0x04,0xf2,EOT}},
86                 {0x2, "COM2",
87                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
88                         {0x00,0x02,0xf8,0x03,0x03,0x04,0x04,0x02,EOT}},
89                 {0x3, "COM1",
90                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
91                         {0x00,0x03,0xf8,0x04,0x03,0x04,0x04,0x02,EOT}},
92                 {0x4, "System wake-up control (SWC)",
93                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,EOT},
94                         {0x00,0x00,0x00,0x00,0x03,0x04,0x04,EOT}},
95                 {0x5, "Mouse",
96                         {0x30,0x70,0x71,0x74,0x75,EOT},
97                         {0x00,0x0c,0x02,0x04,0x04,EOT}},
98                 {0x6, "Keyboard",
99                         {0x30,0x60,0x61,0x62,0x63,0x70,0x71,0x74,0x75,
100                          0xf0,EOT},
101                         {0x01,0x00,0x60,0x00,0x64,0x01,0x02,0x04,0x04,
102                          0x40,EOT}},
103                 {0x7, "GPIO",
104                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,0xf1,EOT},
105                         {0x00,0x00,0x00,0x00,0x03,0x04,0x04,0x00,0x00,EOT}},
106                 {0x8, "Fan speed control",
107                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
108                         {0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x00,EOT}},
109                 {EOT}}},
110         {0xe4, "PC87364", {
111                 {EOT}}},
112         {0xe5, "PC87365", {     /* SRID[7..0] == chip revision */
113                 {EOT}}},
114         {0xe8, "PC87363", {
115                 {EOT}}},
116         {0xe9, "PC87366", {
117                 {NOLDN, NULL,
118                         {0x20,0x21,0x22,0x23,0x24,0x25,0x27,0x28,0x2a,0x2b,
119                          0x2c,0x2d,0x2e,EOT},
120                         {0xe9,0x11,0x00,0x03,0x00,0x00,NANA,0x00,MISC,MISC,
121                          0x00,MISC,RSVD,EOT}},
122                 {0x0, "Floppy",
123                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,0xf1,EOT},
124                         {0x00,0x03,0xf2,0x06,0x03,0x02,0x04,0x24,0x00,EOT}},
125                 {0x1, "Parallel port",
126                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
127                         {0x00,0x02,0x78,0x07,0x02,0x04,0x04,0xf2,EOT}},
128                 {0x2, "COM2",
129                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
130                         {0x00,0x02,0xf8,0x03,0x03,0x04,0x04,0x02,EOT}},
131                 {0x3, "COM1",
132                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
133                         {0x00,0x03,0xf8,0x04,0x03,0x04,0x04,0x02,EOT}},
134                 {0x4, "System wake-up control (SWC)",
135                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,EOT},
136                         {0x00,0x00,0x00,0x00,0x03,0x04,0x04,EOT}},
137                 {0x5, "Mouse",
138                         {0x30,0x70,0x71,0x74,0x75,EOT},
139                         {0x00,0x0c,0x02,0x04,0x04,EOT}},
140                 {0x6, "Keyboard",
141                         {0x30,0x60,0x61,0x62,0x63,0x70,0x71,0x74,0x75,0xf0,
142                          EOT},
143                         {0x01,0x00,0x60,0x00,0x64,0x01,0x02,0x04,0x04,0x40,
144                          EOT}},
145                 {0x7, "GPIO",
146                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,0xf1,0xf2,
147                          EOT},
148                         {0x00,0x00,0x00,0x00,0x03,0x04,0x04,0x00,0x00,0x00,
149                          EOT}},
150                 {0x8, "ACCESS.bus (ACB)",
151                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
152                         {0x00,0x00,0x00,0x00,0x03,0x04,0x04,0x00,EOT}},
153                 {0x9, "Fan speed control and monitor (FSCM)",
154                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,0xf1,0xf2,
155                          EOT},
156                         {0x00,0x00,0x00,0x00,0x03,0x04,0x04,0x00,0x00,0x00,
157                          EOT}},
158                 {0xa, "Watchdog timer (WDT)",
159                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
160                         {0x00,0x00,0x00,0x00,0x03,0x04,0x04,0x02,EOT}},
161                 {0xb, "Game port",
162                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
163                         {0x00,0x02,0x00,0x00,0x03,0x04,0x04,0x00,EOT}},
164                 {0xc, "MIDI port",
165                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
166                         {0x00,0x03,0x30,0x00,0x03,0x04,0x04,0x00,EOT}},
167                 {0xd, "Voltage level monitor (VLM)",
168                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,EOT},
169                         {0x00,0x00,0x00,0x00,0x03,0x04,0x04,EOT}},
170                 {0xe, "Temperature sensor (TMS)",
171                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,EOT},
172                         {0x00,0x00,0x00,0x00,0x03,0x04,0x04,EOT}},
173                 {EOT}}},
174
175         /* SID[7..0]: family, SRID[7..5]: ID, SRID[4..0]: rev. */
176         {0xea, "PC8739x", {
177                 {EOT}}},
178         {0xec, "PC87591x", {
179                 /* SRID[7..5]: 000=PC87591E, 001=PC87591S, 100=PC87591L */
180                 {EOT}}},
181         {0xee, "PC8741x", {
182                 /* SRID[7..5] is marked as "not applicable for the PC8741x". */
183                 {EOT}}},
184         {0xf0, "PC87372", {
185                 {EOT}}},
186         {0xf1, "PC8374L", {
187                 {NOLDN, NULL,
188                         {0x10,0x12,0x13,0x20,0x21,0x22,0x23,0x24,0x25,0x26,
189                          0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,EOT},
190                         {0x00,0x00,0x00,0xf1,0x11,0x00,0x00,0x00,RSVD,0x00,
191                          MISC,RSVD,0x01,0x2e,RSVD,RSVD,RSVD,RSVD,RSVD,EOT}},
192                 {0x0, "Floppy",
193                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,0xf1,0xf8,
194                          EOT},
195                         {0x00,0x03,0xf2,0x06,0x03,0x02,0x04,0x24,0x00,0x24,
196                          EOT}},
197                 {0x1, "Parallel port",
198                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,0xf8,EOT},
199                         {0x00,0x02,0x78,0x07,0x02,0x04,0x04,0xf2,0x07,EOT}},
200                 {0x2, "COM2 / IR",
201                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
202                         {0x00,0x02,0xf8,0x03,0x03,0x04,0x04,0x02,EOT}},
203                 {0x3, "COM1",
204                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
205                         {0x00,0x03,0xf8,0x04,0x03,0x04,0x04,0x02,EOT}},
206                 {0x4, "System wake-up control (SWC)",
207                         {0x30,0x50,0x60,0x61,0x62,0x63,0x70,0x71,0x74,0x75,
208                          EOT},
209                         {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x04,0x04,
210                          EOT}},
211                 {0x5, "Mouse",
212                         {0x30,0x70,0x71,0x74,0x75,EOT},
213                         {0x00,0x0c,0x02,0x04,0x04,EOT}},
214                 {0x6, "Keyboard",
215                         {0x30,0x60,0x61,0x62,0x63,0x70,0x71,0x74,0x75,0xf0,
216                          EOT},
217                         {0x00,0x00,0x60,0x00,0x64,0x01,0x02,0x04,0x04,0x40,
218                          EOT}},
219                 {0x7, "GPIO",
220                         {0x30,0x50,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,0xf1,
221                          0xf2,0xf3,0xf8,EOT},
222                         {0x00,0x00,0x00,0x00,0x00,0x03,0x04,0x04,0x00,MISC,
223                          0x00,MISC,0x01,EOT}},
224                 {0x8, "Health management",
225                         {0x30,0x50,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
226                         {0x00,0x00,0x00,0x00,0x00,0x03,0x04,0x04,0x05,EOT}},
227                 {EOT}}},
228         {0xf2, "PC87427", {
229                 /* SRID[7..5] is marked as "not applicable for the PC87427". */
230                 {EOT}}},
231         {0xf3, "PC87373", {
232                 {EOT}}},
233         {EOT}
234 };
235
236 void probe_idregs_nsc(uint16_t port)
237 {
238         uint8_t id, rev;
239
240         probing_for("NSC", "", port);
241
242         outb(CHIP_ID_REG, port);
243         if (inb(port) != CHIP_ID_REG) {
244                 if (verbose)
245                         printf(NOTFOUND "port=0x%02x, port+1=0x%02x\n",
246                                inb(port), inb(port + 1));
247                 return;
248         }
249         id = inb(port + 1);
250
251         outb(CHIP_REV_REG, port);
252         if (inb(port) != CHIP_REV_REG) {
253                 printf("Warning: Can't get chip revision. Setting to 0xff.\n");
254                 rev = 0xff;
255         } else {
256                 rev = inb(port + 1);
257         }
258
259         if (superio_unknown(reg_table, id)) {
260                 if (verbose)
261                         printf(NOTFOUND "sid=0x%02x, srid=0x%02x\n", id, rev);
262                 return;
263         }
264
265         printf("Found NSC %s (sid=0x%02x, srid=0x%02x) at 0x%x\n",
266                get_superio_name(reg_table, id), id, rev, port);
267         chip_found = 1;
268
269         dump_superio("NSC", reg_table, port, id);
270 }