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/tty.h>
25 #include <linux/serial.h>
26 #include <linux/serialP.h>
27 #include <linux/serial_core.h>
29 #include <asm/bitops.h>
30 #include <asm/byteorder.h>
31 #include <asm/serial.h>
35 #define UNKNOWN_DEV 0x3000
38 static const struct pnp_device_id pnp_dev_table[] = {
39 /* Archtek America Corp. */
40 /* Archtek SmartLink Modem 3334BT Plug & Play */
42 /* Anchor Datacomm BV */
43 /* SXPro 144 External Data Fax Modem Plug & Play */
45 /* SXPro 288 External Data Fax Modem Plug & Play */
47 /* PROLiNK 1456VH ISA PnP K56flex Fax Modem */
49 /* Actiontec ISA PNP 56K X2 Fax Modem */
51 /* Rockwell 56K ACF II Fax+Data+Voice Modem */
52 { "AKY1021", SPCI_FL_NO_SHIRQ },
53 /* AZT3005 PnP SOUND DEVICE */
55 /* Best Data Products Inc. Smart One 336F PnP Modem */
58 /* Boca Complete Ofc Communicator 14.4 Data-FAX */
60 /* Boca Research 33,600 ACF Modem */
62 /* Boca 33.6 Kbps Internal FD34FSVD */
64 /* Boca 33.6 Kbps Internal FD34FSVD */
66 /* Best Data Products Inc. Smart One 336F PnP Modem */
68 /* Computer Peripherals Inc */
69 /* EuroViVa CommCenter-33.6 SP PnP */
72 /* Creative Labs Phone Blaster 28.8 DSVD PnP Voice */
74 /* Creative Labs Modem Blaster 28.8 DSVD PnP Voice */
77 /* Creative Modem Blaster Flash56 DI5601-1 */
79 /* Creative Modem Blaster V.90 DI5660 */
82 /* E-Tech CyberBULLET PC56RVP */
85 /* Fujitsu 33600 PnP-I2 R Plug & Play */
87 /* Fujitsu FMV-FX431 Plug & Play */
89 /* Fujitsu 33600 PnP-I4 R Plug & Play */
91 /* Fujitsu Fax Voice 33600 PNP-I5 R Plug & Play */
93 /* Archtek America Corp. */
94 /* Archtek SmartLink Modem 3334BT Plug & Play */
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 */
257 /* Viking Components, Inc */
258 /* Viking 28.8 INTERNAL Fax+Data+Voice PnP */
261 /* British Telecom */
262 /* Modular Technology */
263 /* Rockwell 33.6 DPF External PnP */
264 /* BT Prologue 33.6 External PnP */
265 /* Modular Technology 33.6 External PnP */
267 /* Viking 56K FAX INT */
269 /* K56 par,VV,Voice,Speakphone,AudioSpan,PnP */
271 /* SupraExpress 28.8 Data/Fax PnP modem */
273 /* SupraExpress 33.6 Data/Fax PnP modem */
275 /* SupraExpress 33.6 Data/Fax PnP modem */
277 /* SupraExpress 33.6 Data/Fax PnP modem */
280 /* Phoebe Micro 33.6 Data Fax 1433VQH Plug & Play */
282 /* Archtek America Corp. */
283 /* Archtek SmartLink Modem 3334BT Plug & Play */
286 /* Gateway Telepath IIvi 33.6 */
288 /* U.S. Robotics Sporster 33.6K Fax INT PnP */
290 /* Sportster Vi 14.4 PnP FAX Voicemail */
292 /* U.S. Robotics 33.6K Voice INT PnP */
294 /* U.S. Robotics 33.6K Voice EXT PnP */
296 /* U.S. Robotics 33.6K Voice INT PnP */
298 /* U.S. Robotics 56K Voice INT PnP */
300 /* U.S. Robotics 56K Voice EXT PnP */
302 /* U.S. Robotics 56K FAX INT */
304 /* U.S. Robotics 56K FAX INT */
306 /* U.S. Robotics 56K Voice INT PnP */
308 /* U.S. Robotics 56K Voice EXT PnP */
310 /* U.S. Robotics 56K Voice INT PnP */
312 /* U.S. Robotics 56K Message */
314 /* U.S. Robotics 56K FAX EXT PnP*/
316 /* U.S. Robotics 56K FAX INT PnP*/
318 /* U.S. Robotics 56K Voice EXT PnP*/
320 /* U.S. Robotics 56K Voice INT PnP*/
322 /* Rockwell's (PORALiNK) 33600 INT PNP */
324 /* Unkown PnP modems */
325 { "PNPCXXX", UNKNOWN_DEV },
326 /* More unkown PnP modems */
327 { "PNPDXXX", UNKNOWN_DEV },
331 MODULE_DEVICE_TABLE(pnp, pnp_dev_table);
333 static char *modem_names[] __devinitdata = {
334 "MODEM", "Modem", "modem", "FAX", "Fax", "fax",
335 "56K", "56k", "K56", "33.6", "28.8", "14.4",
336 "33,600", "28,800", "14,400", "33.600", "28.800", "14.400",
337 "33600", "28800", "14400", "V.90", "V.34", "V.32", 0
340 static int __devinit check_name(char *name)
344 for (tmp = modem_names; *tmp; tmp++)
345 if (strstr(name, *tmp))
351 static int __devinit check_resources(struct pnp_option *option)
353 struct pnp_option *tmp;
357 for (tmp = option; tmp; tmp = tmp->next) {
358 struct pnp_port *port;
359 for (port = tmp->port; port; port = port->next)
360 if ((port->size == 8) &&
361 ((port->min == 0x2f8) ||
362 (port->min == 0x3f8) ||
363 (port->min == 0x2e8) ||
364 (port->min == 0x3e8)))
372 * Given a complete unknown PnP device, try to use some heuristics to
373 * detect modems. Currently use such heuristic set:
374 * - dev->name or dev->bus->name must contain "modem" substring;
375 * - device must have only one IO region (8 byte long) with base address
376 * 0x2e8, 0x3e8, 0x2f8 or 0x3f8.
378 * Such detection looks very ugly, but can detect at least some of numerous
379 * PnP modems, alternatively we must hardcode all modems in pnp_devices[]
382 static int __devinit serial_pnp_guess_board(struct pnp_dev *dev, int *flags)
384 if (!(check_name(pnp_dev_name(dev)) || (dev->card && check_name(dev->card->name))))
387 if (check_resources(dev->independent))
390 if (check_resources(dev->dependent))
397 serial_pnp_probe(struct pnp_dev * dev, const struct pnp_device_id *dev_id)
399 struct serial_struct serial_req;
400 int ret, line, flags = dev_id->driver_data;
401 if (flags & UNKNOWN_DEV) {
402 ret = serial_pnp_guess_board(dev, &flags);
406 memset(&serial_req, 0, sizeof(serial_req));
407 serial_req.irq = pnp_irq(dev,0);
408 serial_req.port = pnp_port_start(dev, 0);
409 if (HIGH_BITS_OFFSET)
410 serial_req.port = pnp_port_start(dev, 0) >> HIGH_BITS_OFFSET;
411 #ifdef SERIAL_DEBUG_PNP
412 printk("Setup PNP port: port %x, irq %d, type %d\n",
413 serial_req.port, serial_req.irq, serial_req.io_type);
416 serial_req.flags = UPF_SKIP_TEST | UPF_AUTOPROBE | UPF_RESOURCES;
417 serial_req.baud_base = 115200;
418 line = register_serial(&serial_req);
421 pnp_set_drvdata(dev, (void *)(line + 1));
422 return line >= 0 ? 0 : -ENODEV;
426 static void __devexit serial_pnp_remove(struct pnp_dev * dev)
428 int line = (int)pnp_get_drvdata(dev);
430 unregister_serial(line - 1);
433 static struct pnp_driver serial_pnp_driver = {
435 .id_table = pnp_dev_table,
436 .probe = serial_pnp_probe,
437 .remove = __devexit_p(serial_pnp_remove),
440 static int __init serial8250_pnp_init(void)
442 return pnp_register_driver(&serial_pnp_driver);
445 static void __exit serial8250_pnp_exit(void)
447 pnp_unregister_driver(&serial_pnp_driver);
450 module_init(serial8250_pnp_init);
451 module_exit(serial8250_pnp_exit);
453 MODULE_LICENSE("GPL");
454 MODULE_DESCRIPTION("Generic 8250/16x50 PnP serial driver");