blob: 6961325388ebf691f6282d149b76db90bffeb640 [file] [log] [blame]
Uwe Hermann0120e1a2007-09-16 18:11:03 +00001/*
Uwe Hermannafe83092007-09-28 15:45:43 +00002 * This file is part of the superiotool project.
Uwe Hermann0120e1a2007-09-16 18:11:03 +00003 *
Uwe Hermann4cb7e712007-09-16 18:17:44 +00004 * Copyright (C) 2007 Carl-Daniel Hailfinger
Uwe Hermann0120e1a2007-09-16 18:11:03 +00005 * Copyright (C) 2007 Uwe Hermann <uwe@hermann-uwe.de>
Robinson P. Tryon552cfb72008-01-15 22:30:55 +00006 * Copyright (C) 2008 Robinson P. Tryon <bishop.robinson@gmail.com>
Uwe Hermann0120e1a2007-09-16 18:11:03 +00007 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23#ifndef SUPERIOTOOL_H
24#define SUPERIOTOOL_H
25
26#include <stdio.h>
27#include <stdlib.h>
Uwe Hermann6ff6af72007-09-18 22:24:34 +000028#include <stdint.h>
Uwe Hermann7e7e9ac2007-09-19 15:52:23 +000029#include <string.h>
Uwe Hermann3acf31e2007-09-19 01:55:35 +000030#include <getopt.h>
Uwe Hermann0120e1a2007-09-16 18:11:03 +000031#include <sys/io.h>
32
Uwe Hermanneec5ff42008-03-01 18:49:39 +000033#define USAGE "Usage: superiotool [-d] [-e] [-l] [-V] [-v] [-h]\n\n\
Uwe Hermann74b29b92007-11-17 17:13:52 +000034 -d | --dump Dump Super I/O register contents\n\
Uwe Hermanneec5ff42008-03-01 18:49:39 +000035 -e | --extra-dump Dump secondary registers too (e.g. EC registers)\n\
Robinson P. Tryon552cfb72008-01-15 22:30:55 +000036 -l | --list-supported Show the list of supported Super I/O chips\n\
Uwe Hermanneddc4732007-09-20 23:57:44 +000037 -V | --verbose Verbose mode\n\
38 -v | --version Show the superiotool version\n\
39 -h | --help Show a short help text\n\n\
Uwe Hermanne4749562007-09-19 16:26:18 +000040Per default (no options) superiotool will just probe for a Super I/O\n\
Uwe Hermannafe83092007-09-28 15:45:43 +000041and print its vendor, name, ID, revision, and config port.\n"
Uwe Hermanne4749562007-09-19 16:26:18 +000042
Uwe Hermann8b8d0392007-10-04 15:23:38 +000043#define NOTFOUND " Failed. Returned data: "
44
Uwe Hermannd754d2c2007-09-18 23:30:24 +000045#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
46
Uwe Hermann4cb7e712007-09-16 18:17:44 +000047#define EOT -1 /* End Of Table */
48#define NOLDN -2 /* NO LDN needed */
49#define NANA -3 /* Not Available */
Uwe Hermann6ff6af72007-09-18 22:24:34 +000050#define RSVD -4 /* Reserved */
Uwe Hermann7e7e9ac2007-09-19 15:52:23 +000051#define MISC -5 /* Needs special comment in output */
Uwe Hermannc3da3662007-09-26 16:14:16 +000052#define MAXNAMELEN 30 /* Maximum Name Length */
Ulf Jordan48c70322007-12-13 23:41:45 +000053#define MAXLDN 0x10 /* Biggest LDN */
Uwe Hermann4cb7e712007-09-16 18:17:44 +000054#define LDNSIZE (MAXLDN + 3) /* Biggest LDN + 0 + NOLDN + EOT */
55#define MAXNUMIDX 70 /* Maximum number of indexes */
56#define IDXSIZE (MAXNUMIDX + 1)
Uwe Hermann14f304a2007-10-08 01:11:11 +000057#define MAXNUMPORTS (6 + 1) /* Maximum number of Super I/O ports */
Uwe Hermann4cb7e712007-09-16 18:17:44 +000058
Uwe Hermann3acf31e2007-09-19 01:55:35 +000059/* Command line parameters. */
Ronald Hoogenboom0be73bb2008-02-25 22:32:41 +000060extern int dump, verbose, extra_dump;
Uwe Hermann3acf31e2007-09-19 01:55:35 +000061
Uwe Hermanne9d46162007-10-07 20:01:23 +000062extern int chip_found;
63
Uwe Hermann4cb7e712007-09-16 18:17:44 +000064struct superio_registers {
Uwe Hermanneddc4732007-09-20 23:57:44 +000065 int32_t superio_id; /* Signed, as we need EOT. */
66 const char name[MAXNAMELEN]; /* Super I/O name */
Uwe Hermann6ff6af72007-09-18 22:24:34 +000067 struct {
Uwe Hermannde24a0e2007-09-19 00:03:14 +000068 int ldn;
Uwe Hermanneddc4732007-09-20 23:57:44 +000069 const char *name; /* LDN name */
Uwe Hermannde24a0e2007-09-19 00:03:14 +000070 int idx[IDXSIZE];
71 int def[IDXSIZE];
Uwe Hermann4cb7e712007-09-16 18:17:44 +000072 } ldn[LDNSIZE];
73};
74
75/* superiotool.c */
Uwe Hermannde24a0e2007-09-19 00:03:14 +000076uint8_t regval(uint16_t port, uint8_t reg);
77void regwrite(uint16_t port, uint8_t reg, uint8_t val);
Uwe Hermannb4db2202007-09-20 23:37:56 +000078void enter_conf_mode_winbond_fintek_ite_8787(uint16_t port);
79void exit_conf_mode_winbond_fintek_ite_8787(uint16_t port);
Uwe Hermann7e7e9ac2007-09-19 15:52:23 +000080int superio_unknown(const struct superio_registers reg_table[], uint16_t id);
Uwe Hermann3acf31e2007-09-19 01:55:35 +000081const char *get_superio_name(const struct superio_registers reg_table[],
82 uint16_t id);
Uwe Hermann519419b2007-09-16 20:59:01 +000083void dump_superio(const char *name, const struct superio_registers reg_table[],
Uwe Hermann25a6c0f2007-09-19 00:48:42 +000084 uint16_t port, uint16_t id);
Uwe Hermann8b8d0392007-10-04 15:23:38 +000085void probing_for(const char *vendor, const char *info, uint16_t port);
Robinson P. Tryon552cfb72008-01-15 22:30:55 +000086void print_vendor_chips(const char *vendor,
87 const struct superio_registers reg_table[]);
Uwe Hermann0120e1a2007-09-16 18:11:03 +000088
Uwe Hermann945045b2007-09-28 15:39:10 +000089/* ali.c */
90void probe_idregs_ali(uint16_t port);
Robinson P. Tryon552cfb72008-01-15 22:30:55 +000091void print_ali_chips(void);
Uwe Hermann945045b2007-09-28 15:39:10 +000092
Uwe Hermann0120e1a2007-09-16 18:11:03 +000093/* fintek.c */
Uwe Hermannde24a0e2007-09-19 00:03:14 +000094void probe_idregs_fintek(uint16_t port);
Robinson P. Tryon552cfb72008-01-15 22:30:55 +000095void print_fintek_chips(void);
Uwe Hermann0120e1a2007-09-16 18:11:03 +000096
97/* ite.c */
Uwe Hermannde24a0e2007-09-19 00:03:14 +000098void probe_idregs_ite(uint16_t port);
Robinson P. Tryon552cfb72008-01-15 22:30:55 +000099void print_ite_chips(void);
Uwe Hermann0120e1a2007-09-16 18:11:03 +0000100
101/* nsc.c */
Uwe Hermann8b8d0392007-10-04 15:23:38 +0000102void probe_idregs_nsc(uint16_t port);
Robinson P. Tryon552cfb72008-01-15 22:30:55 +0000103void print_nsc_chips(void);
Uwe Hermann0120e1a2007-09-16 18:11:03 +0000104
Uwe Hermann6ff6af72007-09-18 22:24:34 +0000105/* smsc.c */
Uwe Hermannde24a0e2007-09-19 00:03:14 +0000106void probe_idregs_smsc(uint16_t port);
Robinson P. Tryon552cfb72008-01-15 22:30:55 +0000107void print_smsc_chips(void);
Uwe Hermannd754d2c2007-09-18 23:30:24 +0000108
Uwe Hermann7e7e9ac2007-09-19 15:52:23 +0000109/* winbond.c */
110void probe_idregs_winbond(uint16_t port);
Robinson P. Tryon552cfb72008-01-15 22:30:55 +0000111void print_winbond_chips(void);
Uwe Hermann7e7e9ac2007-09-19 15:52:23 +0000112
Uwe Hermannc3da3662007-09-26 16:14:16 +0000113/** Table of which config ports to probe for each Super I/O family. */
Uwe Hermann246be7d2007-10-31 22:22:11 +0000114static const struct {
Uwe Hermannde24a0e2007-09-19 00:03:14 +0000115 void (*probe_idregs) (uint16_t port);
116 int ports[MAXNUMPORTS]; /* Signed, as we need EOT. */
Uwe Hermannd754d2c2007-09-18 23:30:24 +0000117} superio_ports_table[] = {
Uwe Hermann945045b2007-09-28 15:39:10 +0000118 {probe_idregs_ali, {0x3f0, 0x370, EOT}},
Uwe Hermann0f867322007-09-24 01:40:09 +0000119 {probe_idregs_fintek, {0x2e, 0x4e, EOT}},
120 {probe_idregs_ite, {0x2e, 0x4e, EOT}},
Uwe Hermann14f304a2007-10-08 01:11:11 +0000121 {probe_idregs_nsc, {0x2e, 0x4e, EOT}},
122 {probe_idregs_smsc, {0x2e, 0x4e, 0x162e, 0x164e, 0x3f0, 0x370, EOT}},
Uwe Hermannc3da3662007-09-26 16:14:16 +0000123 {probe_idregs_winbond, {0x2e, 0x4e, 0x3f0, 0x370, 0x250, EOT}},
Uwe Hermannd754d2c2007-09-18 23:30:24 +0000124};
Uwe Hermann6ff6af72007-09-18 22:24:34 +0000125
Robinson P. Tryon552cfb72008-01-15 22:30:55 +0000126
127/** Table of functions to print out supported Super I/O chips. */
128static const struct {
129 void (*print_list) (void);
130} vendor_print_functions[] = {
131 {print_ali_chips},
132 {print_fintek_chips},
133 {print_ite_chips},
134 {print_nsc_chips},
135 {print_smsc_chips},
136 {print_winbond_chips},
137};
138
Uwe Hermann0120e1a2007-09-16 18:11:03 +0000139#endif