]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - sys/dev/pci/eisa_pci.c
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / sys / dev / pci / eisa_pci.c
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
31 #include <sys/cdefs.h>
32 __FBSDID("$FreeBSD$");
33
34 /*
35  * PCI:EISA bridge support
36  */
37
38 #include <sys/param.h>
39 #include <sys/kernel.h>
40 #include <sys/module.h>
41 #include <sys/bus.h>
42
43 #include <dev/pci/pcivar.h>
44 #include <dev/pci/pcireg.h>
45
46 static int      eisab_probe(device_t dev);
47 static int      eisab_attach(device_t dev);
48
49 static device_method_t eisab_methods[] = {
50     /* Device interface */
51     DEVMETHOD(device_probe,             eisab_probe),
52     DEVMETHOD(device_attach,            eisab_attach),
53     DEVMETHOD(device_shutdown,          bus_generic_shutdown),
54     DEVMETHOD(device_suspend,           bus_generic_suspend),
55     DEVMETHOD(device_resume,            bus_generic_resume),
56
57     /* Bus interface */
58     DEVMETHOD(bus_alloc_resource,       bus_generic_alloc_resource),
59     DEVMETHOD(bus_release_resource,     bus_generic_release_resource),
60     DEVMETHOD(bus_activate_resource,    bus_generic_activate_resource),
61     DEVMETHOD(bus_deactivate_resource,  bus_generic_deactivate_resource),
62     DEVMETHOD(bus_setup_intr,           bus_generic_setup_intr),
63     DEVMETHOD(bus_teardown_intr,        bus_generic_teardown_intr),
64
65     DEVMETHOD_END
66 };
67
68 static driver_t eisab_driver = {
69     "eisab",
70     eisab_methods,
71     0,
72 };
73
74 static devclass_t eisab_devclass;
75
76 DRIVER_MODULE(eisab, pci, eisab_driver, eisab_devclass, 0, 0);
77
78 static int
79 eisab_probe(device_t dev)
80 {
81     int         matched = 0;
82
83     /*
84      * Generic match by class/subclass.
85      */
86     if ((pci_get_class(dev) == PCIC_BRIDGE) &&
87         (pci_get_subclass(dev) == PCIS_BRIDGE_EISA))
88         matched = 1;
89
90     /*
91      * Some bridges don't correctly report their class.
92      */
93     switch (pci_get_devid(dev)) {
94     case 0x04828086:            /* may show up as PCI-HOST or 0:0 */
95         matched = 1;
96         break;
97     default:
98         break;
99     }
100     
101     if (matched) {
102         device_set_desc(dev, "PCI-EISA bridge");
103         return(-10000);
104     }
105     return(ENXIO);
106 }
107
108 static int
109 eisab_attach(device_t dev)
110 {
111     /*
112      * Attach an EISA bus.  Note that we can only have one EISA bus.
113      */
114     if (!devclass_get_device(devclass_find("eisa"), 0))
115         device_add_child(dev, "eisa", -1);
116
117     /*
118      * Attach an ISA bus as well, since the EISA bus may have ISA
119      * cards installed, and we may have no EISA support in the system.
120      */
121     if (!devclass_get_device(devclass_find("isa"), 0))
122         device_add_child(dev, "isa", -1);
123
124     bus_generic_attach(dev);
125
126     return(0);
127 }