1bb0d0a8eSMike Smith /*- 2bb0d0a8eSMike Smith * Copyright (c) 1994,1995 Stefan Esser, Wolfgang StanglMeier 3bb0d0a8eSMike Smith * Copyright (c) 2000 Michael Smith <msmith@freebsd.org> 4bb0d0a8eSMike Smith * Copyright (c) 2000 BSDi 5bb0d0a8eSMike Smith * All rights reserved. 6bb0d0a8eSMike Smith * 7bb0d0a8eSMike Smith * Redistribution and use in source and binary forms, with or without 8bb0d0a8eSMike Smith * modification, are permitted provided that the following conditions 9bb0d0a8eSMike Smith * are met: 10bb0d0a8eSMike Smith * 1. Redistributions of source code must retain the above copyright 11bb0d0a8eSMike Smith * notice, this list of conditions and the following disclaimer. 12bb0d0a8eSMike Smith * 2. Redistributions in binary form must reproduce the above copyright 13bb0d0a8eSMike Smith * notice, this list of conditions and the following disclaimer in the 14bb0d0a8eSMike Smith * documentation and/or other materials provided with the distribution. 15bb0d0a8eSMike Smith * 3. The name of the author may not be used to endorse or promote products 16bb0d0a8eSMike Smith * derived from this software without specific prior written permission. 17bb0d0a8eSMike Smith * 18bb0d0a8eSMike Smith * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19bb0d0a8eSMike Smith * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20bb0d0a8eSMike Smith * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21bb0d0a8eSMike Smith * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22bb0d0a8eSMike Smith * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23bb0d0a8eSMike Smith * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24bb0d0a8eSMike Smith * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25bb0d0a8eSMike Smith * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26bb0d0a8eSMike Smith * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27bb0d0a8eSMike Smith * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28bb0d0a8eSMike Smith * SUCH DAMAGE. 29bb0d0a8eSMike Smith */ 30bb0d0a8eSMike Smith 31aad970f1SDavid E. O'Brien #include <sys/cdefs.h> 32aad970f1SDavid E. O'Brien __FBSDID("$FreeBSD$"); 33aad970f1SDavid E. O'Brien 34bb0d0a8eSMike Smith /* 35bb0d0a8eSMike Smith * PCI:PCI bridge support. 36bb0d0a8eSMike Smith */ 37bb0d0a8eSMike Smith 38bb0d0a8eSMike Smith #include <sys/param.h> 39bb0d0a8eSMike Smith #include <sys/systm.h> 40bb0d0a8eSMike Smith #include <sys/kernel.h> 4141ee9f1cSPoul-Henning Kamp #include <sys/module.h> 42bb0d0a8eSMike Smith #include <sys/bus.h> 43a8b354a8SWarner Losh #include <machine/bus.h> 44a8b354a8SWarner Losh #include <sys/rman.h> 451c54ff33SMatthew N. Dodd #include <sys/sysctl.h> 46bb0d0a8eSMike Smith 47bb0d0a8eSMike Smith #include <machine/resource.h> 48bb0d0a8eSMike Smith 4938d8c994SWarner Losh #include <dev/pci/pcivar.h> 5038d8c994SWarner Losh #include <dev/pci/pcireg.h> 5138d8c994SWarner Losh #include <dev/pci/pcib_private.h> 52bb0d0a8eSMike Smith 53bb0d0a8eSMike Smith #include "pcib_if.h" 54bb0d0a8eSMike Smith 55bb0d0a8eSMike Smith static int pcib_probe(device_t dev); 56bb0d0a8eSMike Smith 57bb0d0a8eSMike Smith static device_method_t pcib_methods[] = { 58bb0d0a8eSMike Smith /* Device interface */ 59bb0d0a8eSMike Smith DEVMETHOD(device_probe, pcib_probe), 60bb0d0a8eSMike Smith DEVMETHOD(device_attach, pcib_attach), 614e30440dSWarner Losh DEVMETHOD(device_detach, bus_generic_detach), 62bb0d0a8eSMike Smith DEVMETHOD(device_shutdown, bus_generic_shutdown), 63bb0d0a8eSMike Smith DEVMETHOD(device_suspend, bus_generic_suspend), 64bb0d0a8eSMike Smith DEVMETHOD(device_resume, bus_generic_resume), 65bb0d0a8eSMike Smith 66bb0d0a8eSMike Smith /* Bus interface */ 67bb0d0a8eSMike Smith DEVMETHOD(bus_print_child, bus_generic_print_child), 68bb0d0a8eSMike Smith DEVMETHOD(bus_read_ivar, pcib_read_ivar), 69bb0d0a8eSMike Smith DEVMETHOD(bus_write_ivar, pcib_write_ivar), 70bb0d0a8eSMike Smith DEVMETHOD(bus_alloc_resource, pcib_alloc_resource), 71bb0d0a8eSMike Smith DEVMETHOD(bus_release_resource, bus_generic_release_resource), 72bb0d0a8eSMike Smith DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), 73bb0d0a8eSMike Smith DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), 74bb0d0a8eSMike Smith DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), 75bb0d0a8eSMike Smith DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), 76bb0d0a8eSMike Smith 77bb0d0a8eSMike Smith /* pcib interface */ 78bb0d0a8eSMike Smith DEVMETHOD(pcib_maxslots, pcib_maxslots), 79bb0d0a8eSMike Smith DEVMETHOD(pcib_read_config, pcib_read_config), 80bb0d0a8eSMike Smith DEVMETHOD(pcib_write_config, pcib_write_config), 81bb0d0a8eSMike Smith DEVMETHOD(pcib_route_interrupt, pcib_route_interrupt), 829bf4c9c1SJohn Baldwin DEVMETHOD(pcib_alloc_msi, pcib_alloc_msi), 839bf4c9c1SJohn Baldwin DEVMETHOD(pcib_release_msi, pcib_release_msi), 849bf4c9c1SJohn Baldwin DEVMETHOD(pcib_alloc_msix, pcib_alloc_msix), 859bf4c9c1SJohn Baldwin DEVMETHOD(pcib_release_msix, pcib_release_msix), 86e706f7f0SJohn Baldwin DEVMETHOD(pcib_map_msi, pcib_map_msi), 87bb0d0a8eSMike Smith 88bb0d0a8eSMike Smith { 0, 0 } 89bb0d0a8eSMike Smith }; 90bb0d0a8eSMike Smith 9104dda605SJohn Baldwin static devclass_t pcib_devclass; 92bb0d0a8eSMike Smith 9304dda605SJohn Baldwin DEFINE_CLASS_0(pcib, pcib_driver, pcib_methods, sizeof(struct pcib_softc)); 94bb0d0a8eSMike Smith DRIVER_MODULE(pcib, pci, pcib_driver, pcib_devclass, 0, 0); 95bb0d0a8eSMike Smith 96bb0d0a8eSMike Smith /* 97b0a2d4b8SWarner Losh * Is the prefetch window open (eg, can we allocate memory in it?) 98b0a2d4b8SWarner Losh */ 99b0a2d4b8SWarner Losh static int 100b0a2d4b8SWarner Losh pcib_is_prefetch_open(struct pcib_softc *sc) 101b0a2d4b8SWarner Losh { 102b0a2d4b8SWarner Losh return (sc->pmembase > 0 && sc->pmembase < sc->pmemlimit); 103b0a2d4b8SWarner Losh } 104b0a2d4b8SWarner Losh 105b0a2d4b8SWarner Losh /* 106b0a2d4b8SWarner Losh * Is the nonprefetch window open (eg, can we allocate memory in it?) 107b0a2d4b8SWarner Losh */ 108b0a2d4b8SWarner Losh static int 109b0a2d4b8SWarner Losh pcib_is_nonprefetch_open(struct pcib_softc *sc) 110b0a2d4b8SWarner Losh { 111b0a2d4b8SWarner Losh return (sc->membase > 0 && sc->membase < sc->memlimit); 112b0a2d4b8SWarner Losh } 113b0a2d4b8SWarner Losh 114b0a2d4b8SWarner Losh /* 115b0a2d4b8SWarner Losh * Is the io window open (eg, can we allocate ports in it?) 116b0a2d4b8SWarner Losh */ 117b0a2d4b8SWarner Losh static int 118b0a2d4b8SWarner Losh pcib_is_io_open(struct pcib_softc *sc) 119b0a2d4b8SWarner Losh { 120b0a2d4b8SWarner Losh return (sc->iobase > 0 && sc->iobase < sc->iolimit); 121b0a2d4b8SWarner Losh } 122b0a2d4b8SWarner Losh 123b0a2d4b8SWarner Losh /* 124bb0d0a8eSMike Smith * Generic device interface 125bb0d0a8eSMike Smith */ 126bb0d0a8eSMike Smith static int 127bb0d0a8eSMike Smith pcib_probe(device_t dev) 128bb0d0a8eSMike Smith { 129bb0d0a8eSMike Smith if ((pci_get_class(dev) == PCIC_BRIDGE) && 130bb0d0a8eSMike Smith (pci_get_subclass(dev) == PCIS_BRIDGE_PCI)) { 131bb0d0a8eSMike Smith device_set_desc(dev, "PCI-PCI bridge"); 132bb0d0a8eSMike Smith return(-10000); 133bb0d0a8eSMike Smith } 134bb0d0a8eSMike Smith return(ENXIO); 135bb0d0a8eSMike Smith } 136bb0d0a8eSMike Smith 1376f0d5884SJohn Baldwin void 1386f0d5884SJohn Baldwin pcib_attach_common(device_t dev) 139bb0d0a8eSMike Smith { 140bb0d0a8eSMike Smith struct pcib_softc *sc; 141b0cb115fSWarner Losh uint8_t iolow; 142abf07f13SWarner Losh struct sysctl_ctx_list *sctx; 143abf07f13SWarner Losh struct sysctl_oid *soid; 144bb0d0a8eSMike Smith 145bb0d0a8eSMike Smith sc = device_get_softc(dev); 146bb0d0a8eSMike Smith sc->dev = dev; 147bb0d0a8eSMike Smith 1484fa59183SMike Smith /* 1494fa59183SMike Smith * Get current bridge configuration. 1504fa59183SMike Smith */ 1518983cfbfSMike Smith sc->command = pci_read_config(dev, PCIR_COMMAND, 1); 15255aaf894SMarius Strobl sc->domain = pci_get_domain(dev); 153abf07f13SWarner Losh sc->pribus = pci_read_config(dev, PCIR_PRIBUS_1, 1); 1544fa59183SMike Smith sc->secbus = pci_read_config(dev, PCIR_SECBUS_1, 1); 1554fa59183SMike Smith sc->subbus = pci_read_config(dev, PCIR_SUBBUS_1, 1); 1564fa59183SMike Smith sc->secstat = pci_read_config(dev, PCIR_SECSTAT_1, 2); 1574fa59183SMike Smith sc->bridgectl = pci_read_config(dev, PCIR_BRIDGECTL_1, 2); 1584fa59183SMike Smith sc->seclat = pci_read_config(dev, PCIR_SECLAT_1, 1); 1594fa59183SMike Smith 1604fa59183SMike Smith /* 161abf07f13SWarner Losh * Setup sysctl reporting nodes 162abf07f13SWarner Losh */ 163abf07f13SWarner Losh sctx = device_get_sysctl_ctx(dev); 164abf07f13SWarner Losh soid = device_get_sysctl_tree(dev); 165abf07f13SWarner Losh SYSCTL_ADD_UINT(sctx, SYSCTL_CHILDREN(soid), OID_AUTO, "domain", 166abf07f13SWarner Losh CTLFLAG_RD, &sc->domain, 0, "Domain number"); 167abf07f13SWarner Losh SYSCTL_ADD_UINT(sctx, SYSCTL_CHILDREN(soid), OID_AUTO, "pribus", 168abf07f13SWarner Losh CTLFLAG_RD, &sc->pribus, 0, "Primary bus number"); 169abf07f13SWarner Losh SYSCTL_ADD_UINT(sctx, SYSCTL_CHILDREN(soid), OID_AUTO, "secbus", 170abf07f13SWarner Losh CTLFLAG_RD, &sc->secbus, 0, "Secondary bus number"); 171abf07f13SWarner Losh SYSCTL_ADD_UINT(sctx, SYSCTL_CHILDREN(soid), OID_AUTO, "subbus", 172abf07f13SWarner Losh CTLFLAG_RD, &sc->subbus, 0, "Subordinate bus number"); 173abf07f13SWarner Losh 174abf07f13SWarner Losh /* 1754fa59183SMike Smith * Determine current I/O decode. 1764fa59183SMike Smith */ 1778983cfbfSMike Smith if (sc->command & PCIM_CMD_PORTEN) { 1784fa59183SMike Smith iolow = pci_read_config(dev, PCIR_IOBASEL_1, 1); 1794fa59183SMike Smith if ((iolow & PCIM_BRIO_MASK) == PCIM_BRIO_32) { 1804fa59183SMike Smith sc->iobase = PCI_PPBIOBASE(pci_read_config(dev, PCIR_IOBASEH_1, 2), 1814fa59183SMike Smith pci_read_config(dev, PCIR_IOBASEL_1, 1)); 1824fa59183SMike Smith } else { 1834fa59183SMike Smith sc->iobase = PCI_PPBIOBASE(0, pci_read_config(dev, PCIR_IOBASEL_1, 1)); 1844fa59183SMike Smith } 1854fa59183SMike Smith 1864fa59183SMike Smith iolow = pci_read_config(dev, PCIR_IOLIMITL_1, 1); 1874fa59183SMike Smith if ((iolow & PCIM_BRIO_MASK) == PCIM_BRIO_32) { 1884fa59183SMike Smith sc->iolimit = PCI_PPBIOLIMIT(pci_read_config(dev, PCIR_IOLIMITH_1, 2), 1894fa59183SMike Smith pci_read_config(dev, PCIR_IOLIMITL_1, 1)); 1904fa59183SMike Smith } else { 1914fa59183SMike Smith sc->iolimit = PCI_PPBIOLIMIT(0, pci_read_config(dev, PCIR_IOLIMITL_1, 1)); 1924fa59183SMike Smith } 1938983cfbfSMike Smith } 1944fa59183SMike Smith 1954fa59183SMike Smith /* 1964fa59183SMike Smith * Determine current memory decode. 1974fa59183SMike Smith */ 1988983cfbfSMike Smith if (sc->command & PCIM_CMD_MEMEN) { 1994fa59183SMike Smith sc->membase = PCI_PPBMEMBASE(0, pci_read_config(dev, PCIR_MEMBASE_1, 2)); 2004fa59183SMike Smith sc->memlimit = PCI_PPBMEMLIMIT(0, pci_read_config(dev, PCIR_MEMLIMIT_1, 2)); 201413d6375SWarner Losh sc->pmembase = PCI_PPBMEMBASE(pci_read_config(dev, PCIR_PMBASEH_1, 4), 2024fa59183SMike Smith pci_read_config(dev, PCIR_PMBASEL_1, 2)); 203413d6375SWarner Losh sc->pmemlimit = PCI_PPBMEMLIMIT(pci_read_config(dev, PCIR_PMLIMITH_1, 4), 2044fa59183SMike Smith pci_read_config(dev, PCIR_PMLIMITL_1, 2)); 2058983cfbfSMike Smith } 2064fa59183SMike Smith 2074fa59183SMike Smith /* 2084fa59183SMike Smith * Quirk handling. 2094fa59183SMike Smith */ 2104fa59183SMike Smith switch (pci_get_devid(dev)) { 2114fa59183SMike Smith case 0x12258086: /* Intel 82454KX/GX (Orion) */ 2124fa59183SMike Smith { 213b0cb115fSWarner Losh uint8_t supbus; 2144fa59183SMike Smith 2154fa59183SMike Smith supbus = pci_read_config(dev, 0x41, 1); 2164fa59183SMike Smith if (supbus != 0xff) { 2174fa59183SMike Smith sc->secbus = supbus + 1; 2184fa59183SMike Smith sc->subbus = supbus + 1; 2194fa59183SMike Smith } 2204fa59183SMike Smith break; 2214fa59183SMike Smith } 2224fa59183SMike Smith 223e4b59fc5SWarner Losh /* 224e4b59fc5SWarner Losh * The i82380FB mobile docking controller is a PCI-PCI bridge, 225e4b59fc5SWarner Losh * and it is a subtractive bridge. However, the ProgIf is wrong 226e4b59fc5SWarner Losh * so the normal setting of PCIB_SUBTRACTIVE bit doesn't 227e4b59fc5SWarner Losh * happen. There's also a Toshiba bridge that behaves this 228e4b59fc5SWarner Losh * way. 229e4b59fc5SWarner Losh */ 230e4b59fc5SWarner Losh case 0x124b8086: /* Intel 82380FB Mobile */ 231e4b59fc5SWarner Losh case 0x060513d7: /* Toshiba ???? */ 232e4b59fc5SWarner Losh sc->flags |= PCIB_SUBTRACTIVE; 233e4b59fc5SWarner Losh break; 234c94d6dbeSJung-uk Kim 235c94d6dbeSJung-uk Kim /* Compaq R3000 BIOS sets wrong subordinate bus number. */ 236c94d6dbeSJung-uk Kim case 0x00dd10de: 237c94d6dbeSJung-uk Kim { 238c94d6dbeSJung-uk Kim char *cp; 239c94d6dbeSJung-uk Kim 2401def0ca6SJung-uk Kim if ((cp = getenv("smbios.planar.maker")) == NULL) 241c94d6dbeSJung-uk Kim break; 2421def0ca6SJung-uk Kim if (strncmp(cp, "Compal", 6) != 0) { 2431def0ca6SJung-uk Kim freeenv(cp); 244c94d6dbeSJung-uk Kim break; 2451def0ca6SJung-uk Kim } 2461def0ca6SJung-uk Kim freeenv(cp); 2471def0ca6SJung-uk Kim if ((cp = getenv("smbios.planar.product")) == NULL) 2481def0ca6SJung-uk Kim break; 2491def0ca6SJung-uk Kim if (strncmp(cp, "08A0", 4) != 0) { 2501def0ca6SJung-uk Kim freeenv(cp); 2511def0ca6SJung-uk Kim break; 2521def0ca6SJung-uk Kim } 2531def0ca6SJung-uk Kim freeenv(cp); 254c94d6dbeSJung-uk Kim if (sc->subbus < 0xa) { 255c94d6dbeSJung-uk Kim pci_write_config(dev, PCIR_SUBBUS_1, 0xa, 1); 256c94d6dbeSJung-uk Kim sc->subbus = pci_read_config(dev, PCIR_SUBBUS_1, 1); 257c94d6dbeSJung-uk Kim } 258c94d6dbeSJung-uk Kim break; 259c94d6dbeSJung-uk Kim } 260e4b59fc5SWarner Losh } 261e4b59fc5SWarner Losh 26222bf1c7fSJohn Baldwin if (pci_msi_device_blacklisted(dev)) 26322bf1c7fSJohn Baldwin sc->flags |= PCIB_DISABLE_MSI; 26422bf1c7fSJohn Baldwin 265e4b59fc5SWarner Losh /* 266e4b59fc5SWarner Losh * Intel 815, 845 and other chipsets say they are PCI-PCI bridges, 267e4b59fc5SWarner Losh * but have a ProgIF of 0x80. The 82801 family (AA, AB, BAM/CAM, 268e4b59fc5SWarner Losh * BA/CA/DB and E) PCI bridges are HUB-PCI bridges, in Intelese. 269e4b59fc5SWarner Losh * This means they act as if they were subtractively decoding 270e4b59fc5SWarner Losh * bridges and pass all transactions. Mark them and real ProgIf 1 271e4b59fc5SWarner Losh * parts as subtractive. 272e4b59fc5SWarner Losh */ 273e4b59fc5SWarner Losh if ((pci_get_devid(dev) & 0xff00ffff) == 0x24008086 || 274657d9f9fSJohn Baldwin pci_read_config(dev, PCIR_PROGIF, 1) == PCIP_BRIDGE_PCI_SUBTRACTIVE) 275e4b59fc5SWarner Losh sc->flags |= PCIB_SUBTRACTIVE; 276e4b59fc5SWarner Losh 277bb0d0a8eSMike Smith if (bootverbose) { 27855aaf894SMarius Strobl device_printf(dev, " domain %d\n", sc->domain); 279bb0d0a8eSMike Smith device_printf(dev, " secondary bus %d\n", sc->secbus); 280bb0d0a8eSMike Smith device_printf(dev, " subordinate bus %d\n", sc->subbus); 281bb0d0a8eSMike Smith device_printf(dev, " I/O decode 0x%x-0x%x\n", sc->iobase, sc->iolimit); 282b0a2d4b8SWarner Losh if (pcib_is_nonprefetch_open(sc)) 283b0a2d4b8SWarner Losh device_printf(dev, " memory decode 0x%jx-0x%jx\n", 284b0a2d4b8SWarner Losh (uintmax_t)sc->membase, (uintmax_t)sc->memlimit); 285b0a2d4b8SWarner Losh if (pcib_is_prefetch_open(sc)) 286b0a2d4b8SWarner Losh device_printf(dev, " prefetched decode 0x%jx-0x%jx\n", 287b0a2d4b8SWarner Losh (uintmax_t)sc->pmembase, (uintmax_t)sc->pmemlimit); 288b0a2d4b8SWarner Losh else 289b0a2d4b8SWarner Losh device_printf(dev, " no prefetched decode\n"); 290e4b59fc5SWarner Losh if (sc->flags & PCIB_SUBTRACTIVE) 291e4b59fc5SWarner Losh device_printf(dev, " Subtractively decoded bridge.\n"); 292bb0d0a8eSMike Smith } 293bb0d0a8eSMike Smith 294bb0d0a8eSMike Smith /* 295bb0d0a8eSMike Smith * XXX If the secondary bus number is zero, we should assign a bus number 296bb0d0a8eSMike Smith * since the BIOS hasn't, then initialise the bridge. 297bb0d0a8eSMike Smith */ 298bb0d0a8eSMike Smith 299bb0d0a8eSMike Smith /* 300bb0d0a8eSMike Smith * XXX If the subordinate bus number is less than the secondary bus number, 301bb0d0a8eSMike Smith * we should pick a better value. One sensible alternative would be to 302bb0d0a8eSMike Smith * pick 255; the only tradeoff here is that configuration transactions 303bb0d0a8eSMike Smith * would be more widely routed than absolutely necessary. 304bb0d0a8eSMike Smith */ 3056f0d5884SJohn Baldwin } 306bb0d0a8eSMike Smith 30738906aedSJohn Baldwin int 3086f0d5884SJohn Baldwin pcib_attach(device_t dev) 3096f0d5884SJohn Baldwin { 3106f0d5884SJohn Baldwin struct pcib_softc *sc; 3116f0d5884SJohn Baldwin device_t child; 3126f0d5884SJohn Baldwin 3136f0d5884SJohn Baldwin pcib_attach_common(dev); 3146f0d5884SJohn Baldwin sc = device_get_softc(dev); 315bb0d0a8eSMike Smith if (sc->secbus != 0) { 316cea0a895SJohn Baldwin child = device_add_child(dev, "pci", sc->secbus); 317bb0d0a8eSMike Smith if (child != NULL) 318bb0d0a8eSMike Smith return(bus_generic_attach(dev)); 319bb0d0a8eSMike Smith } 320bb0d0a8eSMike Smith 321bb0d0a8eSMike Smith /* no secondary bus; we should have fixed this */ 322bb0d0a8eSMike Smith return(0); 323bb0d0a8eSMike Smith } 324bb0d0a8eSMike Smith 3256f0d5884SJohn Baldwin int 326bb0d0a8eSMike Smith pcib_read_ivar(device_t dev, device_t child, int which, uintptr_t *result) 327bb0d0a8eSMike Smith { 328bb0d0a8eSMike Smith struct pcib_softc *sc = device_get_softc(dev); 329bb0d0a8eSMike Smith 330bb0d0a8eSMike Smith switch (which) { 33155aaf894SMarius Strobl case PCIB_IVAR_DOMAIN: 33255aaf894SMarius Strobl *result = sc->domain; 33355aaf894SMarius Strobl return(0); 334bb0d0a8eSMike Smith case PCIB_IVAR_BUS: 335bb0d0a8eSMike Smith *result = sc->secbus; 336bb0d0a8eSMike Smith return(0); 337bb0d0a8eSMike Smith } 338bb0d0a8eSMike Smith return(ENOENT); 339bb0d0a8eSMike Smith } 340bb0d0a8eSMike Smith 3416f0d5884SJohn Baldwin int 342bb0d0a8eSMike Smith pcib_write_ivar(device_t dev, device_t child, int which, uintptr_t value) 343bb0d0a8eSMike Smith { 344bb0d0a8eSMike Smith struct pcib_softc *sc = device_get_softc(dev); 345bb0d0a8eSMike Smith 346bb0d0a8eSMike Smith switch (which) { 34755aaf894SMarius Strobl case PCIB_IVAR_DOMAIN: 34855aaf894SMarius Strobl return(EINVAL); 349bb0d0a8eSMike Smith case PCIB_IVAR_BUS: 350bb0d0a8eSMike Smith sc->secbus = value; 35155aaf894SMarius Strobl return(0); 352bb0d0a8eSMike Smith } 353bb0d0a8eSMike Smith return(ENOENT); 354bb0d0a8eSMike Smith } 355bb0d0a8eSMike Smith 356bb0d0a8eSMike Smith /* 357bb0d0a8eSMike Smith * We have to trap resource allocation requests and ensure that the bridge 358bb0d0a8eSMike Smith * is set up to, or capable of handling them. 359bb0d0a8eSMike Smith */ 3606f0d5884SJohn Baldwin struct resource * 361bb0d0a8eSMike Smith pcib_alloc_resource(device_t dev, device_t child, int type, int *rid, 362bb0d0a8eSMike Smith u_long start, u_long end, u_long count, u_int flags) 363bb0d0a8eSMike Smith { 364bb0d0a8eSMike Smith struct pcib_softc *sc = device_get_softc(dev); 36526043836SJohn Baldwin const char *name, *suffix; 366a8b354a8SWarner Losh int ok; 367bb0d0a8eSMike Smith 368bb0d0a8eSMike Smith /* 369bb0d0a8eSMike Smith * Fail the allocation for this range if it's not supported. 370bb0d0a8eSMike Smith */ 37126043836SJohn Baldwin name = device_get_nameunit(child); 37226043836SJohn Baldwin if (name == NULL) { 37326043836SJohn Baldwin name = ""; 37426043836SJohn Baldwin suffix = ""; 37526043836SJohn Baldwin } else 37626043836SJohn Baldwin suffix = " "; 377bb0d0a8eSMike Smith switch (type) { 378bb0d0a8eSMike Smith case SYS_RES_IOPORT: 379a8b354a8SWarner Losh ok = 0; 380e4b59fc5SWarner Losh if (!pcib_is_io_open(sc)) 381e4b59fc5SWarner Losh break; 382a8b354a8SWarner Losh ok = (start >= sc->iobase && end <= sc->iolimit); 383d98d9b12SMarcel Moolenaar 384d98d9b12SMarcel Moolenaar /* 385d98d9b12SMarcel Moolenaar * Make sure we allow access to VGA I/O addresses when the 386d98d9b12SMarcel Moolenaar * bridge has the "VGA Enable" bit set. 387d98d9b12SMarcel Moolenaar */ 388d98d9b12SMarcel Moolenaar if (!ok && pci_is_vga_ioport_range(start, end)) 389d98d9b12SMarcel Moolenaar ok = (sc->bridgectl & PCIB_BCR_VGA_ENABLE) ? 1 : 0; 390d98d9b12SMarcel Moolenaar 391e4b59fc5SWarner Losh if ((sc->flags & PCIB_SUBTRACTIVE) == 0) { 392a8b354a8SWarner Losh if (!ok) { 39312b8c86eSWarner Losh if (start < sc->iobase) 39412b8c86eSWarner Losh start = sc->iobase; 39512b8c86eSWarner Losh if (end > sc->iolimit) 39612b8c86eSWarner Losh end = sc->iolimit; 3972daa7a07SWarner Losh if (start < end) 3982daa7a07SWarner Losh ok = 1; 399a8b354a8SWarner Losh } 4001c54ff33SMatthew N. Dodd } else { 401e4b59fc5SWarner Losh ok = 1; 402cd8b53edSWarner Losh #if 1 403e4b59fc5SWarner Losh if (start < sc->iobase && end > sc->iolimit) { 404e4b59fc5SWarner Losh start = sc->iobase; 405e4b59fc5SWarner Losh end = sc->iolimit; 4061c54ff33SMatthew N. Dodd } 40770be3980SWarner Losh #endif 40812b8c86eSWarner Losh } 409a8b354a8SWarner Losh if (end < start) { 4102daa7a07SWarner Losh device_printf(dev, "ioport: end (%lx) < start (%lx)\n", 4112daa7a07SWarner Losh end, start); 412a8b354a8SWarner Losh start = 0; 413a8b354a8SWarner Losh end = 0; 414a8b354a8SWarner Losh ok = 0; 415a8b354a8SWarner Losh } 416a8b354a8SWarner Losh if (!ok) { 41726043836SJohn Baldwin device_printf(dev, "%s%srequested unsupported I/O " 418a8b354a8SWarner Losh "range 0x%lx-0x%lx (decoding 0x%x-0x%x)\n", 41926043836SJohn Baldwin name, suffix, start, end, sc->iobase, sc->iolimit); 420bb0d0a8eSMike Smith return (NULL); 421bb0d0a8eSMike Smith } 4224fa59183SMike Smith if (bootverbose) 4232daa7a07SWarner Losh device_printf(dev, 42426043836SJohn Baldwin "%s%srequested I/O range 0x%lx-0x%lx: in range\n", 42526043836SJohn Baldwin name, suffix, start, end); 426bb0d0a8eSMike Smith break; 427bb0d0a8eSMike Smith 428bb0d0a8eSMike Smith case SYS_RES_MEMORY: 429a8b354a8SWarner Losh ok = 0; 430a8b354a8SWarner Losh if (pcib_is_nonprefetch_open(sc)) 431a8b354a8SWarner Losh ok = ok || (start >= sc->membase && end <= sc->memlimit); 432a8b354a8SWarner Losh if (pcib_is_prefetch_open(sc)) 433a8b354a8SWarner Losh ok = ok || (start >= sc->pmembase && end <= sc->pmemlimit); 434d98d9b12SMarcel Moolenaar 435d98d9b12SMarcel Moolenaar /* 436d98d9b12SMarcel Moolenaar * Make sure we allow access to VGA memory addresses when the 437d98d9b12SMarcel Moolenaar * bridge has the "VGA Enable" bit set. 438d98d9b12SMarcel Moolenaar */ 439d98d9b12SMarcel Moolenaar if (!ok && pci_is_vga_memory_range(start, end)) 440d98d9b12SMarcel Moolenaar ok = (sc->bridgectl & PCIB_BCR_VGA_ENABLE) ? 1 : 0; 441d98d9b12SMarcel Moolenaar 442e4b59fc5SWarner Losh if ((sc->flags & PCIB_SUBTRACTIVE) == 0) { 443a8b354a8SWarner Losh if (!ok) { 444a8b354a8SWarner Losh ok = 1; 445a8b354a8SWarner Losh if (flags & RF_PREFETCHABLE) { 446a8b354a8SWarner Losh if (pcib_is_prefetch_open(sc)) { 447a8b354a8SWarner Losh if (start < sc->pmembase) 448a8b354a8SWarner Losh start = sc->pmembase; 449a8b354a8SWarner Losh if (end > sc->pmemlimit) 450a8b354a8SWarner Losh end = sc->pmemlimit; 451a8b354a8SWarner Losh } else { 452a8b354a8SWarner Losh ok = 0; 453a8b354a8SWarner Losh } 454a8b354a8SWarner Losh } else { /* non-prefetchable */ 455a8b354a8SWarner Losh if (pcib_is_nonprefetch_open(sc)) { 456a8b354a8SWarner Losh if (start < sc->membase) 45712b8c86eSWarner Losh start = sc->membase; 45812b8c86eSWarner Losh if (end > sc->memlimit) 45912b8c86eSWarner Losh end = sc->memlimit; 4601c54ff33SMatthew N. Dodd } else { 461a8b354a8SWarner Losh ok = 0; 462a8b354a8SWarner Losh } 463a8b354a8SWarner Losh } 464a8b354a8SWarner Losh } 465a8b354a8SWarner Losh } else if (!ok) { 466e4b59fc5SWarner Losh ok = 1; /* subtractive bridge: always ok */ 467cd8b53edSWarner Losh #if 1 468a8b354a8SWarner Losh if (pcib_is_nonprefetch_open(sc)) { 469e4b59fc5SWarner Losh if (start < sc->membase && end > sc->memlimit) { 470e4b59fc5SWarner Losh start = sc->membase; 471e4b59fc5SWarner Losh end = sc->memlimit; 472e4b59fc5SWarner Losh } 473a8b354a8SWarner Losh } 474a8b354a8SWarner Losh if (pcib_is_prefetch_open(sc)) { 475e4b59fc5SWarner Losh if (start < sc->pmembase && end > sc->pmemlimit) { 476e4b59fc5SWarner Losh start = sc->pmembase; 477e4b59fc5SWarner Losh end = sc->pmemlimit; 478a8b354a8SWarner Losh } 4791c54ff33SMatthew N. Dodd } 48070be3980SWarner Losh #endif 48112b8c86eSWarner Losh } 482a8b354a8SWarner Losh if (end < start) { 4832daa7a07SWarner Losh device_printf(dev, "memory: end (%lx) < start (%lx)\n", 4842daa7a07SWarner Losh end, start); 485a8b354a8SWarner Losh start = 0; 486a8b354a8SWarner Losh end = 0; 487a8b354a8SWarner Losh ok = 0; 488a8b354a8SWarner Losh } 489a8b354a8SWarner Losh if (!ok && bootverbose) 49034428485SWarner Losh device_printf(dev, 49126043836SJohn Baldwin "%s%srequested unsupported memory range %#lx-%#lx " 492b0a2d4b8SWarner Losh "(decoding %#jx-%#jx, %#jx-%#jx)\n", 49326043836SJohn Baldwin name, suffix, start, end, 494b0a2d4b8SWarner Losh (uintmax_t)sc->membase, (uintmax_t)sc->memlimit, 495b0a2d4b8SWarner Losh (uintmax_t)sc->pmembase, (uintmax_t)sc->pmemlimit); 496a8b354a8SWarner Losh if (!ok) 497bb0d0a8eSMike Smith return (NULL); 4984fa59183SMike Smith if (bootverbose) 49926043836SJohn Baldwin device_printf(dev,"%s%srequested memory range " 5002daa7a07SWarner Losh "0x%lx-0x%lx: good\n", 50126043836SJohn Baldwin name, suffix, start, end); 5024fa59183SMike Smith break; 5034fa59183SMike Smith 504bb0d0a8eSMike Smith default: 5054fa59183SMike Smith break; 506bb0d0a8eSMike Smith } 507bb0d0a8eSMike Smith /* 508bb0d0a8eSMike Smith * Bridge is OK decoding this resource, so pass it up. 509bb0d0a8eSMike Smith */ 5102daa7a07SWarner Losh return (bus_generic_alloc_resource(dev, child, type, rid, start, end, 5112daa7a07SWarner Losh count, flags)); 512bb0d0a8eSMike Smith } 513bb0d0a8eSMike Smith 514bb0d0a8eSMike Smith /* 515bb0d0a8eSMike Smith * PCIB interface. 516bb0d0a8eSMike Smith */ 5176f0d5884SJohn Baldwin int 518bb0d0a8eSMike Smith pcib_maxslots(device_t dev) 519bb0d0a8eSMike Smith { 5204fa59183SMike Smith return(PCI_SLOTMAX); 521bb0d0a8eSMike Smith } 522bb0d0a8eSMike Smith 523bb0d0a8eSMike Smith /* 524bb0d0a8eSMike Smith * Since we are a child of a PCI bus, its parent must support the pcib interface. 525bb0d0a8eSMike Smith */ 526b0cb115fSWarner Losh uint32_t 527bb0d0a8eSMike Smith pcib_read_config(device_t dev, int b, int s, int f, int reg, int width) 528bb0d0a8eSMike Smith { 529bb0d0a8eSMike Smith return(PCIB_READ_CONFIG(device_get_parent(device_get_parent(dev)), b, s, f, reg, width)); 530bb0d0a8eSMike Smith } 531bb0d0a8eSMike Smith 5326f0d5884SJohn Baldwin void 533b0cb115fSWarner Losh pcib_write_config(device_t dev, int b, int s, int f, int reg, uint32_t val, int width) 534bb0d0a8eSMike Smith { 535bb0d0a8eSMike Smith PCIB_WRITE_CONFIG(device_get_parent(device_get_parent(dev)), b, s, f, reg, val, width); 536bb0d0a8eSMike Smith } 537bb0d0a8eSMike Smith 538bb0d0a8eSMike Smith /* 539bb0d0a8eSMike Smith * Route an interrupt across a PCI bridge. 540bb0d0a8eSMike Smith */ 5412c2d1d07SBenno Rice int 542bb0d0a8eSMike Smith pcib_route_interrupt(device_t pcib, device_t dev, int pin) 543bb0d0a8eSMike Smith { 544bb0d0a8eSMike Smith device_t bus; 545bb0d0a8eSMike Smith int parent_intpin; 546bb0d0a8eSMike Smith int intnum; 547bb0d0a8eSMike Smith 548bb0d0a8eSMike Smith /* 549bb0d0a8eSMike Smith * 550bb0d0a8eSMike Smith * The PCI standard defines a swizzle of the child-side device/intpin to 551bb0d0a8eSMike Smith * the parent-side intpin as follows. 552bb0d0a8eSMike Smith * 553bb0d0a8eSMike Smith * device = device on child bus 554bb0d0a8eSMike Smith * child_intpin = intpin on child bus slot (0-3) 555bb0d0a8eSMike Smith * parent_intpin = intpin on parent bus slot (0-3) 556bb0d0a8eSMike Smith * 557bb0d0a8eSMike Smith * parent_intpin = (device + child_intpin) % 4 558bb0d0a8eSMike Smith */ 559cdc95e1bSBernd Walter parent_intpin = (pci_get_slot(dev) + (pin - 1)) % 4; 560bb0d0a8eSMike Smith 561bb0d0a8eSMike Smith /* 562bb0d0a8eSMike Smith * Our parent is a PCI bus. Its parent must export the pcib interface 563bb0d0a8eSMike Smith * which includes the ability to route interrupts. 564bb0d0a8eSMike Smith */ 565bb0d0a8eSMike Smith bus = device_get_parent(pcib); 566bb0d0a8eSMike Smith intnum = PCIB_ROUTE_INTERRUPT(device_get_parent(bus), pcib, parent_intpin + 1); 56739981fedSJohn Baldwin if (PCI_INTERRUPT_VALID(intnum) && bootverbose) { 568c6a121abSJohn Baldwin device_printf(pcib, "slot %d INT%c is routed to irq %d\n", 569c6a121abSJohn Baldwin pci_get_slot(dev), 'A' + pin - 1, intnum); 5708046c4b9SMike Smith } 571bb0d0a8eSMike Smith return(intnum); 572bb0d0a8eSMike Smith } 573b173edafSJohn Baldwin 574e706f7f0SJohn Baldwin /* Pass request to alloc MSI/MSI-X messages up to the parent bridge. */ 5759bf4c9c1SJohn Baldwin int 5769bf4c9c1SJohn Baldwin pcib_alloc_msi(device_t pcib, device_t dev, int count, int maxcount, int *irqs) 5779bf4c9c1SJohn Baldwin { 578bd82bbb1SAndrew Gallatin struct pcib_softc *sc = device_get_softc(pcib); 5799bf4c9c1SJohn Baldwin device_t bus; 5809bf4c9c1SJohn Baldwin 58122bf1c7fSJohn Baldwin if (sc->flags & PCIB_DISABLE_MSI) 58222bf1c7fSJohn Baldwin return (ENXIO); 5839bf4c9c1SJohn Baldwin bus = device_get_parent(pcib); 5849bf4c9c1SJohn Baldwin return (PCIB_ALLOC_MSI(device_get_parent(bus), dev, count, maxcount, 5859bf4c9c1SJohn Baldwin irqs)); 5869bf4c9c1SJohn Baldwin } 5879bf4c9c1SJohn Baldwin 588e706f7f0SJohn Baldwin /* Pass request to release MSI/MSI-X messages up to the parent bridge. */ 5899bf4c9c1SJohn Baldwin int 5909bf4c9c1SJohn Baldwin pcib_release_msi(device_t pcib, device_t dev, int count, int *irqs) 5919bf4c9c1SJohn Baldwin { 5929bf4c9c1SJohn Baldwin device_t bus; 5939bf4c9c1SJohn Baldwin 5949bf4c9c1SJohn Baldwin bus = device_get_parent(pcib); 5959bf4c9c1SJohn Baldwin return (PCIB_RELEASE_MSI(device_get_parent(bus), dev, count, irqs)); 5969bf4c9c1SJohn Baldwin } 5979bf4c9c1SJohn Baldwin 5989bf4c9c1SJohn Baldwin /* Pass request to alloc an MSI-X message up to the parent bridge. */ 5999bf4c9c1SJohn Baldwin int 600e706f7f0SJohn Baldwin pcib_alloc_msix(device_t pcib, device_t dev, int *irq) 6019bf4c9c1SJohn Baldwin { 602bd82bbb1SAndrew Gallatin struct pcib_softc *sc = device_get_softc(pcib); 6039bf4c9c1SJohn Baldwin device_t bus; 6049bf4c9c1SJohn Baldwin 60522bf1c7fSJohn Baldwin if (sc->flags & PCIB_DISABLE_MSI) 60622bf1c7fSJohn Baldwin return (ENXIO); 6079bf4c9c1SJohn Baldwin bus = device_get_parent(pcib); 608e706f7f0SJohn Baldwin return (PCIB_ALLOC_MSIX(device_get_parent(bus), dev, irq)); 6095fe82bcaSJohn Baldwin } 6105fe82bcaSJohn Baldwin 6119bf4c9c1SJohn Baldwin /* Pass request to release an MSI-X message up to the parent bridge. */ 6129bf4c9c1SJohn Baldwin int 6139bf4c9c1SJohn Baldwin pcib_release_msix(device_t pcib, device_t dev, int irq) 6149bf4c9c1SJohn Baldwin { 6159bf4c9c1SJohn Baldwin device_t bus; 6169bf4c9c1SJohn Baldwin 6179bf4c9c1SJohn Baldwin bus = device_get_parent(pcib); 6189bf4c9c1SJohn Baldwin return (PCIB_RELEASE_MSIX(device_get_parent(bus), dev, irq)); 6199bf4c9c1SJohn Baldwin } 6209bf4c9c1SJohn Baldwin 621e706f7f0SJohn Baldwin /* Pass request to map MSI/MSI-X message up to parent bridge. */ 622e706f7f0SJohn Baldwin int 623e706f7f0SJohn Baldwin pcib_map_msi(device_t pcib, device_t dev, int irq, uint64_t *addr, 624e706f7f0SJohn Baldwin uint32_t *data) 625e706f7f0SJohn Baldwin { 626e706f7f0SJohn Baldwin device_t bus; 6274522ac77SLuoqi Chen int error; 628e706f7f0SJohn Baldwin 629e706f7f0SJohn Baldwin bus = device_get_parent(pcib); 6304522ac77SLuoqi Chen error = PCIB_MAP_MSI(device_get_parent(bus), dev, irq, addr, data); 6314522ac77SLuoqi Chen if (error) 6324522ac77SLuoqi Chen return (error); 6334522ac77SLuoqi Chen 6344522ac77SLuoqi Chen pci_ht_map_msi(pcib, *addr); 6354522ac77SLuoqi Chen return (0); 636e706f7f0SJohn Baldwin } 637e706f7f0SJohn Baldwin 638b173edafSJohn Baldwin /* 639b173edafSJohn Baldwin * Try to read the bus number of a host-PCI bridge using appropriate config 640b173edafSJohn Baldwin * registers. 641b173edafSJohn Baldwin */ 642b173edafSJohn Baldwin int 643b173edafSJohn Baldwin host_pcib_get_busno(pci_read_config_fn read_config, int bus, int slot, int func, 644b0cb115fSWarner Losh uint8_t *busnum) 645b173edafSJohn Baldwin { 646b0cb115fSWarner Losh uint32_t id; 647b173edafSJohn Baldwin 648b173edafSJohn Baldwin id = read_config(bus, slot, func, PCIR_DEVVENDOR, 4); 6491bbf2464SJohn Baldwin if (id == 0xffffffff) 650b173edafSJohn Baldwin return (0); 651b173edafSJohn Baldwin 652b173edafSJohn Baldwin switch (id) { 653b173edafSJohn Baldwin case 0x12258086: 654b173edafSJohn Baldwin /* Intel 824?? */ 655b173edafSJohn Baldwin /* XXX This is a guess */ 656b173edafSJohn Baldwin /* *busnum = read_config(bus, slot, func, 0x41, 1); */ 657b173edafSJohn Baldwin *busnum = bus; 658b173edafSJohn Baldwin break; 659b173edafSJohn Baldwin case 0x84c48086: 660b173edafSJohn Baldwin /* Intel 82454KX/GX (Orion) */ 661b173edafSJohn Baldwin *busnum = read_config(bus, slot, func, 0x4a, 1); 662b173edafSJohn Baldwin break; 663b173edafSJohn Baldwin case 0x84ca8086: 664b173edafSJohn Baldwin /* 665b173edafSJohn Baldwin * For the 450nx chipset, there is a whole bundle of 666b173edafSJohn Baldwin * things pretending to be host bridges. The MIOC will 667b173edafSJohn Baldwin * be seen first and isn't really a pci bridge (the 668b173edafSJohn Baldwin * actual busses are attached to the PXB's). We need to 669b173edafSJohn Baldwin * read the registers of the MIOC to figure out the 670b173edafSJohn Baldwin * bus numbers for the PXB channels. 671b173edafSJohn Baldwin * 672b173edafSJohn Baldwin * Since the MIOC doesn't have a pci bus attached, we 673b173edafSJohn Baldwin * pretend it wasn't there. 674b173edafSJohn Baldwin */ 675b173edafSJohn Baldwin return (0); 676b173edafSJohn Baldwin case 0x84cb8086: 677b173edafSJohn Baldwin switch (slot) { 678b173edafSJohn Baldwin case 0x12: 679b173edafSJohn Baldwin /* Intel 82454NX PXB#0, Bus#A */ 6801bbf2464SJohn Baldwin *busnum = read_config(bus, 0x10, func, 0xd0, 1); 681b173edafSJohn Baldwin break; 682b173edafSJohn Baldwin case 0x13: 683b173edafSJohn Baldwin /* Intel 82454NX PXB#0, Bus#B */ 6841bbf2464SJohn Baldwin *busnum = read_config(bus, 0x10, func, 0xd1, 1) + 1; 685b173edafSJohn Baldwin break; 686b173edafSJohn Baldwin case 0x14: 687b173edafSJohn Baldwin /* Intel 82454NX PXB#1, Bus#A */ 6881bbf2464SJohn Baldwin *busnum = read_config(bus, 0x10, func, 0xd3, 1); 689b173edafSJohn Baldwin break; 690b173edafSJohn Baldwin case 0x15: 691b173edafSJohn Baldwin /* Intel 82454NX PXB#1, Bus#B */ 6921bbf2464SJohn Baldwin *busnum = read_config(bus, 0x10, func, 0xd4, 1) + 1; 693b173edafSJohn Baldwin break; 694b173edafSJohn Baldwin } 695b173edafSJohn Baldwin break; 696b173edafSJohn Baldwin 697b173edafSJohn Baldwin /* ServerWorks -- vendor 0x1166 */ 698b173edafSJohn Baldwin case 0x00051166: 699b173edafSJohn Baldwin case 0x00061166: 700b173edafSJohn Baldwin case 0x00081166: 701b173edafSJohn Baldwin case 0x00091166: 702b173edafSJohn Baldwin case 0x00101166: 703b173edafSJohn Baldwin case 0x00111166: 704b173edafSJohn Baldwin case 0x00171166: 705b173edafSJohn Baldwin case 0x01011166: 706b173edafSJohn Baldwin case 0x010f1014: 707b173edafSJohn Baldwin case 0x02011166: 708b173edafSJohn Baldwin case 0x03021014: 709b173edafSJohn Baldwin *busnum = read_config(bus, slot, func, 0x44, 1); 710b173edafSJohn Baldwin break; 7115165a17dSJohn Baldwin 7125165a17dSJohn Baldwin /* Compaq/HP -- vendor 0x0e11 */ 7135165a17dSJohn Baldwin case 0x60100e11: 7145165a17dSJohn Baldwin *busnum = read_config(bus, slot, func, 0xc8, 1); 7155165a17dSJohn Baldwin break; 716b173edafSJohn Baldwin default: 717b173edafSJohn Baldwin /* Don't know how to read bus number. */ 718b173edafSJohn Baldwin return 0; 719b173edafSJohn Baldwin } 720b173edafSJohn Baldwin 721b173edafSJohn Baldwin return 1; 722b173edafSJohn Baldwin } 723