summaryrefslogtreecommitdiff
path: root/sys/dev/i2c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2005-11-15 16:23:35 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2005-11-15 16:23:35 +0000
commite81a9e6ddbbcf435959b012f5595da0ed2389886 (patch)
treeaa2643a45c77098fcb86874b7d751970cd00d379 /sys/dev/i2c
parentc8c7014162f692ead770cea7fb5b67b92fd04f97 (diff)
instead of passing OF nodes down to the drivers, pass name/compat string
pointers. This lets their match() functions actually make real decisions. OF-capable machines will pass name/compat pointers, but other machines will not. grudging ok kettenis
Diffstat (limited to 'sys/dev/i2c')
-rw-r--r--sys/dev/i2c/i2c.c4
-rw-r--r--sys/dev/i2c/i2cvar.h4
-rw-r--r--sys/dev/i2c/lm75.c9
-rw-r--r--sys/dev/i2c/lm87.c30
4 files changed, 26 insertions, 21 deletions
diff --git a/sys/dev/i2c/i2c.c b/sys/dev/i2c/i2c.c
index 8cfd6c8cbba..76165044a74 100644
--- a/sys/dev/i2c/i2c.c
+++ b/sys/dev/i2c/i2c.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: i2c.c,v 1.1 2004/05/23 17:33:43 grange Exp $ */
+/* $OpenBSD: i2c.c,v 1.2 2005/11/15 16:23:31 deraadt Exp $ */
/* $NetBSD: i2c.c,v 1.1 2003/09/30 00:35:31 thorpej Exp $ */
/*
@@ -98,6 +98,8 @@ iic_search(struct device *parent, void *arg, void *aux)
ia.ia_tag = sc->sc_tag;
ia.ia_addr = cf->cf_loc[IICCF_ADDR];
ia.ia_size = cf->cf_loc[IICCF_SIZE];
+ ia.ia_name = NULL;
+ ia.ia_compat = NULL;
if (cf->cf_attach->ca_match(parent, cf, &ia) > 0)
config_attach(parent, cf, &ia, iic_print);
diff --git a/sys/dev/i2c/i2cvar.h b/sys/dev/i2c/i2cvar.h
index 7065df99932..bbda44a6595 100644
--- a/sys/dev/i2c/i2cvar.h
+++ b/sys/dev/i2c/i2cvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: i2cvar.h,v 1.1 2004/05/23 17:33:43 grange Exp $ */
+/* $OpenBSD: i2cvar.h,v 1.2 2005/11/15 16:23:31 deraadt Exp $ */
/* $NetBSD: i2cvar.h,v 1.1 2003/09/30 00:35:31 thorpej Exp $ */
/*
@@ -101,6 +101,8 @@ struct i2c_attach_args {
i2c_tag_t ia_tag; /* our controller */
i2c_addr_t ia_addr; /* address of device */
int ia_size; /* size (for EEPROMs) */
+ char *ia_name;
+ char *ia_compat;
};
/*
diff --git a/sys/dev/i2c/lm75.c b/sys/dev/i2c/lm75.c
index 64b5959923c..e833ba12bed 100644
--- a/sys/dev/i2c/lm75.c
+++ b/sys/dev/i2c/lm75.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lm75.c,v 1.3 2005/11/13 00:19:17 deraadt Exp $ */
+/* $OpenBSD: lm75.c,v 1.4 2005/11/15 16:23:31 deraadt Exp $ */
/* $NetBSD: lm75.c,v 1.1 2003/09/30 00:35:31 thorpej Exp $ */
/*
* Copyright (c) 2004 Alexander Yurchenko <grange@openbsd.org>
@@ -95,6 +95,13 @@ lmtemp_match(struct device *parent, void *match, void *aux)
{
struct i2c_attach_args *ia = aux;
+ if (ia->ia_compat) {
+ if (strcmp(ia->ia_compat, "lm75") == 0 ||
+ strcmp(ia->ia_compat, "ds1775") == 0)
+ return (1);
+ return (0);
+ }
+
/* XXX: we allow wider mask for LM77 */
if ((ia->ia_addr & LM75_ADDRMASK) == LM75_ADDR)
return (1);
diff --git a/sys/dev/i2c/lm87.c b/sys/dev/i2c/lm87.c
index 30130ef1297..e67bca2b019 100644
--- a/sys/dev/i2c/lm87.c
+++ b/sys/dev/i2c/lm87.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lm87.c,v 1.1 2005/11/15 16:19:15 deraadt Exp $ */
+/* $OpenBSD: lm87.c,v 1.2 2005/11/15 16:23:31 deraadt Exp $ */
/*
* Copyright (c) 2005 Mark Kettenis
@@ -21,8 +21,7 @@
#include <sys/device.h>
#include <sys/sensors.h>
-#include <dev/ofw/openfirm.h>
-#include <arch/macppc/dev/maci2cvar.h>
+#include <dev/i2c/i2cvar.h>
/* LM87 registers */
#define LM87_2_5V 0x20
@@ -76,27 +75,22 @@ struct cfdriver lmenv_cd = {
int
lmenv_match(struct device *parent, void *match, void *aux)
{
- struct maci2c_attach_args *ia = aux;
- char compat[32], name[32];
+ struct i2c_attach_args *ia = aux;
- memset(compat, 0, sizeof compat);
- OF_getprop(ia->ia_node, "compatible", &compat, sizeof compat);
- if (strcmp(compat, "lm87cimt") == 0)
- return (1);
-
- memset(name, 0, sizeof name);
- OF_getprop(ia->ia_node, "name", &name, sizeof name);
- if (strcmp(name, "lm87") == 0)
- return (1);
-
- return (0);
+ 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 */
}
void
lmenv_attach(struct device *parent, struct device *self, void *aux)
{
struct lmenv_softc *sc = (struct lmenv_softc *)self;
- struct maci2c_attach_args *ia = aux;
+ struct i2c_attach_args *ia = aux;
u_int8_t cmd, data;
int i;
@@ -173,7 +167,7 @@ lmenv_attach(struct device *parent, struct device *self, void *aux)
sizeof(sc->sc_sensor[LMENV_FAN2].desc));
if (sensor_task_register(sc, lmenv_refresh, 5)) {
- printf(": unable to register update task\n");
+ printf(", unable to register update task\n");
return;
}