diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2005-12-28 20:35:43 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2005-12-28 20:35:43 +0000 |
commit | 2fda7f6e48644b59da5a2c20518f0a61c10f9f7a (patch) | |
tree | 41f5ee6bfc82d024fee050c7c09a2424438f7e69 /sys/dev/i2c | |
parent | 75131d753815072d0d0f4c98e26d3d4b8796060f (diff) |
attempt at fan measurement
Diffstat (limited to 'sys/dev/i2c')
-rw-r--r-- | sys/dev/i2c/adm1024.c | 25 | ||||
-rw-r--r-- | sys/dev/i2c/adm1026.c | 68 |
2 files changed, 89 insertions, 4 deletions
diff --git a/sys/dev/i2c/adm1024.c b/sys/dev/i2c/adm1024.c index a0fa5936e41..9e63c248212 100644 --- a/sys/dev/i2c/adm1024.c +++ b/sys/dev/i2c/adm1024.c @@ -1,4 +1,4 @@ -/* $OpenBSD: adm1024.c,v 1.5 2005/12/27 22:49:41 deraadt Exp $ */ +/* $OpenBSD: adm1024.c,v 1.6 2005/12/28 20:35:42 deraadt Exp $ */ /* * Copyright (c) 2005 Theo de Raadt @@ -35,6 +35,7 @@ #define ADM1024_FAN1 0x28 #define ADM1024_FAN2 0x29 #define ADM1024_STATUS2 0x42 +#define ADM1024_FANC 0x47 #define ADM1024_STATUS2_EXT 0x40 #define ADM1024_COMPANY 0x3e /* contains 0x41 */ #define ADM1024_STEPPING 0x3f /* contains 0x2? */ @@ -61,6 +62,8 @@ struct admlc_softc { i2c_addr_t sc_addr; struct sensor sc_sensor[ADMLC_NUM_SENSORS]; + int sc_fan1mul; + int sc_fan2mul; }; int admlc_match(struct device *, void *, void *); @@ -114,6 +117,16 @@ admlc_attach(struct device *parent, struct device *self, void *aux) return; } } + + cmd = ADM1024_FANC; + if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, + sc->sc_addr, &cmd, sizeof cmd, &data, sizeof data, 0)) { + printf(", unable to read fan setting\n"); + return; + } + sc->sc_fan1mul = 8800 * (1 << (data >> 4) & 0x3); + sc->sc_fan2mul = 8800 * (1 << (data >> 6) & 0x3); + iic_release_bus(sc->sc_tag, 0); /* Initialize sensor data. */ @@ -231,7 +244,15 @@ admlc_refresh(void *arg) sc->sc_addr, &cmd, sizeof cmd, &data, sizeof data, I2C_F_POLL) == 0) sc->sc_sensor[ADMLC_Vccp2].value = 2700000 * data / 192; - /* XXX read fan values */ + cmd = ADM1024_FAN1; + if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, + sc->sc_addr, &cmd, sizeof cmd, &data, sizeof data, I2C_F_POLL) == 0) + sc->sc_sensor[ADMLC_FAN1].value = sc->sc_fan1mul * data; + + cmd = ADM1024_FAN2; + if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, + sc->sc_addr, &cmd, sizeof cmd, &data, sizeof data, I2C_F_POLL) == 0) + sc->sc_sensor[ADMLC_FAN2].value = sc->sc_fan2mul * data; iic_release_bus(sc->sc_tag, 0); } diff --git a/sys/dev/i2c/adm1026.c b/sys/dev/i2c/adm1026.c index e27bdf01f1d..264cd5ae4ab 100644 --- a/sys/dev/i2c/adm1026.c +++ b/sys/dev/i2c/adm1026.c @@ -1,4 +1,4 @@ -/* $OpenBSD: adm1026.c,v 1.1 2005/12/28 00:21:43 deraadt Exp $ */ +/* $OpenBSD: adm1026.c,v 1.2 2005/12/28 20:35:42 deraadt Exp $ */ /* * Copyright (c) 2005 Theo de Raadt @@ -79,6 +79,7 @@ struct admcts_softc { i2c_addr_t sc_addr; struct sensor sc_sensor[ADMCTS_NUM_SENSORS]; + int sc_fanmul[8]; }; int admcts_match(struct device *, void *, void *); @@ -132,6 +133,31 @@ admcts_attach(struct device *parent, struct device *self, void *aux) return; } } + + cmd = ADM1026_FAN0123DIV; + if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, + sc->sc_addr, &cmd, sizeof cmd, &data, sizeof data, I2C_F_POLL)) { + iic_release_bus(sc->sc_tag, 0); + printf(": cannot get fan0123div register\n"); + return; + } + sc->sc_fanmul[0] = 8800 * (1 << (data >> 0) & 0x3); + sc->sc_fanmul[1] = 8800 * (1 << (data >> 2) & 0x3); + sc->sc_fanmul[2] = 8800 * (1 << (data >> 4) & 0x3); + sc->sc_fanmul[3] = 8800 * (1 << (data >> 6) & 0x3); + + cmd = ADM1026_FAN4567DIV; + if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, + sc->sc_addr, &cmd, sizeof cmd, &data, sizeof data, I2C_F_POLL)) { + iic_release_bus(sc->sc_tag, 0); + printf(": cannot get fan0123div register\n"); + return; + } + sc->sc_fanmul[4] = 8800 * (1 << (data >> 0) & 0x3); + sc->sc_fanmul[5] = 8800 * (1 << (data >> 2) & 0x3); + sc->sc_fanmul[6] = 8800 * (1 << (data >> 4) & 0x3); + sc->sc_fanmul[7] = 8800 * (1 << (data >> 6) & 0x3); + iic_release_bus(sc->sc_tag, 0); /* Initialize sensor data. */ @@ -281,7 +307,45 @@ admcts_refresh(void *arg) sc->sc_addr, &cmd, sizeof cmd, &data, sizeof data, I2C_F_POLL) == 0) sc->sc_sensor[ADMCTS_Vminus12].value = -2125000 * data / 192; - /* XXX read fan values */ + cmd = ADM1026_FAN0; + if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, + sc->sc_addr, &cmd, sizeof cmd, &data, sizeof data, I2C_F_POLL) == 0) + sc->sc_sensor[ADMCTS_FAN0].value = sc->sc_fanmul[0] * data; + + cmd = ADM1026_FAN1; + if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, + sc->sc_addr, &cmd, sizeof cmd, &data, sizeof data, I2C_F_POLL) == 0) + sc->sc_sensor[ADMCTS_FAN1].value = sc->sc_fanmul[1] * data; + + cmd = ADM1026_FAN2; + if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, + sc->sc_addr, &cmd, sizeof cmd, &data, sizeof data, I2C_F_POLL) == 0) + sc->sc_sensor[ADMCTS_FAN2].value = sc->sc_fanmul[2] * data; + + cmd = ADM1026_FAN3; + if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, + sc->sc_addr, &cmd, sizeof cmd, &data, sizeof data, I2C_F_POLL) == 0) + sc->sc_sensor[ADMCTS_FAN3].value = sc->sc_fanmul[3] * data; + + cmd = ADM1026_FAN4; + if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, + sc->sc_addr, &cmd, sizeof cmd, &data, sizeof data, I2C_F_POLL) == 0) + sc->sc_sensor[ADMCTS_FAN4].value = sc->sc_fanmul[4] * data; + + cmd = ADM1026_FAN5; + if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, + sc->sc_addr, &cmd, sizeof cmd, &data, sizeof data, I2C_F_POLL) == 0) + sc->sc_sensor[ADMCTS_FAN5].value = sc->sc_fanmul[5] * data; + + cmd = ADM1026_FAN6; + if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, + sc->sc_addr, &cmd, sizeof cmd, &data, sizeof data, I2C_F_POLL) == 0) + sc->sc_sensor[ADMCTS_FAN6].value = sc->sc_fanmul[6] * data; + + cmd = ADM1026_FAN7; + if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, + sc->sc_addr, &cmd, sizeof cmd, &data, sizeof data, I2C_F_POLL) == 0) + sc->sc_sensor[ADMCTS_FAN7].value = sc->sc_fanmul[7] * data; iic_release_bus(sc->sc_tag, 0); } |