1/*-
2 * Copyright (c) 2006 Marcel Moolenaar
3 * Copyright (c) 2001 M. Warner Losh
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/dev/uart/uart_bus_pci.c 264257 2014-04-08 07:32:32Z marius $");
29
30#include <sys/param.h>
31#include <sys/systm.h>
32#include <sys/bus.h>
33#include <sys/conf.h>
34#include <sys/kernel.h>
35#include <sys/module.h>
36#include <machine/bus.h>
37#include <sys/rman.h>
38#include <machine/resource.h>
39
40#include <dev/pci/pcivar.h>
41
42#include <dev/uart/uart.h>
43#include <dev/uart/uart_bus.h>
44
45#define DEFAULT_RCLK 1843200
46
47static int uart_pci_probe(device_t dev);
48
49static device_method_t uart_pci_methods[] = {
50 /* Device interface */
51 DEVMETHOD(device_probe, uart_pci_probe),
52 DEVMETHOD(device_attach, uart_bus_attach),
53 DEVMETHOD(device_detach, uart_bus_detach),
54 DEVMETHOD(device_resume, uart_bus_resume),
55 DEVMETHOD_END
56};
57
58static driver_t uart_pci_driver = {
59 uart_driver_name,
60 uart_pci_methods,
61 sizeof(struct uart_softc),
62};
63
64struct pci_id {
65 uint16_t vendor;
66 uint16_t device;
67 uint16_t subven;
68 uint16_t subdev;
69 const char *desc;
70 int rid;
71 int rclk;
72};
73
74static const struct pci_id pci_ns8250_ids[] = {
75{ 0x1028, 0x0008, 0xffff, 0, "Dell Remote Access Card III", 0x14,
76 128 * DEFAULT_RCLK },
77{ 0x1028, 0x0012, 0xffff, 0, "Dell RAC 4 Daughter Card Virtual UART", 0x14,
78 128 * DEFAULT_RCLK },
79{ 0x1033, 0x0074, 0x1033, 0x8014, "NEC RCV56ACF 56k Voice Modem", 0x10 },
80{ 0x1033, 0x007d, 0x1033, 0x8012, "NEC RS232C", 0x10 },
81{ 0x103c, 0x1048, 0x103c, 0x1227, "HP Diva Serial [GSP] UART - Powerbar SP2",
82 0x10 },
83{ 0x103c, 0x1048, 0x103c, 0x1301, "HP Diva RMP3", 0x14 },
84{ 0x103c, 0x1290, 0xffff, 0, "HP Auxiliary Diva Serial Port", 0x18 },
85{ 0x103c, 0x3301, 0xffff, 0, "HP iLO serial port", 0x10 },
86{ 0x11c1, 0x0480, 0xffff, 0, "Agere Systems Venus Modem (V90, 56KFlex)", 0x14 },
87{ 0x115d, 0x0103, 0xffff, 0, "Xircom Cardbus Ethernet + 56k Modem", 0x10 },
88{ 0x1282, 0x6585, 0xffff, 0, "Davicom 56PDV PCI Modem", 0x10 },
89{ 0x12b9, 0x1008, 0xffff, 0, "3Com 56K FaxModem Model 5610", 0x10 },
90{ 0x131f, 0x1000, 0xffff, 0, "Siig CyberSerial (1-port) 16550", 0x18 },
91{ 0x131f, 0x1001, 0xffff, 0, "Siig CyberSerial (1-port) 16650", 0x18 },
92{ 0x131f, 0x1002, 0xffff, 0, "Siig CyberSerial (1-port) 16850", 0x18 },
93{ 0x131f, 0x2000, 0xffff, 0, "Siig CyberSerial (1-port) 16550", 0x10 },
94{ 0x131f, 0x2001, 0xffff, 0, "Siig CyberSerial (1-port) 16650", 0x10 },
95{ 0x131f, 0x2002, 0xffff, 0, "Siig CyberSerial (1-port) 16850", 0x10 },
96{ 0x135c, 0x0190, 0xffff, 0, "Quatech SSCLP-100", 0x18 },
97{ 0x135c, 0x01c0, 0xffff, 0, "Quatech SSCLP-200/300", 0x18 },
98{ 0x135e, 0x7101, 0xffff, 0, "Sealevel Systems Single Port RS-232/422/485/530",
99 0x18 },
100{ 0x1407, 0x0110, 0xffff, 0, "Lava Computer mfg DSerial-PCI Port A", 0x10 },
101{ 0x1407, 0x0111, 0xffff, 0, "Lava Computer mfg DSerial-PCI Port B", 0x10 },
102{ 0x1407, 0x0510, 0xffff, 0, "Lava SP Serial 550 PCI", 0x10 },
103{ 0x1409, 0x7168, 0x1409, 0x4025, "Timedia Technology Serial Port", 0x10,
104 8 * DEFAULT_RCLK },
105{ 0x1409, 0x7168, 0x1409, 0x4027, "Timedia Technology Serial Port", 0x10,
106 8 * DEFAULT_RCLK },
107{ 0x1409, 0x7168, 0x1409, 0x4028, "Timedia Technology Serial Port", 0x10,
108 8 * DEFAULT_RCLK },
109{ 0x1409, 0x7168, 0x1409, 0x5025, "Timedia Technology Serial Port", 0x10,
110 8 * DEFAULT_RCLK },
111{ 0x1409, 0x7168, 0x1409, 0x5027, "Timedia Technology Serial Port", 0x10,
112 8 * DEFAULT_RCLK },
113{ 0x1415, 0x950b, 0xffff, 0, "Oxford Semiconductor OXCB950 Cardbus 16950 UART",
114 0x10, 16384000 },
115{ 0x14e4, 0x4344, 0xffff, 0, "Sony Ericsson GC89 PC Card", 0x10},
116{ 0x151f, 0x0000, 0xffff, 0, "TOPIC Semiconductor TP560 56k modem", 0x10 },
117{ 0x1fd4, 0x1999, 0x1fd4, 0x0001, "Sunix SER5xxxx Serial Port", 0x10,
118 8 * DEFAULT_RCLK },
119{ 0x8086, 0x1c3d, 0xffff, 0, "Intel AMT - KT Controller", 0x10 },
120{ 0x8086, 0x1d3d, 0xffff, 0, "Intel C600/X79 Series Chipset KT Controller", 0x10 },
121{ 0x8086, 0x2e17, 0xffff, 0, "4 Series Chipset Serial KT Controller", 0x10 },
122{ 0x8086, 0x3b67, 0xffff, 0, "5 Series/3400 Series Chipset KT Controller",
123 0x10 },
124{ 0x8086, 0x8811, 0xffff, 0, "Intel EG20T Serial Port 0", 0x10 },
125{ 0x8086, 0x8812, 0xffff, 0, "Intel EG20T Serial Port 1", 0x10 },
126{ 0x8086, 0x8813, 0xffff, 0, "Intel EG20T Serial Port 2", 0x10 },
127{ 0x8086, 0x8814, 0xffff, 0, "Intel EG20T Serial Port 3", 0x10 },
128{ 0x8086, 0x8c3d, 0xffff, 0, "Intel Lynx Point KT Controller", 0x10 },
129{ 0x9710, 0x9820, 0x1000, 1, "NetMos NM9820 Serial Port", 0x10 },
130{ 0x9710, 0x9835, 0x1000, 1, "NetMos NM9835 Serial Port", 0x10 },
131{ 0x9710, 0x9865, 0xa000, 0x1000, "NetMos NM9865 Serial Port", 0x10 },
132{ 0x9710, 0x9900, 0xa000, 0x1000,
133 "MosChip MCS9900 PCIe to Peripheral Controller", 0x10 },
134{ 0x9710, 0x9901, 0xa000, 0x1000,
135 "MosChip MCS9901 PCIe to Peripheral Controller", 0x10 },
136{ 0x9710, 0x9904, 0xa000, 0x1000,
137 "MosChip MCS9904 PCIe to Peripheral Controller", 0x10 },
138{ 0xdeaf, 0x9051, 0xffff, 0, "Middle Digital PC Weasel Serial Port", 0x10 },
139{ 0xffff, 0, 0xffff, 0, NULL, 0, 0}
140};
141
142const static struct pci_id *
143uart_pci_match(device_t dev, const struct pci_id *id)
144{
145 uint16_t device, subdev, subven, vendor;
146
147 vendor = pci_get_vendor(dev);
148 device = pci_get_device(dev);
149 while (id->vendor != 0xffff &&
150 (id->vendor != vendor || id->device != device))
151 id++;
152 if (id->vendor == 0xffff)
153 return (NULL);
154 if (id->subven == 0xffff)
155 return (id);
156 subven = pci_get_subvendor(dev);
157 subdev = pci_get_subdevice(dev);
158 while (id->vendor == vendor && id->device == device &&
159 (id->subven != subven || id->subdev != subdev))
160 id++;
161 return ((id->vendor == vendor && id->device == device) ? id : NULL);
162}
163
164static int
165uart_pci_probe(device_t dev)
166{
167 struct uart_softc *sc;
168 const struct pci_id *id;
169 int result;
170
171 sc = device_get_softc(dev);
172
173 id = uart_pci_match(dev, pci_ns8250_ids);
174 if (id != NULL) {
175 sc->sc_class = &uart_ns8250_class;
176 goto match;
177 }
178 /* Add checks for non-ns8250 IDs here. */
179 return (ENXIO);
180
181 match:
182 result = uart_bus_probe(dev, 0, id->rclk, id->rid, 0);
183 /* Bail out on error. */
184 if (result > 0)
185 return (result);
186 /* Set/override the device description. */
187 if (id->desc)
188 device_set_desc(dev, id->desc);
189 return (result);
190}
191
192DRIVER_MODULE(uart, pci, uart_pci_driver, uart_devclass, NULL, NULL);
2 * Copyright (c) 2006 Marcel Moolenaar
3 * Copyright (c) 2001 M. Warner Losh
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: head/sys/dev/uart/uart_bus_pci.c 264257 2014-04-08 07:32:32Z marius $");
29
30#include <sys/param.h>
31#include <sys/systm.h>
32#include <sys/bus.h>
33#include <sys/conf.h>
34#include <sys/kernel.h>
35#include <sys/module.h>
36#include <machine/bus.h>
37#include <sys/rman.h>
38#include <machine/resource.h>
39
40#include <dev/pci/pcivar.h>
41
42#include <dev/uart/uart.h>
43#include <dev/uart/uart_bus.h>
44
45#define DEFAULT_RCLK 1843200
46
47static int uart_pci_probe(device_t dev);
48
49static device_method_t uart_pci_methods[] = {
50 /* Device interface */
51 DEVMETHOD(device_probe, uart_pci_probe),
52 DEVMETHOD(device_attach, uart_bus_attach),
53 DEVMETHOD(device_detach, uart_bus_detach),
54 DEVMETHOD(device_resume, uart_bus_resume),
55 DEVMETHOD_END
56};
57
58static driver_t uart_pci_driver = {
59 uart_driver_name,
60 uart_pci_methods,
61 sizeof(struct uart_softc),
62};
63
64struct pci_id {
65 uint16_t vendor;
66 uint16_t device;
67 uint16_t subven;
68 uint16_t subdev;
69 const char *desc;
70 int rid;
71 int rclk;
72};
73
74static const struct pci_id pci_ns8250_ids[] = {
75{ 0x1028, 0x0008, 0xffff, 0, "Dell Remote Access Card III", 0x14,
76 128 * DEFAULT_RCLK },
77{ 0x1028, 0x0012, 0xffff, 0, "Dell RAC 4 Daughter Card Virtual UART", 0x14,
78 128 * DEFAULT_RCLK },
79{ 0x1033, 0x0074, 0x1033, 0x8014, "NEC RCV56ACF 56k Voice Modem", 0x10 },
80{ 0x1033, 0x007d, 0x1033, 0x8012, "NEC RS232C", 0x10 },
81{ 0x103c, 0x1048, 0x103c, 0x1227, "HP Diva Serial [GSP] UART - Powerbar SP2",
82 0x10 },
83{ 0x103c, 0x1048, 0x103c, 0x1301, "HP Diva RMP3", 0x14 },
84{ 0x103c, 0x1290, 0xffff, 0, "HP Auxiliary Diva Serial Port", 0x18 },
85{ 0x103c, 0x3301, 0xffff, 0, "HP iLO serial port", 0x10 },
86{ 0x11c1, 0x0480, 0xffff, 0, "Agere Systems Venus Modem (V90, 56KFlex)", 0x14 },
87{ 0x115d, 0x0103, 0xffff, 0, "Xircom Cardbus Ethernet + 56k Modem", 0x10 },
88{ 0x1282, 0x6585, 0xffff, 0, "Davicom 56PDV PCI Modem", 0x10 },
89{ 0x12b9, 0x1008, 0xffff, 0, "3Com 56K FaxModem Model 5610", 0x10 },
90{ 0x131f, 0x1000, 0xffff, 0, "Siig CyberSerial (1-port) 16550", 0x18 },
91{ 0x131f, 0x1001, 0xffff, 0, "Siig CyberSerial (1-port) 16650", 0x18 },
92{ 0x131f, 0x1002, 0xffff, 0, "Siig CyberSerial (1-port) 16850", 0x18 },
93{ 0x131f, 0x2000, 0xffff, 0, "Siig CyberSerial (1-port) 16550", 0x10 },
94{ 0x131f, 0x2001, 0xffff, 0, "Siig CyberSerial (1-port) 16650", 0x10 },
95{ 0x131f, 0x2002, 0xffff, 0, "Siig CyberSerial (1-port) 16850", 0x10 },
96{ 0x135c, 0x0190, 0xffff, 0, "Quatech SSCLP-100", 0x18 },
97{ 0x135c, 0x01c0, 0xffff, 0, "Quatech SSCLP-200/300", 0x18 },
98{ 0x135e, 0x7101, 0xffff, 0, "Sealevel Systems Single Port RS-232/422/485/530",
99 0x18 },
100{ 0x1407, 0x0110, 0xffff, 0, "Lava Computer mfg DSerial-PCI Port A", 0x10 },
101{ 0x1407, 0x0111, 0xffff, 0, "Lava Computer mfg DSerial-PCI Port B", 0x10 },
102{ 0x1407, 0x0510, 0xffff, 0, "Lava SP Serial 550 PCI", 0x10 },
103{ 0x1409, 0x7168, 0x1409, 0x4025, "Timedia Technology Serial Port", 0x10,
104 8 * DEFAULT_RCLK },
105{ 0x1409, 0x7168, 0x1409, 0x4027, "Timedia Technology Serial Port", 0x10,
106 8 * DEFAULT_RCLK },
107{ 0x1409, 0x7168, 0x1409, 0x4028, "Timedia Technology Serial Port", 0x10,
108 8 * DEFAULT_RCLK },
109{ 0x1409, 0x7168, 0x1409, 0x5025, "Timedia Technology Serial Port", 0x10,
110 8 * DEFAULT_RCLK },
111{ 0x1409, 0x7168, 0x1409, 0x5027, "Timedia Technology Serial Port", 0x10,
112 8 * DEFAULT_RCLK },
113{ 0x1415, 0x950b, 0xffff, 0, "Oxford Semiconductor OXCB950 Cardbus 16950 UART",
114 0x10, 16384000 },
115{ 0x14e4, 0x4344, 0xffff, 0, "Sony Ericsson GC89 PC Card", 0x10},
116{ 0x151f, 0x0000, 0xffff, 0, "TOPIC Semiconductor TP560 56k modem", 0x10 },
117{ 0x1fd4, 0x1999, 0x1fd4, 0x0001, "Sunix SER5xxxx Serial Port", 0x10,
118 8 * DEFAULT_RCLK },
119{ 0x8086, 0x1c3d, 0xffff, 0, "Intel AMT - KT Controller", 0x10 },
120{ 0x8086, 0x1d3d, 0xffff, 0, "Intel C600/X79 Series Chipset KT Controller", 0x10 },
121{ 0x8086, 0x2e17, 0xffff, 0, "4 Series Chipset Serial KT Controller", 0x10 },
122{ 0x8086, 0x3b67, 0xffff, 0, "5 Series/3400 Series Chipset KT Controller",
123 0x10 },
124{ 0x8086, 0x8811, 0xffff, 0, "Intel EG20T Serial Port 0", 0x10 },
125{ 0x8086, 0x8812, 0xffff, 0, "Intel EG20T Serial Port 1", 0x10 },
126{ 0x8086, 0x8813, 0xffff, 0, "Intel EG20T Serial Port 2", 0x10 },
127{ 0x8086, 0x8814, 0xffff, 0, "Intel EG20T Serial Port 3", 0x10 },
128{ 0x8086, 0x8c3d, 0xffff, 0, "Intel Lynx Point KT Controller", 0x10 },
129{ 0x9710, 0x9820, 0x1000, 1, "NetMos NM9820 Serial Port", 0x10 },
130{ 0x9710, 0x9835, 0x1000, 1, "NetMos NM9835 Serial Port", 0x10 },
131{ 0x9710, 0x9865, 0xa000, 0x1000, "NetMos NM9865 Serial Port", 0x10 },
132{ 0x9710, 0x9900, 0xa000, 0x1000,
133 "MosChip MCS9900 PCIe to Peripheral Controller", 0x10 },
134{ 0x9710, 0x9901, 0xa000, 0x1000,
135 "MosChip MCS9901 PCIe to Peripheral Controller", 0x10 },
136{ 0x9710, 0x9904, 0xa000, 0x1000,
137 "MosChip MCS9904 PCIe to Peripheral Controller", 0x10 },
138{ 0xdeaf, 0x9051, 0xffff, 0, "Middle Digital PC Weasel Serial Port", 0x10 },
139{ 0xffff, 0, 0xffff, 0, NULL, 0, 0}
140};
141
142const static struct pci_id *
143uart_pci_match(device_t dev, const struct pci_id *id)
144{
145 uint16_t device, subdev, subven, vendor;
146
147 vendor = pci_get_vendor(dev);
148 device = pci_get_device(dev);
149 while (id->vendor != 0xffff &&
150 (id->vendor != vendor || id->device != device))
151 id++;
152 if (id->vendor == 0xffff)
153 return (NULL);
154 if (id->subven == 0xffff)
155 return (id);
156 subven = pci_get_subvendor(dev);
157 subdev = pci_get_subdevice(dev);
158 while (id->vendor == vendor && id->device == device &&
159 (id->subven != subven || id->subdev != subdev))
160 id++;
161 return ((id->vendor == vendor && id->device == device) ? id : NULL);
162}
163
164static int
165uart_pci_probe(device_t dev)
166{
167 struct uart_softc *sc;
168 const struct pci_id *id;
169 int result;
170
171 sc = device_get_softc(dev);
172
173 id = uart_pci_match(dev, pci_ns8250_ids);
174 if (id != NULL) {
175 sc->sc_class = &uart_ns8250_class;
176 goto match;
177 }
178 /* Add checks for non-ns8250 IDs here. */
179 return (ENXIO);
180
181 match:
182 result = uart_bus_probe(dev, 0, id->rclk, id->rid, 0);
183 /* Bail out on error. */
184 if (result > 0)
185 return (result);
186 /* Set/override the device description. */
187 if (id->desc)
188 device_set_desc(dev, id->desc);
189 return (result);
190}
191
192DRIVER_MODULE(uart, pci, uart_pci_driver, uart_devclass, NULL, NULL);