2 * Copyright (c) 2001 M. Warner Losh. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
25 #include <sys/cdefs.h>
26 __FBSDID("$FreeBSD$");
28 #include <sys/param.h>
29 #include <sys/systm.h>
32 #include <sys/kernel.h>
34 #include <sys/malloc.h>
35 #include <sys/mutex.h>
36 #include <sys/module.h>
38 #include <machine/bus.h>
39 #include <sys/timepps.h>
41 #include <dev/sio/siovar.h>
43 #include <dev/pci/pcivar.h>
45 static int sio_pci_attach(device_t dev);
46 static void sio_pci_kludge_unit(device_t dev);
47 static int sio_pci_probe(device_t dev);
49 static device_method_t sio_pci_methods[] = {
50 /* Device interface */
51 DEVMETHOD(device_probe, sio_pci_probe),
52 DEVMETHOD(device_attach, sio_pci_attach),
53 DEVMETHOD(device_detach, siodetach),
58 static driver_t sio_pci_driver = {
70 static struct pci_ids pci_ids[] = {
71 { 0x100812b9, "3COM PCI FaxModem", 0x10 },
72 { 0x2000131f, "CyberSerial (1-port) 16550", 0x10 },
73 { 0x01101407, "Koutech IOFLEX-2S PCI Dual Port Serial", 0x10 },
74 { 0x01111407, "Koutech IOFLEX-2S PCI Dual Port Serial", 0x10 },
75 { 0x048011c1, "Lucent kermit based PCI Modem", 0x14 },
76 { 0x95211415, "Oxford Semiconductor PCI Dual Port Serial", 0x10 },
77 { 0x7101135e, "SeaLevel Ultra 530.PCI Single Port Serial", 0x18 },
78 { 0x0000151f, "SmartLink 5634PCV SurfRider", 0x10 },
79 { 0x0103115d, "Xircom Cardbus modem", 0x10 },
80 { 0x432214e4, "Broadcom 802.11g/GPRS CardBus (Serial)", 0x10 },
81 { 0x01c0135c, "Quatech SSCLP-200/300", 0x18
83 * NB: You must mount the "SPAD" jumper to correctly detect
84 * the FIFO on the UART. Set the options on the jumpers,
85 * we do not support the extra registers on the Quatech.
88 { 0x00000000, NULL, 0 }
98 type = pci_get_devid(dev);
100 while (id->type && id->type != type)
102 if (id->desc == NULL)
104 sio_pci_kludge_unit(dev);
105 return (sioattach(dev, id->rid, 0UL));
109 * Don't cut and paste this to other drivers. It is a horrible kludge
110 * which will fail to work and also be unnecessary in future versions.
113 sio_pci_kludge_unit(dev)
123 while (resource_int_value("sio", unit, "port", &start) == 0 &&
126 if (device_get_unit(dev) < unit) {
127 dc = device_get_devclass(dev);
128 while (devclass_get_device(dc, unit))
130 device_printf(dev, "moving to sio%d\n", unit);
131 err = device_set_unit(dev, unit); /* EVIL DO NOT COPY */
133 device_printf(dev, "error moving device %d\n", err);
144 type = pci_get_devid(dev);
146 while (id->type && id->type != type)
148 if (id->desc == NULL)
150 device_set_desc(dev, id->desc);
152 SET_FLAG(dev, SET_IFTYPE(COM_IF_NS16550));
154 return (sioprobe(dev, id->rid, 0UL, 0));
157 DRIVER_MODULE(sio, pci, sio_pci_driver, sio_devclass, 0, 0);
158 DRIVER_MODULE(sio, cardbus, sio_pci_driver, sio_devclass, 0, 0);