blob: e7c4e2363be92303af4f4d55f177be602c9bda4c [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>
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>
Uwe Hermann6ff6af72007-09-18 22:24:34 +000027#include <stdint.h>
Uwe Hermann7e7e9ac2007-09-19 15:52:23 +000028#include <string.h>
Uwe Hermann3acf31e2007-09-19 01:55:35 +000029#include <getopt.h>
Uwe Hermann0120e1a2007-09-16 18:11:03 +000030#include <sys/io.h>
31
Uwe Hermann7dabe5e2007-10-17 23:43:59 +000032#define USAGE "Usage: superiotool [-d] [-V] [-v] [-h]\n\n\
Uwe Hermann74b29b92007-11-17 17:13:52 +000033 -d | --dump Dump Super I/O register contents\n\
Uwe Hermanneddc4732007-09-20 23:57:44 +000034 -V | --verbose Verbose mode\n\
35 -v | --version Show the superiotool version\n\
36 -h | --help Show a short help text\n\n\
Uwe Hermanne4749562007-09-19 16:26:18 +000037Per default (no options) superiotool will just probe for a Super I/O\n\
Uwe Hermannafe83092007-09-28 15:45:43 +000038and print its vendor, name, ID, revision, and config port.\n"
Uwe Hermanne4749562007-09-19 16:26:18 +000039
Uwe Hermann8b8d0392007-10-04 15:23:38 +000040#define NOTFOUND " Failed. Returned data: "
41
Uwe Hermannd754d2c2007-09-18 23:30:24 +000042#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
43
Uwe Hermann4cb7e712007-09-16 18:17:44 +000044#define EOT -1 /* End Of Table */
45#define NOLDN -2 /* NO LDN needed */
46#define NANA -3 /* Not Available */
Uwe Hermann6ff6af72007-09-18 22:24:34 +000047#define RSVD -4 /* Reserved */
Uwe Hermann7e7e9ac2007-09-19 15:52:23 +000048#define MISC -5 /* Needs special comment in output */
Uwe Hermannc3da3662007-09-26 16:14:16 +000049#define MAXNAMELEN 30 /* Maximum Name Length */
Ulf Jordan48c70322007-12-13 23:41:45 +000050#define MAXLDN 0x10 /* Biggest LDN */
Uwe Hermann4cb7e712007-09-16 18:17:44 +000051#define LDNSIZE (MAXLDN + 3) /* Biggest LDN + 0 + NOLDN + EOT */
52#define MAXNUMIDX 70 /* Maximum number of indexes */
53#define IDXSIZE (MAXNUMIDX + 1)
Uwe Hermann14f304a2007-10-08 01:11:11 +000054#define MAXNUMPORTS (6 + 1) /* Maximum number of Super I/O ports */
Uwe Hermann4cb7e712007-09-16 18:17:44 +000055
Uwe Hermann3acf31e2007-09-19 01:55:35 +000056/* Command line parameters. */
Uwe Hermann7dabe5e2007-10-17 23:43:59 +000057extern int dump, verbose;
Uwe Hermann3acf31e2007-09-19 01:55:35 +000058
Uwe Hermanne9d46162007-10-07 20:01:23 +000059extern int chip_found;
60
Uwe Hermann4cb7e712007-09-16 18:17:44 +000061struct superio_registers {
Uwe Hermanneddc4732007-09-20 23:57:44 +000062 int32_t superio_id; /* Signed, as we need EOT. */
63 const char name[MAXNAMELEN]; /* Super I/O name */
Uwe Hermann6ff6af72007-09-18 22:24:34 +000064 struct {
Uwe Hermannde24a0e2007-09-19 00:03:14 +000065 int ldn;
Uwe Hermanneddc4732007-09-20 23:57:44 +000066 const char *name; /* LDN name */
Uwe Hermannde24a0e2007-09-19 00:03:14 +000067 int idx[IDXSIZE];
68 int def[IDXSIZE];
Uwe Hermann4cb7e712007-09-16 18:17:44 +000069 } ldn[LDNSIZE];
70};
71
72/* superiotool.c */
Uwe Hermannde24a0e2007-09-19 00:03:14 +000073uint8_t regval(uint16_t port, uint8_t reg);
74void regwrite(uint16_t port, uint8_t reg, uint8_t val);
Uwe Hermannb4db2202007-09-20 23:37:56 +000075void enter_conf_mode_winbond_fintek_ite_8787(uint16_t port);
76void exit_conf_mode_winbond_fintek_ite_8787(uint16_t port);
Uwe Hermann7e7e9ac2007-09-19 15:52:23 +000077int superio_unknown(const struct superio_registers reg_table[], uint16_t id);
Uwe Hermann3acf31e2007-09-19 01:55:35 +000078const char *get_superio_name(const struct superio_registers reg_table[],
79 uint16_t id);
Uwe Hermann519419b2007-09-16 20:59:01 +000080void dump_superio(const char *name, const struct superio_registers reg_table[],
Uwe Hermann25a6c0f2007-09-19 00:48:42 +000081 uint16_t port, uint16_t id);
Uwe Hermann8b8d0392007-10-04 15:23:38 +000082void probing_for(const char *vendor, const char *info, uint16_t port);
Uwe Hermann0120e1a2007-09-16 18:11:03 +000083
Uwe Hermann945045b2007-09-28 15:39:10 +000084/* ali.c */
85void probe_idregs_ali(uint16_t port);
86
Uwe Hermann0120e1a2007-09-16 18:11:03 +000087/* fintek.c */
Uwe Hermannde24a0e2007-09-19 00:03:14 +000088void probe_idregs_fintek(uint16_t port);
Uwe Hermann0120e1a2007-09-16 18:11:03 +000089
90/* ite.c */
Uwe Hermannde24a0e2007-09-19 00:03:14 +000091void probe_idregs_ite(uint16_t port);
Uwe Hermann0120e1a2007-09-16 18:11:03 +000092
93/* nsc.c */
Uwe Hermann8b8d0392007-10-04 15:23:38 +000094void probe_idregs_nsc(uint16_t port);
Uwe Hermann0120e1a2007-09-16 18:11:03 +000095
Uwe Hermann6ff6af72007-09-18 22:24:34 +000096/* smsc.c */
Uwe Hermannde24a0e2007-09-19 00:03:14 +000097void probe_idregs_smsc(uint16_t port);
Uwe Hermannd754d2c2007-09-18 23:30:24 +000098
Uwe Hermann7e7e9ac2007-09-19 15:52:23 +000099/* winbond.c */
100void probe_idregs_winbond(uint16_t port);
101
Uwe Hermannc3da3662007-09-26 16:14:16 +0000102/** Table of which config ports to probe for each Super I/O family. */
Uwe Hermann246be7d2007-10-31 22:22:11 +0000103static const struct {
Uwe Hermannde24a0e2007-09-19 00:03:14 +0000104 void (*probe_idregs) (uint16_t port);
105 int ports[MAXNUMPORTS]; /* Signed, as we need EOT. */
Uwe Hermannd754d2c2007-09-18 23:30:24 +0000106} superio_ports_table[] = {
Uwe Hermann945045b2007-09-28 15:39:10 +0000107 {probe_idregs_ali, {0x3f0, 0x370, EOT}},
Uwe Hermann0f867322007-09-24 01:40:09 +0000108 {probe_idregs_fintek, {0x2e, 0x4e, EOT}},
109 {probe_idregs_ite, {0x2e, 0x4e, EOT}},
Uwe Hermann14f304a2007-10-08 01:11:11 +0000110 {probe_idregs_nsc, {0x2e, 0x4e, EOT}},
111 {probe_idregs_smsc, {0x2e, 0x4e, 0x162e, 0x164e, 0x3f0, 0x370, EOT}},
Uwe Hermannc3da3662007-09-26 16:14:16 +0000112 {probe_idregs_winbond, {0x2e, 0x4e, 0x3f0, 0x370, 0x250, EOT}},
Uwe Hermannd754d2c2007-09-18 23:30:24 +0000113};
Uwe Hermann6ff6af72007-09-18 22:24:34 +0000114
Uwe Hermann0120e1a2007-09-16 18:11:03 +0000115#endif