From 2bbf5c811672d5b0c39d5784c61dd91913e8e045 Mon Sep 17 00:00:00 2001 From: Brad Smith Date: Mon, 13 Mar 2006 20:10:50 +0000 Subject: * Add "pcitag_t *pba_bridgetag" to pci_attach_args. This is set to NULL for root PCI busses. For busses behind a bridge, it points to a persistent copy of the bridge's pcitag_t. This can be very useful for machine-dependent PCI bus enumeration code. From NetBSD ok grange@ kettenis@ --- sys/dev/pci/pcivar.h | 9 ++++++++- sys/dev/pci/ppb.c | 15 +++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) (limited to 'sys/dev') diff --git a/sys/dev/pci/pcivar.h b/sys/dev/pci/pcivar.h index 9aa4858e92d..a3546de0868 100644 --- a/sys/dev/pci/pcivar.h +++ b/sys/dev/pci/pcivar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pcivar.h,v 1.43 2006/03/11 22:08:07 brad Exp $ */ +/* $OpenBSD: pcivar.h,v 1.44 2006/03/13 20:10:49 brad Exp $ */ /* $NetBSD: pcivar.h,v 1.23 1997/06/06 23:48:05 thorpej Exp $ */ /* @@ -82,6 +82,12 @@ struct pcibus_attach_args { int pba_bus; /* PCI bus number */ + /* + * Pointer to the pcitag of our parent bridge. If there is no + * parent bridge, then we assume we are a root bus. + */ + pcitag_t *pba_bridgetag; + /* * Interrupt swizzling information. These fields * are only used by secondary busses. @@ -149,6 +155,7 @@ struct pci_softc { void *sc_powerhook; LIST_HEAD(, pci_dev) sc_devs; int sc_bus; + pcitag_t *sc_bridgetag; }; /* diff --git a/sys/dev/pci/ppb.c b/sys/dev/pci/ppb.c index 888f55a4fd6..b40c1a10604 100644 --- a/sys/dev/pci/ppb.c +++ b/sys/dev/pci/ppb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ppb.c,v 1.13 2006/02/27 02:05:19 drahn Exp $ */ +/* $OpenBSD: ppb.c,v 1.14 2006/03/13 20:10:49 brad Exp $ */ /* $NetBSD: ppb.c,v 1.16 1997/06/06 23:48:05 thorpej Exp $ */ /* @@ -50,11 +50,17 @@ #include #include +struct ppb_softc { + struct device sc_dev; /* generic device glue */ + pci_chipset_tag_t sc_pc; /* our PCI chipset... */ + pcitag_t sc_tag; /* ...and tag. */ +}; + int ppbmatch(struct device *, void *, void *); void ppbattach(struct device *, struct device *, void *); struct cfattach ppb_ca = { - sizeof(struct device), ppbmatch, ppbattach + sizeof(struct ppb_softc), ppbmatch, ppbattach }; struct cfdriver ppb_cd = { @@ -96,6 +102,7 @@ ppbattach(parent, self, aux) struct device *parent, *self; void *aux; { + struct ppb_softc *sc = (void *) self; struct pci_attach_args *pa = aux; pci_chipset_tag_t pc = pa->pa_pc; struct pcibus_attach_args pba; @@ -103,6 +110,9 @@ ppbattach(parent, self, aux) printf("\n"); + sc->sc_pc = pc; + sc->sc_tag = pa->pa_tag; + busdata = pci_conf_read(pc, pa->pa_tag, PPB_REG_BUSINFO); if (PPB_BUSINFO_SECONDARY(busdata) == 0) { @@ -132,6 +142,7 @@ ppbattach(parent, self, aux) pba.pba_dmat = pa->pa_dmat; pba.pba_pc = pc; pba.pba_bus = PPB_BUSINFO_SECONDARY(busdata); + pba.pba_bridgetag = &sc->sc_tag; pba.pba_intrswiz = pa->pa_intrswiz; pba.pba_intrtag = pa->pa_intrtag; -- cgit v1.2.3