[ARM] Support register switch in nommu mode
[linux-2.6/verdex.git] / drivers / serial / 8250_pnp.c
blobb79ed0665d519f199c6bb16cf946d42bd7626754
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 /* Creative */
73 /* Creative Modem Blaster Flash56 DI5601-1 */
74 { "DMB1032", 0 },
75 /* Creative Modem Blaster V.90 DI5660 */
76 { "DMB2001", 0 },
77 /* E-Tech */
78 /* E-Tech CyberBULLET PC56RVP */
79 { "ETT0002", 0 },
80 /* FUJITSU */
81 /* Fujitsu 33600 PnP-I2 R Plug & Play */
82 { "FUJ0202", 0 },
83 /* Fujitsu FMV-FX431 Plug & Play */
84 { "FUJ0205", 0 },
85 /* Fujitsu 33600 PnP-I4 R Plug & Play */
86 { "FUJ0206", 0 },
87 /* Fujitsu Fax Voice 33600 PNP-I5 R Plug & Play */
88 { "FUJ0209", 0 },
89 /* Archtek America Corp. */
90 /* Archtek SmartLink Modem 3334BT Plug & Play */
91 { "GVC000F", 0 },
92 /* Hayes */
93 /* Hayes Optima 288 V.34-V.FC + FAX + Voice Plug & Play */
94 { "HAY0001", 0 },
95 /* Hayes Optima 336 V.34 + FAX + Voice PnP */
96 { "HAY000C", 0 },
97 /* Hayes Optima 336B V.34 + FAX + Voice PnP */
98 { "HAY000D", 0 },
99 /* Hayes Accura 56K Ext Fax Modem PnP */
100 { "HAY5670", 0 },
101 /* Hayes Accura 56K Ext Fax Modem PnP */
102 { "HAY5674", 0 },
103 /* Hayes Accura 56K Fax Modem PnP */
104 { "HAY5675", 0 },
105 /* Hayes 288, V.34 + FAX */
106 { "HAYF000", 0 },
107 /* Hayes Optima 288 V.34 + FAX + Voice, Plug & Play */
108 { "HAYF001", 0 },
109 /* IBM */
110 /* IBM Thinkpad 701 Internal Modem Voice */
111 { "IBM0033", 0 },
112 /* Intertex */
113 /* Intertex 28k8 33k6 Voice EXT PnP */
114 { "IXDC801", 0 },
115 /* Intertex 33k6 56k Voice EXT PnP */
116 { "IXDC901", 0 },
117 /* Intertex 28k8 33k6 Voice SP EXT PnP */
118 { "IXDD801", 0 },
119 /* Intertex 33k6 56k Voice SP EXT PnP */
120 { "IXDD901", 0 },
121 /* Intertex 28k8 33k6 Voice SP INT PnP */
122 { "IXDF401", 0 },
123 /* Intertex 28k8 33k6 Voice SP EXT PnP */
124 { "IXDF801", 0 },
125 /* Intertex 33k6 56k Voice SP EXT PnP */
126 { "IXDF901", 0 },
127 /* Kortex International */
128 /* KORTEX 28800 Externe PnP */
129 { "KOR4522", 0 },
130 /* KXPro 33.6 Vocal ASVD PnP */
131 { "KORF661", 0 },
132 /* Lasat */
133 /* LASAT Internet 33600 PnP */
134 { "LAS4040", 0 },
135 /* Lasat Safire 560 PnP */
136 { "LAS4540", 0 },
137 /* Lasat Safire 336 PnP */
138 { "LAS5440", 0 },
139 /* Microcom, Inc. */
140 /* Microcom TravelPorte FAST V.34 Plug & Play */
141 { "MNP0281", 0 },
142 /* Microcom DeskPorte V.34 FAST or FAST+ Plug & Play */
143 { "MNP0336", 0 },
144 /* Microcom DeskPorte FAST EP 28.8 Plug & Play */
145 { "MNP0339", 0 },
146 /* Microcom DeskPorte 28.8P Plug & Play */
147 { "MNP0342", 0 },
148 /* Microcom DeskPorte FAST ES 28.8 Plug & Play */
149 { "MNP0500", 0 },
150 /* Microcom DeskPorte FAST ES 28.8 Plug & Play */
151 { "MNP0501", 0 },
152 /* Microcom DeskPorte 28.8S Internal Plug & Play */
153 { "MNP0502", 0 },
154 /* Motorola */
155 /* Motorola BitSURFR Plug & Play */
156 { "MOT1105", 0 },
157 /* Motorola TA210 Plug & Play */
158 { "MOT1111", 0 },
159 /* Motorola HMTA 200 (ISDN) Plug & Play */
160 { "MOT1114", 0 },
161 /* Motorola BitSURFR Plug & Play */
162 { "MOT1115", 0 },
163 /* Motorola Lifestyle 28.8 Internal */
164 { "MOT1190", 0 },
165 /* Motorola V.3400 Plug & Play */
166 { "MOT1501", 0 },
167 /* Motorola Lifestyle 28.8 V.34 Plug & Play */
168 { "MOT1502", 0 },
169 /* Motorola Power 28.8 V.34 Plug & Play */
170 { "MOT1505", 0 },
171 /* Motorola ModemSURFR External 28.8 Plug & Play */
172 { "MOT1509", 0 },
173 /* Motorola Premier 33.6 Desktop Plug & Play */
174 { "MOT150A", 0 },
175 /* Motorola VoiceSURFR 56K External PnP */
176 { "MOT150F", 0 },
177 /* Motorola ModemSURFR 56K External PnP */
178 { "MOT1510", 0 },
179 /* Motorola ModemSURFR 56K Internal PnP */
180 { "MOT1550", 0 },
181 /* Motorola ModemSURFR Internal 28.8 Plug & Play */
182 { "MOT1560", 0 },
183 /* Motorola Premier 33.6 Internal Plug & Play */
184 { "MOT1580", 0 },
185 /* Motorola OnlineSURFR 28.8 Internal Plug & Play */
186 { "MOT15B0", 0 },
187 /* Motorola VoiceSURFR 56K Internal PnP */
188 { "MOT15F0", 0 },
189 /* Com 1 */
190 /* Deskline K56 Phone System PnP */
191 { "MVX00A1", 0 },
192 /* PC Rider K56 Phone System PnP */
193 { "MVX00F2", 0 },
194 /* NEC 98NOTE SPEAKER PHONE FAX MODEM(33600bps) */
195 { "nEC8241", 0 },
196 /* Pace 56 Voice Internal Plug & Play Modem */
197 { "PMC2430", 0 },
198 /* Generic */
199 /* Generic standard PC COM port */
200 { "PNP0500", 0 },
201 /* Generic 16550A-compatible COM port */
202 { "PNP0501", 0 },
203 /* Compaq 14400 Modem */
204 { "PNPC000", 0 },
205 /* Compaq 2400/9600 Modem */
206 { "PNPC001", 0 },
207 /* Dial-Up Networking Serial Cable between 2 PCs */
208 { "PNPC031", 0 },
209 /* Dial-Up Networking Parallel Cable between 2 PCs */
210 { "PNPC032", 0 },
211 /* Standard 9600 bps Modem */
212 { "PNPC100", 0 },
213 /* Standard 14400 bps Modem */
214 { "PNPC101", 0 },
215 /* Standard 28800 bps Modem*/
216 { "PNPC102", 0 },
217 /* Standard Modem*/
218 { "PNPC103", 0 },
219 /* Standard 9600 bps Modem*/
220 { "PNPC104", 0 },
221 /* Standard 14400 bps Modem*/
222 { "PNPC105", 0 },
223 /* Standard 28800 bps Modem*/
224 { "PNPC106", 0 },
225 /* Standard Modem */
226 { "PNPC107", 0 },
227 /* Standard 9600 bps Modem */
228 { "PNPC108", 0 },
229 /* Standard 14400 bps Modem */
230 { "PNPC109", 0 },
231 /* Standard 28800 bps Modem */
232 { "PNPC10A", 0 },
233 /* Standard Modem */
234 { "PNPC10B", 0 },
235 /* Standard 9600 bps Modem */
236 { "PNPC10C", 0 },
237 /* Standard 14400 bps Modem */
238 { "PNPC10D", 0 },
239 /* Standard 28800 bps Modem */
240 { "PNPC10E", 0 },
241 /* Standard Modem */
242 { "PNPC10F", 0 },
243 /* Standard PCMCIA Card Modem */
244 { "PNP2000", 0 },
245 /* Rockwell */
246 /* Modular Technology */
247 /* Rockwell 33.6 DPF Internal PnP */
248 /* Modular Technology 33.6 Internal PnP */
249 { "ROK0030", 0 },
250 /* Kortex International */
251 /* KORTEX 14400 Externe PnP */
252 { "ROK0100", 0 },
253 /* Rockwell 28.8 */
254 { "ROK4120", 0 },
255 /* Viking Components, Inc */
256 /* Viking 28.8 INTERNAL Fax+Data+Voice PnP */
257 { "ROK4920", 0 },
258 /* Rockwell */
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 */
264 { "RSS00A0", 0 },
265 /* Viking 56K FAX INT */
266 { "RSS0262", 0 },
267 /* K56 par,VV,Voice,Speakphone,AudioSpan,PnP */
268 { "RSS0250", 0 },
269 /* SupraExpress 28.8 Data/Fax PnP modem */
270 { "SUP1310", 0 },
271 /* SupraExpress 33.6 Data/Fax PnP modem */
272 { "SUP1421", 0 },
273 /* SupraExpress 33.6 Data/Fax PnP modem */
274 { "SUP1590", 0 },
275 /* SupraExpress 336i Sp ASVD */
276 { "SUP1620", 0 },
277 /* SupraExpress 33.6 Data/Fax PnP modem */
278 { "SUP1760", 0 },
279 /* SupraExpress 56i Sp Intl */
280 { "SUP2171", 0 },
281 /* Phoebe Micro */
282 /* Phoebe Micro 33.6 Data Fax 1433VQH Plug & Play */
283 { "TEX0011", 0 },
284 /* Archtek America Corp. */
285 /* Archtek SmartLink Modem 3334BT Plug & Play */
286 { "UAC000F", 0 },
287 /* 3Com Corp. */
288 /* Gateway Telepath IIvi 33.6 */
289 { "USR0000", 0 },
290 /* U.S. Robotics Sporster 33.6K Fax INT PnP */
291 { "USR0002", 0 },
292 /* Sportster Vi 14.4 PnP FAX Voicemail */
293 { "USR0004", 0 },
294 /* U.S. Robotics 33.6K Voice INT PnP */
295 { "USR0006", 0 },
296 /* U.S. Robotics 33.6K Voice EXT PnP */
297 { "USR0007", 0 },
298 /* U.S. Robotics Courier V.Everything INT PnP */
299 { "USR0009", 0 },
300 /* U.S. Robotics 33.6K Voice INT PnP */
301 { "USR2002", 0 },
302 /* U.S. Robotics 56K Voice INT PnP */
303 { "USR2070", 0 },
304 /* U.S. Robotics 56K Voice EXT PnP */
305 { "USR2080", 0 },
306 /* U.S. Robotics 56K FAX INT */
307 { "USR3031", 0 },
308 /* U.S. Robotics 56K FAX INT */
309 { "USR3050", 0 },
310 /* U.S. Robotics 56K Voice INT PnP */
311 { "USR3070", 0 },
312 /* U.S. Robotics 56K Voice EXT PnP */
313 { "USR3080", 0 },
314 /* U.S. Robotics 56K Voice INT PnP */
315 { "USR3090", 0 },
316 /* U.S. Robotics 56K Message */
317 { "USR9100", 0 },
318 /* U.S. Robotics 56K FAX EXT PnP*/
319 { "USR9160", 0 },
320 /* U.S. Robotics 56K FAX INT PnP*/
321 { "USR9170", 0 },
322 /* U.S. Robotics 56K Voice EXT PnP*/
323 { "USR9180", 0 },
324 /* U.S. Robotics 56K Voice INT PnP*/
325 { "USR9190", 0 },
326 /* HP Compaq Tablet PC tc1100 Wacom tablet */
327 { "WACF005", 0 },
328 /* Rockwell's (PORALiNK) 33600 INT PNP */
329 { "WCI0003", 0 },
330 /* Unkown PnP modems */
331 { "PNPCXXX", UNKNOWN_DEV },
332 /* More unkown PnP modems */
333 { "PNPDXXX", UNKNOWN_DEV },
334 { "", 0 }
337 MODULE_DEVICE_TABLE(pnp, pnp_dev_table);
339 static char *modem_names[] __devinitdata = {
340 "MODEM", "Modem", "modem", "FAX", "Fax", "fax",
341 "56K", "56k", "K56", "33.6", "28.8", "14.4",
342 "33,600", "28,800", "14,400", "33.600", "28.800", "14.400",
343 "33600", "28800", "14400", "V.90", "V.34", "V.32", NULL
346 static int __devinit check_name(char *name)
348 char **tmp;
350 for (tmp = modem_names; *tmp; tmp++)
351 if (strstr(name, *tmp))
352 return 1;
354 return 0;
357 static int __devinit check_resources(struct pnp_option *option)
359 struct pnp_option *tmp;
360 if (!option)
361 return 0;
363 for (tmp = option; tmp; tmp = tmp->next) {
364 struct pnp_port *port;
365 for (port = tmp->port; port; port = port->next)
366 if ((port->size == 8) &&
367 ((port->min == 0x2f8) ||
368 (port->min == 0x3f8) ||
369 (port->min == 0x2e8) ||
370 (port->min == 0x3e8)))
371 return 1;
374 return 0;
378 * Given a complete unknown PnP device, try to use some heuristics to
379 * detect modems. Currently use such heuristic set:
380 * - dev->name or dev->bus->name must contain "modem" substring;
381 * - device must have only one IO region (8 byte long) with base address
382 * 0x2e8, 0x3e8, 0x2f8 or 0x3f8.
384 * Such detection looks very ugly, but can detect at least some of numerous
385 * PnP modems, alternatively we must hardcode all modems in pnp_devices[]
386 * table.
388 static int __devinit serial_pnp_guess_board(struct pnp_dev *dev, int *flags)
390 if (!(check_name(pnp_dev_name(dev)) || (dev->card && check_name(dev->card->name))))
391 return -ENODEV;
393 if (check_resources(dev->independent))
394 return 0;
396 if (check_resources(dev->dependent))
397 return 0;
399 return -ENODEV;
402 static int __devinit
403 serial_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
405 struct uart_port port;
406 int ret, line, flags = dev_id->driver_data;
408 if (flags & UNKNOWN_DEV) {
409 ret = serial_pnp_guess_board(dev, &flags);
410 if (ret < 0)
411 return ret;
414 memset(&port, 0, sizeof(struct uart_port));
415 port.irq = pnp_irq(dev, 0);
416 if (pnp_port_valid(dev, 0)) {
417 port.iobase = pnp_port_start(dev, 0);
418 port.iotype = UPIO_PORT;
419 } else if (pnp_mem_valid(dev, 0)) {
420 port.mapbase = pnp_mem_start(dev, 0);
421 port.iotype = UPIO_MEM;
422 port.flags = UPF_IOREMAP;
423 } else
424 return -ENODEV;
426 #ifdef SERIAL_DEBUG_PNP
427 printk("Setup PNP port: port %x, mem 0x%lx, irq %d, type %d\n",
428 port.iobase, port.mapbase, port.irq, port.iotype);
429 #endif
431 port.flags |= UPF_SKIP_TEST | UPF_BOOT_AUTOCONF;
432 port.uartclk = 1843200;
433 port.dev = &dev->dev;
435 line = serial8250_register_port(&port);
437 if (line >= 0)
438 pnp_set_drvdata(dev, (void *)((long)line + 1));
439 return line >= 0 ? 0 : -ENODEV;
443 static void __devexit serial_pnp_remove(struct pnp_dev *dev)
445 long line = (long)pnp_get_drvdata(dev);
446 if (line)
447 serial8250_unregister_port(line - 1);
450 static struct pnp_driver serial_pnp_driver = {
451 .name = "serial",
452 .id_table = pnp_dev_table,
453 .probe = serial_pnp_probe,
454 .remove = __devexit_p(serial_pnp_remove),
457 static int __init serial8250_pnp_init(void)
459 return pnp_register_driver(&serial_pnp_driver);
462 static void __exit serial8250_pnp_exit(void)
464 pnp_unregister_driver(&serial_pnp_driver);
467 module_init(serial8250_pnp_init);
468 module_exit(serial8250_pnp_exit);
470 MODULE_LICENSE("GPL");
471 MODULE_DESCRIPTION("Generic 8250/16x50 PnP serial driver");