2 * Copyright (c) 2003 John Baldwin <jhb@FreeBSD.org>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the author nor the names of any co-contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * Host to PCI and PCI to PCI bridge drivers that use the MP Table to route
32 * interrupts from PCI devices to I/O APICs.
35 #include <sys/cdefs.h>
36 __FBSDID("$FreeBSD$");
38 #include <sys/param.h>
39 #include <sys/systm.h>
41 #include <sys/kernel.h>
42 #include <sys/module.h>
44 #include <dev/pci/pcireg.h>
45 #include <dev/pci/pcivar.h>
46 #include <dev/pci/pcib_private.h>
47 #include <machine/legacyvar.h>
48 #include <machine/mptable.h>
49 #include <machine/pci_cfgreg.h>
53 /* Host to PCI bridge driver. */
56 mptable_hostb_probe(device_t dev)
59 if (pci_cfgregopen() == 0)
61 if (mptable_pci_probe_table(pcib_get_bus(dev)) != 0)
63 device_set_desc(dev, "MPTable Host-PCI bridge");
68 mptable_hostb_attach(device_t dev)
71 device_add_child(dev, "pci", pcib_get_bus(dev));
72 return (bus_generic_attach(dev));
75 static device_method_t mptable_hostb_methods[] = {
76 /* Device interface */
77 DEVMETHOD(device_probe, mptable_hostb_probe),
78 DEVMETHOD(device_attach, mptable_hostb_attach),
79 DEVMETHOD(device_shutdown, bus_generic_shutdown),
80 DEVMETHOD(device_suspend, bus_generic_suspend),
81 DEVMETHOD(device_resume, bus_generic_resume),
84 DEVMETHOD(bus_print_child, bus_generic_print_child),
85 DEVMETHOD(bus_read_ivar, legacy_pcib_read_ivar),
86 DEVMETHOD(bus_write_ivar, legacy_pcib_write_ivar),
87 DEVMETHOD(bus_alloc_resource, legacy_pcib_alloc_resource),
88 DEVMETHOD(bus_release_resource, bus_generic_release_resource),
89 DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
90 DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
91 DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
92 DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
95 DEVMETHOD(pcib_maxslots, legacy_pcib_maxslots),
96 DEVMETHOD(pcib_read_config, legacy_pcib_read_config),
97 DEVMETHOD(pcib_write_config, legacy_pcib_write_config),
98 DEVMETHOD(pcib_route_interrupt, mptable_pci_route_interrupt),
103 static devclass_t hostb_devclass;
105 DEFINE_CLASS_0(pcib, mptable_hostb_driver, mptable_hostb_methods, 1);
106 DRIVER_MODULE(mptable_pcib, legacy, mptable_hostb_driver, hostb_devclass, 0, 0);
108 /* PCI to PCI bridge driver. */
111 mptable_pcib_probe(device_t dev)
115 if ((pci_get_class(dev) != PCIC_BRIDGE) ||
116 (pci_get_subclass(dev) != PCIS_BRIDGE_PCI))
118 bus = pci_read_config(dev, PCIR_SECBUS_1, 1);
121 if (mptable_pci_probe_table(bus) != 0)
123 device_set_desc(dev, "MPTable PCI-PCI bridge");
127 static device_method_t mptable_pcib_pci_methods[] = {
128 /* Device interface */
129 DEVMETHOD(device_probe, mptable_pcib_probe),
130 DEVMETHOD(device_attach, pcib_attach),
131 DEVMETHOD(device_shutdown, bus_generic_shutdown),
132 DEVMETHOD(device_suspend, bus_generic_suspend),
133 DEVMETHOD(device_resume, bus_generic_resume),
136 DEVMETHOD(bus_print_child, bus_generic_print_child),
137 DEVMETHOD(bus_read_ivar, pcib_read_ivar),
138 DEVMETHOD(bus_write_ivar, pcib_write_ivar),
139 DEVMETHOD(bus_alloc_resource, pcib_alloc_resource),
140 DEVMETHOD(bus_release_resource, bus_generic_release_resource),
141 DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
142 DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
143 DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
144 DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
147 DEVMETHOD(pcib_maxslots, pcib_maxslots),
148 DEVMETHOD(pcib_read_config, pcib_read_config),
149 DEVMETHOD(pcib_write_config, pcib_write_config),
150 DEVMETHOD(pcib_route_interrupt, mptable_pci_route_interrupt),
155 static devclass_t pcib_devclass;
157 DEFINE_CLASS_0(pcib, mptable_pcib_driver, mptable_pcib_pci_methods,
158 sizeof(struct pcib_softc));
159 DRIVER_MODULE(mptable_pcib, pci, mptable_pcib_driver, pcib_devclass, 0, 0);