2 * Copyright (c) 2008 TAKAHASHI Yoshihiro
3 * Copyright (c) 2003 M. Warner Losh, Marcel Moolenaar
6 * Redistribution and use in source and binary forms, with or without
7 * 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 BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #include <sys/cdefs.h>
29 __FBSDID("$FreeBSD$");
31 #include <sys/param.h>
32 #include <sys/systm.h>
35 #include <machine/bus.h>
37 #include <dev/uart/uart.h>
38 #include <dev/uart/uart_cpu.h>
40 bus_space_tag_t uart_bus_space_io = X86_BUS_SPACE_IO;
41 bus_space_tag_t uart_bus_space_mem = X86_BUS_SPACE_MEM;
45 struct uart_class *class;
46 } uart_pc98_devs[] = {
47 { 0x238, &uart_ns8250_class },
52 uart_pc98_getdev(u_long port)
56 for (i = 0; uart_pc98_devs[i].iobase; i++) {
57 if (port == uart_pc98_devs[i].iobase)
58 return (uart_pc98_devs[i].class);
64 uart_cpu_eqres(struct uart_bas *b1, struct uart_bas *b2)
67 if (bus_space_compare(b1->bst, b1->bsh, b2->bst, b2->bsh) == 0)
74 uart_cpu_getdev(int devtype, struct uart_devinfo *di)
76 struct uart_class *class;
79 class = &uart_ns8250_class;
83 /* Check the environment. */
84 if (uart_getenv(devtype, di, class) == 0)
88 * There is a serial port on all pc98 hardware. It is 8251 or
89 * an enhance version of that. Some pc98 have the second serial
90 * port which is 16550A compatible.
92 for (i = 0; i < 2; i++) {
93 if (resource_int_value("uart", i, "flags", &ivar))
95 if (devtype == UART_DEV_CONSOLE && !UART_FLAGS_CONSOLE(ivar))
97 if (devtype == UART_DEV_DBGPORT && !UART_FLAGS_DBGPORT(ivar))
100 * We have a possible device. Make sure it's enabled and
101 * that we have an I/O port.
103 if (resource_int_value("uart", i, "disabled", &ivar) == 0 &&
106 if (resource_int_value("uart", i, "port", &ivar) != 0 ||
110 class = uart_pc98_getdev(ivar);
114 di->ops = uart_getops(class);
116 di->bas.bst = uart_bus_space_io;
117 if (bus_space_map(di->bas.bst, ivar, uart_getrange(class), 0,
122 if (resource_int_value("uart", i, "baud", &ivar) != 0)
127 di->parity = UART_PARITY_NONE;