2 * Probe module for 8250/16550-type ISAPNP serial ports.
4 * Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o.
6 * Copyright (C) 2001 Russell King, All Rights Reserved.
8 * Ported to the Linux PnP Layer - (C) Adam Belay.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License.
14 #include <linux/module.h>
15 #include <linux/init.h>
16 #include <linux/pci.h>
17 #include <linux/pnp.h>
18 #include <linux/string.h>
19 #include <linux/kernel.h>
20 #include <linux/serial_core.h>
21 #include <linux/bitops.h>
23 #include <asm/byteorder.h>
27 #define UNKNOWN_DEV 0x3000
30 static const struct pnp_device_id pnp_dev_table
[] = {
31 /* Archtek America Corp. */
32 /* Archtek SmartLink Modem 3334BT Plug & Play */
34 /* Anchor Datacomm BV */
35 /* SXPro 144 External Data Fax Modem Plug & Play */
37 /* SXPro 288 External Data Fax Modem Plug & Play */
39 /* PROLiNK 1456VH ISA PnP K56flex Fax Modem */
41 /* Actiontec ISA PNP 56K X2 Fax Modem */
43 /* Rockwell 56K ACF II Fax+Data+Voice Modem */
44 { "AKY1021", 0 /*SPCI_FL_NO_SHIRQ*/ },
45 /* AZT3005 PnP SOUND DEVICE */
47 /* Best Data Products Inc. Smart One 336F PnP Modem */
50 /* Boca Complete Ofc Communicator 14.4 Data-FAX */
52 /* Boca Research 33,600 ACF Modem */
54 /* Boca 33.6 Kbps Internal FD34FSVD */
56 /* Boca 33.6 Kbps Internal FD34FSVD */
58 /* Best Data Products Inc. Smart One 336F PnP Modem */
60 /* Computer Peripherals Inc */
61 /* EuroViVa CommCenter-33.6 SP PnP */
64 /* Creative Labs Phone Blaster 28.8 DSVD PnP Voice */
66 /* Creative Labs Modem Blaster 28.8 DSVD PnP Voice */
68 /* Davicom ISA 33.6K Modem */
71 /* Creative Modem Blaster Flash56 DI5601-1 */
73 /* Creative Modem Blaster V.90 DI5660 */
76 /* E-Tech CyberBULLET PC56RVP */
79 /* Fujitsu 33600 PnP-I2 R Plug & Play */
81 /* Fujitsu FMV-FX431 Plug & Play */
83 /* Fujitsu 33600 PnP-I4 R Plug & Play */
85 /* Fujitsu Fax Voice 33600 PNP-I5 R Plug & Play */
87 /* Archtek America Corp. */
88 /* Archtek SmartLink Modem 3334BT Plug & Play */
90 /* Archtek SmartLink Modem 3334BRV 33.6K Data Fax Voice */
93 /* Hayes Optima 288 V.34-V.FC + FAX + Voice Plug & Play */
95 /* Hayes Optima 336 V.34 + FAX + Voice PnP */
97 /* Hayes Optima 336B V.34 + FAX + Voice PnP */
99 /* Hayes Accura 56K Ext Fax Modem PnP */
101 /* Hayes Accura 56K Ext Fax Modem PnP */
103 /* Hayes Accura 56K Fax Modem PnP */
105 /* Hayes 288, V.34 + FAX */
107 /* Hayes Optima 288 V.34 + FAX + Voice, Plug & Play */
110 /* IBM Thinkpad 701 Internal Modem Voice */
113 /* Intertex 28k8 33k6 Voice EXT PnP */
115 /* Intertex 33k6 56k Voice EXT PnP */
117 /* Intertex 28k8 33k6 Voice SP EXT PnP */
119 /* Intertex 33k6 56k Voice SP EXT PnP */
121 /* Intertex 28k8 33k6 Voice SP INT PnP */
123 /* Intertex 28k8 33k6 Voice SP EXT PnP */
125 /* Intertex 33k6 56k Voice SP EXT PnP */
127 /* Kortex International */
128 /* KORTEX 28800 Externe PnP */
130 /* KXPro 33.6 Vocal ASVD PnP */
133 /* LASAT Internet 33600 PnP */
135 /* Lasat Safire 560 PnP */
137 /* Lasat Safire 336 PnP */
140 /* Microcom TravelPorte FAST V.34 Plug & Play */
142 /* Microcom DeskPorte V.34 FAST or FAST+ Plug & Play */
144 /* Microcom DeskPorte FAST EP 28.8 Plug & Play */
146 /* Microcom DeskPorte 28.8P Plug & Play */
148 /* Microcom DeskPorte FAST ES 28.8 Plug & Play */
150 /* Microcom DeskPorte FAST ES 28.8 Plug & Play */
152 /* Microcom DeskPorte 28.8S Internal Plug & Play */
155 /* Motorola BitSURFR Plug & Play */
157 /* Motorola TA210 Plug & Play */
159 /* Motorola HMTA 200 (ISDN) Plug & Play */
161 /* Motorola BitSURFR Plug & Play */
163 /* Motorola Lifestyle 28.8 Internal */
165 /* Motorola V.3400 Plug & Play */
167 /* Motorola Lifestyle 28.8 V.34 Plug & Play */
169 /* Motorola Power 28.8 V.34 Plug & Play */
171 /* Motorola ModemSURFR External 28.8 Plug & Play */
173 /* Motorola Premier 33.6 Desktop Plug & Play */
175 /* Motorola VoiceSURFR 56K External PnP */
177 /* Motorola ModemSURFR 56K External PnP */
179 /* Motorola ModemSURFR 56K Internal PnP */
181 /* Motorola ModemSURFR Internal 28.8 Plug & Play */
183 /* Motorola Premier 33.6 Internal Plug & Play */
185 /* Motorola OnlineSURFR 28.8 Internal Plug & Play */
187 /* Motorola VoiceSURFR 56K Internal PnP */
190 /* Deskline K56 Phone System PnP */
192 /* PC Rider K56 Phone System PnP */
194 /* NEC 98NOTE SPEAKER PHONE FAX MODEM(33600bps) */
196 /* Pace 56 Voice Internal Plug & Play Modem */
199 /* Generic standard PC COM port */
201 /* Generic 16550A-compatible COM port */
203 /* Compaq 14400 Modem */
205 /* Compaq 2400/9600 Modem */
207 /* Dial-Up Networking Serial Cable between 2 PCs */
209 /* Dial-Up Networking Parallel Cable between 2 PCs */
211 /* Standard 9600 bps Modem */
213 /* Standard 14400 bps Modem */
215 /* Standard 28800 bps Modem*/
219 /* Standard 9600 bps Modem*/
221 /* Standard 14400 bps Modem*/
223 /* Standard 28800 bps Modem*/
227 /* Standard 9600 bps Modem */
229 /* Standard 14400 bps Modem */
231 /* Standard 28800 bps Modem */
235 /* Standard 9600 bps Modem */
237 /* Standard 14400 bps Modem */
239 /* Standard 28800 bps Modem */
243 /* Standard PCMCIA Card Modem */
246 /* Modular Technology */
247 /* Rockwell 33.6 DPF Internal PnP */
248 /* Modular Technology 33.6 Internal PnP */
250 /* Kortex International */
251 /* KORTEX 14400 Externe PnP */
255 /* Viking Components, Inc */
256 /* Viking 28.8 INTERNAL Fax+Data+Voice PnP */
259 /* British Telecom */
260 /* Modular Technology */
261 /* Rockwell 33.6 DPF External PnP */
262 /* BT Prologue 33.6 External PnP */
263 /* Modular Technology 33.6 External PnP */
265 /* Viking 56K FAX INT */
267 /* K56 par,VV,Voice,Speakphone,AudioSpan,PnP */
269 /* SupraExpress 28.8 Data/Fax PnP modem */
271 /* SupraExpress 336i PnP Voice Modem */
273 /* SupraExpress 33.6 Data/Fax PnP modem */
275 /* SupraExpress 33.6 Data/Fax PnP modem */
277 /* SupraExpress 336i Sp ASVD */
279 /* SupraExpress 33.6 Data/Fax PnP modem */
281 /* SupraExpress 56i Sp Intl */
284 /* Phoebe Micro 33.6 Data Fax 1433VQH Plug & Play */
286 /* Archtek America Corp. */
287 /* Archtek SmartLink Modem 3334BT Plug & Play */
290 /* Gateway Telepath IIvi 33.6 */
292 /* U.S. Robotics Sporster 33.6K Fax INT PnP */
294 /* Sportster Vi 14.4 PnP FAX Voicemail */
296 /* U.S. Robotics 33.6K Voice INT PnP */
298 /* U.S. Robotics 33.6K Voice EXT PnP */
300 /* U.S. Robotics Courier V.Everything INT PnP */
302 /* U.S. Robotics 33.6K Voice INT PnP */
304 /* U.S. Robotics 56K Voice INT PnP */
306 /* U.S. Robotics 56K Voice EXT PnP */
308 /* U.S. Robotics 56K FAX INT */
310 /* U.S. Robotics 56K FAX INT */
312 /* U.S. Robotics 56K Voice INT PnP */
314 /* U.S. Robotics 56K Voice EXT PnP */
316 /* U.S. Robotics 56K Voice INT PnP */
318 /* U.S. Robotics 56K Message */
320 /* U.S. Robotics 56K FAX EXT PnP*/
322 /* U.S. Robotics 56K FAX INT PnP*/
324 /* U.S. Robotics 56K Voice EXT PnP*/
326 /* U.S. Robotics 56K Voice INT PnP*/
330 /* Compaq touchscreen */
332 /* Fujitsu Stylistic touchscreens */
335 /* Fujitsu Stylistic LT touchscreens */
337 /* Passive Fujitsu Stylistic touchscreens */
343 /* Fujitsu Wacom Tablet PC device */
345 /* Fujitsu P-series tablet PC device */
347 /* Fujitsu Wacom 2FGT Tablet PC device */
349 /* Fujitsu Wacom 1FGT Tablet PC device */
352 * LG C1 EXPRESS DUAL (C1-PB11A3) touch screen (actually a FUJ02E6 in
356 /* Rockwell's (PORALiNK) 33600 INT PNP */
358 /* Unknown PnP modems */
359 { "PNPCXXX", UNKNOWN_DEV
},
360 /* More unknown PnP modems */
361 { "PNPDXXX", UNKNOWN_DEV
},
365 MODULE_DEVICE_TABLE(pnp
, pnp_dev_table
);
367 static char *modem_names
[] __devinitdata
= {
368 "MODEM", "Modem", "modem", "FAX", "Fax", "fax",
369 "56K", "56k", "K56", "33.6", "28.8", "14.4",
370 "33,600", "28,800", "14,400", "33.600", "28.800", "14.400",
371 "33600", "28800", "14400", "V.90", "V.34", "V.32", NULL
374 static int __devinit
check_name(char *name
)
378 for (tmp
= modem_names
; *tmp
; tmp
++)
379 if (strstr(name
, *tmp
))
385 static int __devinit
check_resources(struct pnp_dev
*dev
)
387 resource_size_t base
[] = {0x2f8, 0x3f8, 0x2e8, 0x3e8};
390 for (i
= 0; i
< ARRAY_SIZE(base
); i
++) {
391 if (pnp_possible_config(dev
, IORESOURCE_IO
, base
[i
], 8))
399 * Given a complete unknown PnP device, try to use some heuristics to
400 * detect modems. Currently use such heuristic set:
401 * - dev->name or dev->bus->name must contain "modem" substring;
402 * - device must have only one IO region (8 byte long) with base address
403 * 0x2e8, 0x3e8, 0x2f8 or 0x3f8.
405 * Such detection looks very ugly, but can detect at least some of numerous
406 * PnP modems, alternatively we must hardcode all modems in pnp_devices[]
409 static int __devinit
serial_pnp_guess_board(struct pnp_dev
*dev
, int *flags
)
411 if (!(check_name(pnp_dev_name(dev
)) ||
412 (dev
->card
&& check_name(dev
->card
->name
))))
415 if (check_resources(dev
))
422 serial_pnp_probe(struct pnp_dev
*dev
, const struct pnp_device_id
*dev_id
)
424 struct uart_port port
;
425 int ret
, line
, flags
= dev_id
->driver_data
;
427 if (flags
& UNKNOWN_DEV
) {
428 ret
= serial_pnp_guess_board(dev
, &flags
);
433 memset(&port
, 0, sizeof(struct uart_port
));
434 if (pnp_irq_valid(dev
, 0))
435 port
.irq
= pnp_irq(dev
, 0);
436 if (pnp_port_valid(dev
, 0)) {
437 port
.iobase
= pnp_port_start(dev
, 0);
438 port
.iotype
= UPIO_PORT
;
439 } else if (pnp_mem_valid(dev
, 0)) {
440 port
.mapbase
= pnp_mem_start(dev
, 0);
441 port
.iotype
= UPIO_MEM
;
442 port
.flags
= UPF_IOREMAP
;
446 #ifdef SERIAL_DEBUG_PNP
448 "Setup PNP port: port %x, mem 0x%lx, irq %d, type %d\n",
449 port
.iobase
, port
.mapbase
, port
.irq
, port
.iotype
);
452 port
.flags
|= UPF_SKIP_TEST
| UPF_BOOT_AUTOCONF
;
453 if (pnp_irq_flags(dev
, 0) & IORESOURCE_IRQ_SHAREABLE
)
454 port
.flags
|= UPF_SHARE_IRQ
;
455 port
.uartclk
= 1843200;
456 port
.dev
= &dev
->dev
;
458 line
= serial8250_register_port(&port
);
462 pnp_set_drvdata(dev
, (void *)((long)line
+ 1));
466 static void __devexit
serial_pnp_remove(struct pnp_dev
*dev
)
468 long line
= (long)pnp_get_drvdata(dev
);
470 serial8250_unregister_port(line
- 1);
474 static int serial_pnp_suspend(struct pnp_dev
*dev
, pm_message_t state
)
476 long line
= (long)pnp_get_drvdata(dev
);
480 serial8250_suspend_port(line
- 1);
484 static int serial_pnp_resume(struct pnp_dev
*dev
)
486 long line
= (long)pnp_get_drvdata(dev
);
490 serial8250_resume_port(line
- 1);
494 #define serial_pnp_suspend NULL
495 #define serial_pnp_resume NULL
496 #endif /* CONFIG_PM */
498 static struct pnp_driver serial_pnp_driver
= {
500 .probe
= serial_pnp_probe
,
501 .remove
= __devexit_p(serial_pnp_remove
),
502 .suspend
= serial_pnp_suspend
,
503 .resume
= serial_pnp_resume
,
504 .id_table
= pnp_dev_table
,
507 static int __init
serial8250_pnp_init(void)
509 return pnp_register_driver(&serial_pnp_driver
);
512 static void __exit
serial8250_pnp_exit(void)
514 pnp_unregister_driver(&serial_pnp_driver
);
517 module_init(serial8250_pnp_init
);
518 module_exit(serial8250_pnp_exit
);
520 MODULE_LICENSE("GPL");
521 MODULE_DESCRIPTION("Generic 8250/16x50 PnP serial driver");