2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 2001 by Thomas Moestl <tmm@FreeBSD.org>.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
20 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 #include <sys/cdefs.h>
30 __FBSDID("$FreeBSD$");
32 #include <sys/param.h>
33 #include <sys/systm.h>
35 #include <sys/kernel.h>
36 #include <sys/module.h>
38 #include <dev/ofw/ofw_bus.h>
40 #include <machine/bus.h>
42 #include <machine/resource.h>
43 #include <machine/ver.h>
45 #include <dev/uart/uart.h>
46 #include <dev/uart/uart_bus.h>
47 #include <dev/uart/uart_cpu.h>
49 static int uart_ebus_probe(device_t dev);
51 static device_method_t uart_ebus_methods[] = {
52 /* Device interface */
53 DEVMETHOD(device_probe, uart_ebus_probe),
54 DEVMETHOD(device_attach, uart_bus_attach),
55 DEVMETHOD(device_detach, uart_bus_detach),
59 static driver_t uart_ebus_driver = {
62 sizeof(struct uart_softc),
66 uart_ebus_probe(device_t dev)
68 const char *nm, *cmpt;
69 struct uart_softc *sc;
70 struct uart_devinfo dummy;
72 sc = device_get_softc(dev);
75 nm = ofw_bus_get_name(dev);
76 cmpt = ofw_bus_get_compat(dev);
79 if (!strcmp(nm, "lom-console") || !strcmp(nm, "su") ||
80 !strcmp(nm, "su_pnp") || !strcmp(cmpt, "rsc-console") ||
81 !strcmp(cmpt, "rsc-control") || !strcmp(cmpt, "su") ||
82 !strcmp(cmpt, "su16550") || !strcmp(cmpt, "su16552")) {
84 * On AXi and AXmp boards the NS16550 (used to connect
85 * keyboard/mouse) share their IRQ lines with the i8042.
86 * Any IRQ activity (typically during attach) of the
87 * NS16550 used to connect the keyboard when actually the
88 * PS/2 keyboard is selected in OFW causes interaction
89 * with the OBP i8042 driver resulting in a hang and vice
90 * versa. As RS232 keyboards and mice obviously aren't
91 * meant to be used in parallel with PS/2 ones on these
92 * boards don't attach to the NS16550 in case the RS232
93 * keyboard isn't selected in order to prevent such hangs.
95 if ((!strcmp(sparc64_model, "SUNW,UltraAX-MP") ||
96 !strcmp(sparc64_model, "SUNW,UltraSPARC-IIi-Engine")) &&
97 uart_cpu_getdev(UART_DEV_KEYBOARD, &dummy)) {
101 sc->sc_class = &uart_ns8250_class;
102 return (uart_bus_probe(dev, 0, 0, 0, 0, 0, 0));
108 DRIVER_MODULE(uart, ebus, uart_ebus_driver, uart_devclass, 0, 0);