]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/sio/sio_pci.c
MFV r328323,328324:
[FreeBSD/FreeBSD.git] / sys / dev / sio / sio_pci.c
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3  *
4  * Copyright (c) 2001 M. Warner Losh.  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$");
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/lock.h>
36 #include <sys/malloc.h>
37 #include <sys/mutex.h>
38 #include <sys/module.h>
39 #include <sys/tty.h>
40 #include <machine/bus.h>
41 #include <sys/timepps.h>
42
43 #include <dev/sio/siovar.h>
44
45 #include <dev/pci/pcivar.h>
46
47 static  int     sio_pci_attach(device_t dev);
48 static  int     sio_pci_probe(device_t dev);
49
50 static device_method_t sio_pci_methods[] = {
51         /* Device interface */
52         DEVMETHOD(device_probe,         sio_pci_probe),
53         DEVMETHOD(device_attach,        sio_pci_attach),
54         DEVMETHOD(device_detach,        siodetach),
55
56         { 0, 0 }
57 };
58
59 static driver_t sio_pci_driver = {
60         sio_driver_name,
61         sio_pci_methods,
62         0,
63 };
64
65 struct pci_ids {
66         u_int32_t       type;
67         const char      *desc;
68         int             rid;
69 };
70
71 static struct pci_ids pci_ids[] = {
72         { 0x100812b9, "3COM PCI FaxModem", 0x10 },
73         { 0x2000131f, "CyberSerial (1-port) 16550", 0x10 },
74         { 0x01101407, "Koutech IOFLEX-2S PCI Dual Port Serial", 0x10 },
75         { 0x01111407, "Koutech IOFLEX-2S PCI Dual Port Serial", 0x10 },
76         { 0x048011c1, "Lucent kermit based PCI Modem", 0x14 },
77         { 0x95211415, "Oxford Semiconductor PCI Dual Port Serial", 0x10 },
78         { 0x7101135e, "SeaLevel Ultra 530.PCI Single Port Serial", 0x18 },
79         { 0x0000151f, "SmartLink 5634PCV SurfRider", 0x10 },
80         { 0x0103115d, "Xircom Cardbus modem", 0x10 },
81         { 0x432214e4, "Broadcom 802.11b/GPRS CardBus (Serial)", 0x10 },
82         { 0x434414e4, "Broadcom 802.11bg/EDGE/GPRS CardBus (Serial)", 0x10 },
83         { 0x01c0135c, "Quatech SSCLP-200/300", 0x18 
84                 /* 
85                  * NB: You must mount the "SPAD" jumper to correctly detect
86                  * the FIFO on the UART.  Set the options on the jumpers,
87                  * we do not support the extra registers on the Quatech.
88                  */
89         },
90         { 0x00000000, NULL, 0 }
91 };
92
93 static int
94 sio_pci_attach(dev)
95         device_t        dev;
96 {
97         u_int32_t       type;
98         struct pci_ids  *id;
99
100         type = pci_get_devid(dev);
101         id = pci_ids;
102         while (id->type && id->type != type)
103                 id++;
104         if (id->desc == NULL)
105                 return (ENXIO);
106         return (sioattach(dev, id->rid, 0UL));
107 }
108
109 static int
110 sio_pci_probe(dev)
111         device_t        dev;
112 {
113         u_int32_t       type;
114         struct pci_ids  *id;
115
116         type = pci_get_devid(dev);
117         id = pci_ids;
118         while (id->type && id->type != type)
119                 id++;
120         if (id->desc == NULL)
121                 return (ENXIO);
122         device_set_desc(dev, id->desc);
123
124         return (sioprobe(dev, id->rid, 0UL, 0));
125 }
126
127 DRIVER_MODULE(sio, pci, sio_pci_driver, sio_devclass, 0, 0);