diff options
-rw-r--r-- | share/man/man4/Makefile | 4 | ||||
-rw-r--r-- | share/man/man4/iic.4 | 6 | ||||
-rw-r--r-- | share/man/man4/sdtemp.4 | 38 | ||||
-rw-r--r-- | sys/dev/i2c/files.i2c | 7 | ||||
-rw-r--r-- | sys/dev/i2c/sdtemp.c | 122 |
5 files changed, 172 insertions, 5 deletions
diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile index 31c9e8b4d1a..c5f38d3e14b 100644 --- a/share/man/man4/Makefile +++ b/share/man/man4/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.445 2008/03/27 01:54:44 cnst Exp $ +# $OpenBSD: Makefile,v 1.446 2008/04/07 01:31:46 deraadt Exp $ MAN= aac.4 ac97.4 acphy.4 \ acpi.4 acpiac.4 acpibat.4 acpibtn.4 acpicpu.4 acpidock.4 \ @@ -43,7 +43,7 @@ MAN= aac.4 ac97.4 acphy.4 \ rtfps.4 rtii.4 rtw.4 safe.4 safte.4 san.4 sbt.4 sbus.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 speaker.4 sppp.4 sqphy.4 \ + sm.4 softraid.4 spdmem.4 sdtemp.4 speaker.4 sppp.4 sqphy.4 \ ss.4 st.4 ste.4 stge.4 sti.4 \ stp.4 sv.4 systrace.4 tcic.4 tcp.4 termios.4 tht.4 ti.4 tl.4 \ tlphy.4 thmc.4 tqphy.4 trm.4 trunk.4 tsl.4 tty.4 tun.4 twe.4 txp.4 \ diff --git a/share/man/man4/iic.4 b/share/man/man4/iic.4 index c551e57de57..d6bf41d6d5f 100644 --- a/share/man/man4/iic.4 +++ b/share/man/man4/iic.4 @@ -1,4 +1,4 @@ -.\" $OpenBSD: iic.4,v 1.68 2008/03/23 08:00:38 cnst Exp $ +.\" $OpenBSD: iic.4,v 1.69 2008/04/07 01:31:46 deraadt Exp $ .\" .\" Copyright (c) 2004, 2006 Alexander Yurchenko <grange@openbsd.org> .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: March 23 2008 $ +.Dd $Mdocdate: April 7 2008 $ .Dt IIC 4 .Os .Sh NAME @@ -156,6 +156,8 @@ Philips PCF8591 temperature sensor Ricoh RS5C372 Real Time Clock .It Xr spdmem 4 Serial Presence Detect memory +.It Xr sdtemp 4 +SO-DIMM (JC-42.4) temperature sensor .It Xr tda 4 Philips TDA8444 fan controller .It Xr thmc 4 diff --git a/share/man/man4/sdtemp.4 b/share/man/man4/sdtemp.4 new file mode 100644 index 00000000000..4ac00b3d922 --- /dev/null +++ b/share/man/man4/sdtemp.4 @@ -0,0 +1,38 @@ +.\" $OpenBSD: sdtemp.4,v 1.1 2008/04/07 01:31:46 deraadt Exp $ +.\" +.\" Copyright (c) 2008 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 $Mdocdate: April 7 2008 $ +.Dt SDTEMP 4 +.Os +.Sh NAME +.Nm sdtemp +.Nd SO-DIMM (JC-42.4) temperature sensor +.Sh SYNOPSIS +.Cd "sdtemp* at iic?" +.Sh DESCRIPTION +The +.Nm +driver retrieves temperature sensor information from memory +modules which contain sensor chips defined in JEDEC JC-42.4. +.Pp +Current sensor chips include the NPX SE98 and AD ADT7408. +.Sh SEE ALSO +.Xr iic 4 +.Sh HISTORY +The +.Nm +device driver first appeared in +.Ox 4.4 . diff --git a/sys/dev/i2c/files.i2c b/sys/dev/i2c/files.i2c index f23f1759f99..205158cc824 100644 --- a/sys/dev/i2c/files.i2c +++ b/sys/dev/i2c/files.i2c @@ -1,4 +1,4 @@ -# $OpenBSD: files.i2c,v 1.44 2008/03/23 07:04:48 cnst Exp $ +# $OpenBSD: files.i2c,v 1.45 2008/04/07 01:31:44 deraadt Exp $ # $NetBSD: files.i2c,v 1.3 2003/10/20 16:24:10 briggs Exp $ define i2c {[addr = -1], [size = -1]} @@ -152,3 +152,8 @@ file dev/i2c/thmc50.c thmc device spdmem attach spdmem at i2c file dev/i2c/spdmem.c spdmem + +# SO-DIMM (JC-42.4) temperature sensor +device sdtemp +attach sdtemp at i2c +file dev/i2c/sdtemp.c sdtemp diff --git a/sys/dev/i2c/sdtemp.c b/sys/dev/i2c/sdtemp.c new file mode 100644 index 00000000000..4ba1d3d1a9c --- /dev/null +++ b/sys/dev/i2c/sdtemp.c @@ -0,0 +1,122 @@ +/* $OpenBSD: sdtemp.c,v 1.1 2008/04/07 01:31:44 deraadt Exp $ */ + +/* + * Copyright (c) 2008 Theo de Raadt + * + * 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> + +/* JDEC JC-42.4 registers */ +#define JC_TEMP 0x05 +#define JC_TEMP_SIGN 0x10 + +/* Sensors */ +#define JCTEMP_TEMP 0 +#define JCTEMP_NUM_SENSORS 1 + +struct sdtemp_softc { + struct device sc_dev; + i2c_tag_t sc_tag; + i2c_addr_t sc_addr; + + struct ksensor sc_sensor[JCTEMP_NUM_SENSORS]; + struct ksensordev sc_sensordev; +}; + +int sdtemp_match(struct device *, void *, void *); +void sdtemp_attach(struct device *, struct device *, void *); +void sdtemp_refresh(void *); + +struct cfattach sdtemp_ca = { + sizeof(struct sdtemp_softc), sdtemp_match, sdtemp_attach +}; + +struct cfdriver sdtemp_cd = { + NULL, "sdtemp", DV_DULL +}; + +int +sdtemp_match(struct device *parent, void *match, void *aux) +{ + struct i2c_attach_args *ia = aux; + + if (strcmp(ia->ia_name, "se98") == 0 || + strcmp(ia->ia_name, "adt7408") == 0) + return (1); + return (0); +} + +void +sdtemp_attach(struct device *parent, struct device *self, void *aux) +{ + struct sdtemp_softc *sc = (struct sdtemp_softc *)self; + struct i2c_attach_args *ia = aux; + + sc->sc_tag = ia->ia_tag; + sc->sc_addr = ia->ia_addr; + + printf(": %s", ia->ia_name); + + /* Initialize sensor data. */ + strlcpy(sc->sc_sensordev.xname, sc->sc_dev.dv_xname, + sizeof(sc->sc_sensordev.xname)); + + sc->sc_sensor[JCTEMP_TEMP].type = SENSOR_TEMP; + strlcpy(sc->sc_sensor[JCTEMP_TEMP].desc, "Temperature", + sizeof(sc->sc_sensor[JCTEMP_TEMP].desc)); + + if (sensor_task_register(sc, sdtemp_refresh, 5) == NULL) { + printf(", unable to register update task\n"); + return; + } + + sensor_attach(&sc->sc_sensordev, &sc->sc_sensor[0]); + sensordev_install(&sc->sc_sensordev); + + printf("\n"); +} + +void +sdtemp_refresh(void *arg) +{ + struct sdtemp_softc *sc = arg; + u_int8_t cmd, data[2]; + int16_t sdata; + + iic_acquire_bus(sc->sc_tag, 0); + + cmd = JC_TEMP; + if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, sc->sc_addr, + &cmd, sizeof cmd, data, sizeof data, 0) == 0) { + sdata = ((data[0] << 8) | data[1]) & 0x0fff; + if (data[0] & JC_TEMP_SIGN) + sdata = -sdata; + sc->sc_sensor[JCTEMP_TEMP].value = + 273150000 + 62500 * sdata; + sc->sc_sensor[JCTEMP_TEMP].flags &= ~SENSOR_FINVALID; +#if 0 + printf("sdtemp %02x%02x %04x %d\n", data[0], data[1], + (u_int)sdata & 0xffff, + sc->sc_sensor[JCTEMP_TEMP].value); +#endif + } + + iic_release_bus(sc->sc_tag, 0); +} |