summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUwe Hermann <uwe@hermann-uwe.de>2007-09-18 23:30:24 +0000
committerUwe Hermann <uwe@hermann-uwe.de>2007-09-18 23:30:24 +0000
commitd754d2c6c4970e686d004ea4d39c5e6599abf46f (patch)
treebcc0de9ddd23ce1f2417b677ee33e007229bfce8
parent6ff6af762158147b3c47bd1701a389622bd043a5 (diff)
downloadcoreboot-d754d2c6c4970e686d004ea4d39c5e6599abf46f.tar.xz
Make the code a bit more generic (trivial). Different Super I/Os
use different config ports. 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@2782 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
-rw-r--r--util/superiotool/Makefile2
-rw-r--r--util/superiotool/smsc.c2
-rw-r--r--util/superiotool/superiotool.c18
-rw-r--r--util/superiotool/superiotool.h16
4 files changed, 24 insertions, 14 deletions
diff --git a/util/superiotool/Makefile b/util/superiotool/Makefile
index c416f93a7e..6e86d01352 100644
--- a/util/superiotool/Makefile
+++ b/util/superiotool/Makefile
@@ -32,7 +32,7 @@ OBJS = superiotool.o fintek.o ite.o nsc.o smsc.o
all: $(PROGRAM)
-$(PROGRAM): $(OBJS)
+$(PROGRAM): $(OBJS) superiotool.h
$(CC) $(CFLAGS) -o $(PROGRAM) $(OBJS)
install: $(PROGRAM)
diff --git a/util/superiotool/smsc.c b/util/superiotool/smsc.c
index 805756f7cd..f836b94a99 100644
--- a/util/superiotool/smsc.c
+++ b/util/superiotool/smsc.c
@@ -53,7 +53,7 @@ void dump_smsc(uint32_t port, uint32_t id)
}
}
-void probe_idregs_smsc(uint32_t port)
+void probe_idregs_smsc(unsigned short port)
{
uint16_t id, rev;
diff --git a/util/superiotool/superiotool.c b/util/superiotool/superiotool.c
index a5dcb2e753..3514b24415 100644
--- a/util/superiotool/superiotool.c
+++ b/util/superiotool/superiotool.c
@@ -97,22 +97,18 @@ void dump_superio(const char *name, const struct superio_registers reg_table[],
int main(int argc, char *argv[])
{
+ int i, j;
+
if (iopl(3) < 0) {
perror("iopl");
exit(1);
}
- probe_idregs_simple(0x2e);
- probe_idregs_simple(0x4e);
-
- probe_idregs_fintek(0x2e);
- probe_idregs_fintek(0x4e);
-
- probe_idregs_ite(0x2e);
- probe_idregs_ite(0x4e);
-
- probe_idregs_smsc(0x3f0);
- probe_idregs_smsc(0x370);
+ for (i = 0; i < ARRAY_SIZE(superio_ports_table); i++) {
+ for (j = 0; superio_ports_table[i].ports[j] != EOT; j++)
+ superio_ports_table[i].probe_idregs(
+ superio_ports_table[i].ports[j]);
+ }
return 0;
}
diff --git a/util/superiotool/superiotool.h b/util/superiotool/superiotool.h
index 229c0d5982..4986ff167c 100644
--- a/util/superiotool/superiotool.h
+++ b/util/superiotool/superiotool.h
@@ -27,6 +27,8 @@
#include <stdint.h>
#include <sys/io.h>
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
+
#define EOT -1 /* End Of Table */
#define NOLDN -2 /* NO LDN needed */
#define NANA -3 /* Not Available */
@@ -36,6 +38,7 @@
#define LDNSIZE (MAXLDN + 3) /* Biggest LDN + 0 + NOLDN + EOT */
#define MAXNUMIDX 70 /* Maximum number of indexes */
#define IDXSIZE (MAXNUMIDX + 1)
+#define MAXNUMPORTS (2 + 1) /* Maximum number of Super I/O ports */
struct superio_registers {
/* Yes, superio_id should be unsigned, but EOT has to be negative. */
@@ -69,6 +72,17 @@ void probe_idregs_simple(unsigned short port);
/* smsc.c */
void dump_smsc(uint32_t port, uint32_t id);
-void probe_idregs_smsc(uint32_t port);
+void probe_idregs_smsc(unsigned short port);
+
+/** Table of which config ports to probe on each Super I/O. */
+const static struct {
+ void (*probe_idregs) (unsigned short port);
+ signed short ports[MAXNUMPORTS]; /* Signed, as we need EOT. */
+} superio_ports_table[] = {
+ {probe_idregs_simple, {0x2e, 0x4e, EOT}},
+ {probe_idregs_fintek, {0x2e, 0x4e, EOT}},
+ {probe_idregs_ite, {0x2e, 0x4e, EOT}},
+ {probe_idregs_smsc, {0x3f0, 0x370, EOT}},
+};
#endif