Decouple the ITE code from fintek.c, it doesn't belong there.
Add common 'enter configuration mode' function for most Winbond/Fintek/ITE
chips which use the 0x87 0x87 sequence for that reason.
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@2794 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
diff --git a/util/superiotool/fintek.c b/util/superiotool/fintek.c
index e2f9c27..a95a383 100644
--- a/util/superiotool/fintek.c
+++ b/util/superiotool/fintek.c
@@ -102,68 +102,32 @@
regval(port, 0xf6), regval(port, 0xf7), regval(port, 0xf8));
}
-static void enter_conf_mode_fintek(uint16_t port)
-{
- /* Enable configuration sequence (Fintek uses this for example)
- * Older ITE chips have the same enable sequence.
- */
- outb(0x87, port);
- outb(0x87, port);
-}
-
-static 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, did_ite, success = 0;
+ uint16_t vid, did;
- enter_conf_mode_fintek(port);
+ enter_conf_mode_winbond_fintek_ite_8787(port);
did = regval(port, DEVICE_ID_BYTE1_REG);
did |= (regval(port, DEVICE_ID_BYTE2_REG) << 8);
- did_ite = ((did & 0xff) << 8) | ((did & 0xff00) >> 8);
vid = regval(port, VENDOR_ID_BYTE1_REG);
vid |= (regval(port, VENDOR_ID_BYTE2_REG) << 8);
- /* FIXME */
- if (vid != 0x3419 && did_ite != 0x8708 && did_ite != 0x8710) {
+ if (vid != 0x3419) {
no_superio_found(port);
- exit_conf_mode_fintek(port);
- return;
- }
-
- if (did_ite == 0x8708 || did_ite == 0x8701) {
- printf("Found ITE IT%04xF (id=0x%04x, rev=0x%01x) at port=0x%x\n", did_ite, did_ite, 0, port); /* FIXME */
- dump_ite(port, did_ite);
- regwrite(port, 0x02, 0x02); /* FIXME */
- return;
- }
-
- if (vid == 0xff || vid == 0xffff) {
- exit_conf_mode_fintek(port);
+ exit_conf_mode_winbond_fintek_ite_8787(port);
return;
}
printf("Found Fintek %s (vid=0x%04x, id=0x%04x) at port=0x%x\n",
get_superio_name(reg_table, did), vid, did, port);
- switch (vid) {
- case 0x3419:
- success = 1;
- dump_fintek(port, did);
- break;
- default:
- break;
- }
+ dump_superio("Fintek", reg_table, port, did);
- if (!success)
- printf("No dump for vid 0x%04x, did 0x%04x\n", vid, did);
+ /* TODO: Revive this as --dump-human-readable output. */
+ /* dump_fintek(port, did); */
- exit_conf_mode_fintek(port);
+ exit_conf_mode_winbond_fintek_ite_8787(port);
}
diff --git a/util/superiotool/ite.c b/util/superiotool/ite.c
index 610516a..1a65e2c 100644
--- a/util/superiotool/ite.c
+++ b/util/superiotool/ite.c
@@ -226,12 +226,10 @@
regwrite(port, 0x02, 0x02);
}
-void probe_idregs_ite(uint16_t port)
+static void probe_idregs_ite_helper(uint16_t port)
{
uint16_t id, chipver;
- enter_conf_mode_ite(port);
-
id = regval(port, CHIP_ID_BYTE1_REG) << 8;
id |= regval(port, CHIP_ID_BYTE2_REG);
chipver = regval(port, CHIP_VERSION_REG) & 0x0f; /* Only bits 3..0 */
@@ -246,7 +244,16 @@
get_superio_name(reg_table, id), id, chipver, port);
dump_superio("ITE", reg_table, port, id);
+}
+void probe_idregs_ite(uint16_t port)
+{
+ enter_conf_mode_ite(port);
+ probe_idregs_ite_helper(port);
exit_conf_mode_ite(port);
+
+ enter_conf_mode_winbond_fintek_ite_8787(port);
+ probe_idregs_ite_helper(port);
+ exit_conf_mode_winbond_fintek_ite_8787(port);
}
diff --git a/util/superiotool/superiotool.c b/util/superiotool/superiotool.c
index 8aea0a0..0a253ad 100644
--- a/util/superiotool/superiotool.c
+++ b/util/superiotool/superiotool.c
@@ -37,6 +37,18 @@
outb(val, port + 1);
}
+void enter_conf_mode_winbond_fintek_ite_8787(uint16_t port)
+{
+ outb(0x87, port);
+ outb(0x87, port);
+}
+
+void exit_conf_mode_winbond_fintek_ite_8787(uint16_t port)
+{
+ outb(0xaa, port); /* Fintek, Winbond */
+ regwrite(port, 0x02, 0x02); /* ITE */
+}
+
int superio_unknown(const struct superio_registers reg_table[], uint16_t id)
{
return !strncmp(get_superio_name(reg_table, id), "<unknown>", 9);
diff --git a/util/superiotool/superiotool.h b/util/superiotool/superiotool.h
index b0d12cd..9b82b4c 100644
--- a/util/superiotool/superiotool.h
+++ b/util/superiotool/superiotool.h
@@ -70,6 +70,8 @@
/* superiotool.c */
uint8_t regval(uint16_t port, uint8_t reg);
void regwrite(uint16_t port, uint8_t reg, uint8_t val);
+void enter_conf_mode_winbond_fintek_ite_8787(uint16_t port);
+void exit_conf_mode_winbond_fintek_ite_8787(uint16_t port);
int superio_unknown(const struct superio_registers reg_table[], uint16_t id);
const char *get_superio_name(const struct superio_registers reg_table[],
uint16_t id);
diff --git a/util/superiotool/winbond.c b/util/superiotool/winbond.c
index ca2d1db..0e8f2b8 100644
--- a/util/superiotool/winbond.c
+++ b/util/superiotool/winbond.c
@@ -126,23 +126,12 @@
{EOT}
};
-static void enter_conf_mode_winbond(uint16_t port)
-{
- outb(0x87, port);
- outb(0x87, port);
-}
-
-static void exit_conf_mode_winbond(uint16_t port)
-{
- outb(0xaa, port);
-}
-
void probe_idregs_winbond(uint16_t port)
{
uint16_t id;
uint8_t devid, rev;
- enter_conf_mode_winbond(port);
+ enter_conf_mode_winbond_fintek_ite_8787(port);
devid = regval(port, DEVICE_ID_REG);
rev = regval(port, DEVICE_REV_REG);
@@ -152,7 +141,7 @@
if (superio_unknown(reg_table, id)) {
no_superio_found(port);
- exit_conf_mode_winbond(port);
+ exit_conf_mode_winbond_fintek_ite_8787(port);
return;
}
@@ -162,6 +151,6 @@
/* TODO: Special notes in dump output for the MISC entries. */
dump_superio("Winbond", reg_table, port, id);
- exit_conf_mode_winbond(port);
+ exit_conf_mode_winbond_fintek_ite_8787(port);
}