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