2 * linux/drivers/char/8250_pnp.c
4 * Probe module for 8250/16550-type ISAPNP serial ports.
6 * Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o.
8 * Copyright (C) 2001 Russell King, All Rights Reserved.
10 * Ported to the Linux PnP Layer - (C) Adam Belay.
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License.
16 * $Id: 8250_pnp.c,v 1.10 2002/07/21 21:32:30 rmk Exp $
18 #include <linux/module.h>
19 #include <linux/init.h>
20 #include <linux/pci.h>
21 #include <linux/pnp.h>
22 #include <linux/string.h>
23 #include <linux/kernel.h>
24 #include <linux/serial_core.h>
25 #include <linux/bitops.h>
27 #include <asm/byteorder.h>
31 #define UNKNOWN_DEV 0x3000
34 static const struct pnp_device_id pnp_dev_table[] = {
35 /* Archtek America Corp. */
36 /* Archtek SmartLink Modem 3334BT Plug & Play */
38 /* Anchor Datacomm BV */
39 /* SXPro 144 External Data Fax Modem Plug & Play */
41 /* SXPro 288 External Data Fax Modem Plug & Play */
43 /* PROLiNK 1456VH ISA PnP K56flex Fax Modem */
45 /* Actiontec ISA PNP 56K X2 Fax Modem */
47 /* Rockwell 56K ACF II Fax+Data+Voice Modem */
48 { "AKY1021", 0 /*SPCI_FL_NO_SHIRQ*/ },
49 /* AZT3005 PnP SOUND DEVICE */
51 /* Best Data Products Inc. Smart One 336F PnP Modem */
54 /* Boca Complete Ofc Communicator 14.4 Data-FAX */
56 /* Boca Research 33,600 ACF Modem */
58 /* Boca 33.6 Kbps Internal FD34FSVD */
60 /* Boca 33.6 Kbps Internal FD34FSVD */
62 /* Best Data Products Inc. Smart One 336F PnP Modem */
64 /* Computer Peripherals Inc */
65 /* EuroViVa CommCenter-33.6 SP PnP */
68 /* Creative Labs Phone Blaster 28.8 DSVD PnP Voice */
70 /* Creative Labs Modem Blaster 28.8 DSVD PnP Voice */
72 /* Davicom ISA 33.6K Modem */
75 /* Creative Modem Blaster Flash56 DI5601-1 */
77 /* Creative Modem Blaster V.90 DI5660 */
80 /* E-Tech CyberBULLET PC56RVP */
83 /* Fujitsu 33600 PnP-I2 R Plug & Play */
85 /* Fujitsu FMV-FX431 Plug & Play */
87 /* Fujitsu 33600 PnP-I4 R Plug & Play */
89 /* Fujitsu Fax Voice 33600 PNP-I5 R Plug & Play */
91 /* Archtek America Corp. */
92 /* Archtek SmartLink Modem 3334BT Plug & Play */
94 /* Archtek SmartLink Modem 3334BRV 33.6K Data Fax Voice */
97 /* Hayes Optima 288 V.34-V.FC + FAX + Voice Plug & Play */
99 /* Hayes Optima 336 V.34 + FAX + Voice PnP */
101 /* Hayes Optima 336B V.34 + FAX + Voice PnP */
103 /* Hayes Accura 56K Ext Fax Modem PnP */
105 /* Hayes Accura 56K Ext Fax Modem PnP */
107 /* Hayes Accura 56K Fax Modem PnP */
109 /* Hayes 288, V.34 + FAX */
111 /* Hayes Optima 288 V.34 + FAX + Voice, Plug & Play */
114 /* IBM Thinkpad 701 Internal Modem Voice */
117 /* Intertex 28k8 33k6 Voice EXT PnP */
119 /* Intertex 33k6 56k Voice EXT PnP */
121 /* Intertex 28k8 33k6 Voice SP EXT PnP */
123 /* Intertex 33k6 56k Voice SP EXT PnP */
125 /* Intertex 28k8 33k6 Voice SP INT PnP */
127 /* Intertex 28k8 33k6 Voice SP EXT PnP */
129 /* Intertex 33k6 56k Voice SP EXT PnP */
131 /* Kortex International */
132 /* KORTEX 28800 Externe PnP */
134 /* KXPro 33.6 Vocal ASVD PnP */
137 /* LASAT Internet 33600 PnP */
139 /* Lasat Safire 560 PnP */
141 /* Lasat Safire 336 PnP */
144 /* Microcom TravelPorte FAST V.34 Plug & Play */
146 /* Microcom DeskPorte V.34 FAST or FAST+ Plug & Play */
148 /* Microcom DeskPorte FAST EP 28.8 Plug & Play */
150 /* Microcom DeskPorte 28.8P Plug & Play */
152 /* Microcom DeskPorte FAST ES 28.8 Plug & Play */
154 /* Microcom DeskPorte FAST ES 28.8 Plug & Play */
156 /* Microcom DeskPorte 28.8S Internal Plug & Play */
159 /* Motorola BitSURFR Plug & Play */
161 /* Motorola TA210 Plug & Play */
163 /* Motorola HMTA 200 (ISDN) Plug & Play */
165 /* Motorola BitSURFR Plug & Play */
167 /* Motorola Lifestyle 28.8 Internal */
169 /* Motorola V.3400 Plug & Play */
171 /* Motorola Lifestyle 28.8 V.34 Plug & Play */
173 /* Motorola Power 28.8 V.34 Plug & Play */
175 /* Motorola ModemSURFR External 28.8 Plug & Play */
177 /* Motorola Premier 33.6 Desktop Plug & Play */
179 /* Motorola VoiceSURFR 56K External PnP */
181 /* Motorola ModemSURFR 56K External PnP */
183 /* Motorola ModemSURFR 56K Internal PnP */
185 /* Motorola ModemSURFR Internal 28.8 Plug & Play */
187 /* Motorola Premier 33.6 Internal Plug & Play */
189 /* Motorola OnlineSURFR 28.8 Internal Plug & Play */
191 /* Motorola VoiceSURFR 56K Internal PnP */
194 /* Deskline K56 Phone System PnP */
196 /* PC Rider K56 Phone System PnP */
198 /* NEC 98NOTE SPEAKER PHONE FAX MODEM(33600bps) */
200 /* Pace 56 Voice Internal Plug & Play Modem */
203 /* Generic standard PC COM port */
205 /* Generic 16550A-compatible COM port */
207 /* Compaq 14400 Modem */
209 /* Compaq 2400/9600 Modem */
211 /* Dial-Up Networking Serial Cable between 2 PCs */
213 /* Dial-Up Networking Parallel Cable between 2 PCs */
215 /* Standard 9600 bps Modem */
217 /* Standard 14400 bps Modem */
219 /* Standard 28800 bps Modem*/
223 /* Standard 9600 bps Modem*/
225 /* Standard 14400 bps Modem*/
227 /* Standard 28800 bps Modem*/
231 /* Standard 9600 bps Modem */
233 /* Standard 14400 bps Modem */
235 /* Standard 28800 bps Modem */
239 /* Standard 9600 bps Modem */
241 /* Standard 14400 bps Modem */
243 /* Standard 28800 bps Modem */
247 /* Standard PCMCIA Card Modem */
250 /* Modular Technology */
251 /* Rockwell 33.6 DPF Internal PnP */
252 /* Modular Technology 33.6 Internal PnP */
254 /* Kortex International */
255 /* KORTEX 14400 Externe PnP */
259 /* Viking Components, Inc */
260 /* Viking 28.8 INTERNAL Fax+Data+Voice PnP */
263 /* British Telecom */
264 /* Modular Technology */
265 /* Rockwell 33.6 DPF External PnP */
266 /* BT Prologue 33.6 External PnP */
267 /* Modular Technology 33.6 External PnP */
269 /* Viking 56K FAX INT */
271 /* K56 par,VV,Voice,Speakphone,AudioSpan,PnP */
273 /* SupraExpress 28.8 Data/Fax PnP modem */
275 /* SupraExpress 33.6 Data/Fax PnP modem */
277 /* SupraExpress 33.6 Data/Fax PnP modem */
279 /* SupraExpress 336i Sp ASVD */
281 /* SupraExpress 33.6 Data/Fax PnP modem */
283 /* SupraExpress 56i Sp Intl */
286 /* Phoebe Micro 33.6 Data Fax 1433VQH Plug & Play */
288 /* Archtek America Corp. */
289 /* Archtek SmartLink Modem 3334BT Plug & Play */
292 /* Gateway Telepath IIvi 33.6 */
294 /* U.S. Robotics Sporster 33.6K Fax INT PnP */
296 /* Sportster Vi 14.4 PnP FAX Voicemail */
298 /* U.S. Robotics 33.6K Voice INT PnP */
300 /* U.S. Robotics 33.6K Voice EXT PnP */
302 /* U.S. Robotics Courier V.Everything INT PnP */
304 /* U.S. Robotics 33.6K Voice INT PnP */
306 /* U.S. Robotics 56K Voice INT PnP */
308 /* U.S. Robotics 56K Voice EXT PnP */
310 /* U.S. Robotics 56K FAX INT */
312 /* U.S. Robotics 56K FAX INT */
314 /* U.S. Robotics 56K Voice INT PnP */
316 /* U.S. Robotics 56K Voice EXT PnP */
318 /* U.S. Robotics 56K Voice INT PnP */
320 /* U.S. Robotics 56K Message */
322 /* U.S. Robotics 56K FAX EXT PnP*/
324 /* U.S. Robotics 56K FAX INT PnP*/
326 /* U.S. Robotics 56K Voice EXT PnP*/
328 /* U.S. Robotics 56K Voice INT PnP*/
336 /* Compaq touchscreen */
338 /* Fujitsu Stylistic touchscreens */
341 /* Fujitsu Stylistic LT touchscreens */
343 /* Passive Fujitsu Stylistic touchscreens */
349 /* Fujitsu Wacom Tablet PC devices */
353 * LG C1 EXPRESS DUAL (C1-PB11A3) touch screen (actually a FUJ02E6 in
357 /* Rockwell's (PORALiNK) 33600 INT PNP */
359 /* Unkown PnP modems */
360 { "PNPCXXX", UNKNOWN_DEV },
361 /* More unkown PnP modems */
362 { "PNPDXXX", UNKNOWN_DEV },
366 MODULE_DEVICE_TABLE(pnp, pnp_dev_table);
368 static char *modem_names[] __devinitdata = {
369 "MODEM", "Modem", "modem", "FAX", "Fax", "fax",
370 "56K", "56k", "K56", "33.6", "28.8", "14.4",
371 "33,600", "28,800", "14,400", "33.600", "28.800", "14.400",
372 "33600", "28800", "14400", "V.90", "V.34", "V.32", NULL
375 static int __devinit check_name(char *name)
379 for (tmp = modem_names; *tmp; tmp++)
380 if (strstr(name, *tmp))
386 static int __devinit check_resources(struct pnp_dev *dev)
388 resource_size_t base[] = {0x2f8, 0x3f8, 0x2e8, 0x3e8};
391 for (i = 0; i < ARRAY_SIZE(base); i++) {
392 if (pnp_possible_config(dev, IORESOURCE_IO, base[i], 8))
400 * Given a complete unknown PnP device, try to use some heuristics to
401 * detect modems. Currently use such heuristic set:
402 * - dev->name or dev->bus->name must contain "modem" substring;
403 * - device must have only one IO region (8 byte long) with base address
404 * 0x2e8, 0x3e8, 0x2f8 or 0x3f8.
406 * Such detection looks very ugly, but can detect at least some of numerous
407 * PnP modems, alternatively we must hardcode all modems in pnp_devices[]
410 static int __devinit serial_pnp_guess_board(struct pnp_dev *dev, int *flags)
412 if (!(check_name(pnp_dev_name(dev)) ||
413 (dev->card && check_name(dev->card->name))))
416 if (check_resources(dev))
423 serial_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
425 struct uart_port port;
426 int ret, line, flags = dev_id->driver_data;
428 if (flags & UNKNOWN_DEV) {
429 ret = serial_pnp_guess_board(dev, &flags);
434 memset(&port, 0, sizeof(struct uart_port));
435 if (pnp_irq_valid(dev, 0))
436 port.irq = pnp_irq(dev, 0);
437 if (pnp_port_valid(dev, 0)) {
438 port.iobase = pnp_port_start(dev, 0);
439 port.iotype = UPIO_PORT;
440 } else if (pnp_mem_valid(dev, 0)) {
441 port.mapbase = pnp_mem_start(dev, 0);
442 port.iotype = UPIO_MEM;
443 port.flags = UPF_IOREMAP;
447 #ifdef SERIAL_DEBUG_PNP
449 "Setup PNP port: port %x, mem 0x%lx, irq %d, type %d\n",
450 port.iobase, port.mapbase, port.irq, port.iotype);
453 port.flags |= UPF_SKIP_TEST | UPF_BOOT_AUTOCONF;
454 if (pnp_irq_flags(dev, 0) & IORESOURCE_IRQ_SHAREABLE)
455 port.flags |= UPF_SHARE_IRQ;
456 port.uartclk = 1843200;
457 port.dev = &dev->dev;
459 line = serial8250_register_port(&port);
463 pnp_set_drvdata(dev, (void *)((long)line + 1));
467 static void __devexit serial_pnp_remove(struct pnp_dev *dev)
469 long line = (long)pnp_get_drvdata(dev);
471 serial8250_unregister_port(line - 1);
475 static int serial_pnp_suspend(struct pnp_dev *dev, pm_message_t state)
477 long line = (long)pnp_get_drvdata(dev);
481 serial8250_suspend_port(line - 1);
485 static int serial_pnp_resume(struct pnp_dev *dev)
487 long line = (long)pnp_get_drvdata(dev);
491 serial8250_resume_port(line - 1);
495 #define serial_pnp_suspend NULL
496 #define serial_pnp_resume NULL
497 #endif /* CONFIG_PM */
499 static struct pnp_driver serial_pnp_driver = {
501 .probe = serial_pnp_probe,
502 .remove = __devexit_p(serial_pnp_remove),
503 .suspend = serial_pnp_suspend,
504 .resume = serial_pnp_resume,
505 .id_table = pnp_dev_table,
508 static int __init serial8250_pnp_init(void)
510 return pnp_register_driver(&serial_pnp_driver);
513 static void __exit serial8250_pnp_exit(void)
515 pnp_unregister_driver(&serial_pnp_driver);
518 module_init(serial8250_pnp_init);
519 module_exit(serial8250_pnp_exit);
521 MODULE_LICENSE("GPL");
522 MODULE_DESCRIPTION("Generic 8250/16x50 PnP serial driver");