blob: 6f15aae2c49267a07e43a0cd26ba36b77c1323db [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\
Uwe Hermann969a9f62008-03-17 13:43:48 +000039 -h | --help Show a short help text\n\n"
40
41#define USAGE_INFO "\
Uwe Hermanne4749562007-09-19 16:26:18 +000042Per default (no options) superiotool will just probe for a Super I/O\n\
Uwe Hermannafe83092007-09-28 15:45:43 +000043and print its vendor, name, ID, revision, and config port.\n"
Uwe Hermanne4749562007-09-19 16:26:18 +000044
Uwe Hermann8b8d0392007-10-04 15:23:38 +000045#define NOTFOUND " Failed. Returned data: "
46
Uwe Hermannd754d2c2007-09-18 23:30:24 +000047#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
48
Uwe Hermann4cb7e712007-09-16 18:17:44 +000049#define EOT -1 /* End Of Table */
50#define NOLDN -2 /* NO LDN needed */
51#define NANA -3 /* Not Available */
Uwe Hermann6ff6af72007-09-18 22:24:34 +000052#define RSVD -4 /* Reserved */
Uwe Hermann7e7e9ac2007-09-19 15:52:23 +000053#define MISC -5 /* Needs special comment in output */
Ulf Jordan48c70322007-12-13 23:41:45 +000054#define MAXLDN 0x10 /* Biggest LDN */
Uwe Hermann4cb7e712007-09-16 18:17:44 +000055#define LDNSIZE (MAXLDN + 3) /* Biggest LDN + 0 + NOLDN + EOT */
Uwe Hermann8cb24582008-05-08 13:50:23 +000056#define MAXNUMIDX 170 /* Maximum number of indexes */
Uwe Hermann4cb7e712007-09-16 18:17:44 +000057#define IDXSIZE (MAXNUMIDX + 1)
Uwe Hermann14f304a2007-10-08 01:11:11 +000058#define MAXNUMPORTS (6 + 1) /* Maximum number of Super I/O ports */
Uwe Hermann4cb7e712007-09-16 18:17:44 +000059
Uwe Hermann3acf31e2007-09-19 01:55:35 +000060/* Command line parameters. */
Ronald Hoogenboom0be73bb2008-02-25 22:32:41 +000061extern int dump, verbose, extra_dump;
Uwe Hermann3acf31e2007-09-19 01:55:35 +000062
Uwe Hermanne9d46162007-10-07 20:01:23 +000063extern int chip_found;
64
Uwe Hermann4cb7e712007-09-16 18:17:44 +000065struct superio_registers {
Uwe Hermanneddc4732007-09-20 23:57:44 +000066 int32_t superio_id; /* Signed, as we need EOT. */
Uwe Hermann42cccdf2008-03-29 01:35:21 +000067 const char *name; /* Super I/O name */
Uwe Hermann6ff6af72007-09-18 22:24:34 +000068 struct {
Uwe Hermann42cccdf2008-03-29 01:35:21 +000069 int8_t ldn;
Uwe Hermanneddc4732007-09-20 23:57:44 +000070 const char *name; /* LDN name */
Uwe Hermann42cccdf2008-03-29 01:35:21 +000071 int16_t idx[IDXSIZE];
72 int16_t def[IDXSIZE];
Uwe Hermann4cb7e712007-09-16 18:17:44 +000073 } ldn[LDNSIZE];
74};
75
76/* superiotool.c */
Uwe Hermannde24a0e2007-09-19 00:03:14 +000077uint8_t regval(uint16_t port, uint8_t reg);
78void regwrite(uint16_t port, uint8_t reg, uint8_t val);
Uwe Hermannb4db2202007-09-20 23:37:56 +000079void enter_conf_mode_winbond_fintek_ite_8787(uint16_t port);
80void exit_conf_mode_winbond_fintek_ite_8787(uint16_t port);
Uwe Hermann7e7e9ac2007-09-19 15:52:23 +000081int superio_unknown(const struct superio_registers reg_table[], uint16_t id);
Uwe Hermann3acf31e2007-09-19 01:55:35 +000082const char *get_superio_name(const struct superio_registers reg_table[],
83 uint16_t id);
Uwe Hermann519419b2007-09-16 20:59:01 +000084void dump_superio(const char *name, const struct superio_registers reg_table[],
Uwe Hermann25a6c0f2007-09-19 00:48:42 +000085 uint16_t port, uint16_t id);
Uwe Hermann8b8d0392007-10-04 15:23:38 +000086void probing_for(const char *vendor, const char *info, uint16_t port);
Robinson P. Tryon552cfb72008-01-15 22:30:55 +000087void print_vendor_chips(const char *vendor,
88 const struct superio_registers reg_table[]);
Uwe Hermann0120e1a2007-09-16 18:11:03 +000089
Uwe Hermann945045b2007-09-28 15:39:10 +000090/* ali.c */
91void probe_idregs_ali(uint16_t port);
Robinson P. Tryon552cfb72008-01-15 22:30:55 +000092void print_ali_chips(void);
Uwe Hermann945045b2007-09-28 15:39:10 +000093
Uwe Hermann0120e1a2007-09-16 18:11:03 +000094/* fintek.c */
Uwe Hermannde24a0e2007-09-19 00:03:14 +000095void probe_idregs_fintek(uint16_t port);
Robinson P. Tryon552cfb72008-01-15 22:30:55 +000096void print_fintek_chips(void);
Uwe Hermann0120e1a2007-09-16 18:11:03 +000097
98/* ite.c */
Uwe Hermannde24a0e2007-09-19 00:03:14 +000099void probe_idregs_ite(uint16_t port);
Robinson P. Tryon552cfb72008-01-15 22:30:55 +0000100void print_ite_chips(void);
Uwe Hermann0120e1a2007-09-16 18:11:03 +0000101
102/* nsc.c */
Uwe Hermann8b8d0392007-10-04 15:23:38 +0000103void probe_idregs_nsc(uint16_t port);
Robinson P. Tryon552cfb72008-01-15 22:30:55 +0000104void print_nsc_chips(void);
Uwe Hermann0120e1a2007-09-16 18:11:03 +0000105
Uwe Hermann6ff6af72007-09-18 22:24:34 +0000106/* smsc.c */
Uwe Hermannde24a0e2007-09-19 00:03:14 +0000107void probe_idregs_smsc(uint16_t port);
Robinson P. Tryon552cfb72008-01-15 22:30:55 +0000108void print_smsc_chips(void);
Uwe Hermannd754d2c2007-09-18 23:30:24 +0000109
Uwe Hermann7e7e9ac2007-09-19 15:52:23 +0000110/* winbond.c */
111void probe_idregs_winbond(uint16_t port);
Robinson P. Tryon552cfb72008-01-15 22:30:55 +0000112void print_winbond_chips(void);
Uwe Hermann7e7e9ac2007-09-19 15:52:23 +0000113
Uwe Hermannc3da3662007-09-26 16:14:16 +0000114/** Table of which config ports to probe for each Super I/O family. */
Uwe Hermann246be7d2007-10-31 22:22:11 +0000115static const struct {
Uwe Hermannde24a0e2007-09-19 00:03:14 +0000116 void (*probe_idregs) (uint16_t port);
117 int ports[MAXNUMPORTS]; /* Signed, as we need EOT. */
Uwe Hermannd754d2c2007-09-18 23:30:24 +0000118} superio_ports_table[] = {
Uwe Hermann945045b2007-09-28 15:39:10 +0000119 {probe_idregs_ali, {0x3f0, 0x370, EOT}},
Uwe Hermann0f867322007-09-24 01:40:09 +0000120 {probe_idregs_fintek, {0x2e, 0x4e, EOT}},
121 {probe_idregs_ite, {0x2e, 0x4e, EOT}},
Uwe Hermann14f304a2007-10-08 01:11:11 +0000122 {probe_idregs_nsc, {0x2e, 0x4e, EOT}},
123 {probe_idregs_smsc, {0x2e, 0x4e, 0x162e, 0x164e, 0x3f0, 0x370, EOT}},
Uwe Hermannc3da3662007-09-26 16:14:16 +0000124 {probe_idregs_winbond, {0x2e, 0x4e, 0x3f0, 0x370, 0x250, EOT}},
Uwe Hermannd754d2c2007-09-18 23:30:24 +0000125};
Uwe Hermann6ff6af72007-09-18 22:24:34 +0000126
Robinson P. Tryon552cfb72008-01-15 22:30:55 +0000127/** 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