diff options
author | jhb <jhb@FreeBSD.org> | 2015-04-01 21:48:54 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2015-04-01 21:48:54 +0000 |
commit | 5fdf8ec7775f40bbf293206a9670387f9b26b1e2 (patch) | |
tree | 0444ef99cffa06c0c3a81e7fa07483f56507ff35 /sys/dev/cardbus/cardbus.c | |
parent | 971b9a0eebccdc50b69052744c2221c13bd1a980 (diff) | |
download | FreeBSD-src-5fdf8ec7775f40bbf293206a9670387f9b26b1e2.zip FreeBSD-src-5fdf8ec7775f40bbf293206a9670387f9b26b1e2.tar.gz |
MFC 261790:
Add support for managing PCI bus numbers. As with BARs and PCI-PCI bridge
I/O windows, the default is to preserve the firmware-assigned resources.
PCI bus numbers are only managed if NEW_PCIB is enabled and the architecture
defines a PCI_RES_BUS resource type.
- Add a helper API to create top-level PCI bus resource managers for each
PCI domain/segment. Host-PCI bridge drivers use this API to allocate
bus numbers from their associated domain.
- Change the PCI bus and CardBus drivers to allocate a bus resource for
their bus number from the parent PCI bridge device.
- Change the PCI-PCI and PCI-CardBus bridge drivers to allocate the
full range of bus numbers from secbus to subbus from their parent bridge.
The drivers also always program their primary bus register. The bridge
drivers also support growing their bus range by extending the bus resource
and updating subbus to match the larger range.
- Add support for managing PCI bus resources to the Host-PCI bridge drivers
used for amd64 and i386 (acpi_pcib, mptable_pcib, legacy_pcib, and qpi_pcib).
- Define a PCI_RES_BUS resource type for amd64 and i386.
PR: 197076
Diffstat (limited to 'sys/dev/cardbus/cardbus.c')
-rw-r--r-- | sys/dev/cardbus/cardbus.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/sys/dev/cardbus/cardbus.c b/sys/dev/cardbus/cardbus.c index 608c1fe..00d4a19 100644 --- a/sys/dev/cardbus/cardbus.c +++ b/sys/dev/cardbus/cardbus.c @@ -96,17 +96,36 @@ static int cardbus_attach(device_t cbdev) { struct cardbus_softc *sc; +#ifdef PCI_RES_BUS + int rid; +#endif sc = device_get_softc(cbdev); sc->sc_dev = cbdev; +#ifdef PCI_RES_BUS + rid = 0; + sc->sc_bus = bus_alloc_resource(cbdev, PCI_RES_BUS, &rid, + pcib_get_bus(cbdev), pcib_get_bus(cbdev), 1, 0); + if (sc->sc_bus == NULL) { + device_printf(cbdev, "failed to allocate bus number\n"); + return (ENXIO); + } +#endif return (0); } static int cardbus_detach(device_t cbdev) { +#ifdef PCI_RES_BUS + struct cardbus_softc *sc; +#endif cardbus_detach_card(cbdev); +#ifdef PCI_RES_BUS + sc = device_get_softc(cbdev); + (void)bus_release_resource(cbdev, PCI_RES_BUS, 0, sc->sc_bus); +#endif return (0); } |