2 * This file is part of the superiotool project.
4 * Copyright (C) 2007 Carl-Daniel Hailfinger
5 * Copyright (C) 2007 Uwe Hermann <uwe@hermann-uwe.de>
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.
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.
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
32 #define USAGE "Usage: superiotool [-d] [-V] [-v] [-h]\n\n\
33 -d | --dump Dump Super I/O register contents\n\
34 -V | --verbose Verbose mode\n\
35 -v | --version Show the superiotool version\n\
36 -h | --help Show a short help text\n\n\
37 Per default (no options) superiotool will just probe for a Super I/O\n\
38 and print its vendor, name, ID, revision, and config port.\n"
40 #define NOTFOUND " Failed. Returned data: "
42 #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
44 #define EOT -1 /* End Of Table */
45 #define NOLDN -2 /* NO LDN needed */
46 #define NANA -3 /* Not Available */
47 #define RSVD -4 /* Reserved */
48 #define MISC -5 /* Needs special comment in output */
49 #define MAXNAMELEN 30 /* Maximum Name Length */
50 #define MAXLDN 0x10 /* Biggest LDN */
51 #define LDNSIZE (MAXLDN + 3) /* Biggest LDN + 0 + NOLDN + EOT */
52 #define MAXNUMIDX 70 /* Maximum number of indexes */
53 #define IDXSIZE (MAXNUMIDX + 1)
54 #define MAXNUMPORTS (6 + 1) /* Maximum number of Super I/O ports */
56 /* Command line parameters. */
57 extern int dump, verbose;
59 extern int chip_found;
61 struct superio_registers {
62 int32_t superio_id; /* Signed, as we need EOT. */
63 const char name[MAXNAMELEN]; /* Super I/O name */
66 const char *name; /* LDN name */
73 uint8_t regval(uint16_t port, uint8_t reg);
74 void regwrite(uint16_t port, uint8_t reg, uint8_t val);
75 void enter_conf_mode_winbond_fintek_ite_8787(uint16_t port);
76 void exit_conf_mode_winbond_fintek_ite_8787(uint16_t port);
77 int superio_unknown(const struct superio_registers reg_table[], uint16_t id);
78 const char *get_superio_name(const struct superio_registers reg_table[],
80 void dump_superio(const char *name, const struct superio_registers reg_table[],
81 uint16_t port, uint16_t id);
82 void probing_for(const char *vendor, const char *info, uint16_t port);
85 void probe_idregs_ali(uint16_t port);
88 void probe_idregs_fintek(uint16_t port);
91 void probe_idregs_ite(uint16_t port);
94 void probe_idregs_nsc(uint16_t port);
97 void probe_idregs_smsc(uint16_t port);
100 void probe_idregs_winbond(uint16_t port);
102 /** Table of which config ports to probe for each Super I/O family. */
103 static const struct {
104 void (*probe_idregs) (uint16_t port);
105 int ports[MAXNUMPORTS]; /* Signed, as we need EOT. */
106 } superio_ports_table[] = {
107 {probe_idregs_ali, {0x3f0, 0x370, EOT}},
108 {probe_idregs_fintek, {0x2e, 0x4e, EOT}},
109 {probe_idregs_ite, {0x2e, 0x4e, EOT}},
110 {probe_idregs_nsc, {0x2e, 0x4e, EOT}},
111 {probe_idregs_smsc, {0x2e, 0x4e, 0x162e, 0x164e, 0x3f0, 0x370, EOT}},
112 {probe_idregs_winbond, {0x2e, 0x4e, 0x3f0, 0x370, 0x250, EOT}},