Source-Changes-HG archive

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

[src/trunk]: src/sys/dev - WBSIO_ID_W83627DHG and newer devices have 12bit de...



details:   https://anonhg.NetBSD.org/src/rev/1aa07b956736
branches:  trunk
changeset: 826164:1aa07b956736
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Fri Aug 18 04:07:51 2017 +0000

description:
- WBSIO_ID_W83627DHG and newer devices have 12bit device ID. So, change sioid
  from 8bit to 16bit and check with it strictly.
- s/lm_match/nslm_match/
- split {wb,lm,def}_match() to XXX_match and XXX_attach().
- Rename lm_probe with lm_match and call {wb,nslm,def}_match() at the end of
  the function to check strictly.
- NCT610[246]D is different from otehrs, so add new nct6102d_sensors[] table.
- Register offsets of vendor ID and chip id of NCT610[246]D are different
  from others. When it failed reading vendor ID or chip ID, fallback to
  NCT610[246]D's register offsets.
- Add debug messages.

diffstat:

 sys/dev/i2c/lm_i2c.c        |    6 +-
 sys/dev/ic/nslm7x.c         |  606 +++++++++++++++++++++++++++++++------------
 sys/dev/ic/nslm7xvar.h      |   15 +-
 sys/dev/isa/lm_isa_common.c |    9 +-
 sys/dev/isa/wbsio.c         |  223 +++++++--------
 sys/dev/isa/wbsioreg.h      |   33 +-
 6 files changed, 578 insertions(+), 314 deletions(-)

diffs (truncated from 1247 to 300 lines):

diff -r 7f9a41094533 -r 1aa07b956736 sys/dev/i2c/lm_i2c.c
--- a/sys/dev/i2c/lm_i2c.c      Thu Aug 17 23:19:51 2017 +0000
+++ b/sys/dev/i2c/lm_i2c.c      Fri Aug 18 04:07:51 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lm_i2c.c,v 1.3 2017/08/17 05:27:48 msaitoh Exp $       */
+/*     $NetBSD: lm_i2c.c,v 1.4 2017/08/18 04:07:51 msaitoh Exp $       */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lm_i2c.c,v 1.3 2017/08/17 05:27:48 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lm_i2c.c,v 1.4 2017/08/18 04:07:51 msaitoh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -76,7 +76,7 @@
        sc.sc_lmsc.lm_readreg = lm_i2c_readreg;
        sc.sc_tag = ia->ia_tag;
        sc.sc_addr = ia->ia_addr;
-       rv = lm_probe(&sc.sc_lmsc);
+       rv = lm_match(&sc.sc_lmsc);
 
        return rv;
 }
diff -r 7f9a41094533 -r 1aa07b956736 sys/dev/ic/nslm7x.c
--- a/sys/dev/ic/nslm7x.c       Thu Aug 17 23:19:51 2017 +0000
+++ b/sys/dev/ic/nslm7x.c       Fri Aug 18 04:07:51 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nslm7x.c,v 1.69 2017/08/17 05:27:48 msaitoh Exp $ */
+/*     $NetBSD: nslm7x.c,v 1.70 2017/08/18 04:07:51 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.69 2017/08/17 05:27:48 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nslm7x.c,v 1.70 2017/08/18 04:07:51 msaitoh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -72,10 +72,16 @@
 
 #define LM_REFRESH_TIMO        (2 * hz)        /* 2 seconds */
 
-static int lm_match(struct lm_softc *);
+static const struct wb_product *wb_lookup(struct lm_softc *,
+    const struct wb_product *, uint16_t);
 static int wb_match(struct lm_softc *);
+static int wb_attach(struct lm_softc *);
+static int nslm_match(struct lm_softc *);
+static int nslm_attach(struct lm_softc *);
 static int def_match(struct lm_softc *);
+static int def_attach(struct lm_softc *);
 static void wb_temp_diode_type(struct lm_softc *, int);
+static uint16_t wb_read_vendorid(struct lm_softc *);
 
 static void lm_refresh(void *);
 
@@ -94,32 +100,18 @@
 static void wb_refresh_fanrpm(struct lm_softc *, int);
 static void wb_w83792d_refresh_fanrpm(struct lm_softc *, int);
 static void wb_nct6776f_refresh_fanrpm(struct lm_softc *, int);
-static const char * wb_nct67xx_id2str(uint8_t);
 
 static void as_refresh_temp(struct lm_softc *, int);
 
 struct lm_chip {
        int (*chip_match)(struct lm_softc *);
+       int (*chip_attach)(struct lm_softc *);
 };
 
 static struct lm_chip lm_chips[] = {
-       { wb_match },
-       { lm_match },
-       { def_match } /* Must be last */
-};
-
-static struct {
-       uint8_t id;
-       const char *str;
-} nct_chips[] = {
-       {WBSIO_ID_NCT6775F, "NCT6775F"},
-       {WBSIO_ID_NCT6776F, "NCT6776F"},
-       {WBSIO_ID_NCT5104D, "NCT5104D or 610[246]D"},
-       {WBSIO_ID_NCT6779D, "NCT6779D"},
-       {WBSIO_ID_NCT6791D, "NCT6791D"},
-       {WBSIO_ID_NCT6792D, "NCT6792D"},
-       {WBSIO_ID_NCT6793D, "NCT6793D"},
-       {WBSIO_ID_NCT6795D, "NCT6795D"},
+       { wb_match,     wb_attach },
+       { nslm_match,   nslm_attach },
+       { def_match,    def_attach } /* Must be last */
 };
 
 /* LM78/78J/79/81 */
@@ -1784,6 +1776,137 @@
        { .desc = NULL }
 };
 
+/* NCT610[246]D */
+static const struct lm_sensor nct6102d_sensors[] = {
+       /* Voltage */
+       {
+               .desc = "VCore",
+               .type = ENVSYS_SVOLTS_DC,
+               .bank = 0,
+               .reg = 0x00,
+               .refresh = lm_refresh_volt,
+               .rfact = RFACT_NONE
+       },
+       {
+               .desc = "VIN0",
+               .type = ENVSYS_SVOLTS_DC,
+               .bank = 0,
+               .reg = 0x01,
+               .refresh = lm_refresh_volt,
+               .rfact = RFACT_NONE
+       },
+       {
+               .desc = "AVCC",
+               .type = ENVSYS_SVOLTS_DC,
+               .bank = 0,
+               .reg = 0x02,
+               .refresh = lm_refresh_volt,
+               .rfact = RFACT(34, 34) / 2
+       },
+       {
+               .desc = "3VCC",
+               .type = ENVSYS_SVOLTS_DC,
+               .bank = 0,
+               .reg = 0x03,
+               .refresh = lm_refresh_volt,
+               .rfact = RFACT(34, 34) / 2
+       },
+       {
+               .desc = "VIN1",
+               .type = ENVSYS_SVOLTS_DC,
+               .bank = 0,
+               .reg = 0x04,
+               .refresh = lm_refresh_volt,
+               .rfact = RFACT_NONE
+       },
+       {
+               .desc = "VIN2",
+               .type = ENVSYS_SVOLTS_DC,
+               .bank = 0,
+               .reg = 0x05,
+               .refresh = lm_refresh_volt,
+               .rfact = RFACT(34, 34) / 2
+       },
+       {
+               .desc = "+3.3VSB",
+               .type = ENVSYS_SVOLTS_DC,
+               .bank = 0,
+               .reg = 0x07,
+               .refresh = lm_refresh_volt,
+               .rfact = RFACT(34, 34) / 2
+       },
+       {
+               .desc = "VBAT",
+               .type = ENVSYS_SVOLTS_DC,
+               .bank = 0,
+               .reg = 0x08,
+               .refresh = lm_refresh_volt,
+               .rfact = RFACT(34, 34) / 2
+       },
+       {
+               .desc = "VTT",
+               .type = ENVSYS_SVOLTS_DC,
+               .bank = 0,
+               .reg = 0x09,
+               .refresh = lm_refresh_volt,
+               .rfact = RFACT_NONE
+       },
+
+       /* Temperature */
+       {
+               .desc = "MB Temperature",
+               .type = ENVSYS_STEMP,
+               .bank = 0,
+               .reg = 0x18,
+               .refresh = lm_refresh_temp,
+               .rfact = 0
+       },
+       {
+               .desc = "CPU Temperature",
+               .type = ENVSYS_STEMP,
+               .bank = 0,
+               .reg = 0x19,
+               .refresh = lm_refresh_temp,
+               .rfact = 0
+       },
+       {
+               .desc = "Aux Temp",
+               .type = ENVSYS_STEMP,
+               .bank = 0,
+               .reg = 0x1a,
+               .refresh = lm_refresh_temp,
+               .rfact = 0
+       },
+
+       /* Fans */
+       {
+               .desc = "System Fan",
+               .type = ENVSYS_SFANRPM,
+               .bank = 0,
+               .reg = 0x30,
+               .refresh = wb_nct6776f_refresh_fanrpm,
+               .rfact = 0
+       },
+       {
+               .desc = "CPU Fan",
+               .type = ENVSYS_SFANRPM,
+               .bank = 0,
+               .reg = 0x32,
+               .refresh = wb_nct6776f_refresh_fanrpm,
+               .rfact = 0
+       },
+       {
+               .desc = "Aux Fan",
+               .type = ENVSYS_SFANRPM,
+               .bank = 0,
+               .reg = 0x34,
+               .refresh = wb_nct6776f_refresh_fanrpm,
+               .rfact = 0
+       },
+
+       { .desc = NULL }
+};
+
 /* NCT6779D */
 static const struct lm_sensor nct6779d_sensors[] = {
        /* Voltage */
@@ -2003,6 +2126,44 @@
        { .desc = NULL }
 };
 
+static const struct wb_product wb_products[] = {
+    { WB_CHIPID_W83627HF,   "W83627HF",        w83627hf_sensors, NULL },
+    { WB_CHIPID_W83627THF,  "W83627THF",w83637hf_sensors, NULL },
+    { WB_CHIPID_W83627EHF_A,"W83627EHF-A",w83627ehf_sensors,NULL },
+    { WB_CHIPID_W83627EHF,  "W83627EHF",w83627ehf_sensors,NULL },
+    { WB_CHIPID_W83627DHG,  NULL,      NULL,   NULL },
+    { WB_CHIPID_W83637HF,   "W83637HF",        w83637hf_sensors, NULL },
+    { WB_CHIPID_W83697HF,   "W83697HF",        w83697hf_sensors, NULL },
+    { WB_CHIPID_W83781D,    "W83781D", w83781d_sensors,  NULL },
+    { WB_CHIPID_W83781D_2,  "W83781D", w83781d_sensors,  NULL },
+    { WB_CHIPID_W83782D,    "W83782D", w83782d_sensors,  NULL },
+    { WB_CHIPID_W83783S,    "W83783S", w83783s_sensors,  NULL },
+    { WB_CHIPID_W83791D,    "W83791D", w83791d_sensors,  NULL },
+    { WB_CHIPID_W83791SD,   "W83791SD",        NULL,             NULL },
+    { WB_CHIPID_W83792D,    "W83792D", w83792d_sensors,  NULL },
+    { WB_CHIPID_AS99127F,   NULL,      NULL,  NULL },
+    { 0, NULL, NULL, NULL }
+};
+
+static const struct wb_product wbsio_products[] = {
+    { WBSIO_ID_W83627DHG,   "W83627DHG",w83627dhg_sensors,NULL },
+    { WBSIO_ID_NCT6775F,    "NCT6775F", nct6776f_sensors, NULL },
+    { WBSIO_ID_NCT6776F,    "NCT6776F", nct6776f_sensors, NULL },
+    { WBSIO_ID_NCT5104D,    "NCT5104D or 610[246]D",nct6102d_sensors,NULL },
+    { WBSIO_ID_NCT6779D,    "NCT6779D", nct6779d_sensors, NULL },
+    { WBSIO_ID_NCT6791D,    "NCT6791D", nct6779d_sensors, NULL },
+    { WBSIO_ID_NCT6792D,    "NCT6792D", nct6779d_sensors, NULL },
+    { WBSIO_ID_NCT6793D,    "NCT6793D", nct6779d_sensors, NULL },
+    { WBSIO_ID_NCT6795D,    "NCT6795D", nct6779d_sensors, NULL },
+    { 0, NULL, NULL, NULL }
+};
+
+static const struct wb_product as99127f_products[] = {
+    { WB_VENDID_ASUS,       "AS99127F", w83781d_sensors,  NULL },
+    { WB_VENDID_WINBOND,    "AS99127F rev 2",as99127f_sensors,NULL },
+    { 0, NULL, NULL, NULL }
+};
+
 static void
 lm_generic_banksel(struct lm_softc *lmsc, uint8_t bank)
 {
@@ -2010,16 +2171,16 @@
 }
 
 /*
- * bus independent probe
+ * bus independent match
  *
  * prerequisites:  lmsc contains valid lm_{read,write}reg() routines
  * and associated bus access data is present in attachment's softc
  */
 int
-lm_probe(struct lm_softc *lmsc)
+lm_match(struct lm_softc *lmsc)
 {
        uint8_t cr;
-       int rv;
+       int i, rv;



Home | Main Index | Thread Index | Old Index