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:ISA 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> 43bb0d0a8eSMike Smith 44c37faf26SJohn Baldwin #include <isa/isavar.h> 4538d8c994SWarner Losh #include <dev/pci/pcivar.h> 4638d8c994SWarner Losh #include <dev/pci/pcireg.h> 47bb0d0a8eSMike Smith 48bb0d0a8eSMike Smith static int isab_probe(device_t dev); 49bb0d0a8eSMike Smith 50bb0d0a8eSMike Smith static device_method_t isab_methods[] = { 51bb0d0a8eSMike Smith /* Device interface */ 52bb0d0a8eSMike Smith DEVMETHOD(device_probe, isab_probe), 53c306d509SJohn Baldwin DEVMETHOD(device_attach, isab_attach), 54c306d509SJohn Baldwin DEVMETHOD(device_detach, bus_generic_detach), 55bb0d0a8eSMike Smith DEVMETHOD(device_shutdown, bus_generic_shutdown), 56c306d509SJohn Baldwin DEVMETHOD(device_suspend, bus_generic_suspend), 57c306d509SJohn Baldwin DEVMETHOD(device_resume, bus_generic_resume), 58bb0d0a8eSMike Smith 59bb0d0a8eSMike Smith /* Bus interface */ 60bb0d0a8eSMike Smith DEVMETHOD(bus_print_child, bus_generic_print_child), 61bb0d0a8eSMike Smith DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource), 62bb0d0a8eSMike Smith DEVMETHOD(bus_release_resource, bus_generic_release_resource), 63bb0d0a8eSMike Smith DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), 64bb0d0a8eSMike Smith DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), 65bb0d0a8eSMike Smith DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), 66bb0d0a8eSMike Smith DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), 67bb0d0a8eSMike Smith 68bb0d0a8eSMike Smith { 0, 0 } 69bb0d0a8eSMike Smith }; 70bb0d0a8eSMike Smith 71bb0d0a8eSMike Smith static driver_t isab_driver = { 72bb0d0a8eSMike Smith "isab", 73bb0d0a8eSMike Smith isab_methods, 74c306d509SJohn Baldwin 0, 75bb0d0a8eSMike Smith }; 76bb0d0a8eSMike Smith 77bb0d0a8eSMike Smith DRIVER_MODULE(isab, pci, isab_driver, isab_devclass, 0, 0); 78bb0d0a8eSMike Smith 79bb0d0a8eSMike Smith /* 80bb0d0a8eSMike Smith * XXX we need to add a quirk list here for bridges that don't correctly 81bb0d0a8eSMike Smith * report themselves. 82bb0d0a8eSMike Smith */ 83bb0d0a8eSMike Smith static int 84bb0d0a8eSMike Smith isab_probe(device_t dev) 85bb0d0a8eSMike Smith { 86bb0d0a8eSMike Smith int matched = 0; 87bb0d0a8eSMike Smith 88bb0d0a8eSMike Smith /* 89bb0d0a8eSMike Smith * Try for a generic match based on class/subclass. 90bb0d0a8eSMike Smith */ 91fed8edf5SMike Smith if ((pci_get_class(dev) == PCIC_BRIDGE) && 92fed8edf5SMike Smith (pci_get_subclass(dev) == PCIS_BRIDGE_ISA)) { 93bb0d0a8eSMike Smith matched = 1; 94e620c314SMike Smith } else { 95bb0d0a8eSMike Smith /* 96e620c314SMike Smith * These are devices that we *know* are PCI:ISA bridges. 97e620c314SMike Smith * Sometimes, however, they don't report themselves as 98e620c314SMike Smith * such. Check in case one of them is pretending to be 99e620c314SMike Smith * something else. 100bb0d0a8eSMike Smith */ 101bb0d0a8eSMike Smith switch (pci_get_devid(dev)) { 102bb0d0a8eSMike Smith case 0x04848086: /* Intel 82378ZB/82378IB */ 103bb0d0a8eSMike Smith case 0x122e8086: /* Intel 82371FB */ 104bb0d0a8eSMike Smith case 0x70008086: /* Intel 82371SB */ 105e620c314SMike Smith case 0x71108086: /* Intel 82371AB */ 106417c87d1SJim Pirzyk case 0x71988086: /* Intel 82443MX */ 107bb0d0a8eSMike Smith case 0x24108086: /* Intel 82801AA (ICH) */ 108bb0d0a8eSMike Smith case 0x24208086: /* Intel 82801AB (ICH0) */ 109e620c314SMike Smith case 0x24408086: /* Intel 82801AB (ICH2) */ 110bb0d0a8eSMike Smith case 0x00061004: /* VLSI 82C593 */ 111bb0d0a8eSMike Smith case 0x05861106: /* VIA 82C586 */ 112e620c314SMike Smith case 0x05961106: /* VIA 82C596 */ 113e620c314SMike Smith case 0x06861106: /* VIA 82C686 */ 114bb0d0a8eSMike Smith case 0x153310b9: /* AcerLabs M1533 */ 115bb0d0a8eSMike Smith case 0x154310b9: /* AcerLabs M1543 */ 116bb0d0a8eSMike Smith case 0x00081039: /* SiS 85c503 */ 117bb0d0a8eSMike Smith case 0x00001078: /* Cyrix Cx5510 */ 118bb0d0a8eSMike Smith case 0x01001078: /* Cyrix Cx5530 */ 119bb0d0a8eSMike Smith case 0xc7001045: /* OPTi 82C700 (FireStar) */ 120bb0d0a8eSMike Smith case 0x00011033: /* NEC 0001 (C-bus) */ 121bb0d0a8eSMike Smith case 0x002c1033: /* NEC 002C (C-bus) */ 122bb0d0a8eSMike Smith case 0x003b1033: /* NEC 003B (C-bus) */ 123bb0d0a8eSMike Smith case 0x886a1060: /* UMC UM8886 ISA */ 124bb0d0a8eSMike Smith case 0x02001166: /* ServerWorks IB6566 PCI */ 125e620c314SMike Smith if (bootverbose) 126e620c314SMike Smith printf("PCI-ISA bridge with incorrect subclass 0x%x\n", 127e620c314SMike Smith pci_get_subclass(dev)); 128bb0d0a8eSMike Smith matched = 1; 129bb0d0a8eSMike Smith break; 130bb0d0a8eSMike Smith 131bb0d0a8eSMike Smith default: 132bb0d0a8eSMike Smith break; 133bb0d0a8eSMike Smith } 134e620c314SMike Smith } 135bb0d0a8eSMike Smith 136bb0d0a8eSMike Smith if (matched) { 137bb0d0a8eSMike Smith device_set_desc(dev, "PCI-ISA bridge"); 138bb0d0a8eSMike Smith return(-10000); 139bb0d0a8eSMike Smith } 140bb0d0a8eSMike Smith return(ENXIO); 141bb0d0a8eSMike Smith } 142