Deleted Added
full compact
sio_pci.c (119283) sio_pci.c (119419)
1/*
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.
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 * $FreeBSD: head/sys/dev/sio/sio_pci.c 119283 2003-08-22 06:17:16Z imp $
25 */
26
23 */
24
25#include <sys/cdefs.h>
26__FBSDID("$FreeBSD: head/sys/dev/sio/sio_pci.c 119419 2003-08-24 18:03:45Z obrien $");
27
27#include <sys/param.h>
28#include <sys/systm.h>
29#include <sys/bus.h>
30#include <sys/conf.h>
31#include <sys/kernel.h>
32#include <sys/lock.h>
33#include <sys/malloc.h>
34#include <sys/mutex.h>
35#include <sys/module.h>
36#include <sys/tty.h>
37#include <machine/bus_pio.h>
38#include <machine/bus.h>
39#include <sys/timepps.h>
40
41#include <dev/sio/siovar.h>
42
43#include <dev/pci/pcivar.h>
44
45static int sio_pci_attach(device_t dev);
46static void sio_pci_kludge_unit(device_t dev);
47static int sio_pci_probe(device_t dev);
48
49static 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),
54
55 { 0, 0 }
56};
57
58static driver_t sio_pci_driver = {
59 sio_driver_name,
60 sio_pci_methods,
61 0,
62};
63
64struct pci_ids {
65 u_int32_t type;
66 const char *desc;
67 int rid;
68};
69
70static 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 { 0x98459710, "Netmos Nm9845 PCI Bridge with Dual UART", 0x10 },
81 { 0x01c0135c, "Quatech SSCLP-200/300", 0x18
82 /*
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.
86 */
87 },
88 { 0x00000000, NULL, 0 }
89};
90
91static int
92sio_pci_attach(dev)
93 device_t dev;
94{
95 u_int32_t type;
96 struct pci_ids *id;
97 int flags;
98
99 type = pci_get_devid(dev);
100 id = pci_ids;
101 while (id->type && id->type != type)
102 id++;
103 if (id->desc == NULL)
104 return (ENXIO);
105 sio_pci_kludge_unit(dev);
106 if (resource_int_value("sio", device_get_unit(dev), "flags", &flags)
107 == 0)
108 device_set_flags(dev, flags);
109 return (sioattach(dev, id->rid, 0UL));
110}
111
112/*
113 * Don't cut and paste this to other drivers. It is a horrible kludge
114 * which will fail to work and also be unnecessary in future versions.
115 */
116static void
117sio_pci_kludge_unit(dev)
118 device_t dev;
119{
120 devclass_t dc;
121 int err;
122 int start;
123 int unit;
124
125 unit = 0;
126 start = 0;
127 while (resource_int_value("sio", unit, "port", &start) == 0 &&
128 start > 0)
129 unit++;
130 if (device_get_unit(dev) < unit) {
131 dc = device_get_devclass(dev);
132 while (devclass_get_device(dc, unit))
133 unit++;
134 device_printf(dev, "moving to sio%d\n", unit);
135 err = device_set_unit(dev, unit); /* EVIL DO NOT COPY */
136 if (err)
137 device_printf(dev, "error moving device %d\n", err);
138 }
139}
140
141static int
142sio_pci_probe(dev)
143 device_t dev;
144{
145 u_int32_t type;
146 struct pci_ids *id;
147
148 type = pci_get_devid(dev);
149 id = pci_ids;
150 while (id->type && id->type != type)
151 id++;
152 if (id->desc == NULL)
153 return (ENXIO);
154 device_set_desc(dev, id->desc);
155#ifdef PC98
156 SET_FLAG(dev, SET_IFTYPE(COM_IF_NS16550));
157#endif
158 return (sioprobe(dev, id->rid, 0UL, 0));
159}
160
161DRIVER_MODULE(sio, pci, sio_pci_driver, sio_devclass, 0, 0);
162DRIVER_MODULE(sio, cardbus, sio_pci_driver, sio_devclass, 0, 0);
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/lock.h>
34#include <sys/malloc.h>
35#include <sys/mutex.h>
36#include <sys/module.h>
37#include <sys/tty.h>
38#include <machine/bus_pio.h>
39#include <machine/bus.h>
40#include <sys/timepps.h>
41
42#include <dev/sio/siovar.h>
43
44#include <dev/pci/pcivar.h>
45
46static int sio_pci_attach(device_t dev);
47static void sio_pci_kludge_unit(device_t dev);
48static int sio_pci_probe(device_t dev);
49
50static 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
59static driver_t sio_pci_driver = {
60 sio_driver_name,
61 sio_pci_methods,
62 0,
63};
64
65struct pci_ids {
66 u_int32_t type;
67 const char *desc;
68 int rid;
69};
70
71static 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 { 0x98459710, "Netmos Nm9845 PCI Bridge with Dual UART", 0x10 },
82 { 0x01c0135c, "Quatech SSCLP-200/300", 0x18
83 /*
84 * NB: You must mount the "SPAD" jumper to correctly detect
85 * the FIFO on the UART. Set the options on the jumpers,
86 * we do not support the extra registers on the Quatech.
87 */
88 },
89 { 0x00000000, NULL, 0 }
90};
91
92static int
93sio_pci_attach(dev)
94 device_t dev;
95{
96 u_int32_t type;
97 struct pci_ids *id;
98 int flags;
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 sio_pci_kludge_unit(dev);
107 if (resource_int_value("sio", device_get_unit(dev), "flags", &flags)
108 == 0)
109 device_set_flags(dev, flags);
110 return (sioattach(dev, id->rid, 0UL));
111}
112
113/*
114 * Don't cut and paste this to other drivers. It is a horrible kludge
115 * which will fail to work and also be unnecessary in future versions.
116 */
117static void
118sio_pci_kludge_unit(dev)
119 device_t dev;
120{
121 devclass_t dc;
122 int err;
123 int start;
124 int unit;
125
126 unit = 0;
127 start = 0;
128 while (resource_int_value("sio", unit, "port", &start) == 0 &&
129 start > 0)
130 unit++;
131 if (device_get_unit(dev) < unit) {
132 dc = device_get_devclass(dev);
133 while (devclass_get_device(dc, unit))
134 unit++;
135 device_printf(dev, "moving to sio%d\n", unit);
136 err = device_set_unit(dev, unit); /* EVIL DO NOT COPY */
137 if (err)
138 device_printf(dev, "error moving device %d\n", err);
139 }
140}
141
142static int
143sio_pci_probe(dev)
144 device_t dev;
145{
146 u_int32_t type;
147 struct pci_ids *id;
148
149 type = pci_get_devid(dev);
150 id = pci_ids;
151 while (id->type && id->type != type)
152 id++;
153 if (id->desc == NULL)
154 return (ENXIO);
155 device_set_desc(dev, id->desc);
156#ifdef PC98
157 SET_FLAG(dev, SET_IFTYPE(COM_IF_NS16550));
158#endif
159 return (sioprobe(dev, id->rid, 0UL, 0));
160}
161
162DRIVER_MODULE(sio, pci, sio_pci_driver, sio_devclass, 0, 0);
163DRIVER_MODULE(sio, cardbus, sio_pci_driver, sio_devclass, 0, 0);