summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--distrib/sets/lists/man/mi1
-rw-r--r--share/man/man4/Makefile5
-rw-r--r--share/man/man4/adt.44
-rw-r--r--share/man/man4/iic.44
-rw-r--r--share/man/man4/schenv.443
-rw-r--r--sys/arch/i386/conf/GENERIC3
-rw-r--r--sys/dev/i2c/adt7460.c143
-rw-r--r--sys/dev/i2c/files.i2c7
-rw-r--r--sys/dev/i2c/sch5017.c336
9 files changed, 113 insertions, 433 deletions
diff --git a/distrib/sets/lists/man/mi b/distrib/sets/lists/man/mi
index 81302aa393f..d11e2376d31 100644
--- a/distrib/sets/lists/man/mi
+++ b/distrib/sets/lists/man/mi
@@ -1531,7 +1531,6 @@
./usr/share/man/cat4/safte.0
./usr/share/man/cat4/san.0
./usr/share/man/cat4/sbus.0
-./usr/share/man/cat4/schenv.0
./usr/share/man/cat4/scsi.0
./usr/share/man/cat4/scsibus.0
./usr/share/man/cat4/sd.0
diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile
index 7d3830fb5a9..c80fc3d59b3 100644
--- a/share/man/man4/Makefile
+++ b/share/man/man4/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.350 2006/04/10 00:54:58 deraadt Exp $
+# $OpenBSD: Makefile,v 1.351 2006/04/10 17:30:36 deraadt Exp $
MAN= aac.4 ac97.4 acphy.4 acpi.4 acpihpet.4 acpitimer.4 \
adc.4 addcom.4 admcts.4 admlc.4 admtemp.4 \
@@ -32,8 +32,7 @@ MAN= aac.4 ac97.4 acphy.4 acpi.4 acpihpet.4 acpitimer.4 \
pf.4 pflog.4 pfsync.4 piixpm.4 pim.4 \
pms.4 ppb.4 ppp.4 pppoe.4 pty.4 puc.4 qsphy.4 radio.4 raid.4 ral.4 \
random.4 ray.4 rd.4 re.4 rgephy.4 rl.4 rln.4 rlphy.4 route.4 rt.4 \
- rtfps.4 rtii.4 rtw.4 safe.4 safte.4 san.4 sbus.4 scsi.4 schenv.4 \
- sd.4 ses.4 \
+ rtfps.4 rtii.4 rtw.4 safe.4 safte.4 san.4 sbus.4 scsi.4 sd.4 ses.4 \
sequencer.4 sf.4 sf2r.4 sfr.4 siop.4 sis.4 sk.4 sl.4 sm.4 \
speaker.4 sppp.4 sqphy.4 ss.4 st.4 ste.4 stge.4 sti.4 stp.4 sv.4 \
systrace.4 tb.4 tcic.4 tcp.4 termios.4 ti.4 tl.4 \
diff --git a/share/man/man4/adt.4 b/share/man/man4/adt.4
index 339b60de212..88b3dd060c7 100644
--- a/share/man/man4/adt.4
+++ b/share/man/man4/adt.4
@@ -1,4 +1,4 @@
-.\" $OpenBSD: adt.4,v 1.7 2006/03/04 02:58:14 deraadt Exp $
+.\" $OpenBSD: adt.4,v 1.8 2006/04/10 17:30:36 deraadt Exp $
.\"
.\" Copyright (c) 2005 Theo de Raadt <deraadt@openbsd.org>
.\"
@@ -29,7 +29,7 @@ driver provides support for the Analog Devices ADT7460,
Analog Devices ADT7467, Analog Devices ADT7476,
Analog Devices ADM1027, National Semiconductor LM85,
National Semiconductor LM96000,
-and SMSC EMC6D10x temperature sensors.
+SMSC EMC6D10x, and SMSC SCH5017 temperature sensors.
The sensor possesses a collection of sensor values which are
made available through the
.Xr sysctl 8
diff --git a/share/man/man4/iic.4 b/share/man/man4/iic.4
index e71b6ac8f2a..e37901b8a36 100644
--- a/share/man/man4/iic.4
+++ b/share/man/man4/iic.4
@@ -1,4 +1,4 @@
-.\" $OpenBSD: iic.4,v 1.48 2006/04/10 08:42:57 jmc Exp $
+.\" $OpenBSD: iic.4,v 1.49 2006/04/10 17:30:37 deraadt Exp $
.\"
.\" Copyright (c) 2004, 2006 Alexander Yurchenko <grange@openbsd.org>
.\"
@@ -137,8 +137,6 @@ Maxim MAX6642/MAX6690 temperature sensor
Philips PCA955[467] GPIO
.It Xr pcfadc 4
Philips PCF8591 I2C Analogue to Digital Converter
-.It Xr schenv 4
-SMSC SCH5017 temperature sensor
.It Xr tsl 4
TAOS TSL2560/61 light-to-digital converter
.El
diff --git a/share/man/man4/schenv.4 b/share/man/man4/schenv.4
deleted file mode 100644
index 3dfd0bcee38..00000000000
--- a/share/man/man4/schenv.4
+++ /dev/null
@@ -1,43 +0,0 @@
-.\" $OpenBSD: schenv.4,v 1.2 2006/04/10 08:46:16 jmc Exp $
-.\"
-.\" Copyright (c) 2005 Theo de Raadt <deraadt@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 May 16, 2004
-.Dt SCHENV 4
-.Os
-.Sh NAME
-.Nm schenv
-.Nd SMSC SCH5017 temperature sensor
-.Sh SYNOPSIS
-.Cd "schenv* at iic?"
-.Sh DESCRIPTION
-The
-.Nm
-driver provides support for the SMSC SCH5017.
-The sensor possesses a collection of sensor values which are
-made available through the
-.Xr sysctl 8
-interface.
-.Sh SEE ALSO
-.Xr iic 4 ,
-.Xr intro 4 ,
-.Xr sensorsd 8 ,
-.Xr sysctl 8
-.Sh AUTHORS
-.An -nosplit
-The
-.Nm
-driver was written by
-.An Roman Hunt .
diff --git a/sys/arch/i386/conf/GENERIC b/sys/arch/i386/conf/GENERIC
index 3bf047bc949..f5ac878926b 100644
--- a/sys/arch/i386/conf/GENERIC
+++ b/sys/arch/i386/conf/GENERIC
@@ -1,4 +1,4 @@
-# $OpenBSD: GENERIC,v 1.481 2006/04/10 00:55:00 deraadt Exp $
+# $OpenBSD: GENERIC,v 1.482 2006/04/10 17:30:38 deraadt Exp $
#
# For further information on compiling OpenBSD kernels, see the config(8)
# man page.
@@ -140,7 +140,6 @@ maxtmp* at iic? # Maxim MAX6642/MAX6690
asbtm* at iic? # Asus ASB100
wbenv* at iic? # Winbond W83L784R/W83L785R/W83L785TS-L
glenv* at iic? # Genesys Logic GL518SM
-schenv* at iic? # SMSC SCH5017
#isagpio0 at isa? port 0x78 # ISA I/O mapped as GPIO
#isagpio1 at isa? port 0x80
diff --git a/sys/dev/i2c/adt7460.c b/sys/dev/i2c/adt7460.c
index 8d8ee4f4c99..c328ec0ad29 100644
--- a/sys/dev/i2c/adt7460.c
+++ b/sys/dev/i2c/adt7460.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: adt7460.c,v 1.9 2006/04/09 21:06:33 deraadt Exp $ */
+/* $OpenBSD: adt7460.c,v 1.10 2006/04/10 17:30:38 deraadt Exp $ */
/*
* Copyright (c) 2005 Mark Kettenis
@@ -25,7 +25,10 @@
/* ADT7460 registers */
#define ADT7460_2_5V 0x20
-#define ADT7460_VCCP1 0x22
+#define ADT7460_VCCP 0x21
+#define ADT7460_VCC 0x22
+#define ADT7460_V5 0x23
+#define ADT7460_V12 0x24
#define ADT7460_REM1_TEMP 0x25
#define ADT7460_LOCAL_TEMP 0x26
#define ADT7460_REM2_TEMP 0x27
@@ -39,24 +42,53 @@
#define ADT7460_TACH4H 0x2f
#define ADT7460_REVISION 0x3f
#define ADT7460_CONFIG 0x40
+#define ADT7460_CONFIG_Vcc 0x80
/* Sensors */
#define ADT_2_5V 0
-#define ADT_VCCP1 1
-#define ADT_REM1_TEMP 2
-#define ADT_LOCAL_TEMP 3
-#define ADT_REM2_TEMP 4
-#define ADT_TACH1 5
-#define ADT_TACH2 6
-#define ADT_TACH3 7
-#define ADT_TACH4 8
-#define ADT_NUM_SENSORS 9
+#define ADT_VCCP 1
+#define ADT_VCC 2
+#define ADT_V5 3
+#define ADT_V12 4
+#define ADT_REM1_TEMP 5
+#define ADT_LOCAL_TEMP 6
+#define ADT_REM2_TEMP 7
+#define ADT_TACH1 8
+#define ADT_TACH2 9
+#define ADT_TACH3 10
+#define ADT_TACH4 11
+#define ADT_NUM_SENSORS 12
+
+struct adt_chip {
+ const char *name;
+ short v25, vccp, vcc, v5, v12;
+ short type;
+} adt_chips[] = {
+ /* register 0x20 0x21 0x22 0x23 0x24 type */
+ /* 2.5v vccp vcc 5v 12v */
+
+ { "adt7460", 2500, 2700, 3300, 5000, 12000, 7460 },
+ { "adt7467", 2500, 2700, 3300, 5000, 12000, 7467 },
+ { "adt7476", 2500, 2700, 3300, 5000, 12000, 7467 },
+ { "adm1027", 2500, 2250, 3300, 5000, 12000, 1027 },
+ { "lm85", 2500, 2700, 3300, 5000, 12000, 7467 },
+ { "emc6d100", 2500, 2700, 3300, 5000, 12000, 7460 },
+ { "emc6w201", 2500, 2700, 3300, 5000, 12000, 7460 },
+ { "lm96000", 2500, 2700, 3300, 5000, 12000, 7460 },
+ { "sch5017", 2500, 2250, 3300, 5000, 12000, 7460 }
+};
+
+struct adt_chip adt_chips_adm1027_vcc5 =
+ { "adm1027", 2500, 2250, 5000, 5000, 12000, 7460 };
+
struct adt_softc {
struct device sc_dev;
i2c_tag_t sc_tag;
i2c_addr_t sc_addr;
int sc_chip;
+ u_int8_t sc_config;
+ struct adt_chip *chip;
struct sensor sc_sensor[ADT_NUM_SENSORS];
};
@@ -78,16 +110,11 @@ int
adt_match(struct device *parent, void *match, void *aux)
{
struct i2c_attach_args *ia = aux;
+ int i;
- if (strcmp(ia->ia_name, "adt7460") == 0 ||
- strcmp(ia->ia_name, "adt7467") == 0 ||
- strcmp(ia->ia_name, "adt7476") == 0 ||
- strcmp(ia->ia_name, "adm1027") == 0 ||
- strcmp(ia->ia_name, "lm85") == 0 ||
- strcmp(ia->ia_name, "lm96000") == 0 ||
- strcmp(ia->ia_name, "emc6d100") == 0 ||
- strcmp(ia->ia_name, "emc6w201") == 0)
- return (1);
+ for (i = 0; i < sizeof(adt_chips) / sizeof(adt_chips[0]); i++)
+ if (strcmp(ia->ia_name, adt_chips[i].name) == 0)
+ return (1);
return (0);
}
@@ -96,7 +123,7 @@ adt_attach(struct device *parent, struct device *self, void *aux)
{
struct adt_softc *sc = (struct adt_softc *)self;
struct i2c_attach_args *ia = aux;
- u_int8_t cmd, rev, data;
+ u_int8_t cmd, rev, data, conf;
int i;
sc->sc_tag = ia->ia_tag;
@@ -104,11 +131,12 @@ adt_attach(struct device *parent, struct device *self, void *aux)
iic_acquire_bus(sc->sc_tag, 0);
- sc->sc_chip = 7460;
- /* check for the fancy "extension" chips XXX */
- if (strcmp(ia->ia_name, "adt7467") == 0 ||
- strcmp(ia->ia_name, "adt7467") == 0)
- sc->sc_chip = 7467;
+ for (i = 0; i < sizeof(adt_chips) / sizeof(adt_chips[0]); i++) {
+ if (strcmp(ia->ia_name, adt_chips[i].name) == 0) {
+ sc->chip = &adt_chips[i];
+ break;
+ }
+ }
cmd = ADT7460_REVISION;
if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP,
@@ -118,6 +146,18 @@ adt_attach(struct device *parent, struct device *self, void *aux)
return;
}
+ cmd = ADT7460_CONFIG;
+ if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP,
+ sc->sc_addr, &cmd, sizeof cmd, &conf, sizeof conf, 0)) {
+ iic_release_bus(sc->sc_tag, 0);
+ printf(": cannot read config register\n");
+ return;
+ }
+
+ /* check if adm1027 is running in V5 mode */
+ if (sc->sc_chip == 1027 && (conf & ADT7460_CONFIG_Vcc))
+ sc->chip = &adt_chips_adm1027_vcc5;
+
if (sc->sc_chip == 7460) {
data = 1;
cmd = ADT7460_CONFIG;
@@ -131,7 +171,7 @@ adt_attach(struct device *parent, struct device *self, void *aux)
iic_release_bus(sc->sc_tag, 0);
- printf(": %s (ADT%d) rev 0x%02x", ia->ia_name, sc->sc_chip, rev);
+ printf(": %s rev 0x%02x", ia->ia_name, rev);
/* Initialize sensor data. */
for (i = 0; i < ADT_NUM_SENSORS; i++)
@@ -142,9 +182,21 @@ adt_attach(struct device *parent, struct device *self, void *aux)
strlcpy(sc->sc_sensor[ADT_2_5V].desc, "+2.5Vin",
sizeof(sc->sc_sensor[ADT_2_5V].desc));
- sc->sc_sensor[ADT_VCCP1].type = SENSOR_VOLTS_DC;
- strlcpy(sc->sc_sensor[ADT_VCCP1].desc, "Vccp1",
- sizeof(sc->sc_sensor[ADT_VCCP1].desc));
+ sc->sc_sensor[ADT_VCCP].type = SENSOR_VOLTS_DC;
+ strlcpy(sc->sc_sensor[ADT_VCCP].desc, "Vccp",
+ sizeof(sc->sc_sensor[ADT_VCCP].desc));
+
+ sc->sc_sensor[ADT_VCC].type = SENSOR_VOLTS_DC;
+ strlcpy(sc->sc_sensor[ADT_VCC].desc, "Vcc",
+ sizeof(sc->sc_sensor[ADT_VCC].desc));
+
+ sc->sc_sensor[ADT_V5].type = SENSOR_VOLTS_DC;
+ strlcpy(sc->sc_sensor[ADT_V5].desc, "+5V",
+ sizeof(sc->sc_sensor[ADT_V5].desc));
+
+ sc->sc_sensor[ADT_V12].type = SENSOR_VOLTS_DC;
+ strlcpy(sc->sc_sensor[ADT_V12].desc, "+12V",
+ sizeof(sc->sc_sensor[ADT_V12].desc));
sc->sc_sensor[ADT_REM1_TEMP].type = SENSOR_TEMP;
strlcpy(sc->sc_sensor[ADT_REM1_TEMP].desc, "Remote1 Temp",
@@ -163,15 +215,15 @@ adt_attach(struct device *parent, struct device *self, void *aux)
sizeof(sc->sc_sensor[ADT_TACH1].desc));
sc->sc_sensor[ADT_TACH2].type = SENSOR_FANRPM;
- strlcpy(sc->sc_sensor[ADT_TACH2].desc, "TACH1",
+ strlcpy(sc->sc_sensor[ADT_TACH2].desc, "TACH2",
sizeof(sc->sc_sensor[ADT_TACH2].desc));
sc->sc_sensor[ADT_TACH3].type = SENSOR_FANRPM;
- strlcpy(sc->sc_sensor[ADT_TACH3].desc, "TACH1",
+ strlcpy(sc->sc_sensor[ADT_TACH3].desc, "TACH3",
sizeof(sc->sc_sensor[ADT_TACH3].desc));
sc->sc_sensor[ADT_TACH4].type = SENSOR_FANRPM;
- strlcpy(sc->sc_sensor[ADT_TACH4].desc, "TACH1",
+ strlcpy(sc->sc_sensor[ADT_TACH4].desc, "TACH4",
sizeof(sc->sc_sensor[ADT_TACH4].desc));
if (sensor_task_register(sc, adt_refresh, 5)) {
@@ -190,7 +242,10 @@ struct {
u_int8_t cmd;
} worklist[] = {
{ ADT_2_5V, ADT7460_2_5V },
- { ADT_VCCP1, ADT7460_VCCP1 },
+ { ADT_VCCP, ADT7460_VCCP },
+ { ADT_VCC, ADT7460_VCC },
+ { ADT_V5, ADT7460_V5 },
+ { ADT_V12, ADT7460_V12 },
{ ADT_REM1_TEMP, ADT7460_REM1_TEMP },
{ ADT_LOCAL_TEMP, ADT7460_LOCAL_TEMP },
{ ADT_REM2_TEMP, ADT7460_REM2_TEMP },
@@ -221,10 +276,24 @@ adt_refresh(void *arg)
sc->sc_sensor[i].flags &= ~SENSOR_FINVALID;
switch (worklist[i].sensor) {
case ADT_2_5V:
- sc->sc_sensor[i].value = 2500000 * data / 192;
+ sc->sc_sensor[i].value = sc->chip->v25 * 1000 *
+ data / 192;
+ break;
+ case ADT_VCCP:
+ sc->sc_sensor[i].value = sc->chip->vccp * 1000 *
+ data / 192;
+ break;
+ case ADT_VCC:
+ sc->sc_sensor[i].value = sc->chip->vcc * 1000 *
+ data / 192;
+ break;
+ case ADT_V5:
+ sc->sc_sensor[i].value = sc->chip->v5 * 1000 *
+ data / 192;
break;
- case ADT_VCCP1:
- sc->sc_sensor[i].value = 2700000 * data / 192;
+ case ADT_V12:
+ sc->sc_sensor[i].value = sc->chip->v12 * 1000 *
+ data / 192;
break;
case ADT_LOCAL_TEMP:
case ADT_REM1_TEMP:
diff --git a/sys/dev/i2c/files.i2c b/sys/dev/i2c/files.i2c
index ae13da5d188..06067fcfc82 100644
--- a/sys/dev/i2c/files.i2c
+++ b/sys/dev/i2c/files.i2c
@@ -1,4 +1,4 @@
-# $OpenBSD: files.i2c,v 1.32 2006/04/10 00:53:11 deraadt Exp $
+# $OpenBSD: files.i2c,v 1.33 2006/04/10 17:30:38 deraadt Exp $
# $NetBSD: files.i2c,v 1.3 2003/10/20 16:24:10 briggs Exp $
define i2c {[addr = -1], [size = -1]}
@@ -107,8 +107,3 @@ file dev/i2c/w83l784r.c wbenv
device glenv
attach glenv at i2c
file dev/i2c/gl518sm.c glenv
-
-# SMSC SCH5017
-device schenv
-attach schenv at i2c
-file dev/i2c/sch5017.c schenv
diff --git a/sys/dev/i2c/sch5017.c b/sys/dev/i2c/sch5017.c
deleted file mode 100644
index ca1a560ded3..00000000000
--- a/sys/dev/i2c/sch5017.c
+++ /dev/null
@@ -1,336 +0,0 @@
-/*
- * Copyright (c) 2006 Roman Hunt
- *
- * 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.
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/device.h>
-#include <sys/sensors.h>
-
-#include <dev/i2c/i2cvar.h>
-
-/*
- * SCH5017 Registers
- */
-#define SCH5017_VCCP 0x21
-#define SCH5017_VCC 0x22
-#define SCH5017_5V 0x23
-#define SCH5017_12V 0x24
-#define SCH5017_RTEMP1 0x25
-#define SCH5017_ITEMP 0x26
-#define SCH5017_RTEMP2 0x27
-#define SCH5017_FAN1_LSB 0x28
-#define SCH5017_FAN1_MSB 0x29
-#define SCH5017_FAN2_LSB 0x2a
-#define SCH5017_FAN2_MSB 0x2b
-#define SCH5017_FAN3_LSB 0x2c
-#define SCH5017_FAN3_MSB 0x2d
-#define SCH5017_FAN4_LSB 0x2e
-#define SCH5017_FAN4_MSB 0x2f
-#define SCH5017_VERSION 0x3f
-
-/*
- * Sensors
- */
-#define SCHENV_VCCP 0
-#define SCHENV_VCC 1
-#define SCHENV_5V 2
-#define SCHENV_12V 3
-#define SCHENV_RTEMP1 4
-#define SCHENV_ITEMP 5
-#define SCHENV_RTEMP2 6
-#define SCHENV_FAN1 7
-#define SCHENV_FAN2 8
-#define SCHENV_FAN3 9
-#define SCHENV_FAN4 10
-#define SCHENV_SENSOR_COUNT 11
-
-struct schenv_softc {
- struct device sc_dev;
- i2c_tag_t sc_tag;
- i2c_addr_t sc_addr;
-
- struct sensor sc_sensor[SCHENV_SENSOR_COUNT];
-};
-
-int schenv_match(struct device *, void *, void *);
-void schenv_attach(struct device *, struct device *, void *);
-
-void schenv_refresh(void *);
-
-struct cfattach schenv_ca = {
- sizeof(struct schenv_softc), schenv_match, schenv_attach
-};
-
-struct cfdriver schenv_cd = {
- NULL, "schenv", DV_DULL
-};
-
-int
-schenv_match(struct device *parent, void *match, void *aux)
-{
- struct i2c_attach_args *ia = aux;
-
- if (strcmp(ia->ia_name, "sch5017") == 0)
- return (1);
- return (0);
-}
-
-void
-schenv_attach(struct device *parent, struct device *self, void *aux)
-{
- struct schenv_softc *sc = (struct schenv_softc *)self;
- struct i2c_attach_args *ia = aux;
- u_int8_t cmd, data;
- int i;
-
- sc->sc_tag = ia->ia_tag;
- sc->sc_addr = ia->ia_addr;
-
- iic_acquire_bus(sc->sc_tag, 0);
-
- cmd = SCH5017_VERSION;
- if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP,
- sc->sc_addr, &cmd, sizeof cmd, &data, sizeof data, 0)) {
- iic_release_bus(sc->sc_tag, 0);
- printf(": cannot read revision register\n");
- return;
- }
- printf(": %s rev %x", ia->ia_name, (data >> 4));
-
- iic_release_bus(sc->sc_tag, 0);
-
- /*
- * Initialize sensors
- */
- for (i = 0; i < SCHENV_SENSOR_COUNT; i++)
- strlcpy(sc->sc_sensor[i].device, sc->sc_dev.dv_xname,
- sizeof(sc->sc_sensor[i].device));
-
- sc->sc_sensor[SCHENV_VCCP].type = SENSOR_VOLTS_DC;
- strlcpy(sc->sc_sensor[SCHENV_VCCP].desc, "Vccp",
- sizeof(sc->sc_sensor[SCHENV_VCCP].desc));
-
- sc->sc_sensor[SCHENV_VCC].type = SENSOR_VOLTS_DC;
- strlcpy(sc->sc_sensor[SCHENV_VCC].desc, "Vcc",
- sizeof(sc->sc_sensor[SCHENV_VCC].desc));
-
- sc->sc_sensor[SCHENV_5V].type = SENSOR_VOLTS_DC;
- strlcpy(sc->sc_sensor[SCHENV_5V].desc, "+5Vin",
- sizeof(sc->sc_sensor[SCHENV_5V].desc));
-
- sc->sc_sensor[SCHENV_12V].type = SENSOR_VOLTS_DC;
- strlcpy(sc->sc_sensor[SCHENV_12V].desc, "+12Vin",
- sizeof(sc->sc_sensor[SCHENV_12V].desc));
-
- sc->sc_sensor[SCHENV_RTEMP1].type = SENSOR_TEMP;
- strlcpy(sc->sc_sensor[SCHENV_RTEMP1].desc, "Ext. Temp. 1",
- sizeof(sc->sc_sensor[SCHENV_RTEMP1].desc));
-
- sc->sc_sensor[SCHENV_ITEMP].type = SENSOR_TEMP;
- strlcpy(sc->sc_sensor[SCHENV_ITEMP].desc, "Int. Temp.",
- sizeof(sc->sc_sensor[SCHENV_ITEMP].desc));
-
- sc->sc_sensor[SCHENV_RTEMP2].type = SENSOR_TEMP;
- strlcpy(sc->sc_sensor[SCHENV_RTEMP2].desc, "Ext. Temp. 2",
- sizeof(sc->sc_sensor[SCHENV_RTEMP1].desc));
-
- sc->sc_sensor[SCHENV_FAN1].type = SENSOR_FANRPM;
- strlcpy(sc->sc_sensor[SCHENV_FAN1].desc, "FAN1",
- sizeof(sc->sc_sensor[SCHENV_FAN1].desc));
-
- sc->sc_sensor[SCHENV_FAN2].type = SENSOR_FANRPM;
- strlcpy(sc->sc_sensor[SCHENV_FAN2].desc, "FAN2",
- sizeof(sc->sc_sensor[SCHENV_FAN2].desc));
-
- sc->sc_sensor[SCHENV_FAN3].type = SENSOR_FANRPM;
- strlcpy(sc->sc_sensor[SCHENV_FAN3].desc, "FAN3",
- sizeof(sc->sc_sensor[SCHENV_FAN3].desc));
-
- sc->sc_sensor[SCHENV_FAN4].type = SENSOR_FANRPM;
- strlcpy(sc->sc_sensor[SCHENV_FAN4].desc, "FAN4",
- sizeof(sc->sc_sensor[SCHENV_FAN4].desc));
-
- if (sensor_task_register(sc, schenv_refresh, 5)) {
- printf(", unable to register update task\n");
- return;
- }
-
- for (i = 0; i < SCHENV_SENSOR_COUNT; i++)
- sensor_add(&sc->sc_sensor[i]);
-
- printf("\n");
-}
-
-void
-schenv_refresh(void *arg)
-{
- struct schenv_softc *sc = arg;
- u_int8_t cmd, data, data2;
- u_int16_t fanword;
- int sensor;
- iic_acquire_bus(sc->sc_tag, 0);
-
- for (sensor = 0; sensor < SCHENV_SENSOR_COUNT; sensor++) {
- cmd = SCH5017_VCCP + sensor;
- if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP,
- sc->sc_addr, &cmd, sizeof cmd, &data, sizeof data, 0)) {
- sc->sc_sensor[sensor].flags |= SENSOR_FINVALID;
- continue;
- }
-
- sc->sc_sensor[sensor].flags &= ~SENSOR_FINVALID;
- switch (sensor) {
- case SCHENV_VCCP:
- sc->sc_sensor[sensor].value = 3000000 / 256 * data;
- break;
- case SCHENV_VCC:
- sc->sc_sensor[sensor].value = 4380000 / 256 * data;
- break;
- case SCHENV_5V:
- sc->sc_sensor[sensor].value = 6640000 / 256 * data;
- break;
- case SCHENV_12V:
- sc->sc_sensor[sensor].value = 16000000 / 256 * data;
- break;
- case SCHENV_RTEMP1:
- /* FALLTHROUGH */
- case SCHENV_ITEMP:
- /* FALLTHROUGH */
- case SCHENV_RTEMP2:
- if (data == 0x80) {
- sc->sc_sensor[sensor].flags |= SENSOR_FINVALID;
- break;
- }
-
- sc->sc_sensor[sensor].value =
- (int8_t)data * 1000000 + 273150000;
-
- break;
- case SCHENV_FAN1:
- cmd = SCH5017_FAN1_LSB;
- if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP,
- sc->sc_addr, &cmd, sizeof cmd, &data,
- sizeof data, 0)) {
- sc->sc_sensor[sensor].flags |=
- SENSOR_FINVALID;
- break;
- }
-
- cmd = SCH5017_FAN1_MSB;
- if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP,
- sc->sc_addr, &cmd, sizeof cmd, &data2,
- sizeof data2, 0)) {
- sc->sc_sensor[sensor].flags |=
- SENSOR_FINVALID;
- break;
- }
- fanword = data2;
- fanword = fanword << 8;
- fanword |= data;
- if (fanword == 0xFFFF) {
- sc->sc_sensor[sensor].flags |= SENSOR_FINVALID;
- break;
- }
- sc->sc_sensor[sensor].value = fanword;
- break;
- case SCHENV_FAN2:
- cmd = SCH5017_FAN2_LSB;
- if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP,
- sc->sc_addr, &cmd, sizeof cmd, &data,
- sizeof data, 0)) {
- sc->sc_sensor[sensor].flags |=
- SENSOR_FINVALID;
- break;
- }
-
- cmd = SCH5017_FAN2_MSB;
- if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP,
- sc->sc_addr, &cmd, sizeof cmd, &data2,
- sizeof data2, 0)) {
- sc->sc_sensor[sensor].flags |=
- SENSOR_FINVALID;
- break;
- }
- fanword = data2;
- fanword = fanword << 8;
- fanword |= data;
- if (fanword == 0xFFFF) {
- sc->sc_sensor[sensor].flags |= SENSOR_FINVALID;
- break;
- }
- sc->sc_sensor[sensor].value = fanword;
- break;
- case SCHENV_FAN3:
- cmd = SCH5017_FAN3_LSB;
- if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP,
- sc->sc_addr, &cmd, sizeof cmd, &data,
- sizeof data, 0)) {
- sc->sc_sensor[sensor].flags |=
- SENSOR_FINVALID;
- break;
- }
-
- cmd = SCH5017_FAN3_MSB;
- if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP,
- sc->sc_addr, &cmd, sizeof cmd, &data2,
- sizeof data2, 0)) {
- sc->sc_sensor[sensor].flags |=
- SENSOR_FINVALID;
- break;
- }
- fanword = data2;
- fanword = fanword << 8;
- fanword |= data;
- if (fanword == 0xFFFF) {
- sc->sc_sensor[sensor].flags |= SENSOR_FINVALID;
- break;
- }
- sc->sc_sensor[sensor].value = fanword;
- break;
- case SCHENV_FAN4:
- cmd = SCH5017_FAN4_LSB;
- if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP,
- sc->sc_addr, &cmd, sizeof cmd, &data,
- sizeof data, 0)) {
- sc->sc_sensor[sensor].flags |=
- SENSOR_FINVALID;
- break;
- }
-
- cmd = SCH5017_FAN4_MSB;
- if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP,
- sc->sc_addr, &cmd, sizeof cmd, &data2,
- sizeof data2, 0)) {
- sc->sc_sensor[sensor].flags |=
- SENSOR_FINVALID;
- break;
- }
- fanword = data2;
- fanword = fanword << 8;
- fanword |= data;
- if (fanword == 0xFFFF) {
- sc->sc_sensor[sensor].flags |= SENSOR_FINVALID;
- break;
- }
- sc->sc_sensor[sensor].value = fanword;
- break;
- default:
- sc->sc_sensor[sensor].flags |= SENSOR_FINVALID;
- break;
- }
- }
- iic_release_bus(sc->sc_tag, 0);
-}