Print a short message if no Super I/O chip could be detected (trivial).
[coreboot.git] / util / superiotool / superiotool.h
1 /*
2  * This file is part of the superiotool project.
3  *
4  * Copyright (C) 2007 Carl-Daniel Hailfinger
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 #ifndef SUPERIOTOOL_H
23 #define SUPERIOTOOL_H
24
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <stdint.h>
28 #include <string.h>
29 #include <getopt.h>
30 #include <sys/io.h>
31
32 #define SUPERIOTOOL_VERSION "$Rev$"
33
34 #define USAGE "Usage: superiotool [-d] [-D] [-V] [-v] [-h]\n\n\
35   -d | --dump            Dump Super I/O registers\n\
36   -D | --dump-readable   Dump Super I/O registers in human-readable format\n\
37   -V | --verbose         Verbose mode\n\
38   -v | --version         Show the superiotool version\n\
39   -h | --help            Show a short help text\n\n\
40 Per default (no options) superiotool will just probe for a Super I/O\n\
41 and print its vendor, name, ID, revision, and config port.\n"
42
43 #define NOTFOUND "  Failed. Returned data: "
44
45 #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
46
47 #define EOT             -1              /* End Of Table */
48 #define NOLDN           -2              /* NO LDN needed */
49 #define NANA            -3              /* Not Available */
50 #define RSVD            -4              /* Reserved */
51 #define MISC            -5              /* Needs special comment in output */
52 #define MAXNAMELEN      30              /* Maximum Name Length */
53 #define MAXLDN          0xa             /* Biggest LDN */
54 #define LDNSIZE         (MAXLDN + 3)    /* Biggest LDN + 0 + NOLDN + EOT */
55 #define MAXNUMIDX       70              /* Maximum number of indexes */
56 #define IDXSIZE         (MAXNUMIDX + 1)
57 #define MAXNUMPORTS     (5 + 1)         /* Maximum number of Super I/O ports */
58
59 /* Command line parameters. */
60 extern int dump, dump_readable, verbose;
61
62 extern int chip_found;
63
64 struct superio_registers {
65         int32_t superio_id;             /* Signed, as we need EOT. */
66         const char name[MAXNAMELEN];    /* Super I/O name */
67         struct {
68                 int ldn;
69                 const char *name;       /* LDN name */
70                 int idx[IDXSIZE];
71                 int def[IDXSIZE];
72         } ldn[LDNSIZE];
73 };
74
75 /* superiotool.c */
76 uint8_t regval(uint16_t port, uint8_t reg);
77 void regwrite(uint16_t port, uint8_t reg, uint8_t val);
78 void enter_conf_mode_winbond_fintek_ite_8787(uint16_t port);
79 void exit_conf_mode_winbond_fintek_ite_8787(uint16_t port);
80 int superio_unknown(const struct superio_registers reg_table[], uint16_t id);
81 const char *get_superio_name(const struct superio_registers reg_table[],
82                              uint16_t id);
83 void dump_superio(const char *name, const struct superio_registers reg_table[],
84                   uint16_t port, uint16_t id);
85 void dump_superio_readable(uint16_t port);
86 void probing_for(const char *vendor, const char *info, uint16_t port);
87
88 /* ali.c */
89 void probe_idregs_ali(uint16_t port);
90
91 /* fintek.c */
92 void probe_idregs_fintek(uint16_t port);
93
94 /* ite.c */
95 void probe_idregs_ite(uint16_t port);
96
97 /* nsc.c */
98 void probe_idregs_nsc(uint16_t port);
99
100 /* smsc.c */
101 void probe_idregs_smsc(uint16_t port);
102
103 /* winbond.c */
104 void probe_idregs_winbond(uint16_t port);
105
106 /** Table of which config ports to probe for each Super I/O family. */
107 const static struct {
108         void (*probe_idregs) (uint16_t port);
109         int ports[MAXNUMPORTS]; /* Signed, as we need EOT. */
110 } superio_ports_table[] = {
111         {probe_idregs_ali,      {0x3f0, 0x370, EOT}},
112         {probe_idregs_nsc,      {0x2e, 0x4e, EOT}},
113         {probe_idregs_fintek,   {0x2e, 0x4e, EOT}},
114         {probe_idregs_ite,      {0x2e, 0x4e, EOT}},
115         {probe_idregs_smsc,     {0x2e, 0x4e, 0x3f0, 0x370, EOT}},
116         {probe_idregs_winbond,  {0x2e, 0x4e, 0x3f0, 0x370, 0x250, EOT}},
117 };
118
119 #endif