coreboot-kgpe-d16/util/superiotool/nsc.c
Uwe Hermann 3acf31e4ea Further code simplifications and improvements.
Add command line option handling code. The following options
are defined at the moment:

-d|--dump      Dump Super I/O registers.
-V|--verbose   Verbose mode.
-v|--version   Show the superiotool version.
-h|--help      Show a short help text.

Per default (no options) we just probe for a Super I/O
and print its vendor, name, ID, version, and config port.

Example:

$ ./superiotool
Found SMSC FDC37N769 Super I/O (id=0x28, rev=0x01) at port=0x03f0

$ ./superiotool -d
Found SMSC FDC37N769 Super I/O (id=0x28, rev=0x01) at port=0x03f0
idx 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f
val 20 90 80 f4 00 00 ff 00 00 00 40 00 0e 28 01 00 00 00 00 00 02 00 01 03 00 00 00 00 00 00 80 00 00 00 00 00 00 ba 00 00 03 00 00 23 03 03 00 00
def 28 9c 88 70 00 00 ff 00 00 00 00 00 02 28 NA 00 00 80 RR RR NA NA NA 03 RR RR RR RR RR RR 80 00 3c RR RR 00 00 00 00 00 00 00 RR 00 00 03 00 00

$ ./superiotool -s
./superiotool: invalid option -- s

$ ./superiotool -h
Usage: superiotool [-d] [-V] [-v] [-h]

$ ./superiotool -v
superiotool 0.1


Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>



git-svn-id: svn://svn.coreboot.org/coreboot/trunk@2788 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
2007-09-19 01:55:35 +00:00

88 lines
2.6 KiB
C

/*
* This file is part of the LinuxBIOS project.
*
* Copyright (C) 2006 Ronald Minnich <rminnich@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "superiotool.h"
/* Well, they really thought this through, eh? Family is 8 bits! */
static const char *familyid[] = {
[0xf1] = "PC8374 (Winbond/NatSemi)"
};
void dump_ns8374(uint16_t port)
{
printf("Enables: 21=%02x, 22=%02x, 23=%02x, 24=%02x, 26=%02x\n",
regval(port, 0x21), regval(port, 0x22), regval(port, 0x23),
regval(port, 0x24), regval(port, 0x26));
printf("SMBUS at %02x\n", regval(port, 0x2a));
/* Check COM1. This is all we care about at present. */
printf("COM 1 is globally %s\n",
regval(port, 0x26) & 8 ? "disabled" : "enabled");
/* Select COM1. */
regwrite(port, 0x07, 0x03);
printf("COM 1 is locally %s\n",
regval(port, 0x30) & 1 ? "enabled" : "disabled");
printf
("COM1 60=%02x, 61=%02x, 70=%02x, 71=%02x, 74=%02x, 75=%02x, f0=%02x\n",
regval(port, 0x60), regval(port, 0x61), regval(port, 0x70),
regval(port, 0x71), regval(port, 0x74), regval(port, 0x75),
regval(port, 0xf0));
/* Select GPIO. */
regwrite(port, 0x07, 0x07);
printf("GPIO is %s\n", regval(port, 0x30) & 1 ? "enabled" : "disabled");
printf
("GPIO 60=%02x, 61=%02x, 70=%02x, 71=%02x, 74=%02x, 75=%02x, f0=%02x\n",
regval(port, 0x60), regval(port, 0x61), regval(port, 0x70),
regval(port, 0x71), regval(port, 0x74), regval(port, 0x75),
regval(port, 0xf0));
}
void probe_idregs_simple(uint16_t port)
{
uint16_t id;
outb(0x20, port);
if (inb(port) != 0x20) {
no_superio_found(port);
return;
}
id = inb(port + 1);
printf("Super I/O found at 0x%02x: id = 0x%02x\n", port, id);
if (id == 0xff)
return;
if (familyid[id])
printf("%s\n", familyid[id]);
else
printf("<unknown>\n");
switch (id) {
case 0xf1:
dump_ns8374(port);
break;
default:
printf("No dump for 0x%02x\n", id);
break;
}
}