2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 2003 Norikatsu Shigemura, Takenori Watanabe All rights reserved.
5 * Copyright (c) 2001 M. Warner Losh <imp@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 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 <sys/kernel.h>
36 #include <sys/module.h>
37 #include <machine/bus.h>
38 #include <machine/resource.h>
40 #include <dev/pccard/pccard_cis.h>
41 #include <dev/pccard/pccardvar.h>
43 #include <dev/uart/uart.h>
44 #include <dev/uart/uart_bus.h>
46 #include "pccarddevs.h"
48 static int uart_pccard_probe(device_t dev);
49 static int uart_pccard_attach(device_t dev);
51 static device_method_t uart_pccard_methods[] = {
52 /* Device interface */
53 DEVMETHOD(device_probe, uart_pccard_probe),
54 DEVMETHOD(device_attach, uart_pccard_attach),
55 DEVMETHOD(device_detach, uart_bus_detach),
60 static uint32_t uart_pccard_function = PCCARD_FUNCTION_SERIAL;
62 static driver_t uart_pccard_driver = {
65 sizeof(struct uart_softc),
69 uart_pccard_probe(device_t dev)
74 fcn = PCCARD_FUNCTION_UNSPEC;
75 error = pccard_get_function(dev, &fcn);
79 * If a serial card, we are likely the right driver. However,
80 * some serial cards are better serviced by other drivers, so
81 * allow other drivers to claim it, if they want.
83 if (fcn == uart_pccard_function)
84 return (BUS_PROBE_GENERIC);
90 uart_pccard_attach(device_t dev)
92 struct uart_softc *sc;
95 sc = device_get_softc(dev);
96 sc->sc_class = &uart_ns8250_class;
98 error = uart_bus_probe(dev, 0, 0, 0, 0, 0, 0);
101 gone_in_dev(dev, 13, "pccard removed");
102 return (uart_bus_attach(dev));
105 DRIVER_MODULE(uart, pccard, uart_pccard_driver, uart_devclass, 0, 0);
106 MODULE_PNP_INFO("U32:function_type;", pccard, uart, &uart_pccard_function,