1 /*-
2 * Copyright (c) 2001 M. Warner Losh. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
17 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */
24
25 #include <sys/cdefs.h>
26 __FBSDID("$FreeBSD$");
27
28 #include <sys/param.h>
29 #include <sys/systm.h>
30 #include <sys/bus.h>
31 #include <sys/conf.h>
32 #include <sys/kernel.h>
33 #include <sys/module.h>
34 #include <machine/bus.h>
35 #include <sys/rman.h>
36 #include <machine/resource.h>
37
38 #include <dev/pci/pcivar.h>
39
40 #include <dev/uart/uart.h>
41 #include <dev/uart/uart_bus.h>
42
43 static int uart_pci_probe(device_t dev);
44
45 static device_method_t uart_pci_methods[] = {
46 /* Device interface */
47 DEVMETHOD(device_probe, uart_pci_probe),
48 DEVMETHOD(device_attach, uart_bus_attach),
49 DEVMETHOD(device_detach, uart_bus_detach),
50 { 0, 0 }
51 };
52
53 static driver_t uart_pci_driver = {
54 uart_driver_name,
55 uart_pci_methods,
56 sizeof(struct uart_softc),
57 };
58
59 struct pci_id {
60 uint32_t type;
61 const char *desc;
62 int rid;
63 };
64
65 static struct pci_id pci_ns8250_ids[] = {
66 { 0x100812b9, "3COM PCI FaxModem", 0x10 },
67 { 0x2000131f, "CyberSerial (1-port) 16550", 0x10 },
68 { 0x01101407, "Koutech IOFLEX-2S PCI Dual Port Serial", 0x10 },
69 { 0x01111407, "Koutech IOFLEX-2S PCI Dual Port Serial", 0x10 },
70 { 0x048011c1, "Lucent kermit based PCI Modem", 0x14 },
71 { 0x95211415, "Oxford Semiconductor PCI Dual Port Serial", 0x10 },
72 { 0x7101135e, "SeaLevel Ultra 530.PCI Single Port Serial", 0x18 },
73 { 0x0000151f, "SmartLink 5634PCV SurfRider", 0x10 },
74 { 0x0103115d, "Xircom Cardbus modem", 0x10 },
75 { 0x98459710, "Netmos Nm9845 PCI Bridge with Dual UART", 0x10 },
76 { 0x01c0135c, "Quatech SSCLP-200/300", 0x18
77 /*
78 * NB: You must mount the "SPAD" jumper to correctly detect
79 * the FIFO on the UART. Set the options on the jumpers,
80 * we do not support the extra registers on the Quatech.
81 */
82 },
83 { 0x00000000, NULL, 0 }
84 };
85
86 static struct pci_id *
87 uart_pci_match(uint32_t type, struct pci_id *id)
88 {
89
90 while (id->type && id->type != type)
91 id++;
92 return ((id->type) ? id : NULL);
93 }
94
95 static int
96 uart_pci_probe(device_t dev)
97 {
98 struct uart_softc *sc;
99 struct pci_id *id;
100
101 sc = device_get_softc(dev);
102
103 id = uart_pci_match(pci_get_devid(dev), pci_ns8250_ids);
104 if (id != NULL) {
105 sc->sc_class = &uart_ns8250_class;
106 goto match;
107 }
108 /* Add checks for non-ns8250 IDs here. */
109 return (ENXIO);
110
111 match:
112 if (id->desc)
113 device_set_desc(dev, id->desc);
114 return (uart_bus_probe(dev, 0, 0, id->rid, 0));
115 }
116
117 DRIVER_MODULE(uart, pci, uart_pci_driver, uart_devclass, 0, 0);
118 DRIVER_MODULE(uart, cardbus, uart_pci_driver, uart_devclass, 0, 0);
Cache object: 058f52b6582509b5a2f2814cb42d852b
|