summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorpgoyette <pgoyette@NetBSD.org>2016-06-01 02:37:47 +0000
committerpgoyette <pgoyette@NetBSD.org>2016-06-01 02:37:47 +0000
commit79e78ef53f6458d2cc193813bc485fceb76feeae (patch)
treee2eca7a06971498573eeb829568cbb22f4c641e1 /sys/dev
parentc50c36dd8c1279d85f3aef6a9a37da683338d6d2 (diff)
Add support for Nuvoton NCT6776F from OpenBSD
From PR kern/49747
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/ic/nslm7x.c182
-rw-r--r--sys/dev/ic/nslm7xvar.h6
-rw-r--r--sys/dev/isa/lm_isa_common.c6
-rw-r--r--sys/dev/isa/wbsio.c24
4 files changed, 205 insertions, 13 deletions
diff --git a/sys/dev/ic/nslm7x.c b/sys/dev/ic/nslm7x.c
index 4236dfa29ed..50e70f9bccd 100644
--- a/sys/dev/ic/nslm7x.c
+++ b/sys/dev/ic/nslm7x.c
@@ -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 @@ static struct lm_sensor as99127f_sensors[] = {
{ .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 @@ static int
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_match(struct lm_softc *sc)
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 @@ wb_match(struct lm_softc *sc)
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 @@ wb_match(struct lm_softc *sc)
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 @@ wb_refresh_fanrpm(struct lm_softc *sc, int n)
}
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 --git a/sys/dev/ic/nslm7xvar.h b/sys/dev/ic/nslm7xvar.h
index 49d0d65edb5..5087426f1c0 100644
--- a/sys/dev/ic/nslm7xvar.h
+++ b/sys/dev/ic/nslm7xvar.h
@@ -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_softc {
struct lm_sensor *lm_sensors;
uint8_t chipid;
uint8_t vrm9;
+ uint8_t sioid;
};
struct lm_sensor {
diff --git a/sys/dev/isa/lm_isa_common.c b/sys/dev/isa/lm_isa_common.c
index 4078ca9b4d6..bf856857024 100644
--- a/sys/dev/isa/lm_isa_common.c
+++ b/sys/dev/isa/lm_isa_common.c
@@ -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 @@ lm_isa_attach(device_t parent, device_t self, void *aux)
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 --git a/sys/dev/isa/wbsio.c b/sys/dev/isa/wbsio.c
index 3708fe609b4..d6c4f53919c 100644
--- a/sys/dev/isa/wbsio.c
+++ b/sys/dev/isa/wbsio.c
@@ -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 $ */
/*
* Copyright (c) 2008 Mark Kettenis <kettenis@openbsd.org>
@@ -53,6 +53,7 @@
#define WBSIO_ID_W83637HF 0x70
#define WBSIO_ID_W83667HG 0xa5
#define WBSIO_ID_W83697HF 0x60
+#define WBSIO_ID_NCT6776F 0xc3
/* Logical Device Number (LDN) Assignments */
#define WBSIO_LDN_HM 0x0b
@@ -147,6 +148,7 @@ wbsio_probe(device_t parent, cfdata_t match, void *aux)
case WBSIO_ID_W83627DHG:
case WBSIO_ID_W83637HF:
case WBSIO_ID_W83697HF:
+ case WBSIO_ID_NCT6776F:
ia->ia_nio = 1;
ia->ia_io[0].ir_size = WBSIO_IOSIZE;
ia->ia_niomem = 0;
@@ -164,6 +166,7 @@ wbsio_attach(device_t parent, device_t self, void *aux)
struct wbsio_softc *sc = device_private(self);
struct isa_attach_args *ia = aux;
const char *desc = NULL;
+ const char *vendor = "Winbond";
uint8_t reg;
sc->sc_dev = self;
@@ -205,20 +208,22 @@ wbsio_attach(device_t parent, device_t self, void *aux)
case WBSIO_ID_W83697HF:
desc = "W83697HF";
break;
+ case WBSIO_ID_NCT6776F:
+ vendor = "Nuvoton";
+ desc = "NCT6776F";
+ break;
}
-
/* Read device revision */
reg = wbsio_conf_read(sc->sc_iot, sc->sc_ioh, WBSIO_REV);
aprint_naive("\n");
- aprint_normal(": Winbond LPC Super I/O %s rev 0x%02x\n", desc, reg);
+ aprint_normal(": %s LPC Super I/O %s rev 0x%02x\n", vendor, desc, reg);
/* Escape from configuration mode */
wbsio_conf_disable(sc->sc_iot, sc->sc_ioh);
if (!pmf_device_register(self, NULL, NULL))
aprint_error_dev(self, "couldn't establish power handler\n");
-
wbsio_rescan(self, "wbsio", NULL);
}
@@ -258,7 +263,7 @@ wbsio_search(device_t parent, cfdata_t cf, const int *slocs, void *aux)
{
struct wbsio_softc *sc = device_private(parent);
uint16_t iobase;
- uint8_t reg0, reg1;
+ uint8_t reg0, reg1, devid;
/* Enter configuration mode */
wbsio_conf_enable(sc->sc_iot, sc->sc_ioh);
@@ -283,6 +288,13 @@ wbsio_search(device_t parent, cfdata_t cf, const int *slocs, void *aux)
if (iobase == 0)
return -1;
+ /* Enter configuration mode */
+ wbsio_conf_enable(sc->sc_iot, sc->sc_ioh);
+ /* Read device ID */
+ devid = wbsio_conf_read(sc->sc_iot, sc->sc_ioh, WBSIO_ID);
+ /* Escape from configuration mode */
+ wbsio_conf_disable(sc->sc_iot, sc->sc_ioh);
+
sc->sc_ia.ia_nio = 1;
sc->sc_ia.ia_io = &sc->sc_io;
sc->sc_ia.ia_io[0].ir_addr = iobase;
@@ -290,6 +302,8 @@ wbsio_search(device_t parent, cfdata_t cf, const int *slocs, void *aux)
sc->sc_ia.ia_niomem = 0;
sc->sc_ia.ia_nirq = 0;
sc->sc_ia.ia_ndrq = 0;
+ /* Store device-id to ia_aux */
+ sc->sc_ia.ia_aux = (void *)(uintptr_t)devid;
sc->sc_lm_dev = config_attach(parent, cf, &sc->sc_ia, wbsio_print);
return 0;