summaryrefslogtreecommitdiff
path: root/sys/dev/i2c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2005-12-27 09:23:29 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2005-12-27 09:23:29 +0000
commit9fe9b26b8e1a6cdbb02bf37ed2e361d6ba4447a7 (patch)
treee5cf367ac217ff31ad5fc71d87e351d775d8e156 /sys/dev/i2c
parent0a3ac9ae2eb6d476c590f0ebde11d3e9c570d63c (diff)
match about 15 more clone chips
Diffstat (limited to 'sys/dev/i2c')
-rw-r--r--sys/dev/i2c/adt7460.c12
-rw-r--r--sys/dev/i2c/i2c_scan.c49
-rw-r--r--sys/dev/i2c/lm87.c48
3 files changed, 80 insertions, 29 deletions
diff --git a/sys/dev/i2c/adt7460.c b/sys/dev/i2c/adt7460.c
index 500b3d1269d..e5c94c66ad7 100644
--- a/sys/dev/i2c/adt7460.c
+++ b/sys/dev/i2c/adt7460.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: adt7460.c,v 1.2 2005/11/17 01:09:36 deraadt Exp $ */
+/* $OpenBSD: adt7460.c,v 1.3 2005/12/27 09:23:28 deraadt Exp $ */
/*
* Copyright (c) 2005 Mark Kettenis
@@ -81,7 +81,10 @@ adt_match(struct device *parent, void *match, void *aux)
if (ia->ia_compat) {
if (strcmp(ia->ia_compat, "adt7460") == 0 ||
- strcmp(ia->ia_compat, "adt7467") == 0)
+ strcmp(ia->ia_compat, "adt7467") == 0 ||
+ strcmp(ia->ia_compat, "adt7476") == 0 ||
+ strcmp(ia->ia_compat, "lm85") == 0 ||
+ strcmp(ia->ia_compat, "emc6d10x") == 0)
return (1);
return (0);
}
@@ -102,7 +105,10 @@ adt_attach(struct device *parent, struct device *self, void *aux)
iic_acquire_bus(sc->sc_tag, 0);
sc->sc_chip = 7460;
- if (ia->ia_compat && strcmp(ia->ia_compat, "adt7467") == 0)
+ /* check for the fancy "extension" chips XXX */
+ if (ia->ia_compat &&
+ (strcmp(ia->ia_compat, "adt7467") == 0 ||
+ strcmp(ia->ia_compat, "adt7467") == 0))
sc->sc_chip = 7467;
cmd = ADT7460_REVISION;
diff --git a/sys/dev/i2c/i2c_scan.c b/sys/dev/i2c/i2c_scan.c
index 70bcc13323a..3ce9729bc38 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.20 2005/12/27 03:46:50 deraadt Exp $ */
+/* $OpenBSD: i2c_scan.c,v 1.21 2005/12/27 09:23:28 deraadt Exp $ */
/*
* Copyright (c) 2005 Alexander Yurchenko <grange@openbsd.org>
@@ -224,8 +224,8 @@ 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 ((addr == 0x2c || addr == 0x2d || addr == 0x2e) &&
- probe(0x3d) == 0x76)
+ if (probe(0x3d) == 0x76 &&
+ (addr == 0x2c || addr == 0x2d || addr == 0x2e))
name = "adt7476";
else if ((addr == 0x2c || addr == 0x2e || addr == 0x2f) &&
probe(0x3d) == 0x70)
@@ -233,6 +233,9 @@ iic_probe(struct device *self, struct i2cbus_attach_args *iba, u_int8_t addr)
else if (probe(0x3d) == 0x27 &&
(probe(0x3f) == 0x62 || probe(0x3f) == 0x6a))
name = "adt7460"; /* complete check */
+ else if (probe(0x3d) == 0x68 && addr == 0x2e &&
+ (probe(0x3f) & 0xf0) == 0x70)
+ name = "adt7467";
else if (probe(0x3d) == 0x33)
name = "adm1033";
else if ((addr & 0x7c) == 0x2c && /* addr 0b01011xx */
@@ -263,10 +266,16 @@ iic_probe(struct device *self, struct i2cbus_attach_args *iba, u_int8_t addr)
name = "adm1024"; /* complete check */
else if ((probe(0xff) & 0xf0) == 0x30)
name = "adm1023";
- else if ((probe(0xff) & 0xf0) == 0x90)
+ if ((probe(0x3f) & 0xf0) == 0xd0 && addr == 0x2e &&
+ (probe(0x40) & 0x80) == 0x00)
+ name = "adm1028"; /* adm1022 clone? */
+ else if ((probe(0x3f) & 0xf0) == 0xc0 &&
+ (addr == 0x2c || addr == 0x2e || addr == 0x2f) &&
+ (probe(0x40) & 0x80) == 0x00)
name = "adm1022";
- else if ((probe(0xff) & 0xf0) == 0x00)
- name = "adm1021"; /* ????? */
+ else if (probe(0x48) == addr && probe(0x00) == 0x00 &&
+ (addr & 0x7c) == 0x2c)
+ name = "adm9240"; /* getting desperate! */
break;
case 0xa1:
/* Philips vendor code 0xa1 at 0x3e */
@@ -302,11 +311,32 @@ 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) & 0xf0) == 0x60 &&
+ (addr == 0x2c || addr == 0x2d || addr == 0x2e))
+ name = "lm85"; /* adt7460 compat */
+ else if (probe(0x3f) == 0x03 && probe(0x48) == addr &&
+ ((probe(0x40) & 0x80) == 0x00) && ((addr & 0x7c) == 0x2c))
+ name = "lm81";
+ break;
+ case 0x49: /* TI */
+ if ((probe(0x3f) & 0xf0) == 0xc0 &&
+ (addr == 0x2c || addr == 0x2e || addr == 0x2f) &&
+ (probe(0x40) & 0x80) == 0x00)
+ name = "thmc50"; /* adm1022 clone */
+ break;
+ case 0x5c: /* SMSC */
+ if ((probe(0x3f) & 0xf0) == 0x60 &&
+ (addr == 0x2c || addr == 0x2d || addr == 0x2e))
+ name = "emc6d10x"; /* adt7460 compat */
break;
case 0x02:
- if ((probe(0x3f) & 0xfc) == 0x04) {
+ if ((probe(0x3f) & 0xfc) == 0x04)
name = "lm87"; /* complete check */
- }
+ break;
+ case 0xda:
+ if (probe(0x3f) == 0x01 && probe(0x48) == addr &&
+ probe(0x00) == 0x00)
+ name = "ds1780"; /* getting desperate! */
break;
}
switch (probe(0x4e)) {
@@ -337,6 +367,9 @@ iic_probe(struct device *self, struct i2cbus_attach_args *iba, u_int8_t addr)
*/
if (probe(0x58) == 0x31)
name = "as99127f";
+ } else if (probe(0x16) == 0x41 && ((probe(0x17) & 0xf0) == 0x40) &&
+ (addr == 0x2c || addr == 0x2d || addr == 0x2e)) {
+ name = "adm1026";
} else if ((addr & 0xfc) == 0x48 && lm75probe()) {
name = "lm75";
#ifdef __i386__
diff --git a/sys/dev/i2c/lm87.c b/sys/dev/i2c/lm87.c
index 544d70309e1..ffcf9c13ceb 100644
--- a/sys/dev/i2c/lm87.c
+++ b/sys/dev/i2c/lm87.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lm87.c,v 1.9 2005/12/27 03:54:27 deraadt Exp $ */
+/* $OpenBSD: lm87.c,v 1.10 2005/12/27 09:23:28 deraadt Exp $ */
/*
* Copyright (c) 2005 Mark Kettenis
@@ -61,7 +61,8 @@ struct lmenv_softc {
i2c_addr_t sc_addr;
struct sensor sc_sensor[LMENV_NUM_SENSORS];
- int sc_fan1_div, sc_fan2_div;
+ int sc_fan1_div, sc_fan2_div;
+ int sc_family;
};
int lmenv_match(struct device *, void *, void *);
@@ -82,13 +83,13 @@ lmenv_match(struct device *parent, void *match, void *aux)
{
struct i2c_attach_args *ia = aux;
- if (ia->ia_name) {
- if (strcmp(ia->ia_name, "lm87") == 0 ||
- strcmp(ia->ia_name, "lm87cimt") == 0)
- return (1);
- return (0);
- }
- return (1); /* accept the address given */
+ if (strcmp(ia->ia_name, "lm87") == 0 ||
+ strcmp(ia->ia_name, "lm87cimt") == 0 ||
+ strcmp(ia->ia_name, "adm9240") == 0 ||
+ strcmp(ia->ia_name, "lm81") == 0 ||
+ strcmp(ia->ia_name, "ds1780") == 0)
+ return (1);
+ return (0);
}
void
@@ -102,6 +103,12 @@ lmenv_attach(struct device *parent, struct device *self, void *aux)
sc->sc_tag = ia->ia_tag;
sc->sc_addr = ia->ia_addr;
+ sc->sc_family = 87;
+ if (strcmp(ia->ia_name, "lm81") == 0 ||
+ strcmp(ia->ia_name, "adm9240") == 0 ||
+ strcmp(ia->ia_name, "ds1780") == 0)
+ sc->sc_family = 81;
+
iic_acquire_bus(sc->sc_tag, 0);
cmd = LM87_REVISION;
@@ -111,7 +118,7 @@ lmenv_attach(struct device *parent, struct device *self, void *aux)
printf(": cannot read ID register\n");
return;
}
- printf(": LM87 rev %x", data);
+ printf(": %s rev %x", ia->ia_name, data);
cmd = LM87_FANDIV;
if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP,
@@ -123,12 +130,14 @@ lmenv_attach(struct device *parent, struct device *self, void *aux)
sc->sc_fan1_div = 1 << ((data >> 4) & 0x03);
sc->sc_fan2_div = 1 << ((data >> 6) & 0x03);
- cmd = LM87_CHANNEL;
- if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP,
- sc->sc_addr, &cmd, sizeof cmd, &channel, sizeof channel, 0)) {
- iic_release_bus(sc->sc_tag, 0);
- printf(", cannot read Channel register\n");
- return;
+ if (sc->sc_family == 87) {
+ cmd = LM87_CHANNEL;
+ if (iic_exec(sc->sc_tag, I2C_OP_READ_WITH_STOP,
+ sc->sc_addr, &cmd, sizeof cmd, &channel, sizeof channel, 0)) {
+ iic_release_bus(sc->sc_tag, 0);
+ printf(", cannot read Channel register\n");
+ return;
+ }
}
cmd = LM87_CONFIG1;
@@ -149,8 +158,6 @@ lmenv_attach(struct device *parent, struct device *self, void *aux)
}
printf(", starting scan");
}
-
-
iic_release_bus(sc->sc_tag, 0);
/* Initialize sensor data. */
@@ -185,6 +192,8 @@ lmenv_attach(struct device *parent, struct device *self, void *aux)
sc->sc_sensor[LMENV_EXT_TEMP].type = SENSOR_TEMP;
strlcpy(sc->sc_sensor[LMENV_EXT_TEMP].desc, "Ext. Temp.",
sizeof(sc->sc_sensor[LMENV_EXT_TEMP].desc));
+ if (sc->sc_family == 81)
+ sc->sc_sensor[LMENV_EXT_TEMP].flags |= SENSOR_FINVALID;
sc->sc_sensor[LMENV_INT_TEMP].type = SENSOR_TEMP;
strlcpy(sc->sc_sensor[LMENV_INT_TEMP].desc, "Int. Temp.",
@@ -258,6 +267,9 @@ lmenv_refresh(void *arg)
sc->sc_sensor[sensor].value = 3300000 * data / 192;
break;
case LMENV_EXT_TEMP:
+ if (sc->sc_family == 81)
+ break; /* missing on LM81 */
+ /* FALLTHROUGH */
case LMENV_INT_TEMP:
if (data == 0x80)
sc->sc_sensor[sensor].flags |= SENSOR_FINVALID;