diff options
author | 2006-02-09 12:16:25 +0000 | |
---|---|---|
committer | 2006-02-09 12:16:25 +0000 | |
commit | 6e8deec5fce1e18645a32762d9ac7ec4548c7eba (patch) | |
tree | 2c61c1640cd54606eceb7505af8fbb1b5a1ae986 | |
parent | No longer need to touch the dhcpd.leases file before running dhcpd. (diff) | |
download | wireguard-openbsd-6e8deec5fce1e18645a32762d9ac7ec4548c7eba.tar.xz wireguard-openbsd-6e8deec5fce1e18645a32762d9ac7ec4548c7eba.zip |
split the ofw scan up into two parts: one to find the i2c bus on a pci
device, and one to find i2c devices on the i2c bus.
tweaks and ok kettenis@ ok djm@
-rw-r--r-- | sys/arch/sparc64/dev/ofwi2c.c | 71 | ||||
-rw-r--r-- | sys/arch/sparc64/dev/ofwi2cvar.h | 5 | ||||
-rw-r--r-- | sys/arch/sparc64/dev/pcfiic_ebus.c | 7 | ||||
-rw-r--r-- | sys/dev/pci/alipm.c | 4 |
4 files changed, 50 insertions, 37 deletions
diff --git a/sys/arch/sparc64/dev/ofwi2c.c b/sys/arch/sparc64/dev/ofwi2c.c index ee2d01c0c55..d56c2e90485 100644 --- a/sys/arch/sparc64/dev/ofwi2c.c +++ b/sys/arch/sparc64/dev/ofwi2c.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ofwi2c.c,v 1.2 2006/02/08 23:15:58 dlg Exp $ */ +/* $OpenBSD: ofwi2c.c,v 1.3 2006/02/09 12:16:25 dlg Exp $ */ /* * Copyright (c) 2006 Theo de Raadt @@ -30,11 +30,31 @@ #include <arch/sparc64/dev/ofwi2cvar.h> void -ofwiic_scan(struct device *self, struct i2cbus_attach_args *iba, void *aux) +ofwiic_pci_scan(struct device *self, struct i2cbus_attach_args *iba, void *aux) { struct pci_attach_args *pa = aux; pcitag_t tag = pa->pa_tag; int iba_node = PCITAG_NODE(tag); + char name[32]; + int node; + + for (node = OF_child(iba_node); node; node = OF_peer(node)) { + memset(name, 0, sizeof(name)); + + if (OF_getprop(node, "compatible", name, sizeof(name)) == -1) + continue; + if (name[0] == '\0') + continue; + + if (strcmp(name, "i2c-smbus") == 0) + ofwiic_scan(self, iba, &node); + } +} + +void +ofwiic_scan(struct device *self, struct i2cbus_attach_args *iba, void *aux) +{ + int iba_node = *(int *)aux; extern int iic_print(void *, const char *); struct i2c_attach_args ia; char name[32]; @@ -42,31 +62,26 @@ ofwiic_scan(struct device *self, struct i2cbus_attach_args *iba, void *aux) int node; for (node = OF_child(iba_node); node; node = OF_peer(node)) { - memset(name, 0, sizeof name); - if (OF_getprop(node, "compatible", &name, - sizeof name) && name[0]) - ia.ia_name = name; - - if (strcmp(name, "i2c-smbus") == 0) { - for (node = OF_child(node); node; node = OF_peer(node)) { - memset(&ia, 0, sizeof ia); - ia.ia_tag = iba->iba_tag; - memset(name, 0, sizeof name); - if (OF_getprop(node, "compatible", &name, - sizeof name) && name[0]) { - ia.ia_name = name; - if (strncmp(ia.ia_name, "i2c-", - strlen("i2c-")) == 0) - ia.ia_name += strlen("i2c-"); - } - if (OF_getprop(node, "reg", ®, - sizeof reg) != sizeof reg) - continue; - ia.ia_addr = (reg[1] >> 1); - if (ia.ia_name) - config_found(self, &ia, iic_print); - } - return; - } + memset(name, 0, sizeof(name)); + memset(reg, 0, sizeof(reg)); + + if (OF_getprop(node, "compatible", name, sizeof(name)) == -1) + continue; + if (name[0] == '\0') + continue; + + if (OF_getprop(node, "reg", reg, sizeof(reg)) == -1) + continue; + + memset(&ia, 0, sizeof(ia)); + ia.ia_tag = iba->iba_tag; + ia.ia_addr = reg[1] >> 1; + ia.ia_name = name; + ia.ia_cookie = &node; + + if (strncmp(ia.ia_name, "i2c-", strlen("i2c-")) == 0) + ia.ia_name += strlen("i2c-"); + + config_found(self, &ia, iic_print); } } diff --git a/sys/arch/sparc64/dev/ofwi2cvar.h b/sys/arch/sparc64/dev/ofwi2cvar.h index d4cd0ef90ea..db71cab93de 100644 --- a/sys/arch/sparc64/dev/ofwi2cvar.h +++ b/sys/arch/sparc64/dev/ofwi2cvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ofwi2cvar.h,v 1.1 2006/01/02 01:58:55 deraadt Exp $ */ +/* $OpenBSD: ofwi2cvar.h,v 1.2 2006/02/09 12:16:25 dlg Exp $ */ /* * Copyright (c) 2006 Theo de Raadt @@ -18,4 +18,5 @@ #include <dev/i2c/i2cvar.h> -void ofwiic_scan(struct device *sc, struct i2cbus_attach_args *iba, void *aux); +void ofwiic_pci_scan(struct device *, struct i2cbus_attach_args *, void *); +void ofwiic_scan(struct device *, struct i2cbus_attach_args *, void *); diff --git a/sys/arch/sparc64/dev/pcfiic_ebus.c b/sys/arch/sparc64/dev/pcfiic_ebus.c index 64ec5be510b..126ac46a9bc 100644 --- a/sys/arch/sparc64/dev/pcfiic_ebus.c +++ b/sys/arch/sparc64/dev/pcfiic_ebus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pcfiic_ebus.c,v 1.2 2006/02/01 11:08:22 dlg Exp $ */ +/* $OpenBSD: pcfiic_ebus.c,v 1.3 2006/02/09 12:16:25 dlg Exp $ */ /* * Copyright (c) 2006 David Gwynne <dlg@openbsd.org> @@ -110,9 +110,6 @@ pcfiic_ebus_attach(struct device *parent, struct device *self, void *aux) if (esc->esc_ih == NULL) sc->sc_poll = 1; - pcfiic_attach(sc, (i2c_addr_t)(addr >> 1), NULL, NULL); -#ifdef notyet - pcfiic_attach(sc, (i2c_addr_t)(addr >> 1), ofwi2c_scan, &ea->ea_node); -#endif + pcfiic_attach(sc, (i2c_addr_t)(addr >> 1), ofwiic_scan, &ea->ea_node); /* the rest of the attach line is printed by pcfiic_attach() */ } diff --git a/sys/dev/pci/alipm.c b/sys/dev/pci/alipm.c index 8f242d6871b..56265ed6314 100644 --- a/sys/dev/pci/alipm.c +++ b/sys/dev/pci/alipm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: alipm.c,v 1.6 2006/01/04 18:32:15 kettenis Exp $ */ +/* $OpenBSD: alipm.c,v 1.7 2006/02/09 12:16:25 dlg Exp $ */ /* * Copyright (c) 2005 Mark Kettenis @@ -220,7 +220,7 @@ alipm_attach(struct device *parent, struct device *self, void *aux) iba.iba_name = "iic"; iba.iba_tag = &sc->sc_smb_tag; #ifdef __sparc64__ - iba.iba_bus_scan = ofwiic_scan; + iba.iba_bus_scan = ofwiic_pci_scan; iba.iba_bus_scan_arg = pa; #endif config_found(&sc->sc_dev, &iba, iicbus_print); |