Source-Changes-HG archive

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

[src/trunk]: src/sys/dev Add support for Nuvoton NCT6776F from OpenBSD



details:   https://anonhg.NetBSD.org/src/rev/1222fc89c3b0
branches:  trunk
changeset: 345565:1222fc89c3b0
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Wed Jun 01 02:37:47 2016 +0000

description:
Add support for Nuvoton NCT6776F from OpenBSD

>From PR kern/49747

diffstat:

 sys/dev/ic/nslm7x.c         |  182 ++++++++++++++++++++++++++++++++++++++++++-
 sys/dev/ic/nslm7xvar.h      |    6 +-
 sys/dev/isa/lm_isa_common.c |    6 +-
 sys/dev/isa/wbsio.c         |   24 ++++-
 4 files changed, 205 insertions(+), 13 deletions(-)

diffs (truncated from 383 to 300 lines):

diff -r 43706a4e9bb3 -r 1222fc89c3b0 sys/dev/ic/nslm7x.c
--- a/sys/dev/ic/nslm7x.c       Wed Jun 01 02:15:26 2016 +0000
+++ b/sys/dev/ic/nslm7x.c       Wed Jun 01 02:37:47 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nslm7x.c,v 1.62 2015/04/23 23:23:00 pgoyette Exp $ */
+/*     $NetBSD: nslm7x.c,v 1.63 2016/06/01 02:37:47 pgoyette Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nslm7x.c,v 1.62 2015/04/23 23:23:00 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nslm7x.c,v 1.63 2016/06/01 02:37:47 pgoyette Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1619,6 +1619,154 @@
        { .desc = NULL }
 };
 
+/*  NCT6776F */
+static struct lm_sensor nct6776f_sensors[] = {
+       /* Voltage */
+       {
+               .desc = "VCore",
+               .type = ENVSYS_SVOLTS_DC,
+               .bank = 0,
+               .reg = 0x20,
+               .refresh = lm_refresh_volt,
+               .rfact = RFACT_NONE / 2
+       },
+       {
+               .desc = "+12V",
+               .type = ENVSYS_SVOLTS_DC,
+               .bank = 0,
+               .reg = 0x21,
+               .refresh = lm_refresh_volt,
+               .rfact = RFACT(56, 10) / 2
+       },
+       {
+               .desc = "AVCC",
+               .type = ENVSYS_SVOLTS_DC,
+               .bank = 0,
+               .reg = 0x22,
+               .refresh = lm_refresh_volt,
+               .rfact = RFACT(34, 34) / 2
+       },
+       {
+               .desc = "+3.3V",
+               .type = ENVSYS_SVOLTS_DC,
+               .bank = 0,
+               .reg = 0x23,
+               .refresh = lm_refresh_volt,
+               .rfact = RFACT(34, 34) / 2
+       },
+       {
+               .desc = "-12V",
+               .type = ENVSYS_SVOLTS_DC,
+               .bank = 0,
+               .reg = 0x24,
+               .refresh = wb_w83627ehf_refresh_nvolt,
+               .rfact = 0
+       },
+       {
+               .desc = "+5V",
+               .type = ENVSYS_SVOLTS_DC,
+               .bank = 0,
+               .reg = 0x25,
+               .refresh = lm_refresh_volt,
+               .rfact = 16000
+       },
+       {
+               .desc = "VIN3",
+               .type = ENVSYS_SVOLTS_DC,
+               .bank = 0,
+               .reg = 0x26,
+               .refresh = lm_refresh_volt,
+               .rfact = RFACT_NONE
+       },
+       {
+               .desc = "+3.3VSB",
+               .type = ENVSYS_SVOLTS_DC,
+               .bank = 5,
+               .reg = 0x50,
+               .refresh = lm_refresh_volt,
+               .rfact = RFACT(34, 34) / 2
+       },
+       {
+               .desc = "VBAT",
+               .type = ENVSYS_SVOLTS_DC,
+               .bank = 5,
+               .reg = 0x51,
+               .refresh = lm_refresh_volt,
+               .rfact = RFACT(34, 34) / 2
+       },
+
+       /* Temperature */
+       {
+               .desc = "MB Temperature",
+               .type = ENVSYS_STEMP,
+               .bank = 0,
+               .reg = 0x27,
+               .refresh = lm_refresh_temp,
+               .rfact = 0
+       },
+       {
+               .desc = "CPU Temperature",
+               .type = ENVSYS_STEMP,
+               .bank = 1,
+               .reg = 0x50,
+               .refresh = wb_refresh_temp,
+               .rfact = 0
+       },
+       {
+               .desc = "Aux Temp",
+               .type = ENVSYS_STEMP,
+               .bank = 2,
+               .reg = 0x50,
+               .refresh = wb_refresh_temp,
+               .rfact = 0
+       },
+
+       /* Fans */
+       {
+               .desc = "System Fan",
+               .type = ENVSYS_SFANRPM,
+               .bank = 6,
+               .reg = 0x56,
+               .refresh = wb_nct6776f_refresh_fanrpm,
+               .rfact = 0
+       },
+       {
+               .desc = "CPU Fan",
+               .type = ENVSYS_SFANRPM,
+               .bank = 6,
+               .reg = 0x58,
+               .refresh = wb_nct6776f_refresh_fanrpm,
+               .rfact = 0
+       },
+       {
+               .desc = "Aux Fan0",
+               .type = ENVSYS_SFANRPM,
+               .bank = 6,
+               .reg = 0x5a,
+               .refresh = wb_nct6776f_refresh_fanrpm,
+               .rfact = 0
+       },
+       {
+               .desc = "Aux Fan1",
+               .type = ENVSYS_SFANRPM,
+               .bank = 6,
+               .reg = 0x5c,
+               .refresh = wb_nct6776f_refresh_fanrpm,
+               .rfact = 0
+       },
+
+       {
+               .desc = "Aux Fan2",
+               .type = ENVSYS_SFANRPM,
+               .bank = 6,
+               .reg = 0x5e,
+               .refresh = wb_nct6776f_refresh_fanrpm,
+               .rfact = 0
+       },
+
+       { .desc = NULL }
+};
+
 static void
 lm_generic_banksel(struct lm_softc *lmsc, int bank)
 {
@@ -1819,6 +1967,7 @@
 wb_match(struct lm_softc *sc)
 {
        const char *model = NULL;
+       const char *vendor = "Winbond";
        int banksel, vendid, cf_flags;
 
        aprint_naive("\n");
@@ -1866,8 +2015,14 @@
                wb_temp_diode_type(sc, cf_flags);
                break;
        case WB_CHIPID_W83627DHG:
-               model = "W83627DHG";
-               lm_setup_sensors(sc, w83627dhg_sensors);
+               if (sc->sioid == WBSIO_ID_NCT6776F) {
+                       vendor = "Nuvoton";
+                       model = "NCT6776F";
+                       lm_setup_sensors(sc, nct6776f_sensors);
+               } else {
+                       model = "W83627DHG";
+                       lm_setup_sensors(sc, w83627dhg_sensors);
+               }
                wb_temp_diode_type(sc, cf_flags);
                break;
        case WB_CHIPID_W83637HF:
@@ -1912,6 +2067,7 @@
                lm_setup_sensors(sc, w83792d_sensors);
                break;
        case WB_CHIPID_AS99127F:
+               vendor = "ASUS";
                if (vendid == WB_VENDID_ASUS) {
                        model = "AS99127F";
                        lm_setup_sensors(sc, w83781d_sensors);
@@ -1929,7 +2085,7 @@
                return 1;
        }
 
-       aprint_normal_dev(sc->sc_dev, "Winbond %s Hardware monitor\n", model);
+       aprint_normal_dev(sc->sc_dev, "%s %s Hardware monitor\n", vendor, model);
 
        sc->refresh_sensor_data = wb_refresh_sensor_data;
        return 1;
@@ -2193,6 +2349,22 @@
 }
 
 static void
+wb_nct6776f_refresh_fanrpm(struct lm_softc *sc, int n)
+{
+       int datah, datal;
+
+       datah = (*sc->lm_readreg)(sc, sc->lm_sensors[n].reg);
+       datal = (*sc->lm_readreg)(sc, sc->lm_sensors[n].reg + 1);
+
+       if ((datah == 0xff) || (datah == 0)) {
+               sc->sensors[n].state = ENVSYS_SINVALID;
+       } else {
+               sc->sensors[n].state = ENVSYS_SVALID;
+               sc->sensors[n].value_cur = (datah << 8) | datal;
+       }
+}
+
+static void
 wb_w83792d_refresh_fanrpm(struct lm_softc *sc, int n)
 {
        int reg, shift, data, divisor = 1;
diff -r 43706a4e9bb3 -r 1222fc89c3b0 sys/dev/ic/nslm7xvar.h
--- a/sys/dev/ic/nslm7xvar.h    Wed Jun 01 02:15:26 2016 +0000
+++ b/sys/dev/ic/nslm7xvar.h    Wed Jun 01 02:37:47 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nslm7xvar.h,v 1.28 2012/01/17 16:14:47 jakllsch Exp $ */
+/*     $NetBSD: nslm7xvar.h,v 1.29 2016/06/01 02:37:47 pgoyette Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -144,6 +144,9 @@
 #define WB_CHIPID_W83627EHF    0xa1
 #define WB_CHIPID_W83627DHG    0xc1
 
+/* wbsio Device IDs */
+#define WBSIO_ID_NCT6776F      0xc3
+
 /* Config bits */
 #define WB_CONFIG_VMR9         0x01
 
@@ -170,6 +173,7 @@
        struct lm_sensor *lm_sensors;
        uint8_t chipid;
        uint8_t vrm9;
+       uint8_t sioid;
 };
 
 struct lm_sensor {
diff -r 43706a4e9bb3 -r 1222fc89c3b0 sys/dev/isa/lm_isa_common.c
--- a/sys/dev/isa/lm_isa_common.c       Wed Jun 01 02:15:26 2016 +0000
+++ b/sys/dev/isa/lm_isa_common.c       Wed Jun 01 02:37:47 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lm_isa_common.c,v 1.3 2012/01/18 00:11:43 jakllsch Exp $ */
+/*     $NetBSD: lm_isa_common.c,v 1.4 2016/06/01 02:37:47 pgoyette Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lm_isa_common.c,v 1.3 2012/01/18 00:11:43 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lm_isa_common.c,v 1.4 2016/06/01 02:37:47 pgoyette Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -121,6 +121,8 @@
        sc->lmsc.sc_dev = self;
        sc->lmsc.lm_writereg = lm_isa_writereg;
        sc->lmsc.lm_readreg = lm_isa_readreg;
+       /* pass wbsio Device ID */
+       sc->lmsc.sioid = (uint8_t)(uintptr_t)ia->ia_aux;
 
        lm_attach(&sc->lmsc);
 }
diff -r 43706a4e9bb3 -r 1222fc89c3b0 sys/dev/isa/wbsio.c
--- a/sys/dev/isa/wbsio.c       Wed Jun 01 02:15:26 2016 +0000
+++ b/sys/dev/isa/wbsio.c       Wed Jun 01 02:37:47 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wbsio.c,v 1.9 2012/01/18 00:23:30 jakllsch Exp $       */
+/*     $NetBSD: wbsio.c,v 1.10 2016/06/01 02:37:47 pgoyette Exp $      */
 /*     $OpenBSD: wbsio.c,v 1.5 2009/03/29 21:53:52 sthen Exp $ */
 /*



Home | Main Index | Thread Index | Old Index