115e32d5dSMike Smith /*- 215e32d5dSMike Smith * Copyright (c) 2000 Michael Smith 315e32d5dSMike Smith * Copyright (c) 2000 BSDi 415e32d5dSMike Smith * All rights reserved. 515e32d5dSMike Smith * 615e32d5dSMike Smith * Redistribution and use in source and binary forms, with or without 715e32d5dSMike Smith * modification, are permitted provided that the following conditions 815e32d5dSMike Smith * are met: 915e32d5dSMike Smith * 1. Redistributions of source code must retain the above copyright 1015e32d5dSMike Smith * notice, this list of conditions and the following disclaimer. 1115e32d5dSMike Smith * 2. Redistributions in binary form must reproduce the above copyright 1215e32d5dSMike Smith * notice, this list of conditions and the following disclaimer in the 1315e32d5dSMike Smith * documentation and/or other materials provided with the distribution. 1415e32d5dSMike Smith * 1515e32d5dSMike Smith * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1615e32d5dSMike Smith * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1715e32d5dSMike Smith * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1815e32d5dSMike Smith * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1915e32d5dSMike Smith * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2015e32d5dSMike Smith * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2115e32d5dSMike Smith * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2215e32d5dSMike Smith * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2315e32d5dSMike Smith * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2415e32d5dSMike Smith * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2515e32d5dSMike Smith * SUCH DAMAGE. 2615e32d5dSMike Smith */ 27dad97feeSDavid E. O'Brien 28dad97feeSDavid E. O'Brien #include <sys/cdefs.h> 29dad97feeSDavid E. O'Brien __FBSDID("$FreeBSD$"); 30dad97feeSDavid E. O'Brien 3115e32d5dSMike Smith #include "opt_acpi.h" 3282cb5c3bSJohn Baldwin #include "opt_pci.h" 3382cb5c3bSJohn Baldwin 3415e32d5dSMike Smith #include <sys/param.h> 3515e32d5dSMike Smith #include <sys/bus.h> 364fa387b6SMike Smith #include <sys/kernel.h> 3734ff71eeSJohn Baldwin #include <sys/limits.h> 38e3aa81b8SNate Lawson #include <sys/malloc.h> 39fe12f24bSPoul-Henning Kamp #include <sys/module.h> 4083c41143SJohn Baldwin #include <sys/rman.h> 41fd492ee0SWarner Losh #include <sys/sysctl.h> 4215e32d5dSMike Smith 43129d3046SJung-uk Kim #include <contrib/dev/acpica/include/acpi.h> 44129d3046SJung-uk Kim #include <contrib/dev/acpica/include/accommon.h> 45129d3046SJung-uk Kim 4615e32d5dSMike Smith #include <dev/acpica/acpivar.h> 4715e32d5dSMike Smith 4815e32d5dSMike Smith #include <machine/pci_cfgreg.h> 494edef187SJohn Baldwin #include <dev/pci/pcireg.h> 50cace7a2aSWarner Losh #include <dev/pci/pcivar.h> 51cace7a2aSWarner Losh #include <dev/pci/pcib_private.h> 5215e32d5dSMike Smith #include "pcib_if.h" 5315e32d5dSMike Smith 542ccfc932SJohn Baldwin #include <dev/acpica/acpi_pcibvar.h> 552ccfc932SJohn Baldwin 56e3aa81b8SNate Lawson /* Hooks for the ACPI CA debugging infrastructure. */ 57e71b6381SMike Smith #define _COMPONENT ACPI_BUS 582ccfc932SJohn Baldwin ACPI_MODULE_NAME("PCI_ACPI") 590ae55423SMike Smith 602ccfc932SJohn Baldwin struct acpi_hpcib_softc { 6115e32d5dSMike Smith device_t ap_dev; 6215e32d5dSMike Smith ACPI_HANDLE ap_handle; 63d4b9ff91SNate Lawson int ap_flags; 6415e32d5dSMike Smith 650d95597cSJohn Baldwin int ap_segment; /* PCI domain */ 6615e32d5dSMike Smith int ap_bus; /* bios-assigned bus number */ 670d95597cSJohn Baldwin int ap_addr; /* device/func of PCI-Host bridge */ 684fa387b6SMike Smith 694fa387b6SMike Smith ACPI_BUFFER ap_prt; /* interrupt routing table */ 7034ff71eeSJohn Baldwin #ifdef NEW_PCIB 7134ff71eeSJohn Baldwin struct pcib_host_resources ap_host_res; 7234ff71eeSJohn Baldwin #endif 7315e32d5dSMike Smith }; 7415e32d5dSMike Smith 752ccfc932SJohn Baldwin static int acpi_pcib_acpi_probe(device_t bus); 762ccfc932SJohn Baldwin static int acpi_pcib_acpi_attach(device_t bus); 77e3aa81b8SNate Lawson static int acpi_pcib_read_ivar(device_t dev, device_t child, 78e3aa81b8SNate Lawson int which, uintptr_t *result); 79e3aa81b8SNate Lawson static int acpi_pcib_write_ivar(device_t dev, device_t child, 80e3aa81b8SNate Lawson int which, uintptr_t value); 811496d4a9SWarner Losh static uint32_t acpi_pcib_read_config(device_t dev, u_int bus, 821496d4a9SWarner Losh u_int slot, u_int func, u_int reg, int bytes); 831496d4a9SWarner Losh static void acpi_pcib_write_config(device_t dev, u_int bus, 841496d4a9SWarner Losh u_int slot, u_int func, u_int reg, uint32_t data, 851496d4a9SWarner Losh int bytes); 862ccfc932SJohn Baldwin static int acpi_pcib_acpi_route_interrupt(device_t pcib, 872ccfc932SJohn Baldwin device_t dev, int pin); 888964299aSJohn Baldwin static int acpi_pcib_alloc_msi(device_t pcib, device_t dev, 898964299aSJohn Baldwin int count, int maxcount, int *irqs); 90e706f7f0SJohn Baldwin static int acpi_pcib_map_msi(device_t pcib, device_t dev, 91e706f7f0SJohn Baldwin int irq, uint64_t *addr, uint32_t *data); 928964299aSJohn Baldwin static int acpi_pcib_alloc_msix(device_t pcib, device_t dev, 93e706f7f0SJohn Baldwin int *irq); 94cd8b53edSWarner Losh static struct resource *acpi_pcib_acpi_alloc_resource(device_t dev, 95cd8b53edSWarner Losh device_t child, int type, int *rid, 962dd1bdf1SJustin Hibbits rman_res_t start, rman_res_t end, rman_res_t count, 97cd8b53edSWarner Losh u_int flags); 9834ff71eeSJohn Baldwin #ifdef NEW_PCIB 9934ff71eeSJohn Baldwin static int acpi_pcib_acpi_adjust_resource(device_t dev, 10034ff71eeSJohn Baldwin device_t child, int type, struct resource *r, 1012dd1bdf1SJustin Hibbits rman_res_t start, rman_res_t end); 1024edef187SJohn Baldwin #ifdef PCI_RES_BUS 1034edef187SJohn Baldwin static int acpi_pcib_acpi_release_resource(device_t dev, 1044edef187SJohn Baldwin device_t child, int type, int rid, 1054edef187SJohn Baldwin struct resource *r); 1064edef187SJohn Baldwin #endif 10734ff71eeSJohn Baldwin #endif 10815e32d5dSMike Smith 1092ccfc932SJohn Baldwin static device_method_t acpi_pcib_acpi_methods[] = { 11015e32d5dSMike Smith /* Device interface */ 1112ccfc932SJohn Baldwin DEVMETHOD(device_probe, acpi_pcib_acpi_probe), 1122ccfc932SJohn Baldwin DEVMETHOD(device_attach, acpi_pcib_acpi_attach), 11315e32d5dSMike Smith DEVMETHOD(device_shutdown, bus_generic_shutdown), 11415e32d5dSMike Smith DEVMETHOD(device_suspend, bus_generic_suspend), 1157d23a9b3SJohn Baldwin DEVMETHOD(device_resume, bus_generic_resume), 11615e32d5dSMike Smith 11715e32d5dSMike Smith /* Bus interface */ 11815e32d5dSMike Smith DEVMETHOD(bus_read_ivar, acpi_pcib_read_ivar), 11915e32d5dSMike Smith DEVMETHOD(bus_write_ivar, acpi_pcib_write_ivar), 120cd8b53edSWarner Losh DEVMETHOD(bus_alloc_resource, acpi_pcib_acpi_alloc_resource), 12134ff71eeSJohn Baldwin #ifdef NEW_PCIB 12234ff71eeSJohn Baldwin DEVMETHOD(bus_adjust_resource, acpi_pcib_acpi_adjust_resource), 12334ff71eeSJohn Baldwin #else 124d2c9344fSJohn Baldwin DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource), 12534ff71eeSJohn Baldwin #endif 1264edef187SJohn Baldwin #if defined(NEW_PCIB) && defined(PCI_RES_BUS) 1274edef187SJohn Baldwin DEVMETHOD(bus_release_resource, acpi_pcib_acpi_release_resource), 1284edef187SJohn Baldwin #else 12915e32d5dSMike Smith DEVMETHOD(bus_release_resource, bus_generic_release_resource), 1304edef187SJohn Baldwin #endif 13115e32d5dSMike Smith DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), 13215e32d5dSMike Smith DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), 13315e32d5dSMike Smith DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), 13415e32d5dSMike Smith DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), 1358d791e5aSJohn Baldwin DEVMETHOD(bus_get_cpus, acpi_pcib_get_cpus), 13615e32d5dSMike Smith 13715e32d5dSMike Smith /* pcib interface */ 1382ccfc932SJohn Baldwin DEVMETHOD(pcib_maxslots, pcib_maxslots), 13915e32d5dSMike Smith DEVMETHOD(pcib_read_config, acpi_pcib_read_config), 14015e32d5dSMike Smith DEVMETHOD(pcib_write_config, acpi_pcib_write_config), 1412ccfc932SJohn Baldwin DEVMETHOD(pcib_route_interrupt, acpi_pcib_acpi_route_interrupt), 1428964299aSJohn Baldwin DEVMETHOD(pcib_alloc_msi, acpi_pcib_alloc_msi), 1439bf4c9c1SJohn Baldwin DEVMETHOD(pcib_release_msi, pcib_release_msi), 1448964299aSJohn Baldwin DEVMETHOD(pcib_alloc_msix, acpi_pcib_alloc_msix), 1459bf4c9c1SJohn Baldwin DEVMETHOD(pcib_release_msix, pcib_release_msix), 146e706f7f0SJohn Baldwin DEVMETHOD(pcib_map_msi, acpi_pcib_map_msi), 14762508c53SJohn Baldwin DEVMETHOD(pcib_power_for_sleep, acpi_pcib_power_for_sleep), 14815e32d5dSMike Smith 1494b7ec270SMarius Strobl DEVMETHOD_END 15015e32d5dSMike Smith }; 15115e32d5dSMike Smith 15204dda605SJohn Baldwin static devclass_t pcib_devclass; 15315e32d5dSMike Smith 15404dda605SJohn Baldwin DEFINE_CLASS_0(pcib, acpi_pcib_acpi_driver, acpi_pcib_acpi_methods, 15504dda605SJohn Baldwin sizeof(struct acpi_hpcib_softc)); 1562ccfc932SJohn Baldwin DRIVER_MODULE(acpi_pcib, acpi, acpi_pcib_acpi_driver, pcib_devclass, 0, 0); 15764278df5SNate Lawson MODULE_DEPEND(acpi_pcib, acpi, 1, 1, 1); 15815e32d5dSMike Smith 15915e32d5dSMike Smith static int 1602ccfc932SJohn Baldwin acpi_pcib_acpi_probe(device_t dev) 16115e32d5dSMike Smith { 16292488a57SJung-uk Kim ACPI_DEVICE_INFO *devinfo; 16392488a57SJung-uk Kim ACPI_HANDLE h; 16492488a57SJung-uk Kim int root; 16515e32d5dSMike Smith 16692488a57SJung-uk Kim if (acpi_disabled("pcib") || (h = acpi_get_handle(dev)) == NULL || 16792488a57SJung-uk Kim ACPI_FAILURE(AcpiGetObjectInfo(h, &devinfo))) 16892488a57SJung-uk Kim return (ENXIO); 16992488a57SJung-uk Kim root = (devinfo->Flags & ACPI_PCI_ROOT_BRIDGE) != 0; 17092488a57SJung-uk Kim AcpiOsFree(devinfo); 17192488a57SJung-uk Kim if (!root || pci_cfgregopen() == 0) 1725fcc8a58SNate Lawson return (ENXIO); 17315e32d5dSMike Smith 1742ccfc932SJohn Baldwin device_set_desc(dev, "ACPI Host-PCI bridge"); 17515e32d5dSMike Smith return (0); 17615e32d5dSMike Smith } 17715e32d5dSMike Smith 17834ff71eeSJohn Baldwin #ifdef NEW_PCIB 17934ff71eeSJohn Baldwin static ACPI_STATUS 18034ff71eeSJohn Baldwin acpi_pcib_producer_handler(ACPI_RESOURCE *res, void *context) 18134ff71eeSJohn Baldwin { 18234ff71eeSJohn Baldwin struct acpi_hpcib_softc *sc; 18334ff71eeSJohn Baldwin UINT64 length, min, max; 18434ff71eeSJohn Baldwin u_int flags; 18534ff71eeSJohn Baldwin int error, type; 18634ff71eeSJohn Baldwin 18734ff71eeSJohn Baldwin sc = context; 18834ff71eeSJohn Baldwin switch (res->Type) { 18934ff71eeSJohn Baldwin case ACPI_RESOURCE_TYPE_START_DEPENDENT: 19034ff71eeSJohn Baldwin case ACPI_RESOURCE_TYPE_END_DEPENDENT: 19134ff71eeSJohn Baldwin panic("host bridge has depenedent resources"); 19234ff71eeSJohn Baldwin case ACPI_RESOURCE_TYPE_ADDRESS16: 19334ff71eeSJohn Baldwin case ACPI_RESOURCE_TYPE_ADDRESS32: 19434ff71eeSJohn Baldwin case ACPI_RESOURCE_TYPE_ADDRESS64: 19534ff71eeSJohn Baldwin case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64: 19634ff71eeSJohn Baldwin if (res->Data.Address.ProducerConsumer != ACPI_PRODUCER) 19734ff71eeSJohn Baldwin break; 19834ff71eeSJohn Baldwin switch (res->Type) { 19934ff71eeSJohn Baldwin case ACPI_RESOURCE_TYPE_ADDRESS16: 2007cf3e94aSJung-uk Kim min = res->Data.Address16.Address.Minimum; 2017cf3e94aSJung-uk Kim max = res->Data.Address16.Address.Maximum; 2027cf3e94aSJung-uk Kim length = res->Data.Address16.Address.AddressLength; 20334ff71eeSJohn Baldwin break; 20434ff71eeSJohn Baldwin case ACPI_RESOURCE_TYPE_ADDRESS32: 2057cf3e94aSJung-uk Kim min = res->Data.Address32.Address.Minimum; 2067cf3e94aSJung-uk Kim max = res->Data.Address32.Address.Maximum; 2077cf3e94aSJung-uk Kim length = res->Data.Address32.Address.AddressLength; 20834ff71eeSJohn Baldwin break; 20934ff71eeSJohn Baldwin case ACPI_RESOURCE_TYPE_ADDRESS64: 2107cf3e94aSJung-uk Kim min = res->Data.Address64.Address.Minimum; 2117cf3e94aSJung-uk Kim max = res->Data.Address64.Address.Maximum; 2127cf3e94aSJung-uk Kim length = res->Data.Address64.Address.AddressLength; 21334ff71eeSJohn Baldwin break; 21434ff71eeSJohn Baldwin default: 21534ff71eeSJohn Baldwin KASSERT(res->Type == 21634ff71eeSJohn Baldwin ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64, 21734ff71eeSJohn Baldwin ("should never happen")); 2187cf3e94aSJung-uk Kim min = res->Data.ExtAddress64.Address.Minimum; 2197cf3e94aSJung-uk Kim max = res->Data.ExtAddress64.Address.Maximum; 2207cf3e94aSJung-uk Kim length = res->Data.ExtAddress64.Address.AddressLength; 22134ff71eeSJohn Baldwin break; 22234ff71eeSJohn Baldwin } 223e9f91b2bSJohn Baldwin if (length == 0) 224e9f91b2bSJohn Baldwin break; 225e9f91b2bSJohn Baldwin if (min + length - 1 != max && 226e9f91b2bSJohn Baldwin (res->Data.Address.MinAddressFixed != ACPI_ADDRESS_FIXED || 227e9f91b2bSJohn Baldwin res->Data.Address.MaxAddressFixed != ACPI_ADDRESS_FIXED)) 22834ff71eeSJohn Baldwin break; 22934ff71eeSJohn Baldwin flags = 0; 23034ff71eeSJohn Baldwin switch (res->Data.Address.ResourceType) { 23134ff71eeSJohn Baldwin case ACPI_MEMORY_RANGE: 23234ff71eeSJohn Baldwin type = SYS_RES_MEMORY; 23334ff71eeSJohn Baldwin if (res->Type != ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64) { 23434ff71eeSJohn Baldwin if (res->Data.Address.Info.Mem.Caching == 23534ff71eeSJohn Baldwin ACPI_PREFETCHABLE_MEMORY) 23634ff71eeSJohn Baldwin flags |= RF_PREFETCHABLE; 23734ff71eeSJohn Baldwin } else { 23834ff71eeSJohn Baldwin /* 23934ff71eeSJohn Baldwin * XXX: Parse prefetch flag out of 24034ff71eeSJohn Baldwin * TypeSpecific. 24134ff71eeSJohn Baldwin */ 24234ff71eeSJohn Baldwin } 24334ff71eeSJohn Baldwin break; 24434ff71eeSJohn Baldwin case ACPI_IO_RANGE: 24534ff71eeSJohn Baldwin type = SYS_RES_IOPORT; 24634ff71eeSJohn Baldwin break; 24734ff71eeSJohn Baldwin #ifdef PCI_RES_BUS 24834ff71eeSJohn Baldwin case ACPI_BUS_NUMBER_RANGE: 24934ff71eeSJohn Baldwin type = PCI_RES_BUS; 25034ff71eeSJohn Baldwin break; 25134ff71eeSJohn Baldwin #endif 25234ff71eeSJohn Baldwin default: 25334ff71eeSJohn Baldwin return (AE_OK); 25434ff71eeSJohn Baldwin } 25534ff71eeSJohn Baldwin 25634ff71eeSJohn Baldwin if (min + length - 1 != max) 25734ff71eeSJohn Baldwin device_printf(sc->ap_dev, 25834ff71eeSJohn Baldwin "Length mismatch for %d range: %jx vs %jx\n", type, 2590c10b85aSJung-uk Kim (uintmax_t)(max - min + 1), (uintmax_t)length); 26034ff71eeSJohn Baldwin #ifdef __i386__ 26134ff71eeSJohn Baldwin if (min > ULONG_MAX) { 26234ff71eeSJohn Baldwin device_printf(sc->ap_dev, 26334ff71eeSJohn Baldwin "Ignoring %d range above 4GB (%#jx-%#jx)\n", 26434ff71eeSJohn Baldwin type, (uintmax_t)min, (uintmax_t)max); 26534ff71eeSJohn Baldwin break; 26634ff71eeSJohn Baldwin } 26734ff71eeSJohn Baldwin if (max > ULONG_MAX) { 26834ff71eeSJohn Baldwin device_printf(sc->ap_dev, 26934ff71eeSJohn Baldwin "Truncating end of %d range above 4GB (%#jx-%#jx)\n", 27034ff71eeSJohn Baldwin type, (uintmax_t)min, (uintmax_t)max); 27134ff71eeSJohn Baldwin max = ULONG_MAX; 27234ff71eeSJohn Baldwin } 27334ff71eeSJohn Baldwin #endif 27434ff71eeSJohn Baldwin error = pcib_host_res_decodes(&sc->ap_host_res, type, min, max, 27534ff71eeSJohn Baldwin flags); 27634ff71eeSJohn Baldwin if (error) 27734ff71eeSJohn Baldwin panic("Failed to manage %d range (%#jx-%#jx): %d", 27834ff71eeSJohn Baldwin type, (uintmax_t)min, (uintmax_t)max, error); 27934ff71eeSJohn Baldwin break; 28034ff71eeSJohn Baldwin default: 28134ff71eeSJohn Baldwin break; 28234ff71eeSJohn Baldwin } 28334ff71eeSJohn Baldwin return (AE_OK); 28434ff71eeSJohn Baldwin } 28534ff71eeSJohn Baldwin #endif 28634ff71eeSJohn Baldwin 2874edef187SJohn Baldwin #if defined(NEW_PCIB) && defined(PCI_RES_BUS) 2884edef187SJohn Baldwin static int 2892dd1bdf1SJustin Hibbits first_decoded_bus(struct acpi_hpcib_softc *sc, rman_res_t *startp) 2904edef187SJohn Baldwin { 2914edef187SJohn Baldwin struct resource_list_entry *rle; 2924edef187SJohn Baldwin 2934edef187SJohn Baldwin rle = resource_list_find(&sc->ap_host_res.hr_rl, PCI_RES_BUS, 0); 2944edef187SJohn Baldwin if (rle == NULL) 2954edef187SJohn Baldwin return (ENXIO); 2964edef187SJohn Baldwin *startp = rle->start; 2974edef187SJohn Baldwin return (0); 2984edef187SJohn Baldwin } 2994edef187SJohn Baldwin #endif 3004edef187SJohn Baldwin 301508c21b6SJohn Baldwin static void 302508c21b6SJohn Baldwin acpi_pcib_osc(struct acpi_hpcib_softc *sc) 303508c21b6SJohn Baldwin { 304508c21b6SJohn Baldwin ACPI_STATUS status; 305508c21b6SJohn Baldwin uint32_t cap_set[3]; 306508c21b6SJohn Baldwin 307508c21b6SJohn Baldwin static uint8_t pci_host_bridge_uuid[ACPI_UUID_LENGTH] = { 308508c21b6SJohn Baldwin 0x5b, 0x4d, 0xdb, 0x33, 0xf7, 0x1f, 0x1c, 0x40, 309508c21b6SJohn Baldwin 0x96, 0x57, 0x74, 0x41, 0xc0, 0x3d, 0xd7, 0x66 310508c21b6SJohn Baldwin }; 311508c21b6SJohn Baldwin 312508c21b6SJohn Baldwin /* Support Field: Extended PCI Config Space, MSI */ 313508c21b6SJohn Baldwin cap_set[1] = 0x11; 314508c21b6SJohn Baldwin 315508c21b6SJohn Baldwin /* Control Field */ 316508c21b6SJohn Baldwin cap_set[2] = 0; 317508c21b6SJohn Baldwin 31882cb5c3bSJohn Baldwin #ifdef PCI_HP 31982cb5c3bSJohn Baldwin /* Control Field: PCI Express Native Hot Plug */ 32082cb5c3bSJohn Baldwin cap_set[2] |= 0x1; 32182cb5c3bSJohn Baldwin #endif 32282cb5c3bSJohn Baldwin 323508c21b6SJohn Baldwin status = acpi_EvaluateOSC(sc->ap_handle, pci_host_bridge_uuid, 1, 3244c26ac69SJohn Baldwin nitems(cap_set), cap_set, cap_set, false); 325508c21b6SJohn Baldwin if (ACPI_FAILURE(status)) { 326508c21b6SJohn Baldwin if (status == AE_NOT_FOUND) 327508c21b6SJohn Baldwin return; 328508c21b6SJohn Baldwin device_printf(sc->ap_dev, "_OSC failed: %s\n", 329508c21b6SJohn Baldwin AcpiFormatException(status)); 330508c21b6SJohn Baldwin return; 331508c21b6SJohn Baldwin } 332508c21b6SJohn Baldwin 333508c21b6SJohn Baldwin if (cap_set[0] != 0) { 334508c21b6SJohn Baldwin device_printf(sc->ap_dev, "_OSC returned error %#x\n", 335508c21b6SJohn Baldwin cap_set[0]); 336508c21b6SJohn Baldwin } 337508c21b6SJohn Baldwin } 338508c21b6SJohn Baldwin 33915e32d5dSMike Smith static int 3402ccfc932SJohn Baldwin acpi_pcib_acpi_attach(device_t dev) 34115e32d5dSMike Smith { 3422ccfc932SJohn Baldwin struct acpi_hpcib_softc *sc; 34315e32d5dSMike Smith ACPI_STATUS status; 3440668724bSJohn Baldwin static int bus0_seen = 0; 3450d95597cSJohn Baldwin u_int slot, func, busok; 3464edef187SJohn Baldwin #if defined(NEW_PCIB) && defined(PCI_RES_BUS) 3474edef187SJohn Baldwin struct resource *bus_res; 3482dd1bdf1SJustin Hibbits rman_res_t start; 3494edef187SJohn Baldwin int rid; 3504edef187SJohn Baldwin #endif 3519debb532SJohn Baldwin uint8_t busno; 3520ae55423SMike Smith 353b4a05238SPeter Wemm ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); 35415e32d5dSMike Smith 35515e32d5dSMike Smith sc = device_get_softc(dev); 35615e32d5dSMike Smith sc->ap_dev = dev; 35715e32d5dSMike Smith sc->ap_handle = acpi_get_handle(dev); 35815e32d5dSMike Smith 35915e32d5dSMike Smith /* 3608f4c2e52SJohn Baldwin * Don't attach if we're not really there. 3618f4c2e52SJohn Baldwin */ 3628f4c2e52SJohn Baldwin if (!acpi_DeviceIsPresent(dev)) 3638f4c2e52SJohn Baldwin return (ENXIO); 3648f4c2e52SJohn Baldwin 365508c21b6SJohn Baldwin acpi_pcib_osc(sc); 366508c21b6SJohn Baldwin 3678f4c2e52SJohn Baldwin /* 3680d95597cSJohn Baldwin * Get our segment number by evaluating _SEG. 3690668724bSJohn Baldwin * It's OK for this to not exist. 3700668724bSJohn Baldwin */ 3710668724bSJohn Baldwin status = acpi_GetInteger(sc->ap_handle, "_SEG", &sc->ap_segment); 3720668724bSJohn Baldwin if (ACPI_FAILURE(status)) { 3730668724bSJohn Baldwin if (status != AE_NOT_FOUND) { 3740668724bSJohn Baldwin device_printf(dev, "could not evaluate _SEG - %s\n", 3750668724bSJohn Baldwin AcpiFormatException(status)); 3760668724bSJohn Baldwin return_VALUE (ENXIO); 3770668724bSJohn Baldwin } 3780668724bSJohn Baldwin /* If it's not found, assume 0. */ 3790668724bSJohn Baldwin sc->ap_segment = 0; 3800668724bSJohn Baldwin } 3810668724bSJohn Baldwin 3820d95597cSJohn Baldwin /* 3830d95597cSJohn Baldwin * Get the address (device and function) of the associated 3840d95597cSJohn Baldwin * PCI-Host bridge device from _ADR. Assume we don't have one if 3850d95597cSJohn Baldwin * it doesn't exist. 3860d95597cSJohn Baldwin */ 3870d95597cSJohn Baldwin status = acpi_GetInteger(sc->ap_handle, "_ADR", &sc->ap_addr); 3880d95597cSJohn Baldwin if (ACPI_FAILURE(status)) { 3890d95597cSJohn Baldwin device_printf(dev, "could not evaluate _ADR - %s\n", 3900d95597cSJohn Baldwin AcpiFormatException(status)); 3910d95597cSJohn Baldwin sc->ap_addr = -1; 3920d95597cSJohn Baldwin } 3930d95597cSJohn Baldwin 39434ff71eeSJohn Baldwin #ifdef NEW_PCIB 39534ff71eeSJohn Baldwin /* 39634ff71eeSJohn Baldwin * Determine which address ranges this bridge decodes and setup 39734ff71eeSJohn Baldwin * resource managers for those ranges. 39834ff71eeSJohn Baldwin */ 39934ff71eeSJohn Baldwin if (pcib_host_res_init(sc->ap_dev, &sc->ap_host_res) != 0) 40034ff71eeSJohn Baldwin panic("failed to init hostb resources"); 40134ff71eeSJohn Baldwin if (!acpi_disabled("hostres")) { 40234ff71eeSJohn Baldwin status = AcpiWalkResources(sc->ap_handle, "_CRS", 40334ff71eeSJohn Baldwin acpi_pcib_producer_handler, sc); 40434ff71eeSJohn Baldwin if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) 40534ff71eeSJohn Baldwin device_printf(sc->ap_dev, "failed to parse resources: %s\n", 40634ff71eeSJohn Baldwin AcpiFormatException(status)); 40734ff71eeSJohn Baldwin } 40834ff71eeSJohn Baldwin #endif 40934ff71eeSJohn Baldwin 4100668724bSJohn Baldwin /* 4119debb532SJohn Baldwin * Get our base bus number by evaluating _BBN. 412c1b1f787SMike Smith * If this doesn't work, we assume we're bus number 0. 41315e32d5dSMike Smith * 41415e32d5dSMike Smith * XXX note that it may also not exist in the case where we are 41515e32d5dSMike Smith * meant to use a private configuration space mechanism for this bus, 41615e32d5dSMike Smith * so we should dig out our resources and check to see if we have 41715e32d5dSMike Smith * anything like that. How do we do this? 418042283a6SMike Smith * XXX If we have the requisite information, and if we don't think the 419042283a6SMike Smith * default PCI configuration space handlers can deal with this bus, 420042283a6SMike Smith * we should attach our own handler. 421042283a6SMike Smith * XXX invoke _REG on this for the PCI config space address space? 4229debb532SJohn Baldwin * XXX It seems many BIOS's with multiple Host-PCI bridges do not set 4239debb532SJohn Baldwin * _BBN correctly. They set _BBN to zero for all bridges. Thus, 4240668724bSJohn Baldwin * if _BBN is zero and PCI bus 0 already exists, we try to read our 4259debb532SJohn Baldwin * bus number from the configuration registers at address _ADR. 4260668724bSJohn Baldwin * We only do this for domain/segment 0 in the hopes that this is 4270668724bSJohn Baldwin * only needed for old single-domain machines. 42815e32d5dSMike Smith */ 429c310653eSNate Lawson status = acpi_GetInteger(sc->ap_handle, "_BBN", &sc->ap_bus); 4309debb532SJohn Baldwin if (ACPI_FAILURE(status)) { 43115e32d5dSMike Smith if (status != AE_NOT_FOUND) { 4329debb532SJohn Baldwin device_printf(dev, "could not evaluate _BBN - %s\n", 4339debb532SJohn Baldwin AcpiFormatException(status)); 4348f4c2e52SJohn Baldwin return (ENXIO); 435c1b1f787SMike Smith } else { 436e3aa81b8SNate Lawson /* If it's not found, assume 0. */ 43715e32d5dSMike Smith sc->ap_bus = 0; 43815e32d5dSMike Smith } 4398745ec57SJohn Baldwin } 4409debb532SJohn Baldwin 4419debb532SJohn Baldwin /* 4420668724bSJohn Baldwin * If this is segment 0, the bus is zero, and PCI bus 0 already 4430668724bSJohn Baldwin * exists, read the bus number via PCI config space. 4449debb532SJohn Baldwin */ 4459debb532SJohn Baldwin busok = 1; 4460668724bSJohn Baldwin if (sc->ap_segment == 0 && sc->ap_bus == 0 && bus0_seen) { 4478745ec57SJohn Baldwin busok = 0; 4480d95597cSJohn Baldwin if (sc->ap_addr != -1) { 4499debb532SJohn Baldwin /* XXX: We assume bus 0. */ 4500d95597cSJohn Baldwin slot = ACPI_ADR_PCI_SLOT(sc->ap_addr); 4510d95597cSJohn Baldwin func = ACPI_ADR_PCI_FUNC(sc->ap_addr); 4529debb532SJohn Baldwin if (bootverbose) 4539debb532SJohn Baldwin device_printf(dev, "reading config registers from 0:%d:%d\n", 4549debb532SJohn Baldwin slot, func); 4558745ec57SJohn Baldwin if (host_pcib_get_busno(pci_cfgregread, 0, slot, func, &busno) == 0) 456e3aa81b8SNate Lawson device_printf(dev, "couldn't read bus number from cfg space\n"); 4578745ec57SJohn Baldwin else { 4589debb532SJohn Baldwin sc->ap_bus = busno; 4598745ec57SJohn Baldwin busok = 1; 4609debb532SJohn Baldwin } 4619debb532SJohn Baldwin } 4629debb532SJohn Baldwin } 4639debb532SJohn Baldwin 4644edef187SJohn Baldwin #if defined(NEW_PCIB) && defined(PCI_RES_BUS) 4654edef187SJohn Baldwin /* 4664edef187SJohn Baldwin * If nothing else worked, hope that ACPI at least lays out the 4674edef187SJohn Baldwin * Host-PCI bridges in order and that as a result the next free 4684edef187SJohn Baldwin * bus number is our bus number. 4694edef187SJohn Baldwin */ 4704edef187SJohn Baldwin if (busok == 0) { 4714edef187SJohn Baldwin /* 4724edef187SJohn Baldwin * If we have a region of bus numbers, use the first 4734edef187SJohn Baldwin * number for our bus. 4744edef187SJohn Baldwin */ 4754edef187SJohn Baldwin if (first_decoded_bus(sc, &start) == 0) 4764edef187SJohn Baldwin sc->ap_bus = start; 4774edef187SJohn Baldwin else { 4784edef187SJohn Baldwin rid = 0; 4794edef187SJohn Baldwin bus_res = pci_domain_alloc_bus(sc->ap_segment, dev, &rid, 0, 4804edef187SJohn Baldwin PCI_BUSMAX, 1, 0); 4814edef187SJohn Baldwin if (bus_res == NULL) { 4824edef187SJohn Baldwin device_printf(dev, 4834edef187SJohn Baldwin "could not allocate bus number\n"); 4844edef187SJohn Baldwin pcib_host_res_free(dev, &sc->ap_host_res); 4854edef187SJohn Baldwin return (ENXIO); 4864edef187SJohn Baldwin } 4874edef187SJohn Baldwin sc->ap_bus = rman_get_start(bus_res); 4884edef187SJohn Baldwin pci_domain_release_bus(sc->ap_segment, dev, rid, bus_res); 4894edef187SJohn Baldwin } 4904edef187SJohn Baldwin } else { 491*a1eff92bSJohn Baldwin /* 492*a1eff92bSJohn Baldwin * Require the bus number from _BBN to match the start of any 493*a1eff92bSJohn Baldwin * decoded range. 494*a1eff92bSJohn Baldwin */ 495*a1eff92bSJohn Baldwin if (first_decoded_bus(sc, &start) == 0 && sc->ap_bus != start) { 496*a1eff92bSJohn Baldwin device_printf(dev, 497*a1eff92bSJohn Baldwin "bus number %d does not match start of decoded range %ju\n", 498*a1eff92bSJohn Baldwin sc->ap_bus, (uintmax_t)start); 499*a1eff92bSJohn Baldwin pcib_host_res_free(dev, &sc->ap_host_res); 500*a1eff92bSJohn Baldwin return (ENXIO); 501*a1eff92bSJohn Baldwin } 5024edef187SJohn Baldwin } 5034edef187SJohn Baldwin #else 5049debb532SJohn Baldwin /* 5059debb532SJohn Baldwin * If nothing else worked, hope that ACPI at least lays out the 5069debb532SJohn Baldwin * host-PCI bridges in order and that as a result our unit number 5079debb532SJohn Baldwin * is actually our bus number. There are several reasons this 5089debb532SJohn Baldwin * might not be true. 5099debb532SJohn Baldwin */ 5109debb532SJohn Baldwin if (busok == 0) { 5119debb532SJohn Baldwin sc->ap_bus = device_get_unit(dev); 5129debb532SJohn Baldwin device_printf(dev, "trying bus number %d\n", sc->ap_bus); 513c1b1f787SMike Smith } 5144edef187SJohn Baldwin #endif 51515e32d5dSMike Smith 5160668724bSJohn Baldwin /* If this is bus 0 on segment 0, note that it has been seen already. */ 5170668724bSJohn Baldwin if (sc->ap_segment == 0 && sc->ap_bus == 0) 5180668724bSJohn Baldwin bus0_seen = 1; 51915e32d5dSMike Smith 52067e7d085SJohn Baldwin acpi_pcib_fetch_prt(dev, &sc->ap_prt); 52167e7d085SJohn Baldwin 52267e7d085SJohn Baldwin if (device_add_child(dev, "pci", -1) == NULL) { 52367e7d085SJohn Baldwin device_printf(device_get_parent(dev), "couldn't attach pci bus\n"); 524*a1eff92bSJohn Baldwin #if defined(NEW_PCIB) && defined(PCI_RES_BUS) 525*a1eff92bSJohn Baldwin pcib_host_res_free(dev, &sc->ap_host_res); 526*a1eff92bSJohn Baldwin #endif 52767e7d085SJohn Baldwin return (ENXIO); 52867e7d085SJohn Baldwin } 52967e7d085SJohn Baldwin return (bus_generic_attach(dev)); 53015e32d5dSMike Smith } 53115e32d5dSMike Smith 5324fa387b6SMike Smith /* 5334fa387b6SMike Smith * Support for standard PCI bridge ivars. 5344fa387b6SMike Smith */ 53515e32d5dSMike Smith static int 53615e32d5dSMike Smith acpi_pcib_read_ivar(device_t dev, device_t child, int which, uintptr_t *result) 53715e32d5dSMike Smith { 5382ccfc932SJohn Baldwin struct acpi_hpcib_softc *sc = device_get_softc(dev); 53915e32d5dSMike Smith 54015e32d5dSMike Smith switch (which) { 54155aaf894SMarius Strobl case PCIB_IVAR_DOMAIN: 54224c93a6fSJohn Baldwin *result = sc->ap_segment; 54355aaf894SMarius Strobl return (0); 54415e32d5dSMike Smith case PCIB_IVAR_BUS: 54515e32d5dSMike Smith *result = sc->ap_bus; 54615e32d5dSMike Smith return (0); 5472ccfc932SJohn Baldwin case ACPI_IVAR_HANDLE: 5482ccfc932SJohn Baldwin *result = (uintptr_t)sc->ap_handle; 5492ccfc932SJohn Baldwin return (0); 550d4b9ff91SNate Lawson case ACPI_IVAR_FLAGS: 551d4b9ff91SNate Lawson *result = (uintptr_t)sc->ap_flags; 552d4b9ff91SNate Lawson return (0); 55315e32d5dSMike Smith } 55415e32d5dSMike Smith return (ENOENT); 55515e32d5dSMike Smith } 55615e32d5dSMike Smith 55715e32d5dSMike Smith static int 55815e32d5dSMike Smith acpi_pcib_write_ivar(device_t dev, device_t child, int which, uintptr_t value) 55915e32d5dSMike Smith { 5602ccfc932SJohn Baldwin struct acpi_hpcib_softc *sc = device_get_softc(dev); 56115e32d5dSMike Smith 56215e32d5dSMike Smith switch (which) { 56355aaf894SMarius Strobl case PCIB_IVAR_DOMAIN: 56455aaf894SMarius Strobl return (EINVAL); 56515e32d5dSMike Smith case PCIB_IVAR_BUS: 56615e32d5dSMike Smith sc->ap_bus = value; 56715e32d5dSMike Smith return (0); 568d4b9ff91SNate Lawson case ACPI_IVAR_HANDLE: 569d4b9ff91SNate Lawson sc->ap_handle = (ACPI_HANDLE)value; 570d4b9ff91SNate Lawson return (0); 571d4b9ff91SNate Lawson case ACPI_IVAR_FLAGS: 572d4b9ff91SNate Lawson sc->ap_flags = (int)value; 573d4b9ff91SNate Lawson return (0); 57415e32d5dSMike Smith } 57515e32d5dSMike Smith return (ENOENT); 57615e32d5dSMike Smith } 57715e32d5dSMike Smith 578e3aa81b8SNate Lawson static uint32_t 5791496d4a9SWarner Losh acpi_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func, 5801496d4a9SWarner Losh u_int reg, int bytes) 58115e32d5dSMike Smith { 58215e32d5dSMike Smith return (pci_cfgregread(bus, slot, func, reg, bytes)); 58315e32d5dSMike Smith } 58415e32d5dSMike Smith 58515e32d5dSMike Smith static void 5861496d4a9SWarner Losh acpi_pcib_write_config(device_t dev, u_int bus, u_int slot, u_int func, 5871496d4a9SWarner Losh u_int reg, uint32_t data, int bytes) 58815e32d5dSMike Smith { 58915e32d5dSMike Smith pci_cfgregwrite(bus, slot, func, reg, data, bytes); 59015e32d5dSMike Smith } 59115e32d5dSMike Smith 59215e32d5dSMike Smith static int 5932ccfc932SJohn Baldwin acpi_pcib_acpi_route_interrupt(device_t pcib, device_t dev, int pin) 59415e32d5dSMike Smith { 5955e1ba6d4SJohn Baldwin struct acpi_hpcib_softc *sc = device_get_softc(pcib); 5964fa387b6SMike Smith 5975e1ba6d4SJohn Baldwin return (acpi_pcib_route_interrupt(pcib, dev, pin, &sc->ap_prt)); 59815e32d5dSMike Smith } 599cd8b53edSWarner Losh 6008964299aSJohn Baldwin static int 6018964299aSJohn Baldwin acpi_pcib_alloc_msi(device_t pcib, device_t dev, int count, int maxcount, 6028964299aSJohn Baldwin int *irqs) 6038964299aSJohn Baldwin { 6048964299aSJohn Baldwin device_t bus; 6058964299aSJohn Baldwin 6068964299aSJohn Baldwin bus = device_get_parent(pcib); 6078964299aSJohn Baldwin return (PCIB_ALLOC_MSI(device_get_parent(bus), dev, count, maxcount, 6088964299aSJohn Baldwin irqs)); 6098964299aSJohn Baldwin } 6108964299aSJohn Baldwin 6118964299aSJohn Baldwin static int 612e706f7f0SJohn Baldwin acpi_pcib_alloc_msix(device_t pcib, device_t dev, int *irq) 6138964299aSJohn Baldwin { 6148964299aSJohn Baldwin device_t bus; 6158964299aSJohn Baldwin 6168964299aSJohn Baldwin bus = device_get_parent(pcib); 617e706f7f0SJohn Baldwin return (PCIB_ALLOC_MSIX(device_get_parent(bus), dev, irq)); 618e706f7f0SJohn Baldwin } 619e706f7f0SJohn Baldwin 620e706f7f0SJohn Baldwin static int 621e706f7f0SJohn Baldwin acpi_pcib_map_msi(device_t pcib, device_t dev, int irq, uint64_t *addr, 622e706f7f0SJohn Baldwin uint32_t *data) 623e706f7f0SJohn Baldwin { 6240d95597cSJohn Baldwin struct acpi_hpcib_softc *sc; 6250d95597cSJohn Baldwin device_t bus, hostb; 6260d95597cSJohn Baldwin int error; 627e706f7f0SJohn Baldwin 628e706f7f0SJohn Baldwin bus = device_get_parent(pcib); 6290d95597cSJohn Baldwin error = PCIB_MAP_MSI(device_get_parent(bus), dev, irq, addr, data); 6300d95597cSJohn Baldwin if (error) 6310d95597cSJohn Baldwin return (error); 6320d95597cSJohn Baldwin 633af0d1ee9SNeel Natu sc = device_get_softc(pcib); 6340d95597cSJohn Baldwin if (sc->ap_addr == -1) 6350d95597cSJohn Baldwin return (0); 6360d95597cSJohn Baldwin /* XXX: Assumes all bridges are on bus 0. */ 6370d95597cSJohn Baldwin hostb = pci_find_dbsf(sc->ap_segment, 0, ACPI_ADR_PCI_SLOT(sc->ap_addr), 6380d95597cSJohn Baldwin ACPI_ADR_PCI_FUNC(sc->ap_addr)); 6390d95597cSJohn Baldwin if (hostb != NULL) 6400d95597cSJohn Baldwin pci_ht_map_msi(hostb, *addr); 6410d95597cSJohn Baldwin return (0); 6428964299aSJohn Baldwin } 6438964299aSJohn Baldwin 644cd8b53edSWarner Losh struct resource * 645cd8b53edSWarner Losh acpi_pcib_acpi_alloc_resource(device_t dev, device_t child, int type, int *rid, 6462dd1bdf1SJustin Hibbits rman_res_t start, rman_res_t end, rman_res_t count, u_int flags) 647cd8b53edSWarner Losh { 64834ff71eeSJohn Baldwin #ifdef NEW_PCIB 64934ff71eeSJohn Baldwin struct acpi_hpcib_softc *sc; 6505d0d779bSJohn Baldwin struct resource *res; 65134ff71eeSJohn Baldwin #endif 65238d7a61bSJohn Baldwin 65338d7a61bSJohn Baldwin #if defined(__i386__) || defined(__amd64__) 65438d7a61bSJohn Baldwin start = hostb_alloc_start(type, start, end, count); 65538d7a61bSJohn Baldwin #endif 65634ff71eeSJohn Baldwin 65734ff71eeSJohn Baldwin #ifdef NEW_PCIB 65834ff71eeSJohn Baldwin sc = device_get_softc(dev); 6594edef187SJohn Baldwin #ifdef PCI_RES_BUS 6604edef187SJohn Baldwin if (type == PCI_RES_BUS) 6614edef187SJohn Baldwin return (pci_domain_alloc_bus(sc->ap_segment, child, rid, start, end, 6624edef187SJohn Baldwin count, flags)); 6634edef187SJohn Baldwin #endif 6645d0d779bSJohn Baldwin res = pcib_host_res_alloc(&sc->ap_host_res, child, type, rid, start, end, 6655d0d779bSJohn Baldwin count, flags); 666a74d6952SJohn Baldwin 667a74d6952SJohn Baldwin /* 668a74d6952SJohn Baldwin * XXX: If this is a request for a specific range, assume it is 669a74d6952SJohn Baldwin * correct and pass it up to the parent. What we probably want to 670a74d6952SJohn Baldwin * do long-term is explicitly trust any firmware-configured 671a74d6952SJohn Baldwin * resources during the initial bus scan on boot and then disable 672a74d6952SJohn Baldwin * this after that. 673a74d6952SJohn Baldwin */ 6745d0d779bSJohn Baldwin if (res == NULL && start + count - 1 == end) 675a74d6952SJohn Baldwin res = bus_generic_alloc_resource(dev, child, type, rid, start, end, 676a74d6952SJohn Baldwin count, flags); 6775d0d779bSJohn Baldwin return (res); 67834ff71eeSJohn Baldwin #else 679cd8b53edSWarner Losh return (bus_generic_alloc_resource(dev, child, type, rid, start, end, 680cd8b53edSWarner Losh count, flags)); 68134ff71eeSJohn Baldwin #endif 682cd8b53edSWarner Losh } 68334ff71eeSJohn Baldwin 68434ff71eeSJohn Baldwin #ifdef NEW_PCIB 68534ff71eeSJohn Baldwin int 68634ff71eeSJohn Baldwin acpi_pcib_acpi_adjust_resource(device_t dev, device_t child, int type, 6872dd1bdf1SJustin Hibbits struct resource *r, rman_res_t start, rman_res_t end) 68834ff71eeSJohn Baldwin { 68934ff71eeSJohn Baldwin struct acpi_hpcib_softc *sc; 69034ff71eeSJohn Baldwin 69134ff71eeSJohn Baldwin sc = device_get_softc(dev); 6924edef187SJohn Baldwin #ifdef PCI_RES_BUS 6934edef187SJohn Baldwin if (type == PCI_RES_BUS) 6944edef187SJohn Baldwin return (pci_domain_adjust_bus(sc->ap_segment, child, r, start, 6954edef187SJohn Baldwin end)); 6964edef187SJohn Baldwin #endif 69734ff71eeSJohn Baldwin return (pcib_host_res_adjust(&sc->ap_host_res, child, type, r, start, 69834ff71eeSJohn Baldwin end)); 69934ff71eeSJohn Baldwin } 7004edef187SJohn Baldwin 7014edef187SJohn Baldwin #ifdef PCI_RES_BUS 7024edef187SJohn Baldwin int 7034edef187SJohn Baldwin acpi_pcib_acpi_release_resource(device_t dev, device_t child, int type, int rid, 7044edef187SJohn Baldwin struct resource *r) 7054edef187SJohn Baldwin { 7064edef187SJohn Baldwin struct acpi_hpcib_softc *sc; 7074edef187SJohn Baldwin 7084edef187SJohn Baldwin sc = device_get_softc(dev); 7094edef187SJohn Baldwin if (type == PCI_RES_BUS) 7104edef187SJohn Baldwin return (pci_domain_release_bus(sc->ap_segment, child, rid, r)); 7114edef187SJohn Baldwin return (bus_generic_release_resource(dev, child, type, rid, r)); 7124edef187SJohn Baldwin } 7134edef187SJohn Baldwin #endif 71434ff71eeSJohn Baldwin #endif 715