summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2006-01-01 20:52:29 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2006-01-01 20:52:29 +0000
commit5c6a275d22890d00126f51fb7cbff1aa01948aca (patch)
tree7b1673167ce83d637e54ce54d8bd795cdcd691f6 /sys/arch
parent2e8171134016d44dbd15da591feea9b72aae4eca (diff)
switch from macppc-specific maciic(4) driver to the generic iic(4),
after teaching it to use a function pointer to get back to the OFW scan.. this will also help the sparc64 later; ok kettenis
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/macppc/conf/GENERIC28
-rw-r--r--sys/arch/macppc/conf/files.macppc13
-rw-r--r--sys/arch/macppc/dev/ki2c.c9
-rw-r--r--sys/arch/macppc/dev/maci2c.c42
-rw-r--r--sys/arch/macppc/dev/maci2cvar.h7
-rw-r--r--sys/arch/macppc/dev/pi2c.c9
-rw-r--r--sys/arch/macppc/dev/smu.c11
7 files changed, 46 insertions, 73 deletions
diff --git a/sys/arch/macppc/conf/GENERIC b/sys/arch/macppc/conf/GENERIC
index 270841bc68c..d5896e05ab3 100644
--- a/sys/arch/macppc/conf/GENERIC
+++ b/sys/arch/macppc/conf/GENERIC
@@ -1,4 +1,4 @@
-# $OpenBSD: GENERIC,v 1.119 2005/12/23 04:01:11 brad Exp $g
+# $OpenBSD: GENERIC,v 1.120 2006/01/01 20:52:23 deraadt Exp $g
#
# For further information on compiling OpenBSD kernels, see the config(8)
# man page.
@@ -250,22 +250,22 @@ radio* at udsbr? # USB radio
ugen* at uhub? # USB Generic driver
# I2C bus support
-maciic* at ki2c?
-maciic* at pi2c?
-maciic* at smu?
+iic* at ki2c?
+iic* at pi2c?
+iic* at smu?
# I2C devices
-lmtemp* at maciic?
-lmenv* at maciic?
-maxtmp* at maciic?
-adc* at maciic?
-tsl* at maciic?
-admtmp* at maciic?
-pcagpio* at maciic?
+lmtemp* at iic?
+lmenv* at iic?
+maxtmp* at iic?
+adc* at iic?
+tsl* at iic?
+admtmp* at iic?
+pcagpio* at iic?
gpio* at pcagpio?
-maxds* at maciic?
-fcu* at maciic?
-adt* at maciic?
+maxds* at iic?
+fcu* at iic?
+adt* at iic?
# CardBus bus support
cardbus* at cardslot?
diff --git a/sys/arch/macppc/conf/files.macppc b/sys/arch/macppc/conf/files.macppc
index b4d7fda95d1..b8a2ce0eba0 100644
--- a/sys/arch/macppc/conf/files.macppc
+++ b/sys/arch/macppc/conf/files.macppc
@@ -1,4 +1,4 @@
-# $OpenBSD: files.macppc,v 1.43 2005/12/21 18:50:51 miod Exp $
+# $OpenBSD: files.macppc,v 1.44 2006/01/01 20:52:23 deraadt Exp $
#
# macppc-specific configuration info
@@ -77,7 +77,7 @@ device ht {} : pcibus
attach ht at mainbus
file arch/macppc/pci/ht.c ht
-device smu {} : i2cbus
+device smu: i2cbus
attach smu at mainbus
file arch/macppc/dev/smu.c smu
file dev/clock_subr.c smu
@@ -185,13 +185,13 @@ attach mediabay at macobio
file arch/macppc/dev/mediabay.c mediabay
# Keywest I2C
-device ki2c {}
+device ki2c: i2cbus
attach ki2c at macobio
attach ki2c at memc with ki2c_memc
file arch/macppc/dev/ki2c.c ki2c
# PMU I2C
-device pi2c {}
+device pi2c: i2cbus
attach pi2c at adb
file arch/macppc/dev/pi2c.c pi2c
@@ -271,10 +271,7 @@ include "dev/usb/files.usb"
# Machine-independent I2C drivers
#
include "dev/i2c/files.i2c"
-
-device maciic {} : i2c
-attach maciic at ki2c, pi2c, smu
-file arch/macppc/dev/maci2c.c maciic
+file arch/macppc/dev/maci2c.c i2cbus
#
# Machine-independent GPIO drivers
diff --git a/sys/arch/macppc/dev/ki2c.c b/sys/arch/macppc/dev/ki2c.c
index a8a7e118b55..f42eac8cf15 100644
--- a/sys/arch/macppc/dev/ki2c.c
+++ b/sys/arch/macppc/dev/ki2c.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ki2c.c,v 1.11 2005/12/13 19:21:45 kettenis Exp $ */
+/* $OpenBSD: ki2c.c,v 1.12 2006/01/01 20:52:25 deraadt Exp $ */
/* $NetBSD: ki2c.c,v 1.1 2003/12/27 02:19:34 grant Exp $ */
/*-
@@ -140,7 +140,7 @@ ki2c_attach(struct device *parent, struct device *self, void *aux)
void
ki2c_attach_bus(struct ki2c_softc *sc, struct ki2c_bus *bus, int node)
{
- struct maci2cbus_attach_args iba;
+ struct i2cbus_attach_args iba;
u_int32_t reg;
if (OF_getprop(node, "reg", &reg, sizeof reg) != sizeof reg)
@@ -153,8 +153,11 @@ ki2c_attach_bus(struct ki2c_softc *sc, struct ki2c_bus *bus, int node)
bus->i2c_tag.ic_exec = ki2c_i2c_exec;
bus->reg = reg;
- iba.iba_node = node;
+ bzero(&iba, sizeof iba);
+ iba.iba_name = "iic";
iba.iba_tag = &bus->i2c_tag;
+ iba.iba_bus_scan = maciic_scan;
+ iba.iba_bus_scan_arg = &node;
config_found(&sc->sc_dev, &iba, NULL);
}
diff --git a/sys/arch/macppc/dev/maci2c.c b/sys/arch/macppc/dev/maci2c.c
index b3978bd87a8..d94ef65175b 100644
--- a/sys/arch/macppc/dev/maci2c.c
+++ b/sys/arch/macppc/dev/maci2c.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: maci2c.c,v 1.4 2005/12/27 17:18:18 deraadt Exp $ */
+/* $OpenBSD: maci2c.c,v 1.5 2006/01/01 20:52:25 deraadt Exp $ */
/*
* Copyright (c) 2005 Mark Kettenis
@@ -25,36 +25,19 @@
#include <arch/macppc/dev/maci2cvar.h>
-int maciic_match(struct device *, void *, void *);
-void maciic_attach(struct device *, struct device *, void *);
int maciic_print(void *, const char *);
-struct cfattach maciic_ca = {
- sizeof (struct device), maciic_match, maciic_attach
-};
-
-struct cfdriver maciic_cd = {
- NULL, "maciic", DV_DULL
-};
-
-int
-maciic_match(struct device *parent, void *cf, void *aux)
-{
- return (1);
-}
-
void
-maciic_attach(struct device *parent, struct device *self, void *aux)
+maciic_scan(struct device *self, struct i2cbus_attach_args *iba, void *aux)
{
- struct maci2cbus_attach_args *iba = aux;
+ int iba_node = *(int *)aux;
+ extern int iic_print(void *, const char *);
struct i2c_attach_args ia;
char name[32];
u_int32_t reg;
int node;
- printf("\n");
-
- for (node = OF_child(iba->iba_node); node; node = OF_peer(node)) {
+ for (node = OF_child(iba_node); node; node = OF_peer(node)) {
if (OF_getprop(node, "reg", &reg, sizeof reg) != sizeof reg &&
OF_getprop(node, "i2c-address", &reg, sizeof reg) != sizeof reg)
continue;
@@ -70,19 +53,6 @@ maciic_attach(struct device *parent, struct device *self, void *aux)
sizeof name) && name[0])
ia.ia_name = name;
if (ia.ia_name)
- config_found(self, &ia, maciic_print);
+ config_found(self, &ia, iic_print);
}
}
-
-int
-maciic_print(void *aux, const char *pnp)
-{
- struct i2c_attach_args *ia = aux;
-
- if (pnp != NULL) {
- printf("\"%s\" at %s", ia->ia_name, pnp);
- }
- printf(" addr 0x%x", ia->ia_addr);
-
- return (UNCONF);
-}
diff --git a/sys/arch/macppc/dev/maci2cvar.h b/sys/arch/macppc/dev/maci2cvar.h
index 7dc43716b20..4575b37fa1b 100644
--- a/sys/arch/macppc/dev/maci2cvar.h
+++ b/sys/arch/macppc/dev/maci2cvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: maci2cvar.h,v 1.2 2005/11/15 16:23:34 deraadt Exp $ */
+/* $OpenBSD: maci2cvar.h,v 1.3 2006/01/01 20:52:25 deraadt Exp $ */
/*
* Copyright (c) 2005 Mark Kettenis
@@ -18,7 +18,4 @@
#include <dev/i2c/i2cvar.h>
-struct maci2cbus_attach_args {
- i2c_tag_t iba_tag;
- int iba_node;
-};
+void maciic_scan(struct device *sc, struct i2cbus_attach_args *iba, void *aux);
diff --git a/sys/arch/macppc/dev/pi2c.c b/sys/arch/macppc/dev/pi2c.c
index 7c5c0bf85a4..ff2fa05e895 100644
--- a/sys/arch/macppc/dev/pi2c.c
+++ b/sys/arch/macppc/dev/pi2c.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pi2c.c,v 1.4 2005/11/28 23:56:51 deraadt Exp $ */
+/* $OpenBSD: pi2c.c,v 1.5 2006/01/01 20:52:25 deraadt Exp $ */
/*
* Copyright (c) 2005 Mark Kettenis
@@ -63,7 +63,7 @@ pi2c_attach(struct device *parent, struct device *self, void *aux)
{
struct pi2c_softc *sc = (struct pi2c_softc *)self;
struct confargs *ca = aux;
- struct maci2cbus_attach_args iba;
+ struct i2cbus_attach_args iba;
printf("\n");
@@ -74,8 +74,11 @@ pi2c_attach(struct device *parent, struct device *self, void *aux)
sc->sc_i2c_tag.ic_release_bus = pi2c_i2c_release_bus;
sc->sc_i2c_tag.ic_exec = pi2c_i2c_exec;
- iba.iba_node = ca->ca_node;
+ bzero(&iba, sizeof iba);
+ iba.iba_name = "iic";
iba.iba_tag = &sc->sc_i2c_tag;
+ iba.iba_bus_scan = maciic_scan;
+ iba.iba_bus_scan_arg = &ca->ca_node;
config_found(&sc->sc_dev, &iba, NULL);
}
diff --git a/sys/arch/macppc/dev/smu.c b/sys/arch/macppc/dev/smu.c
index d9a0219ccd9..70e7edc67d9 100644
--- a/sys/arch/macppc/dev/smu.c
+++ b/sys/arch/macppc/dev/smu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smu.c,v 1.9 2005/12/09 22:55:10 kettenis Exp $ */
+/* $OpenBSD: smu.c,v 1.10 2006/01/01 20:52:25 deraadt Exp $ */
/*
* Copyright (c) 2005 Mark Kettenis
@@ -175,7 +175,7 @@ smu_attach(struct device *parent, struct device *self, void *aux)
{
struct smu_softc *sc = (struct smu_softc *)self;
struct confargs *ca = aux;
- struct maci2cbus_attach_args iba;
+ struct i2cbus_attach_args iba;
struct smu_fan *fan;
struct smu_sensor *sensor;
int nseg, node;
@@ -347,10 +347,13 @@ smu_attach(struct device *parent, struct device *self, void *aux)
sc->sc_i2c_tag.ic_exec = smu_i2c_exec;
node = OF_getnodebyname(ca->ca_node, "smu-i2c-control");
+ node = OF_child(node);
- /* XXX */
- iba.iba_node = OF_child(node);
+ bzero(&iba, sizeof iba);
+ iba.iba_name = "iic";
iba.iba_tag = &sc->sc_i2c_tag;
+ iba.iba_bus_scan = maciic_scan;
+ iba.iba_bus_scan_arg = &node;
config_found(&sc->sc_dev, &iba, NULL);
}