Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[wrt350n-kernel.git] / drivers / serial / 8250_pnp.c
blob7ddbb8609bfd343db5c47f86d8320230a29f3202
1 /*
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>
29 #include "8250.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 */
37 { "AAC000F", 0 },
38 /* Anchor Datacomm BV */
39 /* SXPro 144 External Data Fax Modem Plug & Play */
40 { "ADC0001", 0 },
41 /* SXPro 288 External Data Fax Modem Plug & Play */
42 { "ADC0002", 0 },
43 /* PROLiNK 1456VH ISA PnP K56flex Fax Modem */
44 { "AEI0250", 0 },
45 /* Actiontec ISA PNP 56K X2 Fax Modem */
46 { "AEI1240", 0 },
47 /* Rockwell 56K ACF II Fax+Data+Voice Modem */
48 { "AKY1021", 0 /*SPCI_FL_NO_SHIRQ*/ },
49 /* AZT3005 PnP SOUND DEVICE */
50 { "AZT4001", 0 },
51 /* Best Data Products Inc. Smart One 336F PnP Modem */
52 { "BDP3336", 0 },
53 /* Boca Research */
54 /* Boca Complete Ofc Communicator 14.4 Data-FAX */
55 { "BRI0A49", 0 },
56 /* Boca Research 33,600 ACF Modem */
57 { "BRI1400", 0 },
58 /* Boca 33.6 Kbps Internal FD34FSVD */
59 { "BRI3400", 0 },
60 /* Boca 33.6 Kbps Internal FD34FSVD */
61 { "BRI0A49", 0 },
62 /* Best Data Products Inc. Smart One 336F PnP Modem */
63 { "BDP3336", 0 },
64 /* Computer Peripherals Inc */
65 /* EuroViVa CommCenter-33.6 SP PnP */
66 { "CPI4050", 0 },
67 /* Creative Labs */
68 /* Creative Labs Phone Blaster 28.8 DSVD PnP Voice */
69 { "CTL3001", 0 },
70 /* Creative Labs Modem Blaster 28.8 DSVD PnP Voice */
71 { "CTL3011", 0 },
72 /* Davicom ISA 33.6K Modem */
73 { "DAV0336", 0 },
74 /* Creative */
75 /* Creative Modem Blaster Flash56 DI5601-1 */
76 { "DMB1032", 0 },
77 /* Creative Modem Blaster V.90 DI5660 */
78 { "DMB2001", 0 },
79 /* E-Tech */
80 /* E-Tech CyberBULLET PC56RVP */
81 { "ETT0002", 0 },
82 /* FUJITSU */
83 /* Fujitsu 33600 PnP-I2 R Plug & Play */
84 { "FUJ0202", 0 },
85 /* Fujitsu FMV-FX431 Plug & Play */
86 { "FUJ0205", 0 },
87 /* Fujitsu 33600 PnP-I4 R Plug & Play */
88 { "FUJ0206", 0 },
89 /* Fujitsu Fax Voice 33600 PNP-I5 R Plug & Play */
90 { "FUJ0209", 0 },
91 /* Archtek America Corp. */
92 /* Archtek SmartLink Modem 3334BT Plug & Play */
93 { "GVC000F", 0 },
94 <<<<<<< HEAD:drivers/serial/8250_pnp.c
95 =======
96 /* Archtek SmartLink Modem 3334BRV 33.6K Data Fax Voice */
97 { "GVC0303", 0 },
98 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a:drivers/serial/8250_pnp.c
99 /* Hayes */
100 /* Hayes Optima 288 V.34-V.FC + FAX + Voice Plug & Play */
101 { "HAY0001", 0 },
102 /* Hayes Optima 336 V.34 + FAX + Voice PnP */
103 { "HAY000C", 0 },
104 /* Hayes Optima 336B V.34 + FAX + Voice PnP */
105 { "HAY000D", 0 },
106 /* Hayes Accura 56K Ext Fax Modem PnP */
107 { "HAY5670", 0 },
108 /* Hayes Accura 56K Ext Fax Modem PnP */
109 { "HAY5674", 0 },
110 /* Hayes Accura 56K Fax Modem PnP */
111 { "HAY5675", 0 },
112 /* Hayes 288, V.34 + FAX */
113 { "HAYF000", 0 },
114 /* Hayes Optima 288 V.34 + FAX + Voice, Plug & Play */
115 { "HAYF001", 0 },
116 /* IBM */
117 /* IBM Thinkpad 701 Internal Modem Voice */
118 { "IBM0033", 0 },
119 /* Intertex */
120 /* Intertex 28k8 33k6 Voice EXT PnP */
121 { "IXDC801", 0 },
122 /* Intertex 33k6 56k Voice EXT PnP */
123 { "IXDC901", 0 },
124 /* Intertex 28k8 33k6 Voice SP EXT PnP */
125 { "IXDD801", 0 },
126 /* Intertex 33k6 56k Voice SP EXT PnP */
127 { "IXDD901", 0 },
128 /* Intertex 28k8 33k6 Voice SP INT PnP */
129 { "IXDF401", 0 },
130 /* Intertex 28k8 33k6 Voice SP EXT PnP */
131 { "IXDF801", 0 },
132 /* Intertex 33k6 56k Voice SP EXT PnP */
133 { "IXDF901", 0 },
134 /* Kortex International */
135 /* KORTEX 28800 Externe PnP */
136 { "KOR4522", 0 },
137 /* KXPro 33.6 Vocal ASVD PnP */
138 { "KORF661", 0 },
139 /* Lasat */
140 /* LASAT Internet 33600 PnP */
141 { "LAS4040", 0 },
142 /* Lasat Safire 560 PnP */
143 { "LAS4540", 0 },
144 /* Lasat Safire 336 PnP */
145 { "LAS5440", 0 },
146 /* Microcom, Inc. */
147 /* Microcom TravelPorte FAST V.34 Plug & Play */
148 { "MNP0281", 0 },
149 /* Microcom DeskPorte V.34 FAST or FAST+ Plug & Play */
150 { "MNP0336", 0 },
151 /* Microcom DeskPorte FAST EP 28.8 Plug & Play */
152 { "MNP0339", 0 },
153 /* Microcom DeskPorte 28.8P Plug & Play */
154 { "MNP0342", 0 },
155 /* Microcom DeskPorte FAST ES 28.8 Plug & Play */
156 { "MNP0500", 0 },
157 /* Microcom DeskPorte FAST ES 28.8 Plug & Play */
158 { "MNP0501", 0 },
159 /* Microcom DeskPorte 28.8S Internal Plug & Play */
160 { "MNP0502", 0 },
161 /* Motorola */
162 /* Motorola BitSURFR Plug & Play */
163 { "MOT1105", 0 },
164 /* Motorola TA210 Plug & Play */
165 { "MOT1111", 0 },
166 /* Motorola HMTA 200 (ISDN) Plug & Play */
167 { "MOT1114", 0 },
168 /* Motorola BitSURFR Plug & Play */
169 { "MOT1115", 0 },
170 /* Motorola Lifestyle 28.8 Internal */
171 { "MOT1190", 0 },
172 /* Motorola V.3400 Plug & Play */
173 { "MOT1501", 0 },
174 /* Motorola Lifestyle 28.8 V.34 Plug & Play */
175 { "MOT1502", 0 },
176 /* Motorola Power 28.8 V.34 Plug & Play */
177 { "MOT1505", 0 },
178 /* Motorola ModemSURFR External 28.8 Plug & Play */
179 { "MOT1509", 0 },
180 /* Motorola Premier 33.6 Desktop Plug & Play */
181 { "MOT150A", 0 },
182 /* Motorola VoiceSURFR 56K External PnP */
183 { "MOT150F", 0 },
184 /* Motorola ModemSURFR 56K External PnP */
185 { "MOT1510", 0 },
186 /* Motorola ModemSURFR 56K Internal PnP */
187 { "MOT1550", 0 },
188 /* Motorola ModemSURFR Internal 28.8 Plug & Play */
189 { "MOT1560", 0 },
190 /* Motorola Premier 33.6 Internal Plug & Play */
191 { "MOT1580", 0 },
192 /* Motorola OnlineSURFR 28.8 Internal Plug & Play */
193 { "MOT15B0", 0 },
194 /* Motorola VoiceSURFR 56K Internal PnP */
195 { "MOT15F0", 0 },
196 /* Com 1 */
197 /* Deskline K56 Phone System PnP */
198 { "MVX00A1", 0 },
199 /* PC Rider K56 Phone System PnP */
200 { "MVX00F2", 0 },
201 /* NEC 98NOTE SPEAKER PHONE FAX MODEM(33600bps) */
202 { "nEC8241", 0 },
203 /* Pace 56 Voice Internal Plug & Play Modem */
204 { "PMC2430", 0 },
205 /* Generic */
206 /* Generic standard PC COM port */
207 { "PNP0500", 0 },
208 /* Generic 16550A-compatible COM port */
209 { "PNP0501", 0 },
210 /* Compaq 14400 Modem */
211 { "PNPC000", 0 },
212 /* Compaq 2400/9600 Modem */
213 { "PNPC001", 0 },
214 /* Dial-Up Networking Serial Cable between 2 PCs */
215 { "PNPC031", 0 },
216 /* Dial-Up Networking Parallel Cable between 2 PCs */
217 { "PNPC032", 0 },
218 /* Standard 9600 bps Modem */
219 { "PNPC100", 0 },
220 /* Standard 14400 bps Modem */
221 { "PNPC101", 0 },
222 /* Standard 28800 bps Modem*/
223 { "PNPC102", 0 },
224 /* Standard Modem*/
225 { "PNPC103", 0 },
226 /* Standard 9600 bps Modem*/
227 { "PNPC104", 0 },
228 /* Standard 14400 bps Modem*/
229 { "PNPC105", 0 },
230 /* Standard 28800 bps Modem*/
231 { "PNPC106", 0 },
232 /* Standard Modem */
233 { "PNPC107", 0 },
234 /* Standard 9600 bps Modem */
235 { "PNPC108", 0 },
236 /* Standard 14400 bps Modem */
237 { "PNPC109", 0 },
238 /* Standard 28800 bps Modem */
239 { "PNPC10A", 0 },
240 /* Standard Modem */
241 { "PNPC10B", 0 },
242 /* Standard 9600 bps Modem */
243 { "PNPC10C", 0 },
244 /* Standard 14400 bps Modem */
245 { "PNPC10D", 0 },
246 /* Standard 28800 bps Modem */
247 { "PNPC10E", 0 },
248 /* Standard Modem */
249 { "PNPC10F", 0 },
250 /* Standard PCMCIA Card Modem */
251 { "PNP2000", 0 },
252 /* Rockwell */
253 /* Modular Technology */
254 /* Rockwell 33.6 DPF Internal PnP */
255 /* Modular Technology 33.6 Internal PnP */
256 { "ROK0030", 0 },
257 /* Kortex International */
258 /* KORTEX 14400 Externe PnP */
259 { "ROK0100", 0 },
260 /* Rockwell 28.8 */
261 { "ROK4120", 0 },
262 /* Viking Components, Inc */
263 /* Viking 28.8 INTERNAL Fax+Data+Voice PnP */
264 { "ROK4920", 0 },
265 /* Rockwell */
266 /* British Telecom */
267 /* Modular Technology */
268 /* Rockwell 33.6 DPF External PnP */
269 /* BT Prologue 33.6 External PnP */
270 /* Modular Technology 33.6 External PnP */
271 { "RSS00A0", 0 },
272 /* Viking 56K FAX INT */
273 { "RSS0262", 0 },
274 /* K56 par,VV,Voice,Speakphone,AudioSpan,PnP */
275 { "RSS0250", 0 },
276 /* SupraExpress 28.8 Data/Fax PnP modem */
277 { "SUP1310", 0 },
278 /* SupraExpress 33.6 Data/Fax PnP modem */
279 { "SUP1421", 0 },
280 /* SupraExpress 33.6 Data/Fax PnP modem */
281 { "SUP1590", 0 },
282 /* SupraExpress 336i Sp ASVD */
283 { "SUP1620", 0 },
284 /* SupraExpress 33.6 Data/Fax PnP modem */
285 { "SUP1760", 0 },
286 /* SupraExpress 56i Sp Intl */
287 { "SUP2171", 0 },
288 /* Phoebe Micro */
289 /* Phoebe Micro 33.6 Data Fax 1433VQH Plug & Play */
290 { "TEX0011", 0 },
291 /* Archtek America Corp. */
292 /* Archtek SmartLink Modem 3334BT Plug & Play */
293 { "UAC000F", 0 },
294 /* 3Com Corp. */
295 /* Gateway Telepath IIvi 33.6 */
296 { "USR0000", 0 },
297 /* U.S. Robotics Sporster 33.6K Fax INT PnP */
298 { "USR0002", 0 },
299 /* Sportster Vi 14.4 PnP FAX Voicemail */
300 { "USR0004", 0 },
301 /* U.S. Robotics 33.6K Voice INT PnP */
302 { "USR0006", 0 },
303 /* U.S. Robotics 33.6K Voice EXT PnP */
304 { "USR0007", 0 },
305 /* U.S. Robotics Courier V.Everything INT PnP */
306 { "USR0009", 0 },
307 /* U.S. Robotics 33.6K Voice INT PnP */
308 { "USR2002", 0 },
309 /* U.S. Robotics 56K Voice INT PnP */
310 { "USR2070", 0 },
311 /* U.S. Robotics 56K Voice EXT PnP */
312 { "USR2080", 0 },
313 /* U.S. Robotics 56K FAX INT */
314 { "USR3031", 0 },
315 /* U.S. Robotics 56K FAX INT */
316 { "USR3050", 0 },
317 /* U.S. Robotics 56K Voice INT PnP */
318 { "USR3070", 0 },
319 /* U.S. Robotics 56K Voice EXT PnP */
320 { "USR3080", 0 },
321 /* U.S. Robotics 56K Voice INT PnP */
322 { "USR3090", 0 },
323 /* U.S. Robotics 56K Message */
324 { "USR9100", 0 },
325 /* U.S. Robotics 56K FAX EXT PnP*/
326 { "USR9160", 0 },
327 /* U.S. Robotics 56K FAX INT PnP*/
328 { "USR9170", 0 },
329 /* U.S. Robotics 56K Voice EXT PnP*/
330 { "USR9180", 0 },
331 /* U.S. Robotics 56K Voice INT PnP*/
332 { "USR9190", 0 },
333 /* Wacom tablets */
334 { "WACF004", 0 },
335 { "WACF005", 0 },
336 { "WACF006", 0 },
337 { "WACF007", 0 },
338 { "WACF008", 0 },
339 /* Compaq touchscreen */
340 { "FPI2002", 0 },
341 /* Fujitsu Stylistic touchscreens */
342 { "FUJ02B2", 0 },
343 { "FUJ02B3", 0 },
344 /* Fujitsu Stylistic LT touchscreens */
345 { "FUJ02B4", 0 },
346 /* Passive Fujitsu Stylistic touchscreens */
347 { "FUJ02B6", 0 },
348 { "FUJ02B7", 0 },
349 { "FUJ02B8", 0 },
350 { "FUJ02B9", 0 },
351 { "FUJ02BC", 0 },
352 /* Fujitsu Wacom Tablet PC devices */
353 { "FUJ02E5", 0 },
354 { "FUJ02E6", 0 },
356 * LG C1 EXPRESS DUAL (C1-PB11A3) touch screen (actually a FUJ02E6 in
357 * disguise)
359 { "LTS0001", 0 },
360 /* Rockwell's (PORALiNK) 33600 INT PNP */
361 { "WCI0003", 0 },
362 /* Unkown PnP modems */
363 { "PNPCXXX", UNKNOWN_DEV },
364 /* More unkown PnP modems */
365 { "PNPDXXX", UNKNOWN_DEV },
366 { "", 0 }
369 MODULE_DEVICE_TABLE(pnp, pnp_dev_table);
371 static char *modem_names[] __devinitdata = {
372 "MODEM", "Modem", "modem", "FAX", "Fax", "fax",
373 "56K", "56k", "K56", "33.6", "28.8", "14.4",
374 "33,600", "28,800", "14,400", "33.600", "28.800", "14.400",
375 "33600", "28800", "14400", "V.90", "V.34", "V.32", NULL
378 static int __devinit check_name(char *name)
380 char **tmp;
382 for (tmp = modem_names; *tmp; tmp++)
383 if (strstr(name, *tmp))
384 return 1;
386 return 0;
389 static int __devinit check_resources(struct pnp_option *option)
391 struct pnp_option *tmp;
392 if (!option)
393 return 0;
395 for (tmp = option; tmp; tmp = tmp->next) {
396 struct pnp_port *port;
397 for (port = tmp->port; port; port = port->next)
398 if ((port->size == 8) &&
399 ((port->min == 0x2f8) ||
400 (port->min == 0x3f8) ||
401 (port->min == 0x2e8) ||
402 (port->min == 0x3e8)))
403 return 1;
406 return 0;
410 * Given a complete unknown PnP device, try to use some heuristics to
411 * detect modems. Currently use such heuristic set:
412 * - dev->name or dev->bus->name must contain "modem" substring;
413 * - device must have only one IO region (8 byte long) with base address
414 * 0x2e8, 0x3e8, 0x2f8 or 0x3f8.
416 * Such detection looks very ugly, but can detect at least some of numerous
417 * PnP modems, alternatively we must hardcode all modems in pnp_devices[]
418 * table.
420 static int __devinit serial_pnp_guess_board(struct pnp_dev *dev, int *flags)
422 if (!(check_name(pnp_dev_name(dev)) ||
423 (dev->card && check_name(dev->card->name))))
424 return -ENODEV;
426 if (check_resources(dev->independent))
427 return 0;
429 if (check_resources(dev->dependent))
430 return 0;
432 return -ENODEV;
435 static int __devinit
436 serial_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
438 struct uart_port port;
439 int ret, line, flags = dev_id->driver_data;
441 if (flags & UNKNOWN_DEV) {
442 ret = serial_pnp_guess_board(dev, &flags);
443 if (ret < 0)
444 return ret;
447 memset(&port, 0, sizeof(struct uart_port));
448 if (pnp_irq_valid(dev, 0))
449 port.irq = pnp_irq(dev, 0);
450 if (pnp_port_valid(dev, 0)) {
451 port.iobase = pnp_port_start(dev, 0);
452 port.iotype = UPIO_PORT;
453 } else if (pnp_mem_valid(dev, 0)) {
454 port.mapbase = pnp_mem_start(dev, 0);
455 port.iotype = UPIO_MEM;
456 port.flags = UPF_IOREMAP;
457 } else
458 return -ENODEV;
460 #ifdef SERIAL_DEBUG_PNP
461 printk(KERN_DEBUG
462 "Setup PNP port: port %x, mem 0x%lx, irq %d, type %d\n",
463 port.iobase, port.mapbase, port.irq, port.iotype);
464 #endif
466 port.flags |= UPF_SKIP_TEST | UPF_BOOT_AUTOCONF;
467 if (pnp_irq_flags(dev, 0) & IORESOURCE_IRQ_SHAREABLE)
468 port.flags |= UPF_SHARE_IRQ;
469 port.uartclk = 1843200;
470 port.dev = &dev->dev;
472 line = serial8250_register_port(&port);
473 if (line < 0)
474 return -ENODEV;
476 pnp_set_drvdata(dev, (void *)((long)line + 1));
477 return 0;
480 static void __devexit serial_pnp_remove(struct pnp_dev *dev)
482 long line = (long)pnp_get_drvdata(dev);
483 if (line)
484 serial8250_unregister_port(line - 1);
487 #ifdef CONFIG_PM
488 static int serial_pnp_suspend(struct pnp_dev *dev, pm_message_t state)
490 long line = (long)pnp_get_drvdata(dev);
492 if (!line)
493 return -ENODEV;
494 serial8250_suspend_port(line - 1);
495 return 0;
498 static int serial_pnp_resume(struct pnp_dev *dev)
500 long line = (long)pnp_get_drvdata(dev);
502 if (!line)
503 return -ENODEV;
504 serial8250_resume_port(line - 1);
505 return 0;
507 #else
508 #define serial_pnp_suspend NULL
509 #define serial_pnp_resume NULL
510 #endif /* CONFIG_PM */
512 static struct pnp_driver serial_pnp_driver = {
513 .name = "serial",
514 .probe = serial_pnp_probe,
515 .remove = __devexit_p(serial_pnp_remove),
516 .suspend = serial_pnp_suspend,
517 .resume = serial_pnp_resume,
518 .id_table = pnp_dev_table,
521 static int __init serial8250_pnp_init(void)
523 return pnp_register_driver(&serial_pnp_driver);
526 static void __exit serial8250_pnp_exit(void)
528 pnp_unregister_driver(&serial_pnp_driver);
531 module_init(serial8250_pnp_init);
532 module_exit(serial8250_pnp_exit);
534 MODULE_LICENSE("GPL");
535 MODULE_DESCRIPTION("Generic 8250/16x50 PnP serial driver");