summaryrefslogtreecommitdiff
path: root/sys/dev/isa
diff options
context:
space:
mode:
authorMarco Pfatschbacher <mpf@cvs.openbsd.org>2011-12-06 16:06:08 +0000
committerMarco Pfatschbacher <mpf@cvs.openbsd.org>2011-12-06 16:06:08 +0000
commit7704a284773b1336cb80b8b7ceb719e3a4b6aee4 (patch)
treea7307f4497b57e6dcfe085dfb18dd7dacd9f8bf1 /sys/dev/isa
parenta49b0ba3214da6b72b586c564f3fcdf1283b2832 (diff)
Add support for Nuvoton NCT6776F fan, voltage and temperature sensors.
Tested on a Supermicro X9SCL/X9SCM board. With help from kettenis to make the part that works around a chip ID collision less ugly. OK kettenis
Diffstat (limited to 'sys/dev/isa')
-rw-r--r--sys/dev/isa/lm78_isa.c57
-rw-r--r--sys/dev/isa/wbsio.c45
-rw-r--r--sys/dev/isa/wbsioreg.h36
3 files changed, 102 insertions, 36 deletions
diff --git a/sys/dev/isa/lm78_isa.c b/sys/dev/isa/lm78_isa.c
index 8875dd194e7..2868ca81f9e 100644
--- a/sys/dev/isa/lm78_isa.c
+++ b/sys/dev/isa/lm78_isa.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lm78_isa.c,v 1.6 2011/10/05 15:05:48 deraadt Exp $ */
+/* $OpenBSD: lm78_isa.c,v 1.7 2011/12/06 16:06:07 mpf Exp $ */
/*
* Copyright (c) 2005, 2006 Mark Kettenis
@@ -48,6 +48,7 @@ struct lm_isa_softc {
};
int lm_isa_match(struct device *, void *, void *);
+int lm_wbsio_match(struct device *, void *, void *);
void lm_isa_attach(struct device *, struct device *, void *);
u_int8_t lm_isa_readreg(struct lm_softc *, int);
void lm_isa_writereg(struct lm_softc *, int, int);
@@ -61,11 +62,58 @@ struct cfattach lm_isa_ca = {
struct cfattach lm_wbsio_ca = {
sizeof(struct lm_isa_softc),
- lm_isa_match,
+ lm_wbsio_match,
lm_isa_attach
};
int
+lm_wbsio_match(struct device *parent, void *match, void *aux)
+{
+ bus_space_tag_t iot;
+ bus_addr_t iobase;
+ bus_space_handle_t ioh;
+ struct isa_attach_args *ia = aux;
+ int banksel, vendid;
+
+ iot = ia->ia_iot;
+ iobase = ia->ipa_io[0].base;
+
+ if (bus_space_map(iot, iobase, 8, 0, &ioh)) {
+ DPRINTF(("%s: can't map i/o space\n", __func__));
+ return (0);
+ }
+
+ /* Probe for Winbond chips. */
+ bus_space_write_1(iot, ioh, LMC_ADDR, WB_BANKSEL);
+ banksel = bus_space_read_1(iot, ioh, LMC_DATA);
+ bus_space_write_1(iot, ioh, LMC_ADDR, WB_BANKSEL);
+ bus_space_write_1(iot, ioh, LMC_DATA, WB_BANKSEL_HBAC);
+ bus_space_write_1(iot, ioh, LMC_ADDR, WB_VENDID);
+ vendid = bus_space_read_1(iot, ioh, LMC_DATA) << 8;
+ bus_space_write_1(iot, ioh, LMC_ADDR, WB_BANKSEL);
+ bus_space_write_1(iot, ioh, LMC_DATA, 0);
+ bus_space_write_1(iot, ioh, LMC_ADDR, WB_VENDID);
+ vendid |= bus_space_read_1(iot, ioh, LMC_DATA);
+ bus_space_write_1(iot, ioh, LMC_ADDR, WB_BANKSEL);
+ bus_space_write_1(iot, ioh, LMC_DATA, banksel);
+
+ bus_space_unmap(iot, ioh, 8);
+
+ if (vendid != WB_VENDID_WINBOND)
+ return (0);
+
+ ia->ipa_nio = 1;
+ ia->ipa_io[0].length = 8;
+
+ ia->ipa_nmem = 0;
+ ia->ipa_nirq = 0;
+ ia->ipa_ndrq = 0;
+
+ return (1);
+
+}
+
+int
lm_isa_match(struct device *parent, void *match, void *aux)
{
bus_space_tag_t iot;
@@ -158,6 +206,11 @@ lm_isa_attach(struct device *parent, struct device *self, void *aux)
/* Bus-independant attachment */
sc->sc_lmsc.lm_writereg = lm_isa_writereg;
sc->sc_lmsc.lm_readreg = lm_isa_readreg;
+
+ /* pass through wbsio(4) devid */
+ if (ia->ia_aux)
+ sc->sc_lmsc.sioid = (u_int8_t)(u_long)ia->ia_aux;
+
lm_attach(&sc->sc_lmsc);
/*
diff --git a/sys/dev/isa/wbsio.c b/sys/dev/isa/wbsio.c
index 72667c05e60..d469feb3e79 100644
--- a/sys/dev/isa/wbsio.c
+++ b/sys/dev/isa/wbsio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wbsio.c,v 1.6 2010/07/18 12:44:55 kettenis Exp $ */
+/* $OpenBSD: wbsio.c,v 1.7 2011/12/06 16:06:07 mpf Exp $ */
/*
* Copyright (c) 2008 Mark Kettenis <kettenis@openbsd.org>
*
@@ -28,36 +28,7 @@
#include <dev/isa/isareg.h>
#include <dev/isa/isavar.h>
-
-/* ISA bus registers */
-#define WBSIO_INDEX 0x00 /* Configuration Index Register */
-#define WBSIO_DATA 0x01 /* Configuration Data Register */
-
-#define WBSIO_IOSIZE 0x02 /* ISA I/O space size */
-
-#define WBSIO_CONF_EN_MAGIC 0x87 /* enable configuration mode */
-#define WBSIO_CONF_DS_MAGIC 0xaa /* disable configuration mode */
-
-/* Configuration Space Registers */
-#define WBSIO_LDN 0x07 /* Logical Device Number */
-#define WBSIO_ID 0x20 /* Device ID */
-#define WBSIO_REV 0x21 /* Device Revision */
-
-#define WBSIO_ID_W83627HF 0x52
-#define WBSIO_ID_W83627THF 0x82
-#define WBSIO_ID_W83627EHF 0x88
-#define WBSIO_ID_W83627DHG 0xa0
-#define WBSIO_ID_W83627DHGP 0xb0
-#define WBSIO_ID_W83627SF 0x59
-#define WBSIO_ID_W83637HF 0x70
-#define WBSIO_ID_W83697HF 0x60
-
-/* Logical Device Number (LDN) Assignments */
-#define WBSIO_LDN_HM 0x0b
-
-/* Hardware Monitor Control Registers (LDN B) */
-#define WBSIO_HM_ADDR_MSB 0x60 /* Address [15:8] */
-#define WBSIO_HM_ADDR_LSB 0x61 /* Address [7:0] */
+#include <dev/isa/wbsioreg.h>
#ifdef WBSIO_DEBUG
#define DPRINTF(x) printf x
@@ -139,6 +110,7 @@ wbsio_probe(struct device *parent, void *match, void *aux)
case WBSIO_ID_W83627DHGP:
case WBSIO_ID_W83637HF:
case WBSIO_ID_W83697HF:
+ case WBSIO_ID_NCT6776F:
ia->ipa_nio = 1;
ia->ipa_io[0].length = WBSIO_IOSIZE;
ia->ipa_nmem = 0;
@@ -156,7 +128,7 @@ wbsio_attach(struct device *parent, struct device *self, void *aux)
struct wbsio_softc *sc = (void *)self;
struct isa_attach_args *ia = aux;
struct isa_attach_args nia;
- u_int8_t reg, reg0, reg1;
+ u_int8_t devid, reg, reg0, reg1;
u_int16_t iobase;
/* Map ISA I/O space */
@@ -171,8 +143,8 @@ wbsio_attach(struct device *parent, struct device *self, void *aux)
wbsio_conf_enable(sc->sc_iot, sc->sc_ioh);
/* Read device ID */
- reg = wbsio_conf_read(sc->sc_iot, sc->sc_ioh, WBSIO_ID);
- switch (reg) {
+ devid = wbsio_conf_read(sc->sc_iot, sc->sc_ioh, WBSIO_ID);
+ switch (devid) {
case WBSIO_ID_W83627HF:
printf(": W83627HF");
break;
@@ -194,6 +166,9 @@ wbsio_attach(struct device *parent, struct device *self, void *aux)
case WBSIO_ID_W83697HF:
printf(": W83697HF");
break;
+ case WBSIO_ID_NCT6776F:
+ printf(": NCT6776F");
+ break;
}
/* Read device revision */
@@ -223,6 +198,8 @@ wbsio_attach(struct device *parent, struct device *self, void *aux)
nia = *ia;
nia.ia_iobase = iobase;
+ nia.ia_aux = (void *)(u_long)devid; /* pass devid down to wb_match() */
+
config_found(self, &nia, wbsio_print);
}
diff --git a/sys/dev/isa/wbsioreg.h b/sys/dev/isa/wbsioreg.h
new file mode 100644
index 00000000000..a5dd42f467f
--- /dev/null
+++ b/sys/dev/isa/wbsioreg.h
@@ -0,0 +1,36 @@
+/* $OpenBSD */
+
+/*
+ * Winbond LPC Super I/O driver registers
+ */
+
+/* ISA bus registers */
+#define WBSIO_INDEX 0x00 /* Configuration Index Register */
+#define WBSIO_DATA 0x01 /* Configuration Data Register */
+
+#define WBSIO_IOSIZE 0x02 /* ISA I/O space size */
+
+#define WBSIO_CONF_EN_MAGIC 0x87 /* enable configuration mode */
+#define WBSIO_CONF_DS_MAGIC 0xaa /* disable configuration mode */
+
+/* Configuration Space Registers */
+#define WBSIO_LDN 0x07 /* Logical Device Number */
+#define WBSIO_ID 0x20 /* Device ID */
+#define WBSIO_REV 0x21 /* Device Revision */
+
+#define WBSIO_ID_W83627HF 0x52
+#define WBSIO_ID_W83627THF 0x82
+#define WBSIO_ID_W83627EHF 0x88
+#define WBSIO_ID_W83627DHG 0xa0
+#define WBSIO_ID_W83627DHGP 0xb0
+#define WBSIO_ID_W83627SF 0x59
+#define WBSIO_ID_W83637HF 0x70
+#define WBSIO_ID_W83697HF 0x60
+#define WBSIO_ID_NCT6776F 0xc3
+
+/* Logical Device Number (LDN) Assignments */
+#define WBSIO_LDN_HM 0x0b
+
+/* Hardware Monitor Control Registers (LDN B) */
+#define WBSIO_HM_ADDR_MSB 0x60 /* Address [15:8] */
+#define WBSIO_HM_ADDR_LSB 0x61 /* Address [7:0] */