2 * Copyright 1998 Massachusetts Institute of Technology
4 * Permission to use, copy, modify, and distribute this software and
5 * its documentation for any purpose and without fee is hereby
6 * granted, provided that both the above copyright notice and this
7 * permission notice appear in all copies, that both the above
8 * copyright notice and this permission notice appear in all
9 * supporting documentation, and that the name of M.I.T. not be used
10 * in advertising or publicity pertaining to distribution of the
11 * software without specific, written prior permission. M.I.T. makes
12 * no representations about the suitability of this software for any
13 * purpose. It is provided "as is" without express or implied
16 * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS
17 * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
18 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
20 * SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * Copyright 2001 by Thomas Moestl <tmm@FreeBSD.org>. All rights reserved.
32 * Redistribution and use in source and binary forms, with or without
33 * modification, are permitted provided that the following conditions
35 * 1. Redistributions of source code must retain the above copyright
36 * notice, this list of conditions and the following disclaimer.
37 * 2. Redistributions in binary form must reproduce the above copyright
38 * notice, this list of conditions and the following disclaimer in the
39 * documentation and/or other materials provided with the distribution.
41 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
53 * from: FreeBSD: src/sys/i386/i386/nexus.c,v 1.43 2001/02/09
56 #include <sys/cdefs.h>
57 __FBSDID("$FreeBSD$");
59 #include <sys/param.h>
60 #include <sys/systm.h>
61 #include <sys/module.h>
64 #include <sys/kernel.h>
65 #include <sys/malloc.h>
68 #include <machine/intr_machdep.h>
73 static int nexus_probe(device_t);
74 static int nexus_attach(device_t);
75 static int nexus_activate_resource(device_t, device_t, int, int,
77 static int nexus_deactivate_resource(device_t, device_t, int, int,
80 static int nexus_config_intr(device_t, int, enum intr_trigger,
82 static int nexus_setup_intr(device_t, device_t, struct resource *, int,
83 driver_filter_t *, driver_intr_t *, void *, void **);
84 static int nexus_teardown_intr(device_t, device_t, struct resource *,
87 static device_method_t nexus_methods[] = {
88 /* Device interface */
89 DEVMETHOD(device_probe, nexus_probe),
90 DEVMETHOD(device_attach, nexus_attach),
91 DEVMETHOD(device_detach, bus_generic_detach),
92 DEVMETHOD(device_shutdown, bus_generic_shutdown),
93 DEVMETHOD(device_suspend, bus_generic_suspend),
94 DEVMETHOD(device_resume, bus_generic_resume),
96 /* Bus interface. Resource management is business of the children... */
97 DEVMETHOD(bus_add_child, bus_generic_add_child),
98 DEVMETHOD(bus_probe_nomatch, NULL),
99 DEVMETHOD(bus_read_ivar, NULL),
100 DEVMETHOD(bus_write_ivar, NULL),
101 DEVMETHOD(bus_config_intr, nexus_config_intr),
102 DEVMETHOD(bus_setup_intr, nexus_setup_intr),
103 DEVMETHOD(bus_teardown_intr, nexus_teardown_intr),
104 DEVMETHOD(bus_alloc_resource, NULL),
105 DEVMETHOD(bus_activate_resource, nexus_activate_resource),
106 DEVMETHOD(bus_deactivate_resource, nexus_deactivate_resource),
107 DEVMETHOD(bus_release_resource, NULL),
112 static driver_t nexus_driver = {
117 static devclass_t nexus_devclass;
119 DRIVER_MODULE(nexus, root, nexus_driver, nexus_devclass, 0, 0);
122 nexus_probe(device_t dev)
127 return (BUS_PROBE_DEFAULT);
131 nexus_attach(device_t dev)
134 bus_generic_probe(dev);
135 bus_generic_attach(dev);
140 nexus_activate_resource(device_t bus, device_t child, int type, int rid,
141 struct resource *res)
144 /* Not much to be done yet... */
145 return (rman_activate_resource(res));
149 nexus_deactivate_resource(device_t bus, device_t child, int type, int rid,
150 struct resource *res)
153 /* Not much to be done yet... */
154 return (rman_deactivate_resource(res));
158 nexus_config_intr(device_t bus, int irq, enum intr_trigger trig,
159 enum intr_polarity pol)
162 return (powerpc_config_intr(irq, trig, pol));
166 nexus_setup_intr(device_t bus, device_t child, struct resource *res, int flags,
167 driver_filter_t *ifilt, driver_intr_t *ihand, void *arg, void **cookiep)
173 /* somebody tried to setup an irq that failed to allocate! */
177 if ((rman_get_flags(res) & RF_SHAREABLE) == 0)
180 /* We depend on rman_activate_resource() being idempotent. */
181 error = rman_activate_resource(res);
185 error = powerpc_setup_intr(device_get_nameunit(child),
186 rman_get_start(res), ifilt, ihand, arg, flags, cookiep);
191 nexus_teardown_intr(device_t bus, device_t child, struct resource *res,
199 error = powerpc_teardown_intr(cookie);