diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2007-11-25 00:38:50 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2007-11-25 00:38:50 +0000 |
commit | c8e1d4dfddaf87539c238ef39c8feb9d976deddc (patch) | |
tree | 16837a020add4b192b8ed287252e02f5fb8c0595 /sys/arch | |
parent | 99d3f3adc0276a12b1497ac4a9f464ff30101895 (diff) |
Give the CarBus side of CardBus-PCI bridges a bus number, since OpenFirmware
doesn't do it for us.
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/sparc64/dev/pci_machdep.c | 5 | ||||
-rw-r--r-- | sys/arch/sparc64/include/pci_machdep.h | 3 | ||||
-rw-r--r-- | sys/arch/sparc64/include/rbus_machdep.h | 5 | ||||
-rw-r--r-- | sys/arch/sparc64/sparc64/rbus_machdep.c | 31 |
4 files changed, 40 insertions, 4 deletions
diff --git a/sys/arch/sparc64/dev/pci_machdep.c b/sys/arch/sparc64/dev/pci_machdep.c index 5704dd1447a..6808c3ae637 100644 --- a/sys/arch/sparc64/dev/pci_machdep.c +++ b/sys/arch/sparc64/dev/pci_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pci_machdep.c,v 1.31 2007/10/25 20:00:06 kettenis Exp $ */ +/* $OpenBSD: pci_machdep.c,v 1.32 2007/11/25 00:38:49 kettenis Exp $ */ /* $NetBSD: pci_machdep.c,v 1.22 2001/07/20 00:07:13 eeh Exp $ */ /* @@ -112,6 +112,9 @@ pci_make_tag(pc, b, d, f) bzero(name, sizeof(name)); #endif + if (pc->busnode[b]) + return PCITAG_CREATE(0, b, d, f); + /* * Hunt for the node that corresponds to this device * diff --git a/sys/arch/sparc64/include/pci_machdep.h b/sys/arch/sparc64/include/pci_machdep.h index 5381ae7a90e..c18ca9c5923 100644 --- a/sys/arch/sparc64/include/pci_machdep.h +++ b/sys/arch/sparc64/include/pci_machdep.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pci_machdep.h,v 1.17 2007/08/04 16:39:15 kettenis Exp $ */ +/* $OpenBSD: pci_machdep.h,v 1.18 2007/11/25 00:38:49 kettenis Exp $ */ /* $NetBSD: pci_machdep.h,v 1.7 2001/07/20 00:07:14 eeh Exp $ */ /* @@ -67,6 +67,7 @@ struct sparc_pci_chipset { bus_space_tag_t bustag; bus_space_handle_t bushandle; int rootnode; /* PCI controller */ + int busnode[256]; int tagshift; int (*intr_map)(struct pci_attach_args *, pci_intr_handle_t *); }; diff --git a/sys/arch/sparc64/include/rbus_machdep.h b/sys/arch/sparc64/include/rbus_machdep.h index 5fd4308124e..939f3c7c738 100644 --- a/sys/arch/sparc64/include/rbus_machdep.h +++ b/sys/arch/sparc64/include/rbus_machdep.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rbus_machdep.h,v 1.1 2007/08/04 16:46:03 kettenis Exp $ */ +/* $OpenBSD: rbus_machdep.h,v 1.2 2007/11/25 00:38:49 kettenis Exp $ */ /* * Copyright (c) 2007 Mark Kettenis @@ -32,4 +32,7 @@ rbus_tag_t rbus_pccbb_parent_mem(struct device *, struct pci_attach_args *); bus_space_unmap((t), (h), (size)); \ } while (0) +void pccbb_attach_hook(struct device *, struct device *, + struct pci_attach_args *); + #endif /* _SPARC64_RBUS_MACHDEP_H_ */ diff --git a/sys/arch/sparc64/sparc64/rbus_machdep.c b/sys/arch/sparc64/sparc64/rbus_machdep.c index b76631ad06d..4479e15607f 100644 --- a/sys/arch/sparc64/sparc64/rbus_machdep.c +++ b/sys/arch/sparc64/sparc64/rbus_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rbus_machdep.c,v 1.1 2007/08/04 16:46:03 kettenis Exp $ */ +/* $OpenBSD: rbus_machdep.c,v 1.2 2007/11/25 00:38:49 kettenis Exp $ */ /* * Copyright (c) 2007 Mark Kettenis @@ -89,3 +89,32 @@ rbus_pccbb_parent_io(struct device *self, struct pci_attach_args *pa) return &rbus_null; } + +void +pccbb_attach_hook(struct device *parent, struct device *self, + struct pci_attach_args *pa) +{ + pci_chipset_tag_t pc = pa->pa_pc; + int node = PCITAG_NODE(pa->pa_tag); + int bus, busrange[2]; + pcireg_t bir; + + bir = pci_conf_read(pc, pa->pa_tag, PCI_BUSNUM); + if (((bir >> 8) & 0xff) != 0) + return; + + if (OF_getprop(OF_parent(node), "bus-range", &busrange, + sizeof(busrange)) != sizeof(busrange)) + return; + + bus = busrange[1] + 1; + while (bus < 256 && pc->busnode[bus]) + bus++; + if (bus == 256) + return; + pc->busnode[bus] = node; + + bir &= ~0x0000ff00; + bir |= (bus << 8); + pci_conf_write(pc, pa->pa_tag, PCI_BUSNUM, bir); +} |