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)); 2019c0e9e98SJohn Baldwin iolow = pci_read_config(dev, PCIR_PMBASEL_1, 1); 2029c0e9e98SJohn Baldwin if ((iolow & PCIM_BRPM_MASK) == PCIM_BRPM_64) 2039c0e9e98SJohn Baldwin sc->pmembase = PCI_PPBMEMBASE( 2049c0e9e98SJohn Baldwin pci_read_config(dev, PCIR_PMBASEH_1, 4), 2054fa59183SMike Smith pci_read_config(dev, PCIR_PMBASEL_1, 2)); 2069c0e9e98SJohn Baldwin else 2079c0e9e98SJohn Baldwin sc->pmembase = PCI_PPBMEMBASE(0, 2089c0e9e98SJohn Baldwin pci_read_config(dev, PCIR_PMBASEL_1, 2)); 2099c0e9e98SJohn Baldwin iolow = pci_read_config(dev, PCIR_PMLIMITL_1, 1); 2109c0e9e98SJohn Baldwin if ((iolow & PCIM_BRPM_MASK) == PCIM_BRPM_64) 2119c0e9e98SJohn Baldwin sc->pmemlimit = PCI_PPBMEMLIMIT( 2129c0e9e98SJohn Baldwin pci_read_config(dev, PCIR_PMLIMITH_1, 4), 2139c0e9e98SJohn Baldwin pci_read_config(dev, PCIR_PMLIMITL_1, 2)); 2149c0e9e98SJohn Baldwin else 2159c0e9e98SJohn Baldwin sc->pmemlimit = PCI_PPBMEMLIMIT(0, 2164fa59183SMike Smith pci_read_config(dev, PCIR_PMLIMITL_1, 2)); 2178983cfbfSMike Smith } 2184fa59183SMike Smith 2194fa59183SMike Smith /* 2204fa59183SMike Smith * Quirk handling. 2214fa59183SMike Smith */ 2224fa59183SMike Smith switch (pci_get_devid(dev)) { 2234fa59183SMike Smith case 0x12258086: /* Intel 82454KX/GX (Orion) */ 2244fa59183SMike Smith { 225b0cb115fSWarner Losh uint8_t supbus; 2264fa59183SMike Smith 2274fa59183SMike Smith supbus = pci_read_config(dev, 0x41, 1); 2284fa59183SMike Smith if (supbus != 0xff) { 2294fa59183SMike Smith sc->secbus = supbus + 1; 2304fa59183SMike Smith sc->subbus = supbus + 1; 2314fa59183SMike Smith } 2324fa59183SMike Smith break; 2334fa59183SMike Smith } 2344fa59183SMike Smith 235e4b59fc5SWarner Losh /* 236e4b59fc5SWarner Losh * The i82380FB mobile docking controller is a PCI-PCI bridge, 237e4b59fc5SWarner Losh * and it is a subtractive bridge. However, the ProgIf is wrong 238e4b59fc5SWarner Losh * so the normal setting of PCIB_SUBTRACTIVE bit doesn't 239e4b59fc5SWarner Losh * happen. There's also a Toshiba bridge that behaves this 240e4b59fc5SWarner Losh * way. 241e4b59fc5SWarner Losh */ 242e4b59fc5SWarner Losh case 0x124b8086: /* Intel 82380FB Mobile */ 243e4b59fc5SWarner Losh case 0x060513d7: /* Toshiba ???? */ 244e4b59fc5SWarner Losh sc->flags |= PCIB_SUBTRACTIVE; 245e4b59fc5SWarner Losh break; 246c94d6dbeSJung-uk Kim 247c94d6dbeSJung-uk Kim /* Compaq R3000 BIOS sets wrong subordinate bus number. */ 248c94d6dbeSJung-uk Kim case 0x00dd10de: 249c94d6dbeSJung-uk Kim { 250c94d6dbeSJung-uk Kim char *cp; 251c94d6dbeSJung-uk Kim 2521def0ca6SJung-uk Kim if ((cp = getenv("smbios.planar.maker")) == NULL) 253c94d6dbeSJung-uk Kim break; 2541def0ca6SJung-uk Kim if (strncmp(cp, "Compal", 6) != 0) { 2551def0ca6SJung-uk Kim freeenv(cp); 256c94d6dbeSJung-uk Kim break; 2571def0ca6SJung-uk Kim } 2581def0ca6SJung-uk Kim freeenv(cp); 2591def0ca6SJung-uk Kim if ((cp = getenv("smbios.planar.product")) == NULL) 2601def0ca6SJung-uk Kim break; 2611def0ca6SJung-uk Kim if (strncmp(cp, "08A0", 4) != 0) { 2621def0ca6SJung-uk Kim freeenv(cp); 2631def0ca6SJung-uk Kim break; 2641def0ca6SJung-uk Kim } 2651def0ca6SJung-uk Kim freeenv(cp); 266c94d6dbeSJung-uk Kim if (sc->subbus < 0xa) { 267c94d6dbeSJung-uk Kim pci_write_config(dev, PCIR_SUBBUS_1, 0xa, 1); 268c94d6dbeSJung-uk Kim sc->subbus = pci_read_config(dev, PCIR_SUBBUS_1, 1); 269c94d6dbeSJung-uk Kim } 270c94d6dbeSJung-uk Kim break; 271c94d6dbeSJung-uk Kim } 272e4b59fc5SWarner Losh } 273e4b59fc5SWarner Losh 27422bf1c7fSJohn Baldwin if (pci_msi_device_blacklisted(dev)) 27522bf1c7fSJohn Baldwin sc->flags |= PCIB_DISABLE_MSI; 27622bf1c7fSJohn Baldwin 277e4b59fc5SWarner Losh /* 278e4b59fc5SWarner Losh * Intel 815, 845 and other chipsets say they are PCI-PCI bridges, 279e4b59fc5SWarner Losh * but have a ProgIF of 0x80. The 82801 family (AA, AB, BAM/CAM, 280e4b59fc5SWarner Losh * BA/CA/DB and E) PCI bridges are HUB-PCI bridges, in Intelese. 281e4b59fc5SWarner Losh * This means they act as if they were subtractively decoding 282e4b59fc5SWarner Losh * bridges and pass all transactions. Mark them and real ProgIf 1 283e4b59fc5SWarner Losh * parts as subtractive. 284e4b59fc5SWarner Losh */ 285e4b59fc5SWarner Losh if ((pci_get_devid(dev) & 0xff00ffff) == 0x24008086 || 286657d9f9fSJohn Baldwin pci_read_config(dev, PCIR_PROGIF, 1) == PCIP_BRIDGE_PCI_SUBTRACTIVE) 287e4b59fc5SWarner Losh sc->flags |= PCIB_SUBTRACTIVE; 288e4b59fc5SWarner Losh 289bb0d0a8eSMike Smith if (bootverbose) { 29055aaf894SMarius Strobl device_printf(dev, " domain %d\n", sc->domain); 291bb0d0a8eSMike Smith device_printf(dev, " secondary bus %d\n", sc->secbus); 292bb0d0a8eSMike Smith device_printf(dev, " subordinate bus %d\n", sc->subbus); 293bb0d0a8eSMike Smith device_printf(dev, " I/O decode 0x%x-0x%x\n", sc->iobase, sc->iolimit); 294b0a2d4b8SWarner Losh if (pcib_is_nonprefetch_open(sc)) 295b0a2d4b8SWarner Losh device_printf(dev, " memory decode 0x%jx-0x%jx\n", 296b0a2d4b8SWarner Losh (uintmax_t)sc->membase, (uintmax_t)sc->memlimit); 297b0a2d4b8SWarner Losh if (pcib_is_prefetch_open(sc)) 298b0a2d4b8SWarner Losh device_printf(dev, " prefetched decode 0x%jx-0x%jx\n", 299b0a2d4b8SWarner Losh (uintmax_t)sc->pmembase, (uintmax_t)sc->pmemlimit); 300b0a2d4b8SWarner Losh else 301b0a2d4b8SWarner Losh device_printf(dev, " no prefetched decode\n"); 302e4b59fc5SWarner Losh if (sc->flags & PCIB_SUBTRACTIVE) 303e4b59fc5SWarner Losh device_printf(dev, " Subtractively decoded bridge.\n"); 304bb0d0a8eSMike Smith } 305bb0d0a8eSMike Smith 306bb0d0a8eSMike Smith /* 307bb0d0a8eSMike Smith * XXX If the secondary bus number is zero, we should assign a bus number 3087e178674SWarner Losh * since the BIOS hasn't, then initialise the bridge. A simple 3097e178674SWarner Losh * bus_alloc_resource with the a couple of busses seems like the right 3107e178674SWarner Losh * approach, but we don't know what busses the BIOS might have already 3117e178674SWarner Losh * assigned to other bridges on this bus that probe later than we do. 3127e178674SWarner Losh * 3137e178674SWarner Losh * If the subordinate bus number is less than the secondary bus number, 314bb0d0a8eSMike Smith * we should pick a better value. One sensible alternative would be to 315bb0d0a8eSMike Smith * pick 255; the only tradeoff here is that configuration transactions 3167e178674SWarner Losh * would be more widely routed than absolutely necessary. We could 3177e178674SWarner Losh * then do a walk of the tree later and fix it. 318bb0d0a8eSMike Smith */ 3196f0d5884SJohn Baldwin } 320bb0d0a8eSMike Smith 32138906aedSJohn Baldwin int 3226f0d5884SJohn Baldwin pcib_attach(device_t dev) 3236f0d5884SJohn Baldwin { 3246f0d5884SJohn Baldwin struct pcib_softc *sc; 3256f0d5884SJohn Baldwin device_t child; 3266f0d5884SJohn Baldwin 3276f0d5884SJohn Baldwin pcib_attach_common(dev); 3286f0d5884SJohn Baldwin sc = device_get_softc(dev); 329bb0d0a8eSMike Smith if (sc->secbus != 0) { 330cea0a895SJohn Baldwin child = device_add_child(dev, "pci", sc->secbus); 331bb0d0a8eSMike Smith if (child != NULL) 332bb0d0a8eSMike Smith return(bus_generic_attach(dev)); 333bb0d0a8eSMike Smith } 334bb0d0a8eSMike Smith 335bb0d0a8eSMike Smith /* no secondary bus; we should have fixed this */ 336bb0d0a8eSMike Smith return(0); 337bb0d0a8eSMike Smith } 338bb0d0a8eSMike Smith 3396f0d5884SJohn Baldwin int 340bb0d0a8eSMike Smith pcib_read_ivar(device_t dev, device_t child, int which, uintptr_t *result) 341bb0d0a8eSMike Smith { 342bb0d0a8eSMike Smith struct pcib_softc *sc = device_get_softc(dev); 343bb0d0a8eSMike Smith 344bb0d0a8eSMike Smith switch (which) { 34555aaf894SMarius Strobl case PCIB_IVAR_DOMAIN: 34655aaf894SMarius Strobl *result = sc->domain; 34755aaf894SMarius Strobl return(0); 348bb0d0a8eSMike Smith case PCIB_IVAR_BUS: 349bb0d0a8eSMike Smith *result = sc->secbus; 350bb0d0a8eSMike Smith return(0); 351bb0d0a8eSMike Smith } 352bb0d0a8eSMike Smith return(ENOENT); 353bb0d0a8eSMike Smith } 354bb0d0a8eSMike Smith 3556f0d5884SJohn Baldwin int 356bb0d0a8eSMike Smith pcib_write_ivar(device_t dev, device_t child, int which, uintptr_t value) 357bb0d0a8eSMike Smith { 358bb0d0a8eSMike Smith struct pcib_softc *sc = device_get_softc(dev); 359bb0d0a8eSMike Smith 360bb0d0a8eSMike Smith switch (which) { 36155aaf894SMarius Strobl case PCIB_IVAR_DOMAIN: 36255aaf894SMarius Strobl return(EINVAL); 363bb0d0a8eSMike Smith case PCIB_IVAR_BUS: 364bb0d0a8eSMike Smith sc->secbus = value; 36555aaf894SMarius Strobl return(0); 366bb0d0a8eSMike Smith } 367bb0d0a8eSMike Smith return(ENOENT); 368bb0d0a8eSMike Smith } 369bb0d0a8eSMike Smith 370bb0d0a8eSMike Smith /* 371bb0d0a8eSMike Smith * We have to trap resource allocation requests and ensure that the bridge 372bb0d0a8eSMike Smith * is set up to, or capable of handling them. 373bb0d0a8eSMike Smith */ 3746f0d5884SJohn Baldwin struct resource * 375bb0d0a8eSMike Smith pcib_alloc_resource(device_t dev, device_t child, int type, int *rid, 376bb0d0a8eSMike Smith u_long start, u_long end, u_long count, u_int flags) 377bb0d0a8eSMike Smith { 378bb0d0a8eSMike Smith struct pcib_softc *sc = device_get_softc(dev); 37926043836SJohn Baldwin const char *name, *suffix; 380a8b354a8SWarner Losh int ok; 381bb0d0a8eSMike Smith 382bb0d0a8eSMike Smith /* 383bb0d0a8eSMike Smith * Fail the allocation for this range if it's not supported. 384bb0d0a8eSMike Smith */ 38526043836SJohn Baldwin name = device_get_nameunit(child); 38626043836SJohn Baldwin if (name == NULL) { 38726043836SJohn Baldwin name = ""; 38826043836SJohn Baldwin suffix = ""; 38926043836SJohn Baldwin } else 39026043836SJohn Baldwin suffix = " "; 391bb0d0a8eSMike Smith switch (type) { 392bb0d0a8eSMike Smith case SYS_RES_IOPORT: 393a8b354a8SWarner Losh ok = 0; 394e4b59fc5SWarner Losh if (!pcib_is_io_open(sc)) 395e4b59fc5SWarner Losh break; 396a8b354a8SWarner Losh ok = (start >= sc->iobase && end <= sc->iolimit); 397d98d9b12SMarcel Moolenaar 398d98d9b12SMarcel Moolenaar /* 399d98d9b12SMarcel Moolenaar * Make sure we allow access to VGA I/O addresses when the 400d98d9b12SMarcel Moolenaar * bridge has the "VGA Enable" bit set. 401d98d9b12SMarcel Moolenaar */ 402d98d9b12SMarcel Moolenaar if (!ok && pci_is_vga_ioport_range(start, end)) 403d98d9b12SMarcel Moolenaar ok = (sc->bridgectl & PCIB_BCR_VGA_ENABLE) ? 1 : 0; 404d98d9b12SMarcel Moolenaar 405e4b59fc5SWarner Losh if ((sc->flags & PCIB_SUBTRACTIVE) == 0) { 406a8b354a8SWarner Losh if (!ok) { 40712b8c86eSWarner Losh if (start < sc->iobase) 40812b8c86eSWarner Losh start = sc->iobase; 40912b8c86eSWarner Losh if (end > sc->iolimit) 41012b8c86eSWarner Losh end = sc->iolimit; 4112daa7a07SWarner Losh if (start < end) 4122daa7a07SWarner Losh ok = 1; 413a8b354a8SWarner Losh } 4141c54ff33SMatthew N. Dodd } else { 415e4b59fc5SWarner Losh ok = 1; 416795dceffSWarner Losh /* 417795dceffSWarner Losh * If we overlap with the subtractive range, then 418795dceffSWarner Losh * pick the upper range to use. 419795dceffSWarner Losh */ 420795dceffSWarner Losh if (start < sc->iolimit && end > sc->iobase) 421795dceffSWarner Losh start = sc->iolimit + 1; 42212b8c86eSWarner Losh } 423a8b354a8SWarner Losh if (end < start) { 4242daa7a07SWarner Losh device_printf(dev, "ioport: end (%lx) < start (%lx)\n", 4252daa7a07SWarner Losh end, start); 426a8b354a8SWarner Losh start = 0; 427a8b354a8SWarner Losh end = 0; 428a8b354a8SWarner Losh ok = 0; 429a8b354a8SWarner Losh } 430a8b354a8SWarner Losh if (!ok) { 43126043836SJohn Baldwin device_printf(dev, "%s%srequested unsupported I/O " 432a8b354a8SWarner Losh "range 0x%lx-0x%lx (decoding 0x%x-0x%x)\n", 43326043836SJohn Baldwin name, suffix, start, end, sc->iobase, sc->iolimit); 434bb0d0a8eSMike Smith return (NULL); 435bb0d0a8eSMike Smith } 4364fa59183SMike Smith if (bootverbose) 4372daa7a07SWarner Losh device_printf(dev, 43826043836SJohn Baldwin "%s%srequested I/O range 0x%lx-0x%lx: in range\n", 43926043836SJohn Baldwin name, suffix, start, end); 440bb0d0a8eSMike Smith break; 441bb0d0a8eSMike Smith 442bb0d0a8eSMike Smith case SYS_RES_MEMORY: 443a8b354a8SWarner Losh ok = 0; 444a8b354a8SWarner Losh if (pcib_is_nonprefetch_open(sc)) 445a8b354a8SWarner Losh ok = ok || (start >= sc->membase && end <= sc->memlimit); 446a8b354a8SWarner Losh if (pcib_is_prefetch_open(sc)) 447a8b354a8SWarner Losh ok = ok || (start >= sc->pmembase && end <= sc->pmemlimit); 448d98d9b12SMarcel Moolenaar 449d98d9b12SMarcel Moolenaar /* 450d98d9b12SMarcel Moolenaar * Make sure we allow access to VGA memory addresses when the 451d98d9b12SMarcel Moolenaar * bridge has the "VGA Enable" bit set. 452d98d9b12SMarcel Moolenaar */ 453d98d9b12SMarcel Moolenaar if (!ok && pci_is_vga_memory_range(start, end)) 454d98d9b12SMarcel Moolenaar ok = (sc->bridgectl & PCIB_BCR_VGA_ENABLE) ? 1 : 0; 455d98d9b12SMarcel Moolenaar 456e4b59fc5SWarner Losh if ((sc->flags & PCIB_SUBTRACTIVE) == 0) { 457a8b354a8SWarner Losh if (!ok) { 458a8b354a8SWarner Losh ok = 1; 459a8b354a8SWarner Losh if (flags & RF_PREFETCHABLE) { 460a8b354a8SWarner Losh if (pcib_is_prefetch_open(sc)) { 461a8b354a8SWarner Losh if (start < sc->pmembase) 462a8b354a8SWarner Losh start = sc->pmembase; 463a8b354a8SWarner Losh if (end > sc->pmemlimit) 464a8b354a8SWarner Losh end = sc->pmemlimit; 465a8b354a8SWarner Losh } else { 466a8b354a8SWarner Losh ok = 0; 467a8b354a8SWarner Losh } 468a8b354a8SWarner Losh } else { /* non-prefetchable */ 469a8b354a8SWarner Losh if (pcib_is_nonprefetch_open(sc)) { 470a8b354a8SWarner Losh if (start < sc->membase) 47112b8c86eSWarner Losh start = sc->membase; 47212b8c86eSWarner Losh if (end > sc->memlimit) 47312b8c86eSWarner Losh end = sc->memlimit; 4741c54ff33SMatthew N. Dodd } else { 475a8b354a8SWarner Losh ok = 0; 476a8b354a8SWarner Losh } 477a8b354a8SWarner Losh } 478a8b354a8SWarner Losh } 479a8b354a8SWarner Losh } else if (!ok) { 480e4b59fc5SWarner Losh ok = 1; /* subtractive bridge: always ok */ 481a8b354a8SWarner Losh if (pcib_is_nonprefetch_open(sc)) { 482795dceffSWarner Losh if (start < sc->memlimit && end > sc->membase) 483795dceffSWarner Losh start = sc->memlimit + 1; 484a8b354a8SWarner Losh } 485a8b354a8SWarner Losh if (pcib_is_prefetch_open(sc)) { 486795dceffSWarner Losh if (start < sc->pmemlimit && end > sc->pmembase) 487795dceffSWarner Losh start = sc->pmemlimit + 1; 4881c54ff33SMatthew N. Dodd } 48912b8c86eSWarner Losh } 490a8b354a8SWarner Losh if (end < start) { 4912daa7a07SWarner Losh device_printf(dev, "memory: end (%lx) < start (%lx)\n", 4922daa7a07SWarner Losh end, start); 493a8b354a8SWarner Losh start = 0; 494a8b354a8SWarner Losh end = 0; 495a8b354a8SWarner Losh ok = 0; 496a8b354a8SWarner Losh } 497a8b354a8SWarner Losh if (!ok && bootverbose) 49834428485SWarner Losh device_printf(dev, 49926043836SJohn Baldwin "%s%srequested unsupported memory range %#lx-%#lx " 500b0a2d4b8SWarner Losh "(decoding %#jx-%#jx, %#jx-%#jx)\n", 50126043836SJohn Baldwin name, suffix, start, end, 502b0a2d4b8SWarner Losh (uintmax_t)sc->membase, (uintmax_t)sc->memlimit, 503b0a2d4b8SWarner Losh (uintmax_t)sc->pmembase, (uintmax_t)sc->pmemlimit); 504a8b354a8SWarner Losh if (!ok) 505bb0d0a8eSMike Smith return (NULL); 5064fa59183SMike Smith if (bootverbose) 50726043836SJohn Baldwin device_printf(dev,"%s%srequested memory range " 5082daa7a07SWarner Losh "0x%lx-0x%lx: good\n", 50926043836SJohn Baldwin name, suffix, start, end); 5104fa59183SMike Smith break; 5114fa59183SMike Smith 512bb0d0a8eSMike Smith default: 5134fa59183SMike Smith break; 514bb0d0a8eSMike Smith } 515bb0d0a8eSMike Smith /* 516bb0d0a8eSMike Smith * Bridge is OK decoding this resource, so pass it up. 517bb0d0a8eSMike Smith */ 5182daa7a07SWarner Losh return (bus_generic_alloc_resource(dev, child, type, rid, start, end, 5192daa7a07SWarner Losh count, flags)); 520bb0d0a8eSMike Smith } 521bb0d0a8eSMike Smith 522bb0d0a8eSMike Smith /* 523bb0d0a8eSMike Smith * PCIB interface. 524bb0d0a8eSMike Smith */ 5256f0d5884SJohn Baldwin int 526bb0d0a8eSMike Smith pcib_maxslots(device_t dev) 527bb0d0a8eSMike Smith { 5284fa59183SMike Smith return(PCI_SLOTMAX); 529bb0d0a8eSMike Smith } 530bb0d0a8eSMike Smith 531bb0d0a8eSMike Smith /* 532bb0d0a8eSMike Smith * Since we are a child of a PCI bus, its parent must support the pcib interface. 533bb0d0a8eSMike Smith */ 534b0cb115fSWarner Losh uint32_t 535795dceffSWarner Losh pcib_read_config(device_t dev, u_int b, u_int s, u_int f, u_int reg, int width) 536bb0d0a8eSMike Smith { 537bb0d0a8eSMike Smith return(PCIB_READ_CONFIG(device_get_parent(device_get_parent(dev)), b, s, f, reg, width)); 538bb0d0a8eSMike Smith } 539bb0d0a8eSMike Smith 5406f0d5884SJohn Baldwin void 541795dceffSWarner Losh pcib_write_config(device_t dev, u_int b, u_int s, u_int f, u_int reg, uint32_t val, int width) 542bb0d0a8eSMike Smith { 543bb0d0a8eSMike Smith PCIB_WRITE_CONFIG(device_get_parent(device_get_parent(dev)), b, s, f, reg, val, width); 544bb0d0a8eSMike Smith } 545bb0d0a8eSMike Smith 546bb0d0a8eSMike Smith /* 547bb0d0a8eSMike Smith * Route an interrupt across a PCI bridge. 548bb0d0a8eSMike Smith */ 5492c2d1d07SBenno Rice int 550bb0d0a8eSMike Smith pcib_route_interrupt(device_t pcib, device_t dev, int pin) 551bb0d0a8eSMike Smith { 552bb0d0a8eSMike Smith device_t bus; 553bb0d0a8eSMike Smith int parent_intpin; 554bb0d0a8eSMike Smith int intnum; 555bb0d0a8eSMike Smith 556bb0d0a8eSMike Smith /* 557bb0d0a8eSMike Smith * 558bb0d0a8eSMike Smith * The PCI standard defines a swizzle of the child-side device/intpin to 559bb0d0a8eSMike Smith * the parent-side intpin as follows. 560bb0d0a8eSMike Smith * 561bb0d0a8eSMike Smith * device = device on child bus 562bb0d0a8eSMike Smith * child_intpin = intpin on child bus slot (0-3) 563bb0d0a8eSMike Smith * parent_intpin = intpin on parent bus slot (0-3) 564bb0d0a8eSMike Smith * 565bb0d0a8eSMike Smith * parent_intpin = (device + child_intpin) % 4 566bb0d0a8eSMike Smith */ 567cdc95e1bSBernd Walter parent_intpin = (pci_get_slot(dev) + (pin - 1)) % 4; 568bb0d0a8eSMike Smith 569bb0d0a8eSMike Smith /* 570bb0d0a8eSMike Smith * Our parent is a PCI bus. Its parent must export the pcib interface 571bb0d0a8eSMike Smith * which includes the ability to route interrupts. 572bb0d0a8eSMike Smith */ 573bb0d0a8eSMike Smith bus = device_get_parent(pcib); 574bb0d0a8eSMike Smith intnum = PCIB_ROUTE_INTERRUPT(device_get_parent(bus), pcib, parent_intpin + 1); 57539981fedSJohn Baldwin if (PCI_INTERRUPT_VALID(intnum) && bootverbose) { 576c6a121abSJohn Baldwin device_printf(pcib, "slot %d INT%c is routed to irq %d\n", 577c6a121abSJohn Baldwin pci_get_slot(dev), 'A' + pin - 1, intnum); 5788046c4b9SMike Smith } 579bb0d0a8eSMike Smith return(intnum); 580bb0d0a8eSMike Smith } 581b173edafSJohn Baldwin 582e706f7f0SJohn Baldwin /* Pass request to alloc MSI/MSI-X messages up to the parent bridge. */ 5839bf4c9c1SJohn Baldwin int 5849bf4c9c1SJohn Baldwin pcib_alloc_msi(device_t pcib, device_t dev, int count, int maxcount, int *irqs) 5859bf4c9c1SJohn Baldwin { 586bd82bbb1SAndrew Gallatin struct pcib_softc *sc = device_get_softc(pcib); 5879bf4c9c1SJohn Baldwin device_t bus; 5889bf4c9c1SJohn Baldwin 58922bf1c7fSJohn Baldwin if (sc->flags & PCIB_DISABLE_MSI) 59022bf1c7fSJohn Baldwin return (ENXIO); 5919bf4c9c1SJohn Baldwin bus = device_get_parent(pcib); 5929bf4c9c1SJohn Baldwin return (PCIB_ALLOC_MSI(device_get_parent(bus), dev, count, maxcount, 5939bf4c9c1SJohn Baldwin irqs)); 5949bf4c9c1SJohn Baldwin } 5959bf4c9c1SJohn Baldwin 596e706f7f0SJohn Baldwin /* Pass request to release MSI/MSI-X messages up to the parent bridge. */ 5979bf4c9c1SJohn Baldwin int 5989bf4c9c1SJohn Baldwin pcib_release_msi(device_t pcib, device_t dev, int count, int *irqs) 5999bf4c9c1SJohn Baldwin { 6009bf4c9c1SJohn Baldwin device_t bus; 6019bf4c9c1SJohn Baldwin 6029bf4c9c1SJohn Baldwin bus = device_get_parent(pcib); 6039bf4c9c1SJohn Baldwin return (PCIB_RELEASE_MSI(device_get_parent(bus), dev, count, irqs)); 6049bf4c9c1SJohn Baldwin } 6059bf4c9c1SJohn Baldwin 6069bf4c9c1SJohn Baldwin /* Pass request to alloc an MSI-X message up to the parent bridge. */ 6079bf4c9c1SJohn Baldwin int 608e706f7f0SJohn Baldwin pcib_alloc_msix(device_t pcib, device_t dev, int *irq) 6099bf4c9c1SJohn Baldwin { 610bd82bbb1SAndrew Gallatin struct pcib_softc *sc = device_get_softc(pcib); 6119bf4c9c1SJohn Baldwin device_t bus; 6129bf4c9c1SJohn Baldwin 61322bf1c7fSJohn Baldwin if (sc->flags & PCIB_DISABLE_MSI) 61422bf1c7fSJohn Baldwin return (ENXIO); 6159bf4c9c1SJohn Baldwin bus = device_get_parent(pcib); 616e706f7f0SJohn Baldwin return (PCIB_ALLOC_MSIX(device_get_parent(bus), dev, irq)); 6175fe82bcaSJohn Baldwin } 6185fe82bcaSJohn Baldwin 6199bf4c9c1SJohn Baldwin /* Pass request to release an MSI-X message up to the parent bridge. */ 6209bf4c9c1SJohn Baldwin int 6219bf4c9c1SJohn Baldwin pcib_release_msix(device_t pcib, device_t dev, int irq) 6229bf4c9c1SJohn Baldwin { 6239bf4c9c1SJohn Baldwin device_t bus; 6249bf4c9c1SJohn Baldwin 6259bf4c9c1SJohn Baldwin bus = device_get_parent(pcib); 6269bf4c9c1SJohn Baldwin return (PCIB_RELEASE_MSIX(device_get_parent(bus), dev, irq)); 6279bf4c9c1SJohn Baldwin } 6289bf4c9c1SJohn Baldwin 629e706f7f0SJohn Baldwin /* Pass request to map MSI/MSI-X message up to parent bridge. */ 630e706f7f0SJohn Baldwin int 631e706f7f0SJohn Baldwin pcib_map_msi(device_t pcib, device_t dev, int irq, uint64_t *addr, 632e706f7f0SJohn Baldwin uint32_t *data) 633e706f7f0SJohn Baldwin { 634e706f7f0SJohn Baldwin device_t bus; 6354522ac77SLuoqi Chen int error; 636e706f7f0SJohn Baldwin 637e706f7f0SJohn Baldwin bus = device_get_parent(pcib); 6384522ac77SLuoqi Chen error = PCIB_MAP_MSI(device_get_parent(bus), dev, irq, addr, data); 6394522ac77SLuoqi Chen if (error) 6404522ac77SLuoqi Chen return (error); 6414522ac77SLuoqi Chen 6424522ac77SLuoqi Chen pci_ht_map_msi(pcib, *addr); 6434522ac77SLuoqi Chen return (0); 644e706f7f0SJohn Baldwin } 645e706f7f0SJohn Baldwin 646b173edafSJohn Baldwin /* 647b173edafSJohn Baldwin * Try to read the bus number of a host-PCI bridge using appropriate config 648b173edafSJohn Baldwin * registers. 649b173edafSJohn Baldwin */ 650b173edafSJohn Baldwin int 651b173edafSJohn Baldwin host_pcib_get_busno(pci_read_config_fn read_config, int bus, int slot, int func, 652b0cb115fSWarner Losh uint8_t *busnum) 653b173edafSJohn Baldwin { 654b0cb115fSWarner Losh uint32_t id; 655b173edafSJohn Baldwin 656b173edafSJohn Baldwin id = read_config(bus, slot, func, PCIR_DEVVENDOR, 4); 6571bbf2464SJohn Baldwin if (id == 0xffffffff) 658b173edafSJohn Baldwin return (0); 659b173edafSJohn Baldwin 660b173edafSJohn Baldwin switch (id) { 661b173edafSJohn Baldwin case 0x12258086: 662b173edafSJohn Baldwin /* Intel 824?? */ 663b173edafSJohn Baldwin /* XXX This is a guess */ 664b173edafSJohn Baldwin /* *busnum = read_config(bus, slot, func, 0x41, 1); */ 665b173edafSJohn Baldwin *busnum = bus; 666b173edafSJohn Baldwin break; 667b173edafSJohn Baldwin case 0x84c48086: 668b173edafSJohn Baldwin /* Intel 82454KX/GX (Orion) */ 669b173edafSJohn Baldwin *busnum = read_config(bus, slot, func, 0x4a, 1); 670b173edafSJohn Baldwin break; 671b173edafSJohn Baldwin case 0x84ca8086: 672b173edafSJohn Baldwin /* 673b173edafSJohn Baldwin * For the 450nx chipset, there is a whole bundle of 674b173edafSJohn Baldwin * things pretending to be host bridges. The MIOC will 675b173edafSJohn Baldwin * be seen first and isn't really a pci bridge (the 676b173edafSJohn Baldwin * actual busses are attached to the PXB's). We need to 677b173edafSJohn Baldwin * read the registers of the MIOC to figure out the 678b173edafSJohn Baldwin * bus numbers for the PXB channels. 679b173edafSJohn Baldwin * 680b173edafSJohn Baldwin * Since the MIOC doesn't have a pci bus attached, we 681b173edafSJohn Baldwin * pretend it wasn't there. 682b173edafSJohn Baldwin */ 683b173edafSJohn Baldwin return (0); 684b173edafSJohn Baldwin case 0x84cb8086: 685b173edafSJohn Baldwin switch (slot) { 686b173edafSJohn Baldwin case 0x12: 687b173edafSJohn Baldwin /* Intel 82454NX PXB#0, Bus#A */ 6881bbf2464SJohn Baldwin *busnum = read_config(bus, 0x10, func, 0xd0, 1); 689b173edafSJohn Baldwin break; 690b173edafSJohn Baldwin case 0x13: 691b173edafSJohn Baldwin /* Intel 82454NX PXB#0, Bus#B */ 6921bbf2464SJohn Baldwin *busnum = read_config(bus, 0x10, func, 0xd1, 1) + 1; 693b173edafSJohn Baldwin break; 694b173edafSJohn Baldwin case 0x14: 695b173edafSJohn Baldwin /* Intel 82454NX PXB#1, Bus#A */ 6961bbf2464SJohn Baldwin *busnum = read_config(bus, 0x10, func, 0xd3, 1); 697b173edafSJohn Baldwin break; 698b173edafSJohn Baldwin case 0x15: 699b173edafSJohn Baldwin /* Intel 82454NX PXB#1, Bus#B */ 7001bbf2464SJohn Baldwin *busnum = read_config(bus, 0x10, func, 0xd4, 1) + 1; 701b173edafSJohn Baldwin break; 702b173edafSJohn Baldwin } 703b173edafSJohn Baldwin break; 704b173edafSJohn Baldwin 705b173edafSJohn Baldwin /* ServerWorks -- vendor 0x1166 */ 706b173edafSJohn Baldwin case 0x00051166: 707b173edafSJohn Baldwin case 0x00061166: 708b173edafSJohn Baldwin case 0x00081166: 709b173edafSJohn Baldwin case 0x00091166: 710b173edafSJohn Baldwin case 0x00101166: 711b173edafSJohn Baldwin case 0x00111166: 712b173edafSJohn Baldwin case 0x00171166: 713b173edafSJohn Baldwin case 0x01011166: 714b173edafSJohn Baldwin case 0x010f1014: 715b173edafSJohn Baldwin case 0x02011166: 716b173edafSJohn Baldwin case 0x03021014: 717b173edafSJohn Baldwin *busnum = read_config(bus, slot, func, 0x44, 1); 718b173edafSJohn Baldwin break; 7195165a17dSJohn Baldwin 7205165a17dSJohn Baldwin /* Compaq/HP -- vendor 0x0e11 */ 7215165a17dSJohn Baldwin case 0x60100e11: 7225165a17dSJohn Baldwin *busnum = read_config(bus, slot, func, 0xc8, 1); 7235165a17dSJohn Baldwin break; 724b173edafSJohn Baldwin default: 725b173edafSJohn Baldwin /* Don't know how to read bus number. */ 726b173edafSJohn Baldwin return 0; 727b173edafSJohn Baldwin } 728b173edafSJohn Baldwin 729b173edafSJohn Baldwin return 1; 730b173edafSJohn Baldwin } 731