2 * Copyright (c) 2001 by Thomas Moestl <tmm@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.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
18 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
23 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #include <sys/cdefs.h>
27 __FBSDID("$FreeBSD$");
29 #include <sys/param.h>
30 #include <sys/systm.h>
32 #include <sys/kernel.h>
33 #include <sys/timepps.h>
36 #include <machine/bus.h>
38 #include <dev/sio/siovar.h>
40 #include <ofw/openfirm.h>
41 #include <sparc64/ebus/ebusvar.h>
43 int sio_ofw_inlist(char *name, char *list[]);
44 static int sio_ebus_attach(device_t dev);
45 static int sio_ebus_probe(device_t dev);
47 static device_method_t sio_ebus_methods[] = {
48 /* Device interface */
49 DEVMETHOD(device_probe, sio_ebus_probe),
50 DEVMETHOD(device_attach, sio_ebus_attach),
55 static driver_t sio_ebus_driver = {
61 DRIVER_MODULE(sio, ebus, sio_ebus_driver, sio_devclass, 0, 0);
63 /* Needed for EBus attach and sparc64 console support */
64 char *sio_ofw_names[] = {
71 char *sio_ofw_compat[] = {
78 sio_ofw_inlist(name, list)
86 for (i = 0; list[i] != NULL; i++) {
87 if (strcmp(name, list[i]) == 0)
99 n = ebus_get_name(dev);
100 if (!sio_ofw_inlist(n, sio_ofw_names) && (strcmp(n, "serial") != 0 ||
101 !sio_ofw_inlist(ebus_get_compat(dev), sio_ofw_compat)))
103 /* Do not probe IRQ - isa_irq_pending() does not work for ebus. */
104 return (sioprobe(dev, 0, 0UL, 1));
112 return (sioattach(dev, 0, 0UL));