Author: uwe
Date: 2007-10-04 17:23:38 +0200 (Thu, 04 Oct 2007)
New Revision: 2821

Modified:
   trunk/util/superiotool/ali.c
   trunk/util/superiotool/fintek.c
   trunk/util/superiotool/ite.c
   trunk/util/superiotool/nsc.c
   trunk/util/superiotool/smsc.c
   trunk/util/superiotool/superiotool.c
   trunk/util/superiotool/superiotool.h
   trunk/util/superiotool/winbond.c
Log:
 * Convert the NSC code to the common code structure all other Super I/Os use.

 * Improve the --verbose output a bit more. Print the "Probing..." text for
   all Super I/Os and if a Super I/O is not known, show the data we were
   able to read from the chip (what data this is is very vendor/chip specific).

 * Thus the common no_superio_found() is dropped, it's not useful.
   The "read from 0x20" part was wrong for all Super I/Os other than the
   NSC ones anyway.

 * Winbond: For the 'olddevid' only use bits 3..0, mask away the others.

 * SMSC: Print which ID registers we try to read (in --verbose mode).

 * Minor cosmetic fixes.
   * Rename PC8374 to PC8374L (as per datasheet).
   * Rename probe_idregs_simple() to probe_idregs_nsc().
   * Rename dump_readable_ns8374() to dump_readable_pc8374l().

Signed-off-by: Uwe Hermann <[EMAIL PROTECTED]>
Acked-by: Stefan Reinauer <[EMAIL PROTECTED]>



Modified: trunk/util/superiotool/ali.c
===================================================================
--- trunk/util/superiotool/ali.c        2007-10-04 06:26:41 UTC (rev 2820)
+++ trunk/util/superiotool/ali.c        2007-10-04 15:23:38 UTC (rev 2821)
@@ -72,6 +72,8 @@
        uint16_t id;
        uint8_t rev;
 
+       probing_for("ALi", "", port);
+
        enter_conf_mode_ali(port);
 
        id = regval(port, DEVICE_ID_BYTE1_REG) << 8;
@@ -79,7 +81,8 @@
        rev = regval(port, DEVICE_REV_REG);
 
        if (superio_unknown(reg_table, id)) {
-               no_superio_found("ALi", "", port);
+               if (verbose)
+                       printf(NOTFOUND "id=0x%04x, rev=0x%02x\n", id, rev);
                exit_conf_mode_ali(port);
                return;
        }

Modified: trunk/util/superiotool/fintek.c
===================================================================
--- trunk/util/superiotool/fintek.c     2007-10-04 06:26:41 UTC (rev 2820)
+++ trunk/util/superiotool/fintek.c     2007-10-04 15:23:38 UTC (rev 2821)
@@ -136,6 +136,8 @@
 {
        uint16_t vid, did;
 
+       probing_for("Fintek", "", port);
+
        enter_conf_mode_winbond_fintek_ite_8787(port);
 
        did = regval(port, DEVICE_ID_BYTE1_REG);
@@ -145,12 +147,13 @@
        vid |= (regval(port, VENDOR_ID_BYTE2_REG) << 8);
 
        if (vid != FINTEK_VENDOR_ID || superio_unknown(reg_table, did)) {
-               no_superio_found("Fintek", "", port);
+               if (verbose)
+                       printf(NOTFOUND "vid=0x%04x, id=0x%04x\n", vid, did);
                exit_conf_mode_winbond_fintek_ite_8787(port);
                return;
        }
 
-       printf("Found Fintek %s (vid=0x%04x, id=0x%04x) at port=0x%x\n",
+       printf("Found Fintek %s (vid=0x%04x, id=0x%04x) at 0x%x\n",
               get_superio_name(reg_table, did), vid, did, port);
 
        dump_superio("Fintek", reg_table, port, did);

Modified: trunk/util/superiotool/ite.c
===================================================================
--- trunk/util/superiotool/ite.c        2007-10-04 06:26:41 UTC (rev 2820)
+++ trunk/util/superiotool/ite.c        2007-10-04 15:23:38 UTC (rev 2821)
@@ -23,6 +23,7 @@
 
 #define CHIP_ID_BYTE1_REG      0x20
 #define CHIP_ID_BYTE2_REG      0x21
+
 #define CHIP_VERSION_REG       0x22
 
 /* Note: IT8726F has ID 0x8726 (datasheet wrongly says 0x8716). */
@@ -265,17 +266,20 @@
 {
        uint16_t id, chipver;
 
+       probing_for("ITE", init, 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 */
 
        if (superio_unknown(reg_table, id)) {
-               no_superio_found("ITE", init, port);
+               if (verbose)
+                       printf(NOTFOUND "id=0x%04x, rev=0x%01x\n", id, chipver);
                exit_conf_mode_ite(port);
                return;
        }
 
-       printf("Found ITE %s (id=0x%04x, rev=0x%01x) at port=0x%x\n",
+       printf("Found ITE %s (id=0x%04x, rev=0x%01x) at 0x%x\n",
               get_superio_name(reg_table, id), id, chipver, port);
 
        dump_superio("ITE", reg_table, port, id);

Modified: trunk/util/superiotool/nsc.c
===================================================================
--- trunk/util/superiotool/nsc.c        2007-10-04 06:26:41 UTC (rev 2820)
+++ trunk/util/superiotool/nsc.c        2007-10-04 15:23:38 UTC (rev 2821)
@@ -2,6 +2,7 @@
  * This file is part of the superiotool project.
  *
  * Copyright (C) 2006 Ronald Minnich <[EMAIL PROTECTED]>
+ * Copyright (C) 2007 Uwe Hermann <[EMAIL PROTECTED]>
  *
  * 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
@@ -20,16 +21,23 @@
 
 #include "superiotool.h"
 
-/* Well, they really thought this through, eh? Family is 8 bits! */
-static const char *familyid[] = {
-       [0xf1] = "PC8374 (Winbond/NatSemi)"
+#define CHIP_ID_REG    0x20    /* Super I/O ID (SID) / family */
+#define CHIP_REV_REG   0x27    /* Super I/O revision ID (SRID) */
+
+/* SID[7..0]: chip family. SRID[7..5]: chip ID, SRID[4..0]: chip rev. */
+const static struct superio_registers reg_table[] = {
+       {0xf1, "PC8374L", {
+               {EOT}}},
+       {EOT}
 };
 
-static void dump_readable_ns8374(uint16_t port)
+static void dump_readable_pc8374l(uint16_t port)
 {
        if (!dump_readable)
                return;
 
+       printf("Human-readable register dump:\n");
+
        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));
@@ -59,34 +67,40 @@
             regval(port, 0xf0));
 }
 
-void probe_idregs_simple(uint16_t port)
+void probe_idregs_nsc(uint16_t port)
 {
-       uint16_t id;
+       uint8_t id, rev;
 
-       outb(0x20, port);
-       if (inb(port) != 0x20) {
-               no_superio_found("NSC", "", port);
-               /* TODO: Exit config mode? */
+       probing_for("NSC", "", port);
+
+       outb(CHIP_ID_REG, port);
+       if (inb(port) != CHIP_ID_REG) {
+               if (verbose)
+                       printf(NOTFOUND "port=0x%02x, port+1=0x%02x\n",
+                              inb(port), inb(port + 1));
                return;
        }
        id = inb(port + 1);
 
-       printf("Super I/O found at 0x%02x: id = 0x%02x\n", port, id);
-       if (id == 0xff)
+       outb(CHIP_REV_REG, port);
+       if (inb(port) != CHIP_REV_REG) {
+               printf("Warning: Can't get chip revision. Setting to 0xff.\n");
+               rev = 0xff;
+       } else {
+               rev = inb(port + 1);
+       }
+
+       if (superio_unknown(reg_table, id)) {
+               if (verbose)
+                       printf(NOTFOUND "sid=0x%02x, srid=0x%02x\n", id, rev);
                return;
+       }
 
-       if (familyid[id])
-               printf("%s\n", familyid[id]);
-       else
-               printf("<unknown>\n");
+       printf("Found NSC %s (sid=0x%02x, srid=0x%02x) at 0x%x\n",
+              get_superio_name(reg_table, id), id, rev, port);
 
-       switch (id) {
-       case 0xf1:
-               dump_readable_ns8374(port);
-               break;
-       default:
-               printf("No dump for 0x%02x\n", id);
-               break;
-       }
+       dump_superio("NSC", reg_table, port, id);
+       if (id == 0xf1)
+               dump_readable_pc8374l(port);
 }
 

Modified: trunk/util/superiotool/smsc.c
===================================================================
--- trunk/util/superiotool/smsc.c       2007-10-04 06:26:41 UTC (rev 2820)
+++ trunk/util/superiotool/smsc.c       2007-10-04 15:23:38 UTC (rev 2821)
@@ -133,19 +133,24 @@
                                     uint8_t revreg)
 {
        uint8_t id, rev;
+       const char *info = (idreg == 0x20) ? "(idregs=0x20/0x21) "
+                                          : "(idregs=0x0d/0x0e) ";
 
+       probing_for("SMSC", info, port);
+
        enter_conf_mode_smsc(port);
 
        id = regval(port, idreg);
        rev = regval(port, revreg);
 
        if (superio_unknown(reg_table, id)) {
-               no_superio_found("SMSC", "", port);
+               if (verbose)
+                       printf(NOTFOUND "id=0x%02x, rev=0x%02x\n", id, rev);
                exit_conf_mode_smsc(port);
                return;
        }
 
-       printf("Found %s %s (id=0x%02x, rev=0x%02x) at port=0x%x\n",
+       printf("Found %s %s (id=0x%02x, rev=0x%02x) at 0x%x\n",
               (id == 0x77 ? "ASUS" : "SMSC"), get_superio_name(reg_table, id),
               id, rev, port);
 

Modified: trunk/util/superiotool/superiotool.c
===================================================================
--- trunk/util/superiotool/superiotool.c        2007-10-04 06:26:41 UTC (rev 
2820)
+++ trunk/util/superiotool/superiotool.c        2007-10-04 15:23:38 UTC (rev 
2821)
@@ -155,18 +155,14 @@
                printf("No human-readable dump available for this Super I/O\n");
 }
 
-void no_superio_found(const char *vendor, const char *info, uint16_t port)
+void probing_for(const char *vendor, const char *info, uint16_t port)
 {
        if (!verbose)
                return;
 
-       if (inb(port) == 0xff)
-               /* Yes, there's no space between '%s' and 'at'! */
-               printf("Probing for %s Super I/O %sat 0x%x... failed\n",
-                      vendor, info, port);
-       else
-               printf("Probing 0x%x, failed (0x%02x), data returns 0x%02x\n",
-                      port, inb(port), inb(port + 1));
+       /* Yes, there's no space between '%s' and 'at'! */
+       printf("Probing for %s Super I/O %sat 0x%x...\n",
+              vendor, info, port);
 }
 
 static void print_version(void)

Modified: trunk/util/superiotool/superiotool.h
===================================================================
--- trunk/util/superiotool/superiotool.h        2007-10-04 06:26:41 UTC (rev 
2820)
+++ trunk/util/superiotool/superiotool.h        2007-10-04 15:23:38 UTC (rev 
2821)
@@ -40,6 +40,8 @@
 Per default (no options) superiotool will just probe for a Super I/O\n\
 and print its vendor, name, ID, revision, and config port.\n"
 
+#define NOTFOUND "  Failed. Returned data: "
+
 #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
 
 #define EOT            -1              /* End Of Table */
@@ -79,7 +81,7 @@
 void dump_superio(const char *name, const struct superio_registers reg_table[],
                  uint16_t port, uint16_t id);
 void dump_superio_readable(uint16_t port);
-void no_superio_found(const char *vendor, const char *info, uint16_t port);
+void probing_for(const char *vendor, const char *info, uint16_t port);
 
 /* ali.c */
 void probe_idregs_ali(uint16_t port);
@@ -91,7 +93,7 @@
 void probe_idregs_ite(uint16_t port);
 
 /* nsc.c */
-void probe_idregs_simple(uint16_t port);
+void probe_idregs_nsc(uint16_t port);
 
 /* smsc.c */
 void probe_idregs_smsc(uint16_t port);
@@ -105,7 +107,7 @@
        int ports[MAXNUMPORTS]; /* Signed, as we need EOT. */
 } superio_ports_table[] = {
        {probe_idregs_ali,      {0x3f0, 0x370, EOT}},
-       {probe_idregs_simple,   {0x2e, 0x4e, EOT}},
+       {probe_idregs_nsc,      {0x2e, 0x4e, EOT}},
        {probe_idregs_fintek,   {0x2e, 0x4e, EOT}},
        {probe_idregs_ite,      {0x2e, 0x4e, EOT}},
        {probe_idregs_smsc,     {0x2e, 0x4e, 0x3f0, 0x370, EOT}},

Modified: trunk/util/superiotool/winbond.c
===================================================================
--- trunk/util/superiotool/winbond.c    2007-10-04 06:26:41 UTC (rev 2820)
+++ trunk/util/superiotool/winbond.c    2007-10-04 15:23:38 UTC (rev 2821)
@@ -184,9 +184,11 @@
        uint16_t id;
        uint8_t devid, rev, olddevid;
 
+       probing_for("Winbond", init, port);
+
        devid = regval(port, DEVICE_ID_REG);
        rev = regval(port, DEVICE_REV_REG);
-       olddevid = regval(port, DEVICE_ID_REG_OLD);
+       olddevid = regval(port, DEVICE_ID_REG_OLD) & 0x0f;
 
        if (devid == 0x52)
                id = devid;                              /* ID only */
@@ -199,7 +201,9 @@
                id = olddevid & 0x0f;                    /* ID[3..0] */
 
        if (superio_unknown(reg_table, id)) {
-               no_superio_found("Winbond", init, port);
+               if (verbose)
+                       printf(NOTFOUND "id/oldid=0x%02x/0x%02x, rev=0x%02x\n",
+                              devid, olddevid, rev);
                exit_conf_mode_winbond_fintek_ite_8787(port);
                return;
        }


-- 
linuxbios mailing list
linuxbios@linuxbios.org
http://www.linuxbios.org/mailman/listinfo/linuxbios

Reply via email to