Fix up and generalize the ITE IT8708F code. It was only working out of
pure luck (and broken code elsewhere). Needs some more fixing.

Add more LDN descriptions to various Super I/Os.

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@2793 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
diff --git a/util/superiotool/fintek.c b/util/superiotool/fintek.c
index 8b5fa5b..e2f9c27 100644
--- a/util/superiotool/fintek.c
+++ b/util/superiotool/fintek.c
@@ -20,6 +20,19 @@
 
 #include "superiotool.h"
 
+#define DEVICE_ID_BYTE1_REG	0x20
+#define DEVICE_ID_BYTE2_REG	0x21
+#define VENDOR_ID_BYTE1_REG	0x23
+#define VENDOR_ID_BYTE2_REG	0x24
+
+const static struct superio_registers reg_table[] = {
+	{0x0604, "F71805", {
+		{EOT}}},
+	{0x4103, "F71872", {
+		{EOT}}},
+	{EOT}
+};
+
 void dump_fintek(uint16_t port, uint16_t did)
 {
 	switch (did) {
@@ -106,38 +119,38 @@
 
 void probe_idregs_fintek(uint16_t port)
 {
-	uint16_t vid, did, success = 0;
+	uint16_t vid, did, did_ite, success = 0;
 
 	enter_conf_mode_fintek(port);
 
-	outb(0x20, port);
-	if (inb(port) != 0x20) {
+	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) {
 		no_superio_found(port);
+		exit_conf_mode_fintek(port);
 		return;
 	}
-	did = inb(port + 1);
-	did |= (regval(port, 0x21) << 8);
 
-	vid = regval(port, 0x23);
-	vid |= (regval(port, 0x24) << 8);
-
-	printf("Super I/O found at 0x%02x: vid=0x%04x/did=0x%04x\n",
-	       port, vid, did);
-
-	if (vid == 0xff || vid == 0xffff)
+	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;
-
-	/* printf("%s\n", familyid[id]); */
-	switch (did) {
-	case 0x0887:		/* Pseudoreversed for ITE8708 */
-	case 0x1087:		/* Pseudoreversed for ITE8710 */
-		success = 1;
-		dump_ite(port, ((did & 0xff) << 8) | ((did & 0xff00) >> 8));
-		regwrite(port, 0x02, 0x02);	/* Exit MB PnP mode. */
-		break;
-	default:
-		break;
 	}
+		
+	if (vid == 0xff || vid == 0xffff) {
+		exit_conf_mode_fintek(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: