Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev Identify Nuvoton NCT6798D correctly. It seems that t...



details:   https://anonhg.NetBSD.org/src/rev/cce0ba85d8ca
branches:  trunk
changeset: 461820:cce0ba85d8ca
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Wed Jul 10 16:23:55 2019 +0000

description:
Identify Nuvoton NCT6798D correctly. It seems that the bit width of NCT6796D
and newer devices' device ID is 13bit. The previous series was 12bits.

diffstat:

 sys/dev/ic/nslm7x.c    |   5 +-
 sys/dev/isa/wbsio.c    |  76 +++++++++++++++++++++++++------------------------
 sys/dev/isa/wbsioreg.h |  18 +++++++++--
 3 files changed, 56 insertions(+), 43 deletions(-)

diffs (192 lines):

diff -r 6108aec65f78 -r cce0ba85d8ca sys/dev/ic/nslm7x.c
--- a/sys/dev/ic/nslm7x.c       Wed Jul 10 13:41:14 2019 +0000
+++ b/sys/dev/ic/nslm7x.c       Wed Jul 10 16:23:55 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nslm7x.c,v 1.72 2018/11/30 05:49:23 msaitoh Exp $ */
+/*     $NetBSD: nslm7x.c,v 1.73 2019/07/10 16:23:55 msaitoh Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nslm7x.c,v 1.72 2018/11/30 05:49:23 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nslm7x.c,v 1.73 2019/07/10 16:23:55 msaitoh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -2156,6 +2156,7 @@
     { WBSIO_ID_NCT6793D,    "NCT6793D", nct6779d_sensors, NULL },
     { WBSIO_ID_NCT6795D,    "NCT6795D", nct6779d_sensors, NULL },
     { WBSIO_ID_NCT6796D,    "NCT6796D", nct6779d_sensors, NULL },
+    { WBSIO_ID_NCT6798D,    "NCT6798D", nct6779d_sensors, NULL },
     { 0, NULL, NULL, NULL }
 };
 
diff -r 6108aec65f78 -r cce0ba85d8ca sys/dev/isa/wbsio.c
--- a/sys/dev/isa/wbsio.c       Wed Jul 10 13:41:14 2019 +0000
+++ b/sys/dev/isa/wbsio.c       Wed Jul 10 16:23:55 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wbsio.c,v 1.24 2018/04/25 08:29:45 yamaguchi Exp $     */
+/*     $NetBSD: wbsio.c,v 1.25 2019/07/10 16:23:55 msaitoh Exp $       */
 /*     $OpenBSD: wbsio.c,v 1.10 2015/03/14 03:38:47 jsg Exp $  */
 /*
  * Copyright (c) 2008 Mark Kettenis <kettenis%openbsd.org@localhost>
@@ -73,31 +73,32 @@
 
 static const struct wbsio_product {
        uint16_t id;
-       bool    idis12bits;
+       int idbits;
        const char *str;
 } wbsio_products[] = {
-       { WBSIO_ID_W83627HF,    false,  "W83627HF" },
-       { WBSIO_ID_W83697HF,    false,  "W83697HF" },
-       { WBSIO_ID_W83637HF,    false,  "W83637HF" },
-       { WBSIO_ID_W83627THF,   false,  "W83627THF" },
-       { WBSIO_ID_W83687THF,   false,  "W83687THF" },
-       { WBSIO_ID_W83627DHG,   true,   "W83627DHG" },
-       { WBSIO_ID_W83627DHGP,  true,   "W83627DHG-P" },
-       { WBSIO_ID_W83627EHF,   true,   "W83627EHF" },
-       { WBSIO_ID_W83627SF,    true,   "W83627SF" },
-       { WBSIO_ID_W83627UHG,   true,   "W83627UHG" },
-       { WBSIO_ID_W83667HG,    true,   "W83667HG" },
-       { WBSIO_ID_W83667HGB,   true,   "W83667HGB" },
-       { WBSIO_ID_W83697UG,    true,   "W83697UG" },
-       { WBSIO_ID_NCT6775F,    true,   "NCT6775F" },
-       { WBSIO_ID_NCT6776F,    true,   "NCT6776F" },
-       { WBSIO_ID_NCT5104D,    true,   "NCT5104D or 610[246]D" },
-       { WBSIO_ID_NCT6779D,    true,   "NCT6779D" },
-       { WBSIO_ID_NCT6791D,    true,   "NCT6791D" },
-       { WBSIO_ID_NCT6792D,    true,   "NCT6792D" },
-       { WBSIO_ID_NCT6793D,    true,   "NCT6793D" },
-       { WBSIO_ID_NCT6795D,    true,   "NCT6795D" },
-       { WBSIO_ID_NCT6796D,    true,   "NCT6796D" },
+       { WBSIO_ID_W83627HF,    8,      "W83627HF" },
+       { WBSIO_ID_W83697HF,    8,      "W83697HF" },
+       { WBSIO_ID_W83637HF,    8,      "W83637HF" },
+       { WBSIO_ID_W83627THF,   8,      "W83627THF" },
+       { WBSIO_ID_W83687THF,   8,      "W83687THF" },
+       { WBSIO_ID_W83627DHG,   12,     "W83627DHG" },
+       { WBSIO_ID_W83627DHGP,  12,     "W83627DHG-P" },
+       { WBSIO_ID_W83627EHF,   12,     "W83627EHF" },
+       { WBSIO_ID_W83627SF,    12,     "W83627SF" },
+       { WBSIO_ID_W83627UHG,   12,     "W83627UHG" },
+       { WBSIO_ID_W83667HG,    12,     "W83667HG" },
+       { WBSIO_ID_W83667HGB,   12,     "W83667HGB" },
+       { WBSIO_ID_W83697UG,    12,     "W83697UG" },
+       { WBSIO_ID_NCT6775F,    12,     "NCT6775F" },
+       { WBSIO_ID_NCT6776F,    12,     "NCT6776F" },
+       { WBSIO_ID_NCT5104D,    12,     "NCT5104D or 610[246]D" },
+       { WBSIO_ID_NCT6779D,    12,     "NCT6779D" },
+       { WBSIO_ID_NCT6791D,    12,     "NCT6791D" },
+       { WBSIO_ID_NCT6792D,    12,     "NCT6792D" },
+       { WBSIO_ID_NCT6793D,    12,     "NCT6793D" },
+       { WBSIO_ID_NCT6795D,    12,     "NCT6795D" },
+       { WBSIO_ID_NCT6796D,    13,     "NCT6796D" },
+       { WBSIO_ID_NCT6798D,    13,     "NCT6798D" },
 };
 
 static const struct wbsio_product *wbsio_lookup(uint8_t id, uint8_t rev);
@@ -169,16 +170,19 @@
 static const struct wbsio_product *
 wbsio_lookup(uint8_t id, uint8_t rev)
 {
-       uint16_t wid = ((uint16_t)id << 4) | (rev >> 4);
        int i;
 
        for (i = 0; i < __arraycount(wbsio_products); i++) {
-               if (wbsio_products[i].idis12bits) {
-                       if (wbsio_products[i].id == wid)
-                               return &wbsio_products[i];
-               } else {
-                       if (wbsio_products[i].id == id)
-                               return &wbsio_products[i];
+               const struct wbsio_product *ent = &wbsio_products[i];
+               switch (ent->idbits) {
+               case 13:
+               case 12:
+               case 8:
+                       if (ent->id == WBSIO_MAKEID(id, rev, ent->idbits))
+                               return ent;
+                       break;
+               default:
+                       break;
                }
        }
 
@@ -266,8 +270,7 @@
                aprint_error_dev(self, "Unknown device. Failed to attach\n");
                return;
        }
-       if (product->idis12bits)
-               rev &= 0x0f; /* Revision is low 4bits */
+       rev = WBSIO_MAKEREV(rev, product->idbits);
 
        desc = product->str;
        if (desc[0] == 'W')
@@ -276,8 +279,8 @@
                vendor = "Nuvoton";
        aprint_naive("\n");
        aprint_normal(": %s LPC Super I/O %s rev ", vendor, desc);
-       if (product->idis12bits) {
-               /* Revision filed is 4bit only */
+       if (product->idbits >= 12) {
+               /* Revision filed is 4 or 3bits */
                aprint_normal("%c\n", 'A' + rev);
        } else
                aprint_normal("0x%02x\n", rev);
@@ -394,8 +397,7 @@
                aprint_error_dev(parent, "%s: Unknown device.\n", __func__);
                return -1;
        }
-       if (product->idis12bits)
-               devid = (devid << 4) | (rev >> 4);
+       devid = WBSIO_MAKEID(devid, rev, product->idbits);
 
        sc->sc_ia.ia_nio = 1;
        sc->sc_ia.ia_io = &sc->sc_io;
diff -r 6108aec65f78 -r cce0ba85d8ca sys/dev/isa/wbsioreg.h
--- a/sys/dev/isa/wbsioreg.h    Wed Jul 10 13:41:14 2019 +0000
+++ b/sys/dev/isa/wbsioreg.h    Wed Jul 10 16:23:55 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wbsioreg.h,v 1.8 2018/03/07 09:25:56 msaitoh Exp $ */
+/* $NetBSD: wbsioreg.h,v 1.9 2019/07/10 16:23:55 msaitoh Exp $ */
 
 /* $OpenBSD: wbsioreg.h,v 1.4 2015/01/02 23:02:54 chris Exp $ */
 /*
@@ -48,12 +48,12 @@
 #define WBSIO_SFR              0x2F    /* Strapping Function Result */
 
 
-#define WBSIO_ID_W83627HF      0x52
+#define WBSIO_ID_W83627HF      0x52    /* 8bits */
 #define WBSIO_ID_W83697HF      0x60
 #define WBSIO_ID_W83637HF      0x70
 #define WBSIO_ID_W83627THF     0x82
 #define WBSIO_ID_W83687THF     0x85
-#define WBSIO_ID_W83627SF      0x595
+#define WBSIO_ID_W83627SF      0x595   /* 12bits */
 #define WBSIO_ID_W83697UG      0x681
 #define WBSIO_ID_W83627EHF_A   0x885
 #define WBSIO_ID_W83627EHF     0x886
@@ -70,7 +70,17 @@
 #define WBSIO_ID_NCT6792D      0xc91
 #define WBSIO_ID_NCT6793D      0xd12
 #define WBSIO_ID_NCT6795D      0xd35
-#define WBSIO_ID_NCT6796D      0xd42
+#define WBSIO_ID_NCT6796D      0xd420  /* 13bits */
+#define WBSIO_ID_NCT6798D      0xd428
+
+/* Make the above WBSIO_ID_* vaue from WBSIO_ID, WBSIO_REV and IDbits */
+#define WBSIO_MAKEID(id, rev, bits)                                    \
+       (((bits) == 13) ? (((uint16_t)(id) << 8) | ((rev) & 0xf8)) :    \
+           ((bits) == 12) ? (((uint16_t)(id) << 4) | ((rev) >> 4)) : (id))
+
+#define WBSIO_MAKEREV(rev, bits)                                            \
+       (((bits) == 13) ? ((rev) & 0x07) : ((bits) == 12) ? ((rev) & 0x0f) : \
+           (rev))
 
 /* Strapping Function Result */
 #define WBSIO_SFR_24M48M       0x01



Home | Main Index | Thread Index | Old Index