summaryrefslogtreecommitdiff
path: root/util/superiotool
diff options
context:
space:
mode:
authorUwe Hermann <uwe@hermann-uwe.de>2007-09-19 00:48:42 +0000
committerUwe Hermann <uwe@hermann-uwe.de>2007-09-19 00:48:42 +0000
commit25a6c0f18ce8f2db4483fa8e65a5f5aa5042d958 (patch)
tree8ada258f72d569774a4acbe18fd55857e6c63002 /util/superiotool
parentc73ea4d4fc86a0e3a3c42bec45942e0354dae171 (diff)
Split out enter_conf_mode_*()/exit_conf_mode_() functions, we'll soon need
them. Reduce code duplication a bit by improved 'no dump available' handling. 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@2785 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'util/superiotool')
-rw-r--r--util/superiotool/fintek.c20
-rw-r--r--util/superiotool/ite.c34
-rw-r--r--util/superiotool/smsc.c23
-rw-r--r--util/superiotool/superiotool.c14
-rw-r--r--util/superiotool/superiotool.h8
5 files changed, 60 insertions, 39 deletions
diff --git a/util/superiotool/fintek.c b/util/superiotool/fintek.c
index c12954c7f9..3e7bf9fd36 100644
--- a/util/superiotool/fintek.c
+++ b/util/superiotool/fintek.c
@@ -89,15 +89,26 @@ void dump_fintek(uint16_t port, uint16_t did)
regval(port, 0xf6), regval(port, 0xf7), regval(port, 0xf8));
}
-void probe_idregs_fintek(uint16_t port)
+void enter_conf_mode_fintek(uint16_t port)
{
- uint16_t vid, did, success = 0;
-
/* Enable configuration sequence (Fintek uses this for example)
* Older ITE chips have the same enable sequence.
*/
outb(0x87, port);
outb(0x87, port);
+}
+
+void exit_conf_mode_fintek(uint16_t port)
+{
+ /* Exit MB PnP mode (for Fintek, doesn't hurt ITE). */
+ outb(0xaa, port);
+}
+
+void probe_idregs_fintek(uint16_t port)
+{
+ uint16_t vid, did, success = 0;
+
+ enter_conf_mode_fintek(port);
outb(0x20, port);
if (inb(port) != 0x20) {
@@ -143,7 +154,6 @@ void probe_idregs_fintek(uint16_t port)
if (!success)
printf("No dump for vid 0x%04x, did 0x%04x\n", vid, did);
- /* Exit MB PnP mode (for Fintek, doesn't hurt ITE). */
- outb(0xaa, port);
+ exit_conf_mode_fintek(port);
}
diff --git a/util/superiotool/ite.c b/util/superiotool/ite.c
index 938613efd4..8b0fc53b4b 100644
--- a/util/superiotool/ite.c
+++ b/util/superiotool/ite.c
@@ -211,10 +211,8 @@ void dump_ite(uint16_t port, uint16_t id)
}
}
-void probe_idregs_ite(uint16_t port)
+void enter_conf_mode_ite(uint16_t port)
{
- uint16_t id, chipver;
-
/* Enable configuration sequence (ITE uses this for newer IT87[012]x)
* IT871[01] uses 0x87, 0x87 -> fintek detection should handle it
* IT8708 uses 0x87, 0x87 -> fintek detection should handle it
@@ -230,6 +228,18 @@ void probe_idregs_ite(uint16_t port)
outb(0x55, port);
else
outb(0xAA, port);
+}
+
+void exit_conf_mode_ite(uint16_t port)
+{
+ regwrite(port, 0x02, 0x02);
+}
+
+void probe_idregs_ite(uint16_t port)
+{
+ uint16_t id, chipver;
+
+ enter_conf_mode_ite(port);
/* Read Chip ID Byte 1. */
id = regval(port, 0x20);
@@ -252,20 +262,8 @@ void probe_idregs_ite(uint16_t port)
printf("Super I/O found at 0x%02x: id=0x%04x, chipver=0x%01x\n",
port, id, chipver);
- switch (id) {
- case 0x8702:
- case 0x8705:
- case 0x8708:
- case 0x8712:
- case 0x8716:
- case 0x8718:
- case 0x8726:
- dump_ite(port, id);
- break;
- default:
- printf("No dump for ID 0x%04x\n", id);
- break;
- }
- regwrite(port, 0x02, 0x02); /* Exit MB PnP mode. */
+ dump_ite(port, id);
+
+ exit_conf_mode_ite(port);
}
diff --git a/util/superiotool/smsc.c b/util/superiotool/smsc.c
index 7636001bc1..e583471bac 100644
--- a/util/superiotool/smsc.c
+++ b/util/superiotool/smsc.c
@@ -40,6 +40,16 @@ const static struct superio_registers reg_table[] = {
{EOT}
};
+void enter_conf_mode_smsc(uint16_t port)
+{
+ outb(0x55, port);
+}
+
+void exit_conf_mode_smsc(uint16_t port)
+{
+ outb(0xaa, port);
+}
+
/* Note: The actual SMSC ID is 16 bits, but we must pass 32 bits here. */
void dump_smsc(uint16_t port, uint16_t id)
{
@@ -57,7 +67,7 @@ void probe_idregs_smsc(uint16_t port)
{
uint16_t id, rev;
- outb(0x55, port); /* Enter configuration mode. */
+ enter_conf_mode_smsc(port);
/* Read device ID. */
id = regval(port, DEVICE_ID_REG);
@@ -75,15 +85,8 @@ void probe_idregs_smsc(uint16_t port)
printf("Super I/O found at 0x%04x: id=0x%02x, rev=0x%02x\n",
port, id, rev);
- switch (id) {
- case 0x28:
- dump_smsc(port, id);
- break;
- default:
- printf("No dump for ID 0x%04x\n", id);
- break;
- }
+ dump_smsc(port, id );
- outb(0xaa, port); /* Exit configuration mode. */
+ exit_conf_mode_smsc(port);
}
diff --git a/util/superiotool/superiotool.c b/util/superiotool/superiotool.c
index e95f1baac6..fd49c309ee 100644
--- a/util/superiotool/superiotool.c
+++ b/util/superiotool/superiotool.c
@@ -34,14 +34,12 @@ void regwrite(uint16_t port, uint8_t reg, uint8_t val)
outb(val, port + 1);
}
-void dump_superio(const char *name, const struct superio_registers reg_table[],
+void dump_superio(const char *vendor, const struct superio_registers reg_table[],
uint16_t port, uint16_t id)
{
- int i, j, k;
+ int i, j, k, nodump;
int *idx;
- printf("%s ", name);
-
for (i = 0; /* Nothing */; i++) {
if (reg_table[i].superio_id == EOT)
break;
@@ -49,12 +47,15 @@ void dump_superio(const char *name, const struct superio_registers reg_table[],
if ((uint16_t)reg_table[i].superio_id != id)
continue;
- printf("%s\n", reg_table[i].name);
+ nodump = 1;
for (j = 0; /* Nothing */; j++) {
if (reg_table[i].ldn[j].ldn == EOT)
break;
+ printf("%s %s\n", vendor, reg_table[i].name);
+ nodump = 0;
+
if (reg_table[i].ldn[j].ldn != NOLDN) {
printf("Switching to LDN 0x%02x\n",
reg_table[i].ldn[j].ldn);
@@ -91,6 +92,9 @@ void dump_superio(const char *name, const struct superio_registers reg_table[],
}
printf("\n");
}
+
+ if (nodump)
+ printf("No dump for %s %s\n", vendor, reg_table[i].name);
}
}
diff --git a/util/superiotool/superiotool.h b/util/superiotool/superiotool.h
index f4b2a85935..0dcc2fa261 100644
--- a/util/superiotool/superiotool.h
+++ b/util/superiotool/superiotool.h
@@ -54,14 +54,18 @@ struct superio_registers {
uint8_t regval(uint16_t port, uint8_t reg);
void regwrite(uint16_t port, uint8_t reg, uint8_t val);
void dump_superio(const char *name, const struct superio_registers reg_table[],
- uint16_t port, uint16_t id);
+ uint16_t port, uint16_t id);
void probe_superio(uint16_t port);
/* fintek.c */
+void enter_conf_mode_fintek(uint16_t port);
+void exit_conf_mode_fintek(uint16_t port);
void dump_fintek(uint16_t port, uint16_t did);
void probe_idregs_fintek(uint16_t port);
/* ite.c */
+void enter_conf_mode_ite(uint16_t port);
+void exit_conf_mode_ite(uint16_t port);
void dump_ite(uint16_t port, uint16_t id);
void probe_idregs_ite(uint16_t port);
@@ -70,6 +74,8 @@ void dump_ns8374(uint16_t port);
void probe_idregs_simple(uint16_t port);
/* smsc.c */
+void enter_conf_mode_smsc(uint16_t port);
+void exit_conf_mode_smsc(uint16_t port);
void dump_smsc(uint16_t port, uint16_t id);
void probe_idregs_smsc(uint16_t port);