diff options
-rw-r--r-- | share/man/man4/Makefile | 5 | ||||
-rw-r--r-- | share/man/man4/isa.4 | 6 | ||||
-rw-r--r-- | share/man/man4/schsio.4 | 69 | ||||
-rw-r--r-- | sys/arch/amd64/conf/GENERIC | 7 | ||||
-rw-r--r-- | sys/arch/i386/conf/GENERIC | 7 | ||||
-rw-r--r-- | sys/dev/isa/files.isa | 7 | ||||
-rw-r--r-- | sys/dev/isa/sch311x.c | 467 |
7 files changed, 561 insertions, 7 deletions
diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile index b20cb365e63..c1df61d3afe 100644 --- a/share/man/man4/Makefile +++ b/share/man/man4/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.474 2009/01/16 05:03:52 kevlo Exp $ +# $OpenBSD: Makefile,v 1.475 2009/01/23 20:32:22 mk Exp $ MAN= aac.4 ac97.4 acphy.4 \ acpi.4 acpiac.4 acpiasus.4 acpibat.4 acpibtn.4 acpicpu.4 acpidock.4 \ @@ -40,7 +40,8 @@ MAN= aac.4 ac97.4 acphy.4 \ pms.4 ppb.4 ppp.4 pppoe.4 pty.4 puc.4 pwdog.4 qsphy.4 radio.4 raid.4 \ ral.4 random.4 ray.4 rd.4 re.4 rgephy.4 ricohrtc.4 \ rl.4 rlphy.4 route.4 rt.4 rum.4 run.4 \ - rtfps.4 rtii.4 rtw.4 safe.4 safte.4 san.4 sbt.4 sbus.4 scsi.4 sd.4 \ + rtfps.4 rtii.4 rtw.4 safe.4 safte.4 san.4 sbt.4 sbus.4 schsio.4 \ + scsi.4 sd.4 \ sdmmc.4 sdhc.4 ses.4 \ sequencer.4 sf.4 sf2r.4 sfr.4 sili.4 siop.4 sis.4 sk.4 sl.4 sli.4 \ sm.4 softraid.4 spdmem.4 sdtemp.4 speaker.4 sppp.4 sqphy.4 \ diff --git a/share/man/man4/isa.4 b/share/man/man4/isa.4 index 797ec4cba3c..1ab1f3d0dcf 100644 --- a/share/man/man4/isa.4 +++ b/share/man/man4/isa.4 @@ -1,4 +1,4 @@ -.\" $OpenBSD: isa.4,v 1.62 2009/01/16 14:43:00 jmc Exp $ +.\" $OpenBSD: isa.4,v 1.63 2009/01/23 20:32:22 mk Exp $ .\" $NetBSD: isa.4,v 1.19 2000/03/18 16:54:37 augustss Exp $ .\" .\" Copyright (c) 2000 Theo de Raadt. All rights reserved. @@ -31,7 +31,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: January 16 2009 $ +.Dd $Mdocdate: January 23 2009 $ .Dt ISA 4 .Os .Sh NAME @@ -200,6 +200,8 @@ temperature, voltage, and fan sensor with watchdog timer National Semiconductor LM78/79/81 temperature, voltage, and fan sensor .It Xr nsclpcsio 4 National Semiconductor PC87366 LPC Super I/O with GPIO +.It Xr schsio 4 +SMSC SCH311x LPC Super I/O .It Xr viasio 4 VIA VT1211 LPC Super I/O .It Xr wbsio 4 diff --git a/share/man/man4/schsio.4 b/share/man/man4/schsio.4 new file mode 100644 index 00000000000..4b03d0badea --- /dev/null +++ b/share/man/man4/schsio.4 @@ -0,0 +1,69 @@ +.\" $OpenBSD: schsio.4,v 1.1 2009/01/23 20:32:22 mk Exp $ +.\" +.\" Copyright (c) 2009 Michael Knudsen <mk@openbsd.org> +.\" +.\" Permission to use, copy, modify, and distribute this software for any +.\" purpose with or without fee is hereby granted, provided that the above +.\" copyright notice and this permission notice appear in all copies. +.\" +.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +.Dd $Mdocdate: January 23 2009 $ +.Dt SCHSIO 4 +.Os +.Sh NAME +.Nm schsio +.Nd SMSC SCH311x LPC Super I/O +.Sh SYNOPSIS +.Cd "schsio* at isa? port 0x2e flags 0x0000" +.Cd "schsio* at isa? port 0x4e flags 0x0000" +.Cd "schsio* at isa? port 0x162e flags 0x0000" +.Cd "schsio* at isa? port 0x164e flags 0x0000" +.Sh DESCRIPTION +The +.Nm +driver provides support for the SMSC SCH3112, SCH3114, and SCH3116 +ICs. +Among other things, the devices contain environment sensors, a watchdog +timer, and fan control. +The +.Nm +driver currently only supports the environment sensors. +The hardware provides the following sensors: +.Bl -column "Internal diode" "Units" "Typical" -offset indent +.It Sy "Sensor" Ta Sy "Units" Ta Sy "Typical use" +.It Li "Internal diode" Ta "uK" Ta "IC internal thermal diode" +.It Li "Remote diode 1" Ta "uK" Ta "External thermal diode" +.It Li "Remove diode 2" Ta "uK" Ta "External thermal diode" +.It Li "FAN1" Ta "RPM" Ta "Fan tachometer" +.It Li "FAN2" Ta "RPM" Ta "Fan tachometer" +.It Li "FAN3" Ta "RPM" Ta "Fan tachometer" +.It Li "+2.5V" Ta "uV" Ta "Voltage" +.It Li "+1.5V (Vccp)" Ta "uV" Ta "Voltage" +.It Li "+3.3V (VCC)" Ta "uV" Ta "Voltage" +.It Li "+5V" Ta "uV" Ta "Voltage" +.It Li "+12V" Ta "uV" Ta "Voltage" +.It Li "+3.3V (VTR)" Ta "uV" Ta "Voltage" +.It Li "+3V (Vbat)" Ta "uV" Ta "Voltage" +.El +.Sh SEE ALSO +.Xr intro 4 , +.Xr isa 4 , +.Xr watchdog 4 , +.Xr sensorsd 8 , +.Xr sysctl 8 +.Sh HISTORY +The +.Nm +driver first appeared in +.Ox 4.5 . +.Sh AUTHORS +The +.Nm +driver was written by +.An Michael Knudsen Aq mk@openbsd.org . diff --git a/sys/arch/amd64/conf/GENERIC b/sys/arch/amd64/conf/GENERIC index 0678609356b..eb63ca9a462 100644 --- a/sys/arch/amd64/conf/GENERIC +++ b/sys/arch/amd64/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.255 2009/01/18 04:41:26 kevlo Exp $ +# $OpenBSD: GENERIC,v 1.256 2009/01/23 20:32:22 mk Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -78,6 +78,11 @@ it* at isa? port 0x2e # ITE IT8705F, IT8712F, IT8716F, IT8718F, it* at isa? port 0x4e # IT8726F and SiS SiS950 monitors and # watchdog timer +schsio* at isa? port 0x2e # SMSC SCH311x Super I/O +schsio* at isa? port 0x4e +#schsio* at isa? port 0x162e +#schsio* at isa? port 0x164e + viaenv* at pci? # VIA VT82C686A hardware monitor #viasio* at isa? port 0x2e flags 0x0000 # VIA VT1211 LPC Super I/O #viasio* at isa? port 0x4e flags 0x0000 diff --git a/sys/arch/i386/conf/GENERIC b/sys/arch/i386/conf/GENERIC index 70e83754990..b8d960bc75b 100644 --- a/sys/arch/i386/conf/GENERIC +++ b/sys/arch/i386/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.649 2009/01/18 04:41:26 kevlo Exp $ +# $OpenBSD: GENERIC,v 1.650 2009/01/23 20:32:22 mk Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -131,6 +131,11 @@ it* at isa? port 0x2e # ITE IT8705F, IT8712F, IT8716F, it* at isa? port 0x4e # IT8718F, IT8726F and SiS SiS950 # monitors and watchdog timer +schsio* at isa? port 0x2e # SMSC SCH311x Super I/O +schsio* at isa? port 0x4e +#schsio* at isa? port 0x162e +#schsio* at isa? port 0x164e + viaenv* at pci? # VIA VT82C686A hardware monitor viasio* at isa? port 0x2e flags 0x0000 # VIA VT1211 LPC Super I/O viasio* at isa? port 0x4e flags 0x0000 diff --git a/sys/dev/isa/files.isa b/sys/dev/isa/files.isa index e9051b11971..1489c93ac09 100644 --- a/sys/dev/isa/files.isa +++ b/sys/dev/isa/files.isa @@ -1,4 +1,4 @@ -# $OpenBSD: files.isa,v 1.104 2008/04/23 13:28:59 jsg Exp $ +# $OpenBSD: files.isa,v 1.105 2009/01/23 20:32:22 mk Exp $ # $NetBSD: files.isa,v 1.21 1996/05/16 03:45:55 mycroft Exp $ # # Config file and device description for machine-independent ISA code. @@ -337,6 +337,11 @@ device wbsio {} attach wbsio at isa file dev/isa/wbsio.c wbsio +# SMSC SCH311x Super I/O +device schsio {} +attach schsio at isa +file dev/isa/sch311x.c schsio + # National Semiconductor LM78/79/81 and compatible hardware monitors attach lm at isa with lm_isa attach lm at wbsio with lm_wbsio diff --git a/sys/dev/isa/sch311x.c b/sys/dev/isa/sch311x.c new file mode 100644 index 00000000000..d288f94803c --- /dev/null +++ b/sys/dev/isa/sch311x.c @@ -0,0 +1,467 @@ +/* $OpenBSD: sch311x.c,v 1.1 2009/01/23 20:32:22 mk Exp $ */ +/* + * Copyright (c) 2008 Mark Kettenis <kettenis@openbsd.org> + * Copyright (c) 2009 Michael Knudsen <mk@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* + * SMSC SCH3112, SCH3114, and SCH3116 LPC Super I/O driver. + */ + +#include <sys/param.h> +#include <sys/device.h> +#include <sys/kernel.h> +#include <sys/systm.h> +#include <sys/types.h> +#include <sys/sensors.h> + +#include <machine/bus.h> + +#include <dev/isa/isareg.h> +#include <dev/isa/isavar.h> + +/* Device identifiers */ +#define SCHSIO_ID_SCH3112 0x7c +#define SCHSIO_ID_SCH3114 0x7d +#define SCHSIO_ID_SCH3116 0x7f + +#define SCHSIO_IOSIZE 0x02 +#define SCHSIO_PORT_CONFIG 0x00 + +/* These are used in configuration mode */ +#define SCHSIO_PORT_INDEX 0x00 +#define SCHSIO_PORT_DATA 0x01 + +#define SCHSIO_CONFIG_ENTER 0x55 +#define SCHSIO_CONFIG_LEAVE 0xaa + +/* Register definitions */ +#define SCHSIO_IDX_LDEVSEL 0x07 /* Logical device select */ +#define SCHSIO_IDX_DEVICE 0x20 /* Device ID */ +#define SCHSIO_IDX_REV 0x21 /* Device revision */ + +#define SCHSIO_IDX_BASE_HI 0x60 /* Configuration base address */ +#define SCHSIO_IDX_BASE_LO 0x61 + +/* Logical devices */ +#define SCHSIO_LDEV_RUNTIME 0x0a /* holds wdog and sensors */ + + +/* Hardware monitor */ +#define SCHSIO_HWM_INTERVAL 5 /* seconds */ + +/* Register access */ +#define SCHSIO_HWM_IOSIZE 0x02 +#define SCHSIO_HWM_OFFSET 0x70 +#define SCHSIO_HWM_INDEX 0x00 +#define SCHSIO_HWM_DATA 0x01 + +/* Sensor definitions */ +/* Voltage */ +#define SCHSIO_HWM_VOLT1 0x20 +#define SCHSIO_HWM_VOLT2 0x21 +#define SCHSIO_HWM_VOLT3 0x22 +#define SCHSIO_HWM_VOLT4 0x23 +#define SCHSIO_HWM_VOLT5 0x24 +#define SCHSIO_HWM_VOLT6 0x99 +#define SCHSIO_HWM_VOLT7 0x9a + +/* Temperature */ +#define SCHSIO_HWM_TEMP1 0x26 +#define SCHSIO_HWM_TEMP2 0x25 +#define SCHSIO_HWM_TEMP3 0x27 + +/* Fan speed */ +#define SCHSIO_HWM_TACH1_L 0x28 +#define SCHSIO_HWM_TACH1_U 0x29 +#define SCHSIO_HWM_TACH2_L 0x2a +#define SCHSIO_HWM_TACH2_U 0x2b +#define SCHSIO_HWM_TACH3_L 0x2c +#define SCHSIO_HWM_TACH3_U 0x2d + +/* 11111 = 90kHz * 10^9 */ +#define SCHSIO_FAN_RPM(x) (1000000000 / ((x) * 11111) * 60) + +#define SCHSIO_CONV_VOLT1 66400 +#define SCHSIO_CONV_VOLT2 20000 +#define SCHSIO_CONV_VOLT3 43800 +#define SCHSIO_CONV_VOLT4 66400 +#define SCHSIO_CONV_VOLT5 160000 +#define SCHSIO_CONV_VOLT6 43800 +#define SCHSIO_CONV_VOLT7 43800 +#define SCHSIO_VOLT_MUV(x, k) (1000000 * (x) / 2560000 * (k)) + +#define SCHSIO_TEMP_MUK(x) (((x) + 273) * 1000000) + +#define SCHSIO_SENSORS 13 + +#define SCHSIO_SENSOR_FAN1 0 +#define SCHSIO_SENSOR_FAN2 1 +#define SCHSIO_SENSOR_FAN3 2 + +#define SCHSIO_SENSOR_VOLT1 3 +#define SCHSIO_SENSOR_VOLT2 4 +#define SCHSIO_SENSOR_VOLT3 5 +#define SCHSIO_SENSOR_VOLT4 6 +#define SCHSIO_SENSOR_VOLT5 7 +#define SCHSIO_SENSOR_VOLT6 8 +#define SCHSIO_SENSOR_VOLT7 9 + +#define SCHSIO_SENSOR_TEMP1 10 +#define SCHSIO_SENSOR_TEMP2 11 +#define SCHSIO_SENSOR_TEMP3 12 + + +#ifdef SCHSIO_DEBUG +#define DPRINTF(x) printf x +#else +#define DPRINTF(x) +#endif + +#define DEVNAME(x) ((x)->sc_dev.dv_xname) + +struct schsio_softc { + struct device sc_dev; + + bus_space_tag_t sc_iot; + bus_space_handle_t sc_ioh; + + bus_space_handle_t sc_hwm_ioh; + + struct ksensordev sc_sensordev; + struct ksensor sc_sensor[SCHSIO_SENSORS]; +}; + +int schsio_probe(struct device *, void *, void *); +void schsio_attach(struct device *, struct device *, void *); +int schsio_print(void *, const char *); + +static __inline void schsio_config_enable(bus_space_tag_t iot, + bus_space_handle_t ioh); +static __inline void schsio_config_disable(bus_space_tag_t iot, + bus_space_handle_t ioh); + +u_int8_t schsio_config_read(bus_space_tag_t iot, bus_space_handle_t ioh, + int reg); +void schsio_config_write(bus_space_tag_t iot, + bus_space_handle_t ioh, int reg, u_int8_t val); + +/* HWM prototypes */ +void schsio_hwm_init(struct schsio_softc *sc); +void schsio_hwm_update(void *arg); + +u_int8_t schsio_hwm_read(struct schsio_softc *sc, int reg); + + +struct cfattach schsio_ca = { + sizeof(struct schsio_softc), + schsio_probe, + schsio_attach +}; + +struct cfdriver schsio_cd = { + NULL, "schsio", DV_DULL +}; + +static __inline void +schsio_config_enable(bus_space_tag_t iot, bus_space_handle_t ioh) +{ + bus_space_write_1(iot, ioh, SCHSIO_PORT_CONFIG, SCHSIO_CONFIG_ENTER); +} + +static __inline void +schsio_config_disable(bus_space_tag_t iot, bus_space_handle_t ioh) +{ + bus_space_write_1(iot, ioh, SCHSIO_PORT_CONFIG, SCHSIO_CONFIG_LEAVE); +} + +u_int8_t +schsio_config_read(bus_space_tag_t iot, bus_space_handle_t ioh, int reg) +{ + bus_space_write_1(iot, ioh, SCHSIO_PORT_INDEX, reg); + return (bus_space_read_1(iot, ioh, SCHSIO_PORT_DATA)); +} + +void +schsio_config_write(bus_space_tag_t iot, bus_space_handle_t ioh, int reg, + u_int8_t val) +{ + bus_space_write_1(iot, ioh, SCHSIO_PORT_INDEX, reg); + bus_space_write_1(iot, ioh, SCHSIO_PORT_DATA, val); +} + +int +schsio_probe(struct device *parent, void *match, void *aux) +{ + struct isa_attach_args *ia = aux; + bus_space_tag_t iot; + bus_space_handle_t ioh; + u_int8_t reg; + + /* Match by device ID */ + iot = ia->ia_iot; + if (bus_space_map(iot, ia->ipa_io[0].base, SCHSIO_IOSIZE, 0, &ioh)) + return (0); + + schsio_config_enable(iot, ioh); + reg = schsio_config_read(iot, ioh, SCHSIO_IDX_DEVICE); + schsio_config_disable(iot, ioh); + + bus_space_unmap(iot, ia->ipa_io[0].base, SCHSIO_IOSIZE); + + switch (reg) { + case SCHSIO_ID_SCH3112: + case SCHSIO_ID_SCH3114: + case SCHSIO_ID_SCH3116: + ia->ipa_nio = 1; + ia->ipa_io[0].length = SCHSIO_IOSIZE; + ia->ipa_nmem = 0; + ia->ipa_nirq = 0; + ia->ipa_ndrq = 0; + + return (1); + break; + } + + return (0); +} + +void +schsio_attach(struct device *parent, struct device *self, void *aux) +{ + struct schsio_softc *sc = (void *)self; + struct isa_attach_args *ia = aux; + u_int8_t reg; + + /* Map ISA I/O space */ + sc->sc_iot = ia->ia_iot; + if (bus_space_map(sc->sc_iot, ia->ipa_io[0].base, + SCHSIO_IOSIZE, 0, &sc->sc_ioh)) { + printf(": can't map I/O space\n"); + return; + } + + /* Enter configuration mode */ + schsio_config_enable(sc->sc_iot, sc->sc_ioh); + + /* Read device ID */ + reg = schsio_config_read(sc->sc_iot, sc->sc_ioh, SCHSIO_IDX_DEVICE); + switch (reg) { + case SCHSIO_ID_SCH3112: + printf(": SCH3112"); + break; + case SCHSIO_ID_SCH3114: + printf(": SCH3114"); + break; + case SCHSIO_ID_SCH3116: + printf(": SCH3116"); + break; + } + + /* Read device revision */ + reg = schsio_config_read(sc->sc_iot, sc->sc_ioh, SCHSIO_IDX_REV); + printf(" rev 0x%02x", reg); + + schsio_hwm_init(sc); + + printf("\n"); + + /* Escape from configuration mode */ + schsio_config_disable(sc->sc_iot, sc->sc_ioh); + +} + +void +schsio_hwm_init(struct schsio_softc *sc) +{ + int i; + u_int16_t iobase; + u_int8_t reg0, reg1; + + /* Select runtime registers logical device */ + schsio_config_write(sc->sc_iot, sc->sc_ioh, SCHSIO_IDX_LDEVSEL, + SCHSIO_LDEV_RUNTIME); + + reg0 = schsio_config_read(sc->sc_iot, sc->sc_ioh, + SCHSIO_IDX_BASE_HI); + reg1 = schsio_config_read(sc->sc_iot, sc->sc_ioh, + SCHSIO_IDX_BASE_LO); + iobase = ((reg0 << 8) | reg1) + SCHSIO_HWM_OFFSET; + + + if (bus_space_map(sc->sc_iot, iobase, + SCHSIO_HWM_IOSIZE, 0, &sc->sc_hwm_ioh)) { + printf(": can't map I/O space\n"); + return; + } + + /* Set up sensors */ + strlcpy(sc->sc_sensor[SCHSIO_SENSOR_FAN1].desc, "", + sizeof(sc->sc_sensor[SCHSIO_SENSOR_FAN1].desc)); + strlcpy(sc->sc_sensor[SCHSIO_SENSOR_FAN2].desc, "", + sizeof(sc->sc_sensor[SCHSIO_SENSOR_FAN2].desc)); + strlcpy(sc->sc_sensor[SCHSIO_SENSOR_FAN3].desc, "", + sizeof(sc->sc_sensor[SCHSIO_SENSOR_FAN3].desc)); + for (i = SCHSIO_SENSOR_FAN1; i < SCHSIO_SENSOR_FAN3 + 1; i++) { + sc->sc_sensor[i].type = SENSOR_FANRPM; + sc->sc_sensor[i].flags = SENSOR_FINVALID; + sc->sc_sensor[i].status = SENSOR_S_OK; + sc->sc_sensor[i].value = 0; + } + + strlcpy(sc->sc_sensor[SCHSIO_SENSOR_VOLT1].desc, "+2.5V", + sizeof(sc->sc_sensor[SCHSIO_SENSOR_VOLT1].desc)); + strlcpy(sc->sc_sensor[SCHSIO_SENSOR_VOLT2].desc, "+1.5V (Vccp)", + sizeof(sc->sc_sensor[SCHSIO_SENSOR_VOLT2].desc)); + strlcpy(sc->sc_sensor[SCHSIO_SENSOR_VOLT3].desc, "+3.3V (VCC)", + sizeof(sc->sc_sensor[SCHSIO_SENSOR_VOLT3].desc)); + strlcpy(sc->sc_sensor[SCHSIO_SENSOR_VOLT4].desc, "+5V", + sizeof(sc->sc_sensor[SCHSIO_SENSOR_VOLT4].desc)); + strlcpy(sc->sc_sensor[SCHSIO_SENSOR_VOLT5].desc, "+12V", + sizeof(sc->sc_sensor[SCHSIO_SENSOR_VOLT5].desc)); + strlcpy(sc->sc_sensor[SCHSIO_SENSOR_VOLT6].desc, "+3.3V (VTR)", + sizeof(sc->sc_sensor[SCHSIO_SENSOR_VOLT6].desc)); + strlcpy(sc->sc_sensor[SCHSIO_SENSOR_VOLT7].desc, "+3V (Vbat)", + sizeof(sc->sc_sensor[SCHSIO_SENSOR_VOLT7].desc)); + for (i = SCHSIO_SENSOR_VOLT1; i < SCHSIO_SENSOR_VOLT7 + 1; i++) { + sc->sc_sensor[i].type = SENSOR_VOLTS_DC; + sc->sc_sensor[i].flags = SENSOR_FINVALID; + sc->sc_sensor[i].status = SENSOR_S_OK; + sc->sc_sensor[i].value = 0; + } + + strlcpy(sc->sc_sensor[SCHSIO_SENSOR_TEMP1].desc, "Internal", + sizeof(sc->sc_sensor[SCHSIO_SENSOR_TEMP1].desc)); + strlcpy(sc->sc_sensor[SCHSIO_SENSOR_TEMP2].desc, "Remote", + sizeof(sc->sc_sensor[SCHSIO_SENSOR_TEMP2].desc)); + strlcpy(sc->sc_sensor[SCHSIO_SENSOR_TEMP3].desc, "Remote", + sizeof(sc->sc_sensor[SCHSIO_SENSOR_TEMP3].desc)); + for (i = SCHSIO_SENSOR_TEMP1; i < SCHSIO_SENSOR_TEMP3 + 1; i++) { + sc->sc_sensor[i].type = SENSOR_TEMP; + sc->sc_sensor[i].flags = SENSOR_FINVALID; + sc->sc_sensor[i].status = SENSOR_S_OK; + sc->sc_sensor[i].value = 0; + } + + strlcpy(sc->sc_sensordev.xname, DEVNAME(sc), + sizeof(sc->sc_sensordev.xname)); + + for (i = 0; i < SCHSIO_SENSORS; i++) + sensor_attach(&sc->sc_sensordev, &sc->sc_sensor[i]); + + sensordev_install(&sc->sc_sensordev); + + sensor_task_register(sc, schsio_hwm_update, SCHSIO_HWM_INTERVAL); +} + +void +schsio_hwm_update(void *arg) +{ + struct schsio_softc *sc; + u_int16_t tach; + int8_t temp; + u_int8_t volt; + u_int8_t reg0, reg1; + + sc = (struct schsio_softc *)arg; + + schsio_config_enable(sc->sc_iot, sc->sc_ioh); + + /* Select logical device a */ + schsio_config_write(sc->sc_iot, sc->sc_ioh, SCHSIO_IDX_LDEVSEL, + SCHSIO_LDEV_RUNTIME); + + reg0 = schsio_hwm_read(sc, SCHSIO_HWM_TACH1_L); + reg1 = schsio_hwm_read(sc, SCHSIO_HWM_TACH1_U); + tach = (reg1 << 8) | reg0; + sc->sc_sensor[SCHSIO_SENSOR_FAN1].value = SCHSIO_FAN_RPM(tach); + sc->sc_sensor[SCHSIO_SENSOR_FAN1].flags = + (tach == 0xffff) ? SENSOR_FINVALID : 0; + + reg0 = schsio_hwm_read(sc, SCHSIO_HWM_TACH2_L); + reg1 = schsio_hwm_read(sc, SCHSIO_HWM_TACH2_U); + tach = (reg1 << 8) | reg0; + sc->sc_sensor[SCHSIO_SENSOR_FAN2].value = SCHSIO_FAN_RPM(tach); + sc->sc_sensor[SCHSIO_SENSOR_FAN2].flags = + (tach == 0xffff) ? SENSOR_FINVALID : 0; + + reg0 = schsio_hwm_read(sc, SCHSIO_HWM_TACH3_L); + reg1 = schsio_hwm_read(sc, SCHSIO_HWM_TACH3_U); + tach = (reg1 << 8) | reg0; + sc->sc_sensor[SCHSIO_SENSOR_FAN3].value = SCHSIO_FAN_RPM(tach); + sc->sc_sensor[SCHSIO_SENSOR_FAN3].flags = + (tach == 0xffff) ? SENSOR_FINVALID : 0; + + volt = schsio_hwm_read(sc, SCHSIO_HWM_VOLT1); + sc->sc_sensor[SCHSIO_SENSOR_VOLT1].value = + SCHSIO_VOLT_MUV(volt, SCHSIO_CONV_VOLT1); + sc->sc_sensor[SCHSIO_SENSOR_VOLT1].flags = 0; + + volt = schsio_hwm_read(sc, SCHSIO_HWM_VOLT2); + sc->sc_sensor[SCHSIO_SENSOR_VOLT2].value = + SCHSIO_VOLT_MUV(volt, SCHSIO_CONV_VOLT2); + sc->sc_sensor[SCHSIO_SENSOR_VOLT2].flags = 0; + + volt = schsio_hwm_read(sc, SCHSIO_HWM_VOLT3); + sc->sc_sensor[SCHSIO_SENSOR_VOLT3].value = + SCHSIO_VOLT_MUV(volt, SCHSIO_CONV_VOLT3); + sc->sc_sensor[SCHSIO_SENSOR_VOLT3].flags = 0; + + volt = schsio_hwm_read(sc, SCHSIO_HWM_VOLT4); + sc->sc_sensor[SCHSIO_SENSOR_VOLT4].value = + SCHSIO_VOLT_MUV(volt, SCHSIO_CONV_VOLT4); + sc->sc_sensor[SCHSIO_SENSOR_VOLT4].flags = 0; + + volt = schsio_hwm_read(sc, SCHSIO_HWM_VOLT5); + sc->sc_sensor[SCHSIO_SENSOR_VOLT5].value = + SCHSIO_VOLT_MUV(volt, SCHSIO_CONV_VOLT5); + sc->sc_sensor[SCHSIO_SENSOR_VOLT5].flags = 0; + + volt = schsio_hwm_read(sc, SCHSIO_HWM_VOLT6); + sc->sc_sensor[SCHSIO_SENSOR_VOLT6].value = + SCHSIO_VOLT_MUV(volt, SCHSIO_CONV_VOLT6); + sc->sc_sensor[SCHSIO_SENSOR_VOLT6].flags = 0; + + volt = schsio_hwm_read(sc, SCHSIO_HWM_VOLT7); + sc->sc_sensor[SCHSIO_SENSOR_VOLT7].value = + SCHSIO_VOLT_MUV(volt, SCHSIO_CONV_VOLT7); + sc->sc_sensor[SCHSIO_SENSOR_VOLT7].flags = 0; + + temp = schsio_hwm_read(sc, SCHSIO_HWM_TEMP1); + sc->sc_sensor[SCHSIO_SENSOR_TEMP1].value = SCHSIO_TEMP_MUK(temp); + sc->sc_sensor[SCHSIO_SENSOR_TEMP1].flags = + ((uint8_t)temp == 0x80) ? SENSOR_FINVALID : 0; + + temp = schsio_hwm_read(sc, SCHSIO_HWM_TEMP2); + sc->sc_sensor[SCHSIO_SENSOR_TEMP2].value = SCHSIO_TEMP_MUK(temp); + sc->sc_sensor[SCHSIO_SENSOR_TEMP2].flags = + ((uint8_t)temp == 0x80) ? SENSOR_FINVALID : 0; + + temp = schsio_hwm_read(sc, SCHSIO_HWM_TEMP3); + sc->sc_sensor[SCHSIO_SENSOR_TEMP3].value = SCHSIO_TEMP_MUK(temp); + sc->sc_sensor[SCHSIO_SENSOR_TEMP3].flags = + ((uint8_t)temp == 0x80) ? SENSOR_FINVALID : 0; + + schsio_config_disable(sc->sc_iot, sc->sc_ioh); + +} + +u_int8_t +schsio_hwm_read(struct schsio_softc *sc, int reg) +{ + bus_space_write_1(sc->sc_iot, sc->sc_hwm_ioh, SCHSIO_HWM_INDEX, reg); + return (bus_space_read_1(sc->sc_iot, sc->sc_hwm_ioh, SCHSIO_HWM_DATA)); +} + |