Fix superiotool build on non-NetBSD x86_64.
[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         {0xcf, "PC97307", {
29                 {NOLDN, NULL,
30                         {0x20,0x21,0x22,0x23,0x24,0x27,EOT},
31                         {0xcf,MISC,MISC,0x00,0x00,NANA,EOT}},
32                 {0x0, "Keyboard",
33                         {0x30,0x31,0x60,0x61,0x62,0x63,0x70,0x71,0x74,0x75,
34                          0xf0,EOT},
35                         {MISC,0x00,0x00,0x60,0x00,0x64,0x01,0x02,0x04,0x04,
36                          0x40,EOT}},
37                 {0x1, "Mouse",
38                         {0x30,0x70,0x71,0x74,0x75,EOT},
39                         {0x00,0x0c,0x02,0x04,0x04,EOT}},
40                 {0x2, "Real-time clock (RTC), advanced power control (APC)",
41                         {0x30,0x31,0x60,0x61,0x70,0x71,0x74,0x75,EOT},
42                         {MISC,0x00,0x00,0x70,0x08,0x00,0x04,0x04,EOT}},
43                 {0x3, "Floppy",
44                         {0x30,0x31,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,0xf1,
45                          EOT},
46                         {MISC,0x00,0x03,0xf2,0x06,0x03,0x02,0x04,0x20,0x00,
47                          EOT}},
48                 {0x4, "Parallel port",
49                         {0x30,0x31,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
50                         {0x00,0x00,0x02,0x78,0x07,0x00,0x04,0x04,0xf2,EOT}},
51                 {0x5, "COM2 / IR",
52                         {0x30,0x31,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
53                         {0x00,0x00,0x02,0xf8,0x03,0x03,0x04,0x04,0x02,EOT}},
54                 {0x6, "COM1",
55                         {0x30,0x31,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
56                         {0x00,0x00,0x03,0xf8,0x04,0x03,0x04,0x04,0x02,EOT}},
57                 {0x7, "GPIO",
58                         {0x30,0x31,0x60,0x61,0x74,0x75,EOT},
59                         {0x00,0x00,0x00,0x00,0x04,0x04,EOT}},
60                 {0x8, "Power management",
61                         {0x30,0x31,0x60,0x61,0x74,0x75,EOT},
62                         {0x00,0x00,0x00,0x00,0x04,0x04,EOT}},
63                 {EOT}}},
64         {0xd0, "PC87317", {
65                 {NOLDN, NULL,
66                         {0x20,0x21,0x22,0x23,0x24,0x25,EOT},
67                         {0xd0,MISC,MISC,0x00,0x00,0x00,EOT}},
68                 {0x0, "Keyboard",
69                         {0x30,0x31,0x60,0x61,0x62,0x63,0x70,0x71,0x74,0x75,
70                          0xf0,EOT},
71                         {MISC,0x00,0x00,0x60,0x00,0x64,0x01,0x02,0x04,0x04,
72                          0x40,EOT}},
73                 {0x1, "Mouse",
74                         {0x30,0x70,0x71,0x74,0x75,EOT},
75                         {0x00,0x0c,0x02,0x04,0x04,EOT}},
76                 {0x2, "Real-time clock (RTC), advanced power control (APC)",
77                         {0x30,0x31,0x60,0x61,0x70,0x71,0x74,0x75,EOT},
78                         {MISC,0x00,0x00,0x70,0x08,0x00,0x04,0x04,EOT}},
79                 {0x3, "Floppy",
80                         {0x30,0x31,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,0xf1,
81                          EOT},
82                         {MISC,0x00,0x03,0xf2,0x06,0x03,0x02,0x04,0x20,0x00,
83                          EOT}},
84                 {0x4, "Parallel port",
85                         {0x30,0x31,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
86                         {0x00,0x00,0x02,0x78,0x07,0x00,0x04,0x04,0xf2,EOT}},
87                 {0x5, "COM2 / IR",
88                         {0x30,0x31,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
89                         {0x00,0x00,0x02,0xf8,0x03,0x03,0x04,0x04,0x02,EOT}},
90                 {0x6, "COM1",
91                         {0x30,0x31,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
92                         {0x00,0x00,0x03,0xf8,0x04,0x03,0x04,0x04,0x02,EOT}},
93                 {0x7, "GPIO",
94                         {0x30,0x31,0x60,0x61,0x74,0x75,EOT},
95                         {0x00,0x00,0x00,0x00,0x04,0x04,EOT}},
96                 {0x8, "Power management",
97                         {0x30,0x31,0x60,0x61,0x74,0x75,EOT},
98                         {0x00,0x00,0x00,0x00,0x04,0x04,EOT}},
99                 {EOT}}},
100         {0xdf, "PC97317", {
101                 {NOLDN, NULL,
102                         {0x20,0x21,0x22,0x23,0x24,0x25,0x27,EOT},
103                         {0xdf,MISC,MISC,0x00,0x00,0x00,NANA,EOT}},
104                 {0x0, "Keyboard",
105                         {0x30,0x31,0x60,0x61,0x62,0x63,0x70,0x71,0x74,0x75,
106                          0xf0,EOT},
107                         {MISC,0x00,0x00,0x60,0x00,0x64,0x01,0x02,0x04,0x04,
108                          0x40,EOT}},
109                 {0x1, "Mouse",
110                         {0x30,0x70,0x71,0x74,0x75,EOT},
111                         {0x00,0x0c,0x02,0x04,0x04,EOT}},
112                 {0x2, "Real-time clock (RTC), advanced power control (APC)",
113                         {0x30,0x31,0x60,0x61,0x70,0x71,0x74,0x75,EOT},
114                         {MISC,0x00,0x00,0x70,0x08,0x00,0x04,0x04,EOT}},
115                 {0x3, "Floppy",
116                         {0x30,0x31,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,0xf1,
117                          EOT},
118                         {MISC,0x00,0x03,0xf2,0x06,0x03,0x02,0x04,0x20,0x00,
119                          EOT}},
120                 {0x4, "Parallel port",
121                         {0x30,0x31,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
122                         {0x00,0x00,0x02,0x78,0x07,0x00,0x04,0x04,0xf2,EOT}},
123                 {0x5, "COM2 / IR",
124                         {0x30,0x31,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
125                         {0x00,0x00,0x02,0xf8,0x03,0x03,0x04,0x04,0x02,EOT}},
126                 {0x6, "COM1",
127                         {0x30,0x31,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
128                         {0x00,0x00,0x03,0xf8,0x04,0x03,0x04,0x04,0x02,EOT}},
129                 {0x7, "GPIO",
130                         {0x30,0x31,0x60,0x61,0x74,0x75,EOT},
131                         {0x00,0x00,0x00,0x00,0x04,0x04,EOT}},
132                 {0x8, "Power management",
133                         {0x30,0x31,0x60,0x61,0x74,0x75,EOT},
134                         {0x00,0x00,0x00,0x00,0x04,0x04,EOT}},
135                 {EOT}}},
136         {0xe0, "PC87309", {
137                 {NOLDN, NULL,
138                         {0x20,0x21,0x22,0x27,0x2e,EOT},
139                         {0xe0,MISC,0x00,NANA,RSVD,EOT}},
140                 {0x0, "Floppy",
141                         {0x30,0x31,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,0xf1,
142                          EOT},
143                         {MISC,0x00,0x03,0xf2,0x06,0x03,0x02,0x04,0x20,0x00,
144                          EOT}},
145                 {0x1, "Parallel port",
146                         {0x30,0x31,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
147                         {0x00,0x00,0x02,0x78,0x07,0x00,0x04,0x04,0xf2,EOT}},
148                 {0x2, "COM2 / IR",
149                         {0x30,0x31,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
150                         {0x00,0x00,0x02,0xf8,0x03,0x03,0x04,0x04,0x02,EOT}},
151                 {0x3, "COM1",
152                         {0x30,0x31,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
153                         {0x00,0x00,0x03,0xf8,0x04,0x03,0x04,0x04,0x02,EOT}},
154                 {0x4, "Power management",
155                         {0x30,0x31,0x60,0x61,0x74,0x75,EOT},
156                         {0x00,0x00,0x00,0x00,0x04,0x04,EOT}},
157                 {0x5, "Mouse",
158                         {0x30,0x70,0x71,0x74,0x75,EOT},
159                         {0x00,0x0c,0x02,0x04,0x04,EOT}},
160                 {0x6, "Keyboard",
161                         {0x30,0x31,0x60,0x61,0x62,0x63,0x70,0x71,0x74,0x75,
162                          0xf0,EOT},
163                         {0x01,0x00,0x00,0x60,0x00,0x64,0x01,0x02,0x04,0x04,
164                          0x40,EOT}},
165                 {EOT}}},
166         {0xe1, "PC87360", {
167                 {NOLDN, NULL,
168                         {0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x2a,
169                          0x2b,0x2c,0x2d,0x2e,EOT},
170                         {0xe1,0x11,0x00,0x03,0x00,0x00,0x00,NANA,0x00,MISC,
171                          0x00,0x00,0x00,RSVD,EOT}},
172                 {0x0, "Floppy",
173                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,0xf1,EOT},
174                         {0x00,0x03,0xf2,0x06,0x03,0x02,0x04,0x24,0x00,EOT}},
175                 {0x1, "Parallel port",
176                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
177                         {0x00,0x02,0x78,0x07,0x02,0x04,0x04,0xf2,EOT}},
178                 {0x2, "COM2",
179                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
180                         {0x00,0x02,0xf8,0x03,0x03,0x04,0x04,0x02,EOT}},
181                 {0x3, "COM1",
182                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
183                         {0x00,0x03,0xf8,0x04,0x03,0x04,0x04,0x02,EOT}},
184                 {0x4, "System wake-up control (SWC)",
185                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,EOT},
186                         {0x00,0x00,0x00,0x00,0x03,0x04,0x04,EOT}},
187                 {0x5, "Mouse",
188                         {0x30,0x70,0x71,0x74,0x75,EOT},
189                         {0x00,0x0c,0x02,0x04,0x04,EOT}},
190                 {0x6, "Keyboard",
191                         {0x30,0x60,0x61,0x62,0x63,0x70,0x71,0x74,0x75,0xf0,
192                          EOT},
193                         {0x01,0x00,0x60,0x00,0x64,0x01,0x02,0x04,0x04,0x40,
194                          EOT}},
195                 {0x7, "GPIO",
196                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,0xf1,0xf2,
197                          EOT},
198                         {0x00,0x00,0x00,0x00,0x03,0x04,0x04,0x00,0x00,0x00,
199                          EOT}},
200                 {0x8, "ACCESS.bus (ACB)",
201                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
202                         {0x00,0x00,0x00,0x00,0x03,0x04,0x04,0x00,EOT}},
203                 {0x9, "Fan speed control and monitor (FSCM)",
204                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
205                         {0x00,0x00,0x00,0x00,0x03,0x04,0x04,0x00,EOT}},
206                 {0xa, "Watchdog timer",
207                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
208                         {0x00,0x00,0x00,0x00,0x03,0x04,0x04,0x02,EOT}},
209                 {EOT}}},
210         {0xe2, "PC87351", {
211                 {NOLDN, NULL,
212                         {0x20,0x21,0x22,0x23,0x24,0x27,0x2e,EOT},
213                         {0xe2,0x11,0xa1,0x00,MISC,NANA,RSVD,EOT}},
214                 {0x0, "Floppy",
215                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,0xf1,EOT},
216                         {0x00,0x03,0xf2,0x06,0x03,0x02,0x04,0x24,0x00,EOT}},
217                 {0x1, "Parallel port",
218                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
219                         {0x00,0x02,0x78,0x07,0x02,0x04,0x04,0xf2,EOT}},
220                 {0x2, "COM2",
221                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
222                         {0x00,0x02,0xf8,0x03,0x03,0x04,0x04,0x02,EOT}},
223                 {0x3, "COM1",
224                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
225                         {0x00,0x03,0xf8,0x04,0x03,0x04,0x04,0x02,EOT}},
226                 {0x4, "System wake-up control (SWC)",
227                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,EOT},
228                         {0x00,0x00,0x00,0x00,0x03,0x04,0x04,EOT}},
229                 {0x5, "Mouse",
230                         {0x30,0x70,0x71,0x74,0x75,EOT},
231                         {0x00,0x0c,0x02,0x04,0x04,EOT}},
232                 {0x6, "Keyboard",
233                         {0x30,0x60,0x61,0x62,0x63,0x70,0x71,0x74,0x75,
234                          0xf0,EOT},
235                         {0x01,0x00,0x60,0x00,0x64,0x01,0x02,0x04,0x04,
236                          0x40,EOT}},
237                 {0x7, "GPIO",
238                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,0xf1,EOT},
239                         {0x00,0x00,0x00,0x00,0x03,0x04,0x04,0x00,0x00,EOT}},
240                 {0x8, "Fan speed control",
241                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
242                         {0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x00,EOT}},
243                 {EOT}}},
244         {0xe4, "PC87364", {
245                 {EOT}}},
246         {0xe5, "PC87365", {     /* SRID[7..0] == chip revision */
247                 {EOT}}},
248         {0xe8, "PC87363", {
249                 {EOT}}},
250         {0xe9, "PC87366", {
251                 {NOLDN, NULL,
252                         {0x20,0x21,0x22,0x23,0x24,0x25,0x27,0x28,0x2a,0x2b,
253                          0x2c,0x2d,0x2e,EOT},
254                         {0xe9,0x11,0x00,0x03,0x00,0x00,NANA,0x00,MISC,MISC,
255                          0x00,MISC,RSVD,EOT}},
256                 {0x0, "Floppy",
257                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,0xf1,EOT},
258                         {0x00,0x03,0xf2,0x06,0x03,0x02,0x04,0x24,0x00,EOT}},
259                 {0x1, "Parallel port",
260                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
261                         {0x00,0x02,0x78,0x07,0x02,0x04,0x04,0xf2,EOT}},
262                 {0x2, "COM2",
263                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
264                         {0x00,0x02,0xf8,0x03,0x03,0x04,0x04,0x02,EOT}},
265                 {0x3, "COM1",
266                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
267                         {0x00,0x03,0xf8,0x04,0x03,0x04,0x04,0x02,EOT}},
268                 {0x4, "System wake-up control (SWC)",
269                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,EOT},
270                         {0x00,0x00,0x00,0x00,0x03,0x04,0x04,EOT}},
271                 {0x5, "Mouse",
272                         {0x30,0x70,0x71,0x74,0x75,EOT},
273                         {0x00,0x0c,0x02,0x04,0x04,EOT}},
274                 {0x6, "Keyboard",
275                         {0x30,0x60,0x61,0x62,0x63,0x70,0x71,0x74,0x75,0xf0,
276                          EOT},
277                         {0x01,0x00,0x60,0x00,0x64,0x01,0x02,0x04,0x04,0x40,
278                          EOT}},
279                 {0x7, "GPIO",
280                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,0xf1,0xf2,
281                          EOT},
282                         {0x00,0x00,0x00,0x00,0x03,0x04,0x04,0x00,0x00,0x00,
283                          EOT}},
284                 {0x8, "ACCESS.bus (ACB)",
285                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
286                         {0x00,0x00,0x00,0x00,0x03,0x04,0x04,0x00,EOT}},
287                 {0x9, "Fan speed control and monitor (FSCM)",
288                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,0xf1,0xf2,
289                          EOT},
290                         {0x00,0x00,0x00,0x00,0x03,0x04,0x04,0x00,0x00,0x00,
291                          EOT}},
292                 {0xa, "Watchdog timer (WDT)",
293                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
294                         {0x00,0x00,0x00,0x00,0x03,0x04,0x04,0x02,EOT}},
295                 {0xb, "Game port",
296                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
297                         {0x00,0x02,0x00,0x00,0x03,0x04,0x04,0x00,EOT}},
298                 {0xc, "MIDI port",
299                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
300                         {0x00,0x03,0x30,0x00,0x03,0x04,0x04,0x00,EOT}},
301                 {0xd, "Voltage level monitor (VLM)",
302                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,EOT},
303                         {0x00,0x00,0x00,0x00,0x03,0x04,0x04,EOT}},
304                 {0xe, "Temperature sensor (TMS)",
305                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,EOT},
306                         {0x00,0x00,0x00,0x00,0x03,0x04,0x04,EOT}},
307                 {EOT}}},
308
309         /* SID[7..0]: family, SRID[7..5]: ID, SRID[4..0]: rev. */
310         {0xea, "PC8739x", {
311                 {NOLDN, NULL,
312                         {0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,
313                          0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,EOT},
314                         {0xea,0x11,MISC,MISC,MISC,0x80,0x00,NANA,0x00,MISC,
315                          0x37,RSVD,RSVD,RSVD,RSVD,RSVD,EOT}},
316                 {0x0, "Floppy",
317                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,0xf1,EOT},
318                         {0x00,0x03,0xf2,0x06,0x03,0x02,0x04,0x24,0x00,EOT}},
319                 {0x1, "Parallel port",
320                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
321                         {0x00,0x02,0x78,0x07,0x02,0x04,0x04,0xf2,EOT}},
322                 {0x2, "COM2 / FIR",
323                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
324                         {0x00,0x02,0xf8,0x03,0x03,0x04,0x04,0x02,EOT}},
325                 {0x3, "COM1",
326                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
327                         {0x00,0x03,0xf8,0x04,0x03,0x04,0x04,0x02,EOT}},
328                 {0x7, "GPIO",
329                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,0xf1,0xf2,
330                          EOT},
331                         {0x00,0x00,0x00,0x00,0x03,0x04,0x04,0x00,0x44,0x01,
332                          EOT}},
333                 {0xa, "Watchdog timer (WDT)",
334                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
335                         {0x00,0x00,0x00,0x00,0x03,0x04,0x04,0x02,EOT}},
336                 {0xb, "Game port",
337                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
338                         {0x00,0x02,0x01,0x00,0x03,0x04,0x04,0x00,EOT}},
339                 {0xc, "MIDI port",
340                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
341                         {0x00,0x03,0x30,0x00,0x03,0x04,0x04,0x00,EOT}},
342                 {0xf, "X-Bus",
343                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,0xf1,0xf2,
344                          0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,EOT},
345                         {0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x00,0x00,0x00,
346                          0x00,0x00,0x00,0x00,0x00,0x00,0x00,EOT}},
347                 {EOT}}},
348         {0xec, "PC87591x", {
349                 /* SRID[7..5]: 000=PC87591E, 001=PC87591S, 100=PC87591L */
350                 {EOT}}},
351         {0xee, "PC8741x", {
352                 /* SRID[7..5] is marked as "not applicable for the PC8741x". */
353                 {NOLDN, NULL,
354                         {0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,
355                          0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,EOT},
356                         {0xee,0x11,0x20,MISC,MISC,MISC,0x00,NANA,0x00,MISC,
357                          0x00,RSVD,RSVD,RSVD,RSVD,RSVD,EOT}},
358                 {0x0, "Floppy",
359                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,0xf1,EOT},
360                         {0x00,0x03,0xf2,0x06,0x03,0x02,0x04,0x24,0x00,EOT}},
361                 {0x1, "Parallel port",
362                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
363                         {0x00,0x02,0x78,0x07,0x02,0x04,0x04,0xf2,EOT}},
364                 {0x2, "COM2",
365                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
366                         {0x00,0x02,0xf8,0x03,0x03,0x04,0x04,0x02,EOT}},
367                 {0x3, "COM1",
368                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
369                         {0x00,0x03,0xf8,0x04,0x03,0x04,0x04,0x02,EOT}},
370                 {0x4, "System wake-up control (SWC)",
371                         {0x30,0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x70,
372                          0x71,0x74,0x75,EOT},
373                         {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
374                          0x03,0x04,0x04,EOT}},
375                 {0x5, "Mouse",
376                         {0x30,0x70,0x71,0x74,0x75,EOT},
377                         {0x00,0x0c,0x02,0x04,0x04,EOT}},
378                 {0x6, "Keyboard",
379                         {0x30,0x60,0x61,0x62,0x63,0x70,0x71,0x74,0x75,0xf0,
380                          EOT},
381                         {0x00,0x00,0x60,0x00,0x64,0x01,0x02,0x04,0x04,0x40,
382                          EOT}},
383                 {0x7, "GPIO",
384                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,0xf1,0xf2,
385                          0xf3,EOT},
386                         {0x00,0x00,0x00,0x00,0x03,0x04,0x04,0x00,MISC,0x01,
387                          0x00,EOT}},
388                 {0xf, "X-Bus",
389                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,0xf1,0xf2,
390                          0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa,0xfb,0xfc,
391                          EOT},
392                         {0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x00,0x00,0x00,
393                          0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
394                          EOT}},
395                 {0x10, "Real-time clock (RTC)",
396                         {0x30,0x60,0x61,0x62,0x63,0x70,0x71,0x74,0x75,0xf0,
397                          0xf1,0xf2,0xf3,EOT},
398                         {0x00,0x00,0x70,0x00,0x72,0x08,0x00,0x04,0x04,0x00,
399                          0x00,0x00,0x00,EOT}},
400                 {EOT}}},
401         {0xf0, "PC87372", {
402                 {EOT}}},
403         {0x0f1, "PC8374L", {
404                 {NOLDN, NULL,
405                         {0x10,0x12,0x13,0x20,0x21,0x22,0x23,0x24,0x25,0x26,
406                          0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,EOT},
407                         {0x00,0x00,0x00,0xf1,0x11,0x00,0x00,0x00,RSVD,0x00,
408                          MISC,RSVD,0x01,0x2e,RSVD,RSVD,RSVD,RSVD,RSVD,EOT}},
409                 {0x0, "Floppy",
410                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,0xf1,0xf8,
411                          EOT},
412                         {0x00,0x03,0xf2,0x06,0x03,0x02,0x04,0x24,0x00,0x24,
413                          EOT}},
414                 {0x1, "Parallel port",
415                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,0xf8,EOT},
416                         {0x00,0x02,0x78,0x07,0x02,0x04,0x04,0xf2,0x07,EOT}},
417                 {0x2, "COM2 / IR",
418                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
419                         {0x00,0x02,0xf8,0x03,0x03,0x04,0x04,0x02,EOT}},
420                 {0x3, "COM1",
421                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
422                         {0x00,0x03,0xf8,0x04,0x03,0x04,0x04,0x02,EOT}},
423                 {0x4, "System wake-up control (SWC)",
424                         {0x30,0x50,0x60,0x61,0x62,0x63,0x70,0x71,0x74,0x75,
425                          EOT},
426                         {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x04,0x04,
427                          EOT}},
428                 {0x5, "Mouse",
429                         {0x30,0x70,0x71,0x74,0x75,EOT},
430                         {0x00,0x0c,0x02,0x04,0x04,EOT}},
431                 {0x6, "Keyboard",
432                         {0x30,0x60,0x61,0x62,0x63,0x70,0x71,0x74,0x75,0xf0,
433                          EOT},
434                         {0x00,0x00,0x60,0x00,0x64,0x01,0x02,0x04,0x04,0x40,
435                          EOT}},
436                 {0x7, "GPIO",
437                         {0x30,0x50,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,0xf1,
438                          0xf2,0xf3,0xf8,EOT},
439                         {0x00,0x00,0x00,0x00,0x00,0x03,0x04,0x04,0x00,MISC,
440                          0x00,MISC,0x01,EOT}},
441                 {0x8, "Health management",
442                         {0x30,0x50,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
443                         {0x00,0x00,0x00,0x00,0x00,0x03,0x04,0x04,0x05,EOT}},
444                 {EOT}}},
445         {0x8f1, "WPCD376I", {
446                 {NOLDN, NULL,
447                         {0x10,0x12,0x13,0x20,0x21,0x22,0x23,0x24,0x25,0x26,
448                          0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,EOT},
449                         {0x00,0x00,0x00,0xf1,0x11,0x00,0x00,0x00,RSVD,0x00,
450                          MISC,RSVD,0x01,0x2e,RSVD,RSVD,RSVD,RSVD,RSVD,EOT}},
451                 {0x0, "Floppy",
452                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,0xf1,0xf8,
453                          EOT},
454                         {0x00,0x03,0xf2,0x06,0x03,0x02,0x04,0x24,0x00,0x24,
455                          EOT}},
456                 {0x1, "Parallel port",
457                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,0xf8,EOT},
458                         {0x00,0x02,0x78,0x07,0x02,0x04,0x04,0xf2,0x07,EOT}},
459                 {0x2, "IR",
460                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
461                         {0x00,0x02,0xf8,0x03,0x03,0x04,0x04,0x02,EOT}},
462                 {0x3, "COM1",
463                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
464                         {0x00,0x03,0xf8,0x04,0x03,0x04,0x04,0x02,EOT}},
465                 {0x4, "System wake-up control (SWC)",
466                         {0x30,0x50,0x60,0x61,0x62,0x63,0x70,0x71,0x74,0x75,
467                          EOT},
468                         {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x04,0x04,
469                          EOT}},
470                 {0x5, "Mouse",
471                         {0x30,0x70,0x71,0x74,0x75,EOT},
472                         {0x00,0x0c,0x02,0x04,0x04,EOT}},
473                 {0x6, "Keyboard",
474                         {0x30,0x60,0x61,0x62,0x63,0x70,0x71,0x74,0x75,0xf0,
475                          EOT},
476                         {0x00,0x00,0x60,0x00,0x64,0x01,0x02,0x04,0x04,0x40,
477                          EOT}},
478                 {0x7, "GPIO",
479                         {0x30,0x50,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,0xf1,
480                          0xf2,0xf3,0xf8,EOT},
481                         {0x00,0x00,0x00,0x00,0x00,0x03,0x04,0x04,0x00,MISC,
482                          0x00,MISC,0x01,EOT}},
483                 {EOT}}},
484         {0xf2, "PC87427", {
485                 /* SRID[7..5] is marked as "not applicable for the PC87427". */
486                 {NOLDN, NULL,
487                         {0x10,0x12,0x13,0x1d,0x20,0x21,0x22,0x23,0x24,0x25,
488                          0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
489                          EOT},
490                         {0x00,0x00,0x00,0x00,0xf2,0x11,0xa0,MISC,MISC,MISC,
491                          0x02,NANA,0x00,MISC,0x00,0x00,MISC,MISC,RSVD,RSVD,
492                          EOT}},
493                 {0x0, "Floppy",
494                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,0xf1,EOT},
495                         {0x00,0x03,0xf2,0x06,0x03,0x02,0x04,0x24,0x00,EOT}},
496                 {0x2, "COM2",
497                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
498                         {0x00,0x02,0xf8,0x03,0x03,0x04,0x04,0x02,EOT}},
499                 {0x3, "COM1",
500                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
501                         {0x00,0x03,0xf8,0x04,0x03,0x04,0x04,0x02,EOT}},
502                 {0x4, "System wake-up control (SWC)",
503                         {0x30,0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x70,
504                          0x71,0x74,0x75,EOT},
505                         {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
506                          0x03,0x04,0x04,EOT}},
507                 {0x5, "Mouse",
508                         {0x30,0x70,0x71,0x74,0x75,EOT},
509                         {0x00,0x0c,0x02,0x04,0x04,EOT}},
510                 {0x6, "Keyboard",
511                         {0x30,0x60,0x61,0x62,0x63,0x70,0x71,0x74,0x75,0xf0,
512                          EOT},
513                         {0x00,0x00,0x60,0x00,0x64,0x01,0x02,0x04,0x04,0x40,
514                          EOT}},
515                 {0x7, "GPIO",
516                         {0x30,0x50,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,0xf1,
517                          0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,EOT},
518                         {0x00,0x00,0x00,0x00,0x00,0x03,0x04,0x04,0x00,MISC,
519                          0x01,0x00,0x00,0x00,0x00,0x00,0x00,EOT}},
520                 {0x9, "Fan Monitor and Control (FMC)",
521                         {0x30,0x50,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,0xf1,
522                          EOT},
523                         {0x00,0x00,0x00,0x00,0x00,0x03,0x04,0x04,0x19,0x06,
524                          EOT}},
525                 {0xa, "Watchdog timer (WDT)",
526                         {0x30,0x50,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,EOT},
527                         {0x00,0x00,0x00,0x00,0x00,0x03,0x04,0x04,0x00,EOT}},
528                 {0xf, "X-Bus",
529                         {0x30,0x60,0x61,0x70,0x71,0x74,0x75,0xf0,0xf1,0xf2,
530                          0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa,0xfb,0xfc,
531                          0xfd,0xfe,0xff,EOT},
532                         {0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x00,0x00,0x00,
533                          0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
534                          0x00,0x80,0x10,EOT}},
535                 {0x10, "Real-time clock (RTC)",
536                         {0x30,0x60,0x61,0x62,0x63,0x70,0x71,0x74,0x75,0xf0,
537                          0xf1,0xf2,0xf3,0xf6,0xf7,EOT},
538                         {0x00,0x00,0x70,0x00,0x72,0x08,0x00,0x04,0x04,0x00,
539                          0x00,0x00,0x00,MISC,0x00,EOT}},
540                 {0x14, "Health monitoring and control (HMC)",
541                         {0x30,0x50,0x60,0x61,0x62,0x63,0x70,0x71,0x74,0x75,
542                          0xf0,EOT},
543                         {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x04,0x04,
544                          0x05,EOT}},
545                 {EOT}}},
546         {0xf3, "PC87373", {
547                 {EOT}}},
548         {EOT}
549 };
550
551 void probe_idregs_nsc(uint16_t port)
552 {
553         uint8_t id, rev;
554         uint16_t magic;
555
556         probing_for("NSC", "", port);
557
558         OUTB(CHIP_ID_REG, port);
559         if (INB(port) != CHIP_ID_REG) {
560                 if (verbose)
561                         printf(NOTFOUND "port=0x%02x, port+1=0x%02x\n",
562                                INB(port), INB(port + 1));
563                 return;
564         }
565         id = INB(port + 1);
566
567         OUTB(CHIP_REV_REG, port);
568         if (INB(port) != CHIP_REV_REG) {
569                 printf("Warning: Can't get chip revision. Setting to 0xff.\n");
570                 rev = 0xff;
571         } else {
572                 rev = INB(port + 1);
573         }
574
575         /*
576          * NSC PC8374L has ID 0xf1, rev 0b000xxxxx according to datasheet.
577          * Winbond WPCD376I has ID 0xf1, rev 0b100xxxxx according to datasheet.
578          */
579         if (id == 0xf1)
580                 magic = ((rev & 0xe0) << 4) | id;
581         else
582                 magic = id;
583
584         if (superio_unknown(reg_table, magic)) {
585                 if (verbose)
586                         printf(NOTFOUND "sid=0x%02x, srid=0x%02x\n", id, rev);
587                 return;
588         }
589
590         printf("Found %s %s (sid=0x%02x, srid=0x%02x) at 0x%x\n",
591                magic == 0x8f1 ? "Winbond" : "NSC",
592                get_superio_name(reg_table, magic), id, rev, port);
593         chip_found = 1;
594
595         dump_superio(magic == 0x8f1 ? "Winbond" : "NSC",
596                      reg_table, port, magic, LDN_SEL);
597 }
598
599 void print_nsc_chips(void)
600 {
601         print_vendor_chips("NSC", reg_table);
602 }