More meth updates.
[linux-2.6/linux-mips.git] / drivers / serial / 8250_pnp.c
blobd21396e514e6505eef22732fd2b910e6195145cd
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.h>
25 #include <linux/serialP.h>
27 #include <asm/bitops.h>
28 #include <asm/byteorder.h>
29 #include <asm/serial.h>
31 #include "8250.h"
33 #define UNKNOWN_DEV 0x3000
36 static const struct pnp_device_id pnp_dev_table[] = {
37 /* Archtek America Corp. */
38 /* Archtek SmartLink Modem 3334BT Plug & Play */
39 { "AAC000F", 0 },
40 /* Anchor Datacomm BV */
41 /* SXPro 144 External Data Fax Modem Plug & Play */
42 { "ADC0001", 0 },
43 /* SXPro 288 External Data Fax Modem Plug & Play */
44 { "ADC0002", 0 },
45 /* Actiontec ISA PNP 56K X2 Fax Modem */
46 { "AEI1240", 0 },
47 /* Rockwell 56K ACF II Fax+Data+Voice Modem */
48 { "AKY1021", 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 /* FUJITSU */
78 /* Fujitsu 33600 PnP-I2 R Plug & Play */
79 { "FUJ0202", 0 },
80 /* Fujitsu FMV-FX431 Plug & Play */
81 { "FUJ0205", 0 },
82 /* Fujitsu 33600 PnP-I4 R Plug & Play */
83 { "FUJ0206", 0 },
84 /* Fujitsu Fax Voice 33600 PNP-I5 R Plug & Play */
85 { "FUJ0209", 0 },
86 /* Archtek America Corp. */
87 /* Archtek SmartLink Modem 3334BT Plug & Play */
88 { "GVC000F", 0 },
89 /* Hayes */
90 /* Hayes Optima 288 V.34-V.FC + FAX + Voice Plug & Play */
91 { "HAY0001", 0 },
92 /* Hayes Optima 336 V.34 + FAX + Voice PnP */
93 { "HAY000C", 0 },
94 /* Hayes Optima 336B V.34 + FAX + Voice PnP */
95 { "HAY000D", 0 },
96 /* Hayes Accura 56K Ext Fax Modem PnP */
97 { "HAY5670", 0 },
98 /* Hayes Accura 56K Ext Fax Modem PnP */
99 { "HAY5674", 0 },
100 /* Hayes Accura 56K Fax Modem PnP */
101 { "HAY5675", 0 },
102 /* Hayes 288, V.34 + FAX */
103 { "HAYF000", 0 },
104 /* Hayes Optima 288 V.34 + FAX + Voice, Plug & Play */
105 { "HAYF001", 0 },
106 /* IBM */
107 /* IBM Thinkpad 701 Internal Modem Voice */
108 { "IBM0033", 0 },
109 /* Intertex */
110 /* Intertex 28k8 33k6 Voice EXT PnP */
111 { "IXDC801", 0 },
112 /* Intertex 33k6 56k Voice EXT PnP */
113 { "IXDC901", 0 },
114 /* Intertex 28k8 33k6 Voice SP EXT PnP */
115 { "IXDD801", 0 },
116 /* Intertex 33k6 56k Voice SP EXT PnP */
117 { "IXDD901", 0 },
118 /* Intertex 28k8 33k6 Voice SP INT PnP */
119 { "IXDF401", 0 },
120 /* Intertex 28k8 33k6 Voice SP EXT PnP */
121 { "IXDF801", 0 },
122 /* Intertex 33k6 56k Voice SP EXT PnP */
123 { "IXDF901", 0 },
124 /* Kortex International */
125 /* KORTEX 28800 Externe PnP */
126 { "KOR4522", 0 },
127 /* KXPro 33.6 Vocal ASVD PnP */
128 { "KORF661", 0 },
129 /* Lasat */
130 /* LASAT Internet 33600 PnP */
131 { "LAS4040", 0 },
132 /* Lasat Safire 560 PnP */
133 { "LAS4540", 0 },
134 /* Lasat Safire 336 PnP */
135 { "LAS5440", 0 },
136 /* Microcom, Inc. */
137 /* Microcom TravelPorte FAST V.34 Plug & Play */
138 { "MNP0281", 0 },
139 /* Microcom DeskPorte V.34 FAST or FAST+ Plug & Play */
140 { "MNP0336", 0 },
141 /* Microcom DeskPorte FAST EP 28.8 Plug & Play */
142 { "MNP0339", 0 },
143 /* Microcom DeskPorte 28.8P Plug & Play */
144 { "MNP0342", 0 },
145 /* Microcom DeskPorte FAST ES 28.8 Plug & Play */
146 { "MNP0500", 0 },
147 /* Microcom DeskPorte FAST ES 28.8 Plug & Play */
148 { "MNP0501", 0 },
149 /* Microcom DeskPorte 28.8S Internal Plug & Play */
150 { "MNP0502", 0 },
151 /* Motorola */
152 /* Motorola BitSURFR Plug & Play */
153 { "MOT1105", 0 },
154 /* Motorola TA210 Plug & Play */
155 { "MOT1111", 0 },
156 /* Motorola HMTA 200 (ISDN) Plug & Play */
157 { "MOT1114", 0 },
158 /* Motorola BitSURFR Plug & Play */
159 { "MOT1115", 0 },
160 /* Motorola Lifestyle 28.8 Internal */
161 { "MOT1190", 0 },
162 /* Motorola V.3400 Plug & Play */
163 { "MOT1501", 0 },
164 /* Motorola Lifestyle 28.8 V.34 Plug & Play */
165 { "MOT1502", 0 },
166 /* Motorola Power 28.8 V.34 Plug & Play */
167 { "MOT1505", 0 },
168 /* Motorola ModemSURFR External 28.8 Plug & Play */
169 { "MOT1509", 0 },
170 /* Motorola Premier 33.6 Desktop Plug & Play */
171 { "MOT150A", 0 },
172 /* Motorola VoiceSURFR 56K External PnP */
173 { "MOT150F", 0 },
174 /* Motorola ModemSURFR 56K External PnP */
175 { "MOT1510", 0 },
176 /* Motorola ModemSURFR 56K Internal PnP */
177 { "MOT1550", 0 },
178 /* Motorola ModemSURFR Internal 28.8 Plug & Play */
179 { "MOT1560", 0 },
180 /* Motorola Premier 33.6 Internal Plug & Play */
181 { "MOT1580", 0 },
182 /* Motorola OnlineSURFR 28.8 Internal Plug & Play */
183 { "MOT15B0", 0 },
184 /* Motorola VoiceSURFR 56K Internal PnP */
185 { "MOT15F0", 0 },
186 /* Com 1 */
187 /* Deskline K56 Phone System PnP */
188 { "MVX00A1", 0 },
189 /* PC Rider K56 Phone System PnP */
190 { "MVX00F2", 0 },
191 /* NEC 98NOTE SPEAKER PHONE FAX MODEM(33600bps) */
192 { "nEC8241", 0 },
193 /* Pace 56 Voice Internal Plug & Play Modem */
194 { "PMC2430", 0 },
195 /* Generic */
196 /* Generic standard PC COM port */
197 { "PNP0500", 0 },
198 /* Generic 16550A-compatible COM port */
199 { "PNP0501", 0 },
200 /* Compaq 14400 Modem */
201 { "PNPC000", 0 },
202 /* Compaq 2400/9600 Modem */
203 { "PNPC001", 0 },
204 /* Dial-Up Networking Serial Cable between 2 PCs */
205 { "PNPC031", 0 },
206 /* Dial-Up Networking Parallel Cable between 2 PCs */
207 { "PNPC032", 0 },
208 /* Standard 9600 bps Modem */
209 { "PNPC100", 0 },
210 /* Standard 14400 bps Modem */
211 { "PNPC101", 0 },
212 /* Standard 28800 bps Modem*/
213 { "PNPC102", 0 },
214 /* Standard Modem*/
215 { "PNPC103", 0 },
216 /* Standard 9600 bps Modem*/
217 { "PNPC104", 0 },
218 /* Standard 14400 bps Modem*/
219 { "PNPC105", 0 },
220 /* Standard 28800 bps Modem*/
221 { "PNPC106", 0 },
222 /* Standard Modem */
223 { "PNPC107", 0 },
224 /* Standard 9600 bps Modem */
225 { "PNPC108", 0 },
226 /* Standard 14400 bps Modem */
227 { "PNPC109", 0 },
228 /* Standard 28800 bps Modem */
229 { "PNPC10A", 0 },
230 /* Standard Modem */
231 { "PNPC10B", 0 },
232 /* Standard 9600 bps Modem */
233 { "PNPC10C", 0 },
234 /* Standard 14400 bps Modem */
235 { "PNPC10D", 0 },
236 /* Standard 28800 bps Modem */
237 { "PNPC10E", 0 },
238 /* Standard Modem */
239 { "PNPC10F", 0 },
240 /* Standard PCMCIA Card Modem */
241 { "PNP2000", 0 },
242 /* Rockwell */
243 /* Modular Technology */
244 /* Rockwell 33.6 DPF Internal PnP */
245 /* Modular Technology 33.6 Internal PnP */
246 { "ROK0030", 0 },
247 /* Kortex International */
248 /* KORTEX 14400 Externe PnP */
249 { "ROK0100", 0 },
250 /* Viking Components, Inc */
251 /* Viking 28.8 INTERNAL Fax+Data+Voice PnP */
252 { "ROK4920", 0 },
253 /* Rockwell */
254 /* British Telecom */
255 /* Modular Technology */
256 /* Rockwell 33.6 DPF External PnP */
257 /* BT Prologue 33.6 External PnP */
258 /* Modular Technology 33.6 External PnP */
259 { "RSS00A0", 0 },
260 /* Viking 56K FAX INT */
261 { "RSS0262", 0 },
262 /* SupraExpress 28.8 Data/Fax PnP modem */
263 { "SUP1310", 0 },
264 /* SupraExpress 33.6 Data/Fax PnP modem */
265 { "SUP1421", 0 },
266 /* SupraExpress 33.6 Data/Fax PnP modem */
267 { "SUP1590", 0 },
268 /* SupraExpress 33.6 Data/Fax PnP modem */
269 { "SUP1760", 0 },
270 /* Phoebe Micro */
271 /* Phoebe Micro 33.6 Data Fax 1433VQH Plug & Play */
272 { "TEX0011", 0 },
273 /* Archtek America Corp. */
274 /* Archtek SmartLink Modem 3334BT Plug & Play */
275 { "UAC000F", 0 },
276 /* 3Com Corp. */
277 /* Gateway Telepath IIvi 33.6 */
278 { "USR0000", 0 },
279 /* Sportster Vi 14.4 PnP FAX Voicemail */
280 { "USR0004", 0 },
281 /* U.S. Robotics 33.6K Voice INT PnP */
282 { "USR0006", 0 },
283 /* U.S. Robotics 33.6K Voice EXT PnP */
284 { "USR0007", 0 },
285 /* U.S. Robotics 33.6K Voice INT PnP */
286 { "USR2002", 0 },
287 /* U.S. Robotics 56K Voice INT PnP */
288 { "USR2070", 0 },
289 /* U.S. Robotics 56K Voice EXT PnP */
290 { "USR2080", 0 },
291 /* U.S. Robotics 56K FAX INT */
292 { "USR3031", 0 },
293 /* U.S. Robotics 56K Voice INT PnP */
294 { "USR3070", 0 },
295 /* U.S. Robotics 56K Voice EXT PnP */
296 { "USR3080", 0 },
297 /* U.S. Robotics 56K Voice INT PnP */
298 { "USR3090", 0 },
299 /* U.S. Robotics 56K Message */
300 { "USR9100", 0 },
301 /* U.S. Robotics 56K FAX EXT PnP*/
302 { "USR9160", 0 },
303 /* U.S. Robotics 56K FAX INT PnP*/
304 { "USR9170", 0 },
305 /* U.S. Robotics 56K Voice EXT PnP*/
306 { "USR9180", 0 },
307 /* U.S. Robotics 56K Voice INT PnP*/
308 { "USR9190", 0 },
309 /* Unkown PnP modems */
310 { "PNPCXXX", UNKNOWN_DEV },
311 /* More unkown PnP modems */
312 { "PNPDXXX", UNKNOWN_DEV },
313 { "", 0 }
316 MODULE_DEVICE_TABLE(pnp, pnp_dev_table);
318 static char *modem_names[] __devinitdata = {
319 "MODEM", "Modem", "modem", "FAX", "Fax", "fax",
320 "56K", "56k", "K56", "33.6", "28.8", "14.4",
321 "33,600", "28,800", "14,400", "33.600", "28.800", "14.400",
322 "33600", "28800", "14400", "V.90", "V.34", "V.32", 0
325 static int __devinit check_name(char *name)
327 char **tmp;
329 for (tmp = modem_names; *tmp; tmp++)
330 if (strstr(name, *tmp))
331 return 1;
333 return 0;
336 static int __devinit check_resources(struct pnp_option *option)
338 struct pnp_option *tmp;
339 if (!option)
340 return 0;
342 for (tmp = option; tmp; tmp = tmp->next) {
343 struct pnp_port *port;
344 for (port = tmp->port; port; port = port->next)
345 if ((port->size == 8) &&
346 ((port->min == 0x2f8) ||
347 (port->min == 0x3f8) ||
348 (port->min == 0x2e8) ||
349 #ifdef CONFIG_X86_PC9800
350 (port->min == 0x8b0) ||
351 #endif
352 (port->min == 0x3e8)))
353 return 1;
356 return 0;
360 * Given a complete unknown PnP device, try to use some heuristics to
361 * detect modems. Currently use such heuristic set:
362 * - dev->name or dev->bus->name must contain "modem" substring;
363 * - device must have only one IO region (8 byte long) with base address
364 * 0x2e8, 0x3e8, 0x2f8 or 0x3f8.
366 * Such detection looks very ugly, but can detect at least some of numerous
367 * PnP modems, alternatively we must hardcode all modems in pnp_devices[]
368 * table.
370 static int __devinit serial_pnp_guess_board(struct pnp_dev *dev, int *flags)
372 if (!(check_name(dev->dev.name) || (dev->card && check_name(dev->card->dev.name))))
373 return -ENODEV;
375 if (check_resources(dev->independent))
376 return 0;
378 if (check_resources(dev->dependent))
379 return 0;
381 return -ENODEV;
384 static int
385 serial_pnp_probe(struct pnp_dev * dev, const struct pnp_device_id *dev_id)
387 struct serial_struct serial_req;
388 int ret, line, flags = dev_id->driver_data;
389 if (flags & UNKNOWN_DEV) {
390 ret = serial_pnp_guess_board(dev, &flags);
391 if (ret < 0)
392 return ret;
394 memset(&serial_req, 0, sizeof(serial_req));
395 serial_req.irq = pnp_irq(dev,0);
396 serial_req.port = pnp_port_start(dev, 0);
397 if (HIGH_BITS_OFFSET)
398 serial_req.port = pnp_port_start(dev, 0) >> HIGH_BITS_OFFSET;
399 #ifdef SERIAL_DEBUG_PNP
400 printk("Setup PNP port: port %x, irq %d, type %d\n",
401 serial_req.port, serial_req.irq, serial_req.io_type);
402 #endif
404 serial_req.flags = ASYNC_SKIP_TEST | ASYNC_AUTOPROBE;
405 serial_req.baud_base = 115200;
406 line = register_serial(&serial_req);
408 if (line >= 0)
409 pnp_set_drvdata(dev, (void *)(line + 1));
410 return line >= 0 ? 0 : -ENODEV;
414 static void serial_pnp_remove(struct pnp_dev * dev)
416 return;
419 static struct pnp_driver serial_pnp_driver = {
420 .name = "serial",
421 .id_table = pnp_dev_table,
422 .probe = serial_pnp_probe,
423 .remove = serial_pnp_remove,
426 static int __init serial8250_pnp_init(void)
428 return pnp_register_driver(&serial_pnp_driver);
431 static void __exit serial8250_pnp_exit(void)
433 /* FIXME */
436 module_init(serial8250_pnp_init);
437 module_exit(serial8250_pnp_exit);
439 MODULE_LICENSE("GPL");
440 MODULE_DESCRIPTION("Generic 8250/16x50 PnP serial driver");