eisa_pci.c revision 69890
1/*- 2 * Copyright (c) 1994,1995 Stefan Esser, Wolfgang StanglMeier 3 * Copyright (c) 2000 Michael Smith <msmith@freebsd.org> 4 * Copyright (c) 2000 BSDi 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. The name of the author may not be used to endorse or promote products 16 * derived from this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 * 30 * $FreeBSD: head/sys/dev/pci/eisa_pci.c 69890 2000-12-12 03:33:02Z msmith $ 31 */ 32 33/* 34 * PCI:EISA bridge support 35 */ 36 37#include <sys/param.h> 38#include <sys/kernel.h> 39#include <sys/bus.h> 40 41#include <pci/pcivar.h> 42#include <pci/pcireg.h> 43 44static int eisab_probe(device_t dev); 45static int eisab_attach(device_t dev); 46 47static device_method_t eisab_methods[] = { 48 /* Device interface */ 49 DEVMETHOD(device_probe, eisab_probe), 50 DEVMETHOD(device_attach, eisab_attach), 51 DEVMETHOD(device_shutdown, bus_generic_shutdown), 52 DEVMETHOD(device_suspend, bus_generic_suspend), 53 DEVMETHOD(device_resume, bus_generic_resume), 54 55 /* Bus interface */ 56 DEVMETHOD(bus_print_child, bus_generic_print_child), 57 DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource), 58 DEVMETHOD(bus_release_resource, bus_generic_release_resource), 59 DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), 60 DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), 61 DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), 62 DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), 63 64 { 0, 0 } 65}; 66 67static driver_t eisab_driver = { 68 "eisab", 69 eisab_methods, 70 0, 71}; 72 73static devclass_t eisab_devclass; 74 75DRIVER_MODULE(eisab, pci, eisab_driver, eisab_devclass, 0, 0); 76 77static int 78eisab_probe(device_t dev) 79{ 80 int matched = 0; 81 82 /* 83 * Generic match by class/subclass. 84 */ 85 if ((pci_get_class(dev) == PCIC_BRIDGE) && 86 (pci_get_subclass(dev) == PCIS_BRIDGE_EISA)) 87 matched = 1; 88 89 /* 90 * Some bridges don't correctly report their class. 91 */ 92 switch (pci_get_devid(dev)) { 93 case 0x04828086: /* reports PCI-HOST class (!) */ 94 matched = 1; 95 break; 96 default: 97 break; 98 } 99 100 if (matched) { 101 device_set_desc(dev, "PCI-EISA bridge"); 102 return(-10000); 103 } 104 return(ENXIO); 105} 106 107static int 108eisab_attach(device_t dev) 109{ 110 device_t child; 111 112 /* 113 * Attach an EISA bus. Note that we can only have one EISA bus. 114 */ 115 child = device_add_child(dev, "eisa", 0); 116 if (child != NULL) 117 bus_generic_attach(dev); 118 119 /* 120 * Attach an ISA bus as well (should this be a child of EISA?) 121 */ 122 child = device_add_child(dev, "isa", 0); 123 if (child != NULL) 124 bus_generic_attach(dev); 125 126 return(0); 127} 128 129