169783Smsmith/*- 269783Smsmith * Copyright (c) 1994,1995 Stefan Esser, Wolfgang StanglMeier 369783Smsmith * Copyright (c) 2000 Michael Smith <msmith@freebsd.org> 469783Smsmith * Copyright (c) 2000 BSDi 569783Smsmith * All rights reserved. 669783Smsmith * 769783Smsmith * Redistribution and use in source and binary forms, with or without 869783Smsmith * modification, are permitted provided that the following conditions 969783Smsmith * are met: 1069783Smsmith * 1. Redistributions of source code must retain the above copyright 1169783Smsmith * notice, this list of conditions and the following disclaimer. 1269783Smsmith * 2. Redistributions in binary form must reproduce the above copyright 1369783Smsmith * notice, this list of conditions and the following disclaimer in the 1469783Smsmith * documentation and/or other materials provided with the distribution. 1569783Smsmith * 3. The name of the author may not be used to endorse or promote products 1669783Smsmith * derived from this software without specific prior written permission. 1769783Smsmith * 1869783Smsmith * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1969783Smsmith * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2069783Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2169783Smsmith * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2269783Smsmith * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2369783Smsmith * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2469783Smsmith * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2569783Smsmith * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2669783Smsmith * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2769783Smsmith * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2869783Smsmith * SUCH DAMAGE. 2969783Smsmith */ 3069783Smsmith 31119418Sobrien#include <sys/cdefs.h> 32119418Sobrien__FBSDID("$FreeBSD$"); 33119418Sobrien 3469783Smsmith/* 3569783Smsmith * PCI:EISA bridge support 3669783Smsmith */ 3769783Smsmith 3869783Smsmith#include <sys/param.h> 3969783Smsmith#include <sys/kernel.h> 40129879Sphk#include <sys/module.h> 4169783Smsmith#include <sys/bus.h> 4269783Smsmith 43119285Simp#include <dev/pci/pcivar.h> 44119285Simp#include <dev/pci/pcireg.h> 4569783Smsmith 4669783Smsmithstatic int eisab_probe(device_t dev); 4769783Smsmithstatic int eisab_attach(device_t dev); 4869783Smsmith 4969783Smsmithstatic device_method_t eisab_methods[] = { 5069783Smsmith /* Device interface */ 5169783Smsmith DEVMETHOD(device_probe, eisab_probe), 5269783Smsmith DEVMETHOD(device_attach, eisab_attach), 5369783Smsmith DEVMETHOD(device_shutdown, bus_generic_shutdown), 5469783Smsmith DEVMETHOD(device_suspend, bus_generic_suspend), 5569783Smsmith DEVMETHOD(device_resume, bus_generic_resume), 5669783Smsmith 5769783Smsmith /* Bus interface */ 5869783Smsmith DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource), 5969783Smsmith DEVMETHOD(bus_release_resource, bus_generic_release_resource), 6069783Smsmith DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), 6169783Smsmith DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), 6269783Smsmith DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), 6369783Smsmith DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), 6469783Smsmith 65229093Shselasky DEVMETHOD_END 6669783Smsmith}; 6769783Smsmith 6869783Smsmithstatic driver_t eisab_driver = { 6969783Smsmith "eisab", 7069783Smsmith eisab_methods, 7169783Smsmith 0, 7269783Smsmith}; 7369783Smsmith 7469783Smsmithstatic devclass_t eisab_devclass; 7569783Smsmith 7669783SmsmithDRIVER_MODULE(eisab, pci, eisab_driver, eisab_devclass, 0, 0); 7769783Smsmith 7869783Smsmithstatic int 7969783Smsmitheisab_probe(device_t dev) 8069783Smsmith{ 8169783Smsmith int matched = 0; 8269783Smsmith 8369783Smsmith /* 8469783Smsmith * Generic match by class/subclass. 8569783Smsmith */ 8669783Smsmith if ((pci_get_class(dev) == PCIC_BRIDGE) && 8769783Smsmith (pci_get_subclass(dev) == PCIS_BRIDGE_EISA)) 8869783Smsmith matched = 1; 8969783Smsmith 9069783Smsmith /* 9169783Smsmith * Some bridges don't correctly report their class. 9269783Smsmith */ 9369783Smsmith switch (pci_get_devid(dev)) { 9469953Smsmith case 0x04828086: /* may show up as PCI-HOST or 0:0 */ 9569783Smsmith matched = 1; 9669783Smsmith break; 9769783Smsmith default: 9869783Smsmith break; 9969783Smsmith } 10069783Smsmith 10169783Smsmith if (matched) { 10269783Smsmith device_set_desc(dev, "PCI-EISA bridge"); 10369783Smsmith return(-10000); 10469783Smsmith } 10569783Smsmith return(ENXIO); 10669783Smsmith} 10769783Smsmith 10869783Smsmithstatic int 10969783Smsmitheisab_attach(device_t dev) 11069783Smsmith{ 11169783Smsmith /* 11269783Smsmith * Attach an EISA bus. Note that we can only have one EISA bus. 11369783Smsmith */ 11469953Smsmith if (!devclass_get_device(devclass_find("eisa"), 0)) 11569953Smsmith device_add_child(dev, "eisa", -1); 11669783Smsmith 11769783Smsmith /* 11869953Smsmith * Attach an ISA bus as well, since the EISA bus may have ISA 11969953Smsmith * cards installed, and we may have no EISA support in the system. 12069783Smsmith */ 12169953Smsmith if (!devclass_get_device(devclass_find("isa"), 0)) 12269953Smsmith device_add_child(dev, "isa", -1); 12369783Smsmith 12469953Smsmith bus_generic_attach(dev); 12569953Smsmith 12669783Smsmith return(0); 12769783Smsmith} 128