1 // SPDX-License-Identifier: GPL-2.0+
3 * Support for common PCI multi-I/O cards (which is most of them)
5 * Copyright (C) 2001 Tim Waugh <twaugh@redhat.com>
7 * Multi-function PCI cards are supposed to present separate logical
8 * devices on the bus. A common thing to do seems to be to just use
9 * one logical device with lots of base address registers for both
10 * parallel ports and serial ports. This driver is for dealing with
14 #include <linux/interrupt.h>
15 #include <linux/module.h>
16 #include <linux/parport.h>
17 #include <linux/parport_pc.h>
18 #include <linux/pci.h>
19 #include <linux/slab.h>
20 #include <linux/types.h>
22 #include <linux/8250_pci.h>
24 enum parport_pc_pci_cards
{
74 /* each element directly indexed from enum list, above */
75 struct parport_pc_pci
{
77 struct { /* BAR (base address registers) numbers in the config
80 int hi
; /* -1 if not there, >6 for offset-method (max
84 /* If set, this is called immediately after pci_enable_device.
85 * If it returns non-zero, no probing will take place and the
86 * ports will not be used. */
87 int (*preinit_hook
) (struct pci_dev
*pdev
, struct parport_pc_pci
*card
,
88 int autoirq
, int autodma
);
90 /* If set, this is called after probing for ports. If 'failed'
91 * is non-zero we couldn't use any of the ports. */
92 void (*postinit_hook
) (struct pci_dev
*pdev
,
93 struct parport_pc_pci
*card
, int failed
);
96 static int netmos_parallel_init(struct pci_dev
*dev
, struct parport_pc_pci
*par
,
97 int autoirq
, int autodma
)
99 /* the rule described below doesn't hold for this device */
100 if (dev
->device
== PCI_DEVICE_ID_NETMOS_9835
&&
101 dev
->subsystem_vendor
== PCI_VENDOR_ID_IBM
&&
102 dev
->subsystem_device
== 0x0299)
105 if (dev
->device
== PCI_DEVICE_ID_NETMOS_9912
) {
109 * Netmos uses the subdevice ID to indicate the number of parallel
110 * and serial ports. The form is 0x00PS, where <P> is the number of
111 * parallel ports and <S> is the number of serial ports.
113 par
->numports
= (dev
->subsystem_device
& 0xf0) >> 4;
114 if (par
->numports
> ARRAY_SIZE(par
->addr
))
115 par
->numports
= ARRAY_SIZE(par
->addr
);
121 static struct parport_pc_pci cards
[] = {
122 /* titan_110l */ { 1, { { 3, -1 }, } },
123 /* titan_210l */ { 1, { { 3, -1 }, } },
124 /* netmos_9xx5_combo */ { 1, { { 2, -1 }, }, netmos_parallel_init
},
125 /* netmos_9855 */ { 1, { { 0, -1 }, }, netmos_parallel_init
},
126 /* netmos_9855_2p */ { 2, { { 0, -1 }, { 2, -1 }, } },
127 /* netmos_9900 */ {1, { { 3, 4 }, }, netmos_parallel_init
},
128 /* netmos_9900_2p */ {2, { { 0, 1 }, { 3, 4 }, } },
129 /* netmos_99xx_1p */ {1, { { 0, 1 }, } },
130 /* avlab_1s1p */ { 1, { { 1, 2}, } },
131 /* avlab_1s2p */ { 2, { { 1, 2}, { 3, 4 },} },
132 /* avlab_2s1p */ { 1, { { 2, 3}, } },
133 /* siig_1s1p_10x */ { 1, { { 3, 4 }, } },
134 /* siig_2s1p_10x */ { 1, { { 4, 5 }, } },
135 /* siig_2p1s_20x */ { 2, { { 1, 2 }, { 3, 4 }, } },
136 /* siig_1s1p_20x */ { 1, { { 1, 2 }, } },
137 /* siig_2s1p_20x */ { 1, { { 2, 3 }, } },
138 /* timedia_4078a */ { 1, { { 2, -1 }, } },
139 /* timedia_4079h */ { 1, { { 2, 3 }, } },
140 /* timedia_4085h */ { 2, { { 2, -1 }, { 4, -1 }, } },
141 /* timedia_4088a */ { 2, { { 2, 3 }, { 4, 5 }, } },
142 /* timedia_4089a */ { 2, { { 2, 3 }, { 4, 5 }, } },
143 /* timedia_4095a */ { 2, { { 2, 3 }, { 4, 5 }, } },
144 /* timedia_4096a */ { 2, { { 2, 3 }, { 4, 5 }, } },
145 /* timedia_4078u */ { 1, { { 2, -1 }, } },
146 /* timedia_4079a */ { 1, { { 2, 3 }, } },
147 /* timedia_4085u */ { 2, { { 2, -1 }, { 4, -1 }, } },
148 /* timedia_4079r */ { 1, { { 2, 3 }, } },
149 /* timedia_4079s */ { 1, { { 2, 3 }, } },
150 /* timedia_4079d */ { 1, { { 2, 3 }, } },
151 /* timedia_4079e */ { 1, { { 2, 3 }, } },
152 /* timedia_4079f */ { 1, { { 2, 3 }, } },
153 /* timedia_9079a */ { 1, { { 2, 3 }, } },
154 /* timedia_9079b */ { 1, { { 2, 3 }, } },
155 /* timedia_9079c */ { 1, { { 2, 3 }, } },
156 /* wch_ch353_1s1p*/ { 1, { { 1, -1}, } },
157 /* wch_ch353_2s1p*/ { 1, { { 2, -1}, } },
158 /* wch_ch382_0s1p*/ { 1, { { 2, -1}, } },
159 /* wch_ch382_2s1p*/ { 1, { { 2, -1}, } },
160 /* brainboxes_5s1p */ { 1, { { 3, -1 }, } },
161 /* sunix_4008a */ { 1, { { 1, 2 }, } },
162 /* sunix_5069a */ { 1, { { 1, 2 }, } },
163 /* sunix_5079a */ { 1, { { 1, 2 }, } },
164 /* sunix_5099a */ { 1, { { 1, 2 }, } },
165 /* brainboxes_uc257 */ { 1, { { 3, -1 }, } },
166 /* brainboxes_is300 */ { 1, { { 3, -1 }, } },
167 /* brainboxes_uc414 */ { 1, { { 3, -1 }, } },
168 /* brainboxes_px263 */ { 1, { { 3, -1 }, } },
171 static struct pci_device_id parport_serial_pci_tbl
[] = {
173 { PCI_VENDOR_ID_TITAN
, PCI_DEVICE_ID_TITAN_110L
,
174 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, titan_110l
},
175 { PCI_VENDOR_ID_TITAN
, PCI_DEVICE_ID_TITAN_210L
,
176 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, titan_210l
},
177 { PCI_VENDOR_ID_NETMOS
, PCI_DEVICE_ID_NETMOS_9735
,
178 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, netmos_9xx5_combo
},
179 { PCI_VENDOR_ID_NETMOS
, PCI_DEVICE_ID_NETMOS_9745
,
180 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, netmos_9xx5_combo
},
181 { PCI_VENDOR_ID_NETMOS
, PCI_DEVICE_ID_NETMOS_9835
,
182 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, netmos_9xx5_combo
},
183 { PCI_VENDOR_ID_NETMOS
, PCI_DEVICE_ID_NETMOS_9845
,
184 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, netmos_9xx5_combo
},
185 { PCI_VENDOR_ID_NETMOS
, PCI_DEVICE_ID_NETMOS_9855
,
186 0x1000, 0x0020, 0, 0, netmos_9855_2p
},
187 { PCI_VENDOR_ID_NETMOS
, PCI_DEVICE_ID_NETMOS_9855
,
188 0x1000, 0x0022, 0, 0, netmos_9855_2p
},
189 { PCI_VENDOR_ID_NETMOS
, PCI_DEVICE_ID_NETMOS_9855
,
190 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, netmos_9855
},
191 { PCI_VENDOR_ID_NETMOS
, PCI_DEVICE_ID_NETMOS_9900
,
192 0xA000, 0x3011, 0, 0, netmos_9900
},
193 { PCI_VENDOR_ID_NETMOS
, PCI_DEVICE_ID_NETMOS_9900
,
194 0xA000, 0x3012, 0, 0, netmos_9900
},
195 { PCI_VENDOR_ID_NETMOS
, PCI_DEVICE_ID_NETMOS_9900
,
196 0xA000, 0x3020, 0, 0, netmos_9900_2p
},
197 { PCI_VENDOR_ID_NETMOS
, PCI_DEVICE_ID_NETMOS_9912
,
198 0xA000, 0x2000, 0, 0, netmos_99xx_1p
},
199 /* PCI_VENDOR_ID_AVLAB/Intek21 has another bunch of cards ...*/
200 { PCI_VENDOR_ID_AFAVLAB
, 0x2110,
201 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, avlab_1s1p
},
202 { PCI_VENDOR_ID_AFAVLAB
, 0x2111,
203 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, avlab_1s1p
},
204 { PCI_VENDOR_ID_AFAVLAB
, 0x2112,
205 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, avlab_1s1p
},
206 { PCI_VENDOR_ID_AFAVLAB
, 0x2140,
207 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, avlab_1s2p
},
208 { PCI_VENDOR_ID_AFAVLAB
, 0x2141,
209 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, avlab_1s2p
},
210 { PCI_VENDOR_ID_AFAVLAB
, 0x2142,
211 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, avlab_1s2p
},
212 { PCI_VENDOR_ID_AFAVLAB
, 0x2160,
213 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, avlab_2s1p
},
214 { PCI_VENDOR_ID_AFAVLAB
, 0x2161,
215 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, avlab_2s1p
},
216 { PCI_VENDOR_ID_AFAVLAB
, 0x2162,
217 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, avlab_2s1p
},
218 { PCI_VENDOR_ID_SIIG
, PCI_DEVICE_ID_SIIG_1S1P_10x_550
,
219 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, siig_1s1p_10x
},
220 { PCI_VENDOR_ID_SIIG
, PCI_DEVICE_ID_SIIG_1S1P_10x_650
,
221 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, siig_1s1p_10x
},
222 { PCI_VENDOR_ID_SIIG
, PCI_DEVICE_ID_SIIG_1S1P_10x_850
,
223 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, siig_1s1p_10x
},
224 { PCI_VENDOR_ID_SIIG
, PCI_DEVICE_ID_SIIG_2S1P_10x_550
,
225 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, siig_2s1p_10x
},
226 { PCI_VENDOR_ID_SIIG
, PCI_DEVICE_ID_SIIG_2S1P_10x_650
,
227 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, siig_2s1p_10x
},
228 { PCI_VENDOR_ID_SIIG
, PCI_DEVICE_ID_SIIG_2S1P_10x_850
,
229 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, siig_2s1p_10x
},
230 { PCI_VENDOR_ID_SIIG
, PCI_DEVICE_ID_SIIG_2P1S_20x_550
,
231 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, siig_2p1s_20x
},
232 { PCI_VENDOR_ID_SIIG
, PCI_DEVICE_ID_SIIG_2P1S_20x_650
,
233 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, siig_2p1s_20x
},
234 { PCI_VENDOR_ID_SIIG
, PCI_DEVICE_ID_SIIG_2P1S_20x_850
,
235 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, siig_2p1s_20x
},
236 { PCI_VENDOR_ID_SIIG
, PCI_DEVICE_ID_SIIG_1S1P_20x_550
,
237 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, siig_2s1p_20x
},
238 { PCI_VENDOR_ID_SIIG
, PCI_DEVICE_ID_SIIG_1S1P_20x_650
,
239 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, siig_1s1p_20x
},
240 { PCI_VENDOR_ID_SIIG
, PCI_DEVICE_ID_SIIG_1S1P_20x_850
,
241 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, siig_1s1p_20x
},
242 { PCI_VENDOR_ID_SIIG
, PCI_DEVICE_ID_SIIG_2S1P_20x_550
,
243 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, siig_2s1p_20x
},
244 { PCI_VENDOR_ID_SIIG
, PCI_DEVICE_ID_SIIG_2S1P_20x_650
,
245 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, siig_2s1p_20x
},
246 { PCI_VENDOR_ID_SIIG
, PCI_DEVICE_ID_SIIG_2S1P_20x_850
,
247 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, siig_2s1p_20x
},
248 /* PCI_VENDOR_ID_TIMEDIA/SUNIX has many differing cards ...*/
249 { 0x1409, 0x7168, 0x1409, 0x4078, 0, 0, timedia_4078a
},
250 { 0x1409, 0x7168, 0x1409, 0x4079, 0, 0, timedia_4079h
},
251 { 0x1409, 0x7168, 0x1409, 0x4085, 0, 0, timedia_4085h
},
252 { 0x1409, 0x7168, 0x1409, 0x4088, 0, 0, timedia_4088a
},
253 { 0x1409, 0x7168, 0x1409, 0x4089, 0, 0, timedia_4089a
},
254 { 0x1409, 0x7168, 0x1409, 0x4095, 0, 0, timedia_4095a
},
255 { 0x1409, 0x7168, 0x1409, 0x4096, 0, 0, timedia_4096a
},
256 { 0x1409, 0x7168, 0x1409, 0x5078, 0, 0, timedia_4078u
},
257 { 0x1409, 0x7168, 0x1409, 0x5079, 0, 0, timedia_4079a
},
258 { 0x1409, 0x7168, 0x1409, 0x5085, 0, 0, timedia_4085u
},
259 { 0x1409, 0x7168, 0x1409, 0x6079, 0, 0, timedia_4079r
},
260 { 0x1409, 0x7168, 0x1409, 0x7079, 0, 0, timedia_4079s
},
261 { 0x1409, 0x7168, 0x1409, 0x8079, 0, 0, timedia_4079d
},
262 { 0x1409, 0x7168, 0x1409, 0x9079, 0, 0, timedia_4079e
},
263 { 0x1409, 0x7168, 0x1409, 0xa079, 0, 0, timedia_4079f
},
264 { 0x1409, 0x7168, 0x1409, 0xb079, 0, 0, timedia_9079a
},
265 { 0x1409, 0x7168, 0x1409, 0xc079, 0, 0, timedia_9079b
},
266 { 0x1409, 0x7168, 0x1409, 0xd079, 0, 0, timedia_9079c
},
269 { 0x4348, 0x5053, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, wch_ch353_1s1p
},
270 { 0x4348, 0x7053, 0x4348, 0x3253, 0, 0, wch_ch353_2s1p
},
271 { 0x1c00, 0x3050, 0x1c00, 0x3050, 0, 0, wch_ch382_0s1p
},
272 { 0x1c00, 0x3250, 0x1c00, 0x3250, 0, 0, wch_ch382_2s1p
},
274 /* BrainBoxes PX272/PX306 MIO card */
275 { PCI_VENDOR_ID_INTASHIELD
, 0x4100,
276 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, brainboxes_5s1p
},
279 { PCI_VENDOR_ID_SUNIX
, PCI_DEVICE_ID_SUNIX_1999
, PCI_VENDOR_ID_SUNIX
,
280 0x0100, 0, 0, sunix_4008a
},
281 { PCI_VENDOR_ID_SUNIX
, PCI_DEVICE_ID_SUNIX_1999
, PCI_VENDOR_ID_SUNIX
,
282 0x0101, 0, 0, sunix_5069a
},
283 { PCI_VENDOR_ID_SUNIX
, PCI_DEVICE_ID_SUNIX_1999
, PCI_VENDOR_ID_SUNIX
,
284 0x0102, 0, 0, sunix_5079a
},
285 { PCI_VENDOR_ID_SUNIX
, PCI_DEVICE_ID_SUNIX_1999
, PCI_VENDOR_ID_SUNIX
,
286 0x0104, 0, 0, sunix_5099a
},
288 /* Brainboxes UC-203 */
289 { PCI_VENDOR_ID_INTASHIELD
, 0x0bc1,
290 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, brainboxes_uc257
},
291 { PCI_VENDOR_ID_INTASHIELD
, 0x0bc2,
292 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, brainboxes_uc257
},
294 /* Brainboxes UC-257 */
295 { PCI_VENDOR_ID_INTASHIELD
, 0x0861,
296 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, brainboxes_uc257
},
297 { PCI_VENDOR_ID_INTASHIELD
, 0x0862,
298 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, brainboxes_uc257
},
299 { PCI_VENDOR_ID_INTASHIELD
, 0x0863,
300 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, brainboxes_uc257
},
302 /* Brainboxes UC-414 */
303 { PCI_VENDOR_ID_INTASHIELD
, 0x0e61,
304 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, brainboxes_uc414
},
306 /* Brainboxes UC-475 */
307 { PCI_VENDOR_ID_INTASHIELD
, 0x0981,
308 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, brainboxes_uc257
},
309 { PCI_VENDOR_ID_INTASHIELD
, 0x0982,
310 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, brainboxes_uc257
},
312 /* Brainboxes IS-300/IS-500 */
313 { PCI_VENDOR_ID_INTASHIELD
, 0x0da0,
314 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, brainboxes_is300
},
316 /* Brainboxes PX-263/PX-295 */
317 { PCI_VENDOR_ID_INTASHIELD
, 0x402c,
318 PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, brainboxes_px263
},
320 { 0, } /* terminate list */
322 MODULE_DEVICE_TABLE(pci
,parport_serial_pci_tbl
);
325 * This table describes the serial "geometry" of these boards. Any
326 * quirks for these can be found in drivers/serial/8250_pci.c
328 * Cards not tested are marked n/t
329 * If you have one of these cards and it works for you, please tell me..
331 static struct pciserial_board pci_parport_serial_boards
[] = {
333 .flags
= FL_BASE1
| FL_BASE_BARS
,
339 .flags
= FL_BASE1
| FL_BASE_BARS
,
344 [netmos_9xx5_combo
] = {
345 .flags
= FL_BASE0
| FL_BASE_BARS
,
351 .flags
= FL_BASE2
| FL_BASE_BARS
,
357 .flags
= FL_BASE4
| FL_BASE_BARS
,
362 [netmos_9900
] = { /* n/t */
363 .flags
= FL_BASE0
| FL_BASE_BARS
,
368 [netmos_9900_2p
] = { /* parallel only */ /* n/t */
374 [netmos_99xx_1p
] = { /* parallel only */ /* n/t */
380 [avlab_1s1p
] = { /* n/t */
381 .flags
= FL_BASE0
| FL_BASE_BARS
,
386 [avlab_1s2p
] = { /* n/t */
387 .flags
= FL_BASE0
| FL_BASE_BARS
,
392 [avlab_2s1p
] = { /* n/t */
393 .flags
= FL_BASE0
| FL_BASE_BARS
,
429 .flags
= FL_BASE0
|FL_BASE_BARS
,
435 .flags
= FL_BASE0
|FL_BASE_BARS
,
441 .flags
= FL_BASE0
|FL_BASE_BARS
,
447 .flags
= FL_BASE0
|FL_BASE_BARS
,
453 .flags
= FL_BASE0
|FL_BASE_BARS
,
459 .flags
= FL_BASE0
|FL_BASE_BARS
,
465 .flags
= FL_BASE0
|FL_BASE_BARS
,
471 .flags
= FL_BASE0
|FL_BASE_BARS
,
477 .flags
= FL_BASE0
|FL_BASE_BARS
,
483 .flags
= FL_BASE0
|FL_BASE_BARS
,
489 .flags
= FL_BASE0
|FL_BASE_BARS
,
495 .flags
= FL_BASE0
|FL_BASE_BARS
,
501 .flags
= FL_BASE0
|FL_BASE_BARS
,
507 .flags
= FL_BASE0
|FL_BASE_BARS
,
513 .flags
= FL_BASE0
|FL_BASE_BARS
,
519 .flags
= FL_BASE0
|FL_BASE_BARS
,
525 .flags
= FL_BASE0
|FL_BASE_BARS
,
531 .flags
= FL_BASE0
|FL_BASE_BARS
,
537 .flags
= FL_BASE0
|FL_BASE_BARS
,
543 .flags
= FL_BASE0
|FL_BASE_BARS
,
559 .first_offset
= 0xC0,
561 [brainboxes_5s1p
] = {
585 [brainboxes_uc257
] = {
591 [brainboxes_is300
] = {
597 [brainboxes_uc414
] = {
603 [brainboxes_px263
] = {
611 struct parport_serial_private
{
612 struct serial_private
*serial
;
614 struct parport
*port
[PARPORT_MAX
];
615 struct parport_pc_pci par
;
618 /* Register the serial port(s) of a PCI card. */
619 static int serial_register(struct pci_dev
*dev
, const struct pci_device_id
*id
)
621 struct parport_serial_private
*priv
= pci_get_drvdata (dev
);
622 struct pciserial_board
*board
;
623 struct serial_private
*serial
;
625 board
= &pci_parport_serial_boards
[id
->driver_data
];
626 if (board
->num_ports
== 0)
629 serial
= pciserial_init_ports(dev
, board
);
631 return PTR_ERR(serial
);
633 priv
->serial
= serial
;
637 /* Register the parallel port(s) of a PCI card. */
638 static int parport_register(struct pci_dev
*dev
, const struct pci_device_id
*id
)
640 struct parport_pc_pci
*card
;
641 struct parport_serial_private
*priv
= pci_get_drvdata (dev
);
644 priv
->par
= cards
[id
->driver_data
];
646 if (card
->preinit_hook
&&
647 card
->preinit_hook (dev
, card
, PARPORT_IRQ_NONE
, PARPORT_DMA_NONE
))
650 for (n
= 0; n
< card
->numports
; n
++) {
651 struct parport
*port
;
652 int lo
= card
->addr
[n
].lo
;
653 int hi
= card
->addr
[n
].hi
;
654 unsigned long io_lo
, io_hi
;
657 if (priv
->num_par
== ARRAY_SIZE (priv
->port
)) {
659 "only %zu parallel ports supported (%d reported)\n",
660 ARRAY_SIZE(priv
->port
), card
->numports
);
664 io_lo
= pci_resource_start (dev
, lo
);
666 if ((hi
>= 0) && (hi
<= 6))
667 io_hi
= pci_resource_start (dev
, hi
);
669 io_lo
+= hi
; /* Reinterpret the meaning of
670 "hi" as an offset (see SYBA
672 /* TODO: test if sharing interrupts works */
673 irq
= pci_irq_vector(dev
, 0);
677 irq
= PARPORT_IRQ_NONE
;
678 if (irq
== PARPORT_IRQ_NONE
) {
680 "PCI parallel port detected: I/O at %#lx(%#lx)\n",
684 "PCI parallel port detected: I/O at %#lx(%#lx), IRQ %d\n",
687 port
= parport_pc_probe_port (io_lo
, io_hi
, irq
,
688 PARPORT_DMA_NONE
, &dev
->dev
, IRQF_SHARED
);
690 priv
->port
[priv
->num_par
++] = port
;
695 if (card
->postinit_hook
)
696 card
->postinit_hook (dev
, card
, !success
);
701 static int parport_serial_pci_probe(struct pci_dev
*dev
,
702 const struct pci_device_id
*id
)
704 struct parport_serial_private
*priv
;
707 priv
= devm_kzalloc(&dev
->dev
, sizeof(*priv
), GFP_KERNEL
);
711 pci_set_drvdata (dev
, priv
);
713 err
= pcim_enable_device(dev
);
717 err
= parport_register(dev
, id
);
721 err
= serial_register(dev
, id
);
724 for (i
= 0; i
< priv
->num_par
; i
++)
725 parport_pc_unregister_port (priv
->port
[i
]);
732 static void parport_serial_pci_remove(struct pci_dev
*dev
)
734 struct parport_serial_private
*priv
= pci_get_drvdata (dev
);
739 pciserial_remove_ports(priv
->serial
);
742 for (i
= 0; i
< priv
->num_par
; i
++)
743 parport_pc_unregister_port (priv
->port
[i
]);
748 static int __maybe_unused
parport_serial_pci_suspend(struct device
*dev
)
750 struct parport_serial_private
*priv
= dev_get_drvdata(dev
);
753 pciserial_suspend_ports(priv
->serial
);
755 /* FIXME: What about parport? */
759 static int __maybe_unused
parport_serial_pci_resume(struct device
*dev
)
761 struct parport_serial_private
*priv
= dev_get_drvdata(dev
);
764 pciserial_resume_ports(priv
->serial
);
766 /* FIXME: What about parport? */
770 static SIMPLE_DEV_PM_OPS(parport_serial_pm_ops
,
771 parport_serial_pci_suspend
, parport_serial_pci_resume
);
773 static struct pci_driver parport_serial_pci_driver
= {
774 .name
= "parport_serial",
775 .id_table
= parport_serial_pci_tbl
,
776 .probe
= parport_serial_pci_probe
,
777 .remove
= parport_serial_pci_remove
,
779 .pm
= &parport_serial_pm_ops
,
782 module_pci_driver(parport_serial_pci_driver
);
784 MODULE_AUTHOR("Tim Waugh <twaugh@redhat.com>");
785 MODULE_DESCRIPTION("Driver for common parallel+serial multi-I/O PCI cards");
786 MODULE_LICENSE("GPL");