summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2005-12-26 08:14:18 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2005-12-26 08:14:18 +0000
commitc99cc60e752e29a5735255ae50b2dbb761f9f41f (patch)
tree31b48768ec374821bc66e5d56f1cbe7bad4a19d1 /sys/dev
parentc8408a1cb3488bfb630e1559ad51742682ba1759 (diff)
add address qualifiers to a few chips (ie. they can only occur at certain
addresses) there are some "xeon" sensors that are actually real maxim1617, and hence have a 0xfe register containing maxim's identifier .. cope. remove totally bogus lm81 detection.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/i2c/adm1021.c30
-rw-r--r--sys/dev/i2c/i2c_scan.c60
2 files changed, 58 insertions, 32 deletions
diff --git a/sys/dev/i2c/adm1021.c b/sys/dev/i2c/adm1021.c
index c805aa10658..b576d9c54bb 100644
--- a/sys/dev/i2c/adm1021.c
+++ b/sys/dev/i2c/adm1021.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: adm1021.c,v 1.9 2005/12/26 01:59:36 deraadt Exp $ */
+/* $OpenBSD: adm1021.c,v 1.10 2005/12/26 08:14:17 deraadt Exp $ */
/*
* Copyright (c) 2005 Theo de Raadt
@@ -65,7 +65,7 @@ admtemp_match(struct device *parent, void *match, void *aux)
struct i2c_attach_args *ia = aux;
if (strcmp(ia->ia_name, "adm1021") == 0 ||
- strcmp(ia->ia_name, "xeon") == 0 ||
+ strcmp(ia->ia_name, "xeontemp") == 0 ||
strcmp(ia->ia_name, "maxim1617") == 0)
return (1);
return (0);
@@ -82,7 +82,7 @@ admtemp_attach(struct device *parent, struct device *self, void *aux)
sc->sc_tag = ia->ia_tag;
sc->sc_addr = ia->ia_addr;
- if (ia->ia_name && strcmp(ia->ia_name, "xeon") == 0) {
+ if (ia->ia_name && strcmp(ia->ia_name, "xeontemp") == 0) {
printf(": Xeon");
sc->sc_xeon = 1;
}
@@ -141,16 +141,28 @@ admtemp_refresh(void *arg)
cmd = ADM1021_EXT_TEMP;
if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, sc->sc_addr,
- &cmd, sizeof cmd, &sdata, sizeof sdata, I2C_F_POLL) == 0)
- sc->sc_sensor[ADMTEMP_EXT].value =
- 273150000 + 1000000 * sdata;
+ &cmd, sizeof cmd, &sdata, sizeof sdata, I2C_F_POLL) == 0) {
+ if (sdata == 0x7f) {
+ sc->sc_sensor[ADMTEMP_EXT].flags &= ~SENSOR_FINVALID;
+ } else {
+ sc->sc_sensor[ADMTEMP_EXT].value =
+ 273150000 + 1000000 * sdata;
+ sc->sc_sensor[ADMTEMP_EXT].flags &= ~SENSOR_FINVALID;
+ }
+ }
if (sc->sc_xeon == 0) {
cmd = ADM1021_INT_TEMP;
if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP, sc->sc_addr,
- &cmd, sizeof cmd, &sdata, sizeof sdata, I2C_F_POLL) == 0)
- sc->sc_sensor[ADMTEMP_INT].value =
- 273150000 + 1000000 * sdata;
+ &cmd, sizeof cmd, &sdata, sizeof sdata, I2C_F_POLL) == 0) {
+ if (sdata == 0x7f) {
+ sc->sc_sensor[ADMTEMP_INT].flags &= ~SENSOR_FINVALID;
+ } else {
+ sc->sc_sensor[ADMTEMP_INT].value =
+ 273150000 + 1000000 * sdata;
+ sc->sc_sensor[ADMTEMP_INT].flags &= ~SENSOR_FINVALID;
+ }
+ }
}
iic_release_bus(sc->sc_tag, 0);
diff --git a/sys/dev/i2c/i2c_scan.c b/sys/dev/i2c/i2c_scan.c
index b9abf0fda15..8ecbdf179fb 100644
--- a/sys/dev/i2c/i2c_scan.c
+++ b/sys/dev/i2c/i2c_scan.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: i2c_scan.c,v 1.17 2005/12/25 12:41:40 deraadt Exp $ */
+/* $OpenBSD: i2c_scan.c,v 1.18 2005/12/26 08:14:17 deraadt Exp $ */
/*
* Copyright (c) 2005 Alexander Yurchenko <grange@openbsd.org>
@@ -174,24 +174,28 @@ lm75probe(void)
}
#ifdef __i386__
-static int xeonprobe(u_int8_t);
+static char *xeonprobe(u_int8_t);
-static int
+static char *
xeonprobe(u_int8_t addr)
{
if (addr == 0x18 || addr == 0x1a || addr == 0x29 ||
addr == 0x2b || addr == 0x4c || addr == 0x4e) {
- int reg;
+ u_int8_t reg, val;
for (reg = 0x00; reg < 0x09; reg++)
if (probe(reg) == 0xff)
- return (0);
- for (reg = 0x09; reg <= 0xff; reg++)
- if (probe(reg) != 0xff)
- return (0);
- return (1);
+ return (NULL);
+ val = probe(0x09);
+ for (reg = 0x0a; reg < 0xfe; reg++)
+ if (probe(reg) != val)
+ return (NULL);
+ if (probe(0xfe) == 0x4d)
+ return ("maxim1617");
+ /* 0xfe may be maxim, or some other vendor */
+ return ("xeontemp");
}
- return (0);
+ return (NULL);
}
#endif
@@ -214,19 +218,19 @@ iic_probe(struct device *self, struct i2cbus_attach_args *iba, u_int8_t addr)
* product number, while older ones encoded the product
* into the upper half of the step at 0x3f
*/
- if (probe(0x3d) == 0x03 || probe(0x3d) == 0x08 ||
- probe(0x3d) == 0x07)
- name = "adt7516"; /* adt7517, adt7519 */
- if (probe(0x3d) == 0x76)
+ if ((addr == 0x2c || addr == 0x2d || addr == 0x2e) &&
+ probe(0x3d) == 0x76)
name = "adt7476";
- else if (probe(0x3d) == 0x70)
+ else if ((addr == 0x2c || addr == 0x2e || addr == 0x2f) &&
+ probe(0x3d) == 0x70)
name = "adt7470";
else if (probe(0x3d) == 0x27 &&
(probe(0x3f) == 0x62 || probe(0x3f) == 0x6a))
name = "adt7460"; /* complete check */
else if (probe(0x3d) == 0x33)
name = "adm1033";
- else if (probe(0x3d) == 0x30 &&
+ else if ((addr & 0x7c) == 0x2c && /* addr 0b01011xx */
+ probe(0x3d) == 0x30 &&
(probe(0x3f) & 0x70) == 0x00 &&
(probe(0x01) & 0x4a) == 0x00 &&
(probe(0x03) & 0x3f) == 0x00 &&
@@ -234,18 +238,21 @@ iic_probe(struct device *self, struct i2cbus_attach_args *iba, u_int8_t addr)
(probe(0x0d) & 0x70) == 0x00 &&
(probe(0x0e) & 0x70) == 0x00)
name = "adm1030"; /* complete check */
- else if (probe(0x3d) == 0x31 &&
+ else if ((addr & 0x7c) == 0x2c && /* addr 0b01011xx */
+ probe(0x3d) == 0x31 &&
(probe(0x03) & 0x3f) == 0x00 &&
(probe(0x0d) & 0x70) == 0x00 &&
(probe(0x0e) & 0x70) == 0x00 &&
(probe(0x0f) & 0x70) == 0x00)
name = "adm1031"; /* complete check */
- else if ((probe(0x3f) & 0xf0) == 0x20 &&
+ else if ((addr & 0x7c) == 0x2c && /* addr 0b01011xx */
+ (probe(0x3f) & 0xf0) == 0x20 &&
(probe(0x40) & 0x80) == 0x00 &&
(probe(0x41) & 0xc0) == 0x00 &&
(probe(0x42) & 0xbc) == 0x00)
name = "adm1025"; /* complete check */
- else if ((probe(0x3f) & 0xf0) == 0x10 &&
+ else if ((addr & 0x7c) == 0x2c && /* addr 0b01011xx */
+ (probe(0x3f) & 0xf0) == 0x10 &&
(probe(0x40) & 0x80) == 0x00)
name = "adm1024"; /* complete check */
else if ((probe(0xff) & 0xf0) == 0x30)
@@ -289,8 +296,6 @@ iic_probe(struct device *self, struct i2cbus_attach_args *iba, u_int8_t addr)
name = "lm93";
else if (probe(0x3f) == 0x17)
name = "lm86";
- else if (probe(0x3f) == 0x03) /* are there others? */
- name = "lm81";
break;
case 0x02:
if ((probe(0x3f) & 0xfc) == 0x04) {
@@ -298,6 +303,15 @@ iic_probe(struct device *self, struct i2cbus_attach_args *iba, u_int8_t addr)
}
break;
}
+ switch (probe(0x4e)) {
+ case 0x41:
+ if ((addr == 0x48 || addr == 0x4a || addr == 0x4b) &&
+ /* addr 0b1001{000, 010, 011} */
+ (probe(0x4d) == 0x03 || probe(0x4d) == 0x08 ||
+ probe(0x4d) == 0x07))
+ name = "adt7516"; /* adt7517, adt7519 */
+ break;
+ }
if (probe(0xfe) == 0x01) {
/* Some more National devices ...*/
@@ -315,8 +329,8 @@ iic_probe(struct device *self, struct i2cbus_attach_args *iba, u_int8_t addr)
} else if ((addr & 0xfc) == 0x48 && lm75probe()) {
name = "lm75";
#ifdef __i386__
- } else if (xeonprobe(addr)) {
- name = "xeon";
+ } else if (name == NULL) {
+ name = xeonprobe(addr);
#endif
}