blob: 682a2fbe5c065be61c350088c86f16ba5a89ceff [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Sean Young835d8442012-09-07 19:06:23 +01002 * Probe for 8250/16550-type ISAPNP serial ports.
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
4 * Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o.
5 *
6 * Copyright (C) 2001 Russell King, All Rights Reserved.
7 *
8 * Ported to the Linux PnP Layer - (C) Adam Belay.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License.
Linus Torvalds1da177e2005-04-16 15:20:36 -070013 */
14#include <linux/module.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#include <linux/pci.h>
16#include <linux/pnp.h>
17#include <linux/string.h>
18#include <linux/kernel.h>
19#include <linux/serial_core.h>
20#include <linux/bitops.h>
21
22#include <asm/byteorder.h>
23
24#include "8250.h"
25
26#define UNKNOWN_DEV 0x3000
Sean Young65ecc9c2012-09-07 19:06:24 +010027#define CIR_PORT 0x0800
Linus Torvalds1da177e2005-04-16 15:20:36 -070028
29static const struct pnp_device_id pnp_dev_table[] = {
30 /* Archtek America Corp. */
31 /* Archtek SmartLink Modem 3334BT Plug & Play */
32 { "AAC000F", 0 },
33 /* Anchor Datacomm BV */
34 /* SXPro 144 External Data Fax Modem Plug & Play */
35 { "ADC0001", 0 },
36 /* SXPro 288 External Data Fax Modem Plug & Play */
37 { "ADC0002", 0 },
38 /* PROLiNK 1456VH ISA PnP K56flex Fax Modem */
39 { "AEI0250", 0 },
40 /* Actiontec ISA PNP 56K X2 Fax Modem */
41 { "AEI1240", 0 },
42 /* Rockwell 56K ACF II Fax+Data+Voice Modem */
43 { "AKY1021", 0 /*SPCI_FL_NO_SHIRQ*/ },
44 /* AZT3005 PnP SOUND DEVICE */
45 { "AZT4001", 0 },
46 /* Best Data Products Inc. Smart One 336F PnP Modem */
47 { "BDP3336", 0 },
48 /* Boca Research */
49 /* Boca Complete Ofc Communicator 14.4 Data-FAX */
50 { "BRI0A49", 0 },
51 /* Boca Research 33,600 ACF Modem */
52 { "BRI1400", 0 },
53 /* Boca 33.6 Kbps Internal FD34FSVD */
54 { "BRI3400", 0 },
55 /* Boca 33.6 Kbps Internal FD34FSVD */
56 { "BRI0A49", 0 },
57 /* Best Data Products Inc. Smart One 336F PnP Modem */
58 { "BDP3336", 0 },
59 /* Computer Peripherals Inc */
60 /* EuroViVa CommCenter-33.6 SP PnP */
61 { "CPI4050", 0 },
62 /* Creative Labs */
63 /* Creative Labs Phone Blaster 28.8 DSVD PnP Voice */
64 { "CTL3001", 0 },
65 /* Creative Labs Modem Blaster 28.8 DSVD PnP Voice */
66 { "CTL3011", 0 },
Bjorn Helgaasdbd0cf42007-11-14 16:58:36 -080067 /* Davicom ISA 33.6K Modem */
68 { "DAV0336", 0 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070069 /* Creative */
70 /* Creative Modem Blaster Flash56 DI5601-1 */
71 { "DMB1032", 0 },
72 /* Creative Modem Blaster V.90 DI5660 */
73 { "DMB2001", 0 },
74 /* E-Tech */
75 /* E-Tech CyberBULLET PC56RVP */
76 { "ETT0002", 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 },
Bjorn Helgaas51587cb2008-03-04 14:28:21 -080089 /* Archtek SmartLink Modem 3334BRV 33.6K Data Fax Voice */
90 { "GVC0303", 0 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070091 /* Hayes */
92 /* Hayes Optima 288 V.34-V.FC + FAX + Voice Plug & Play */
93 { "HAY0001", 0 },
94 /* Hayes Optima 336 V.34 + FAX + Voice PnP */
95 { "HAY000C", 0 },
96 /* Hayes Optima 336B V.34 + FAX + Voice PnP */
97 { "HAY000D", 0 },
98 /* Hayes Accura 56K Ext Fax Modem PnP */
99 { "HAY5670", 0 },
100 /* Hayes Accura 56K Ext Fax Modem PnP */
101 { "HAY5674", 0 },
102 /* Hayes Accura 56K Fax Modem PnP */
103 { "HAY5675", 0 },
104 /* Hayes 288, V.34 + FAX */
105 { "HAYF000", 0 },
106 /* Hayes Optima 288 V.34 + FAX + Voice, Plug & Play */
107 { "HAYF001", 0 },
108 /* IBM */
109 /* IBM Thinkpad 701 Internal Modem Voice */
110 { "IBM0033", 0 },
Bjorn Helgaasab8ba3a2011-08-16 12:02:28 -0600111 /* Intermec */
112 /* Intermec CV60 touchscreen port */
113 { "PNP4972", 0 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114 /* Intertex */
115 /* Intertex 28k8 33k6 Voice EXT PnP */
116 { "IXDC801", 0 },
117 /* Intertex 33k6 56k Voice EXT PnP */
118 { "IXDC901", 0 },
119 /* Intertex 28k8 33k6 Voice SP EXT PnP */
120 { "IXDD801", 0 },
121 /* Intertex 33k6 56k Voice SP EXT PnP */
122 { "IXDD901", 0 },
123 /* Intertex 28k8 33k6 Voice SP INT PnP */
124 { "IXDF401", 0 },
125 /* Intertex 28k8 33k6 Voice SP EXT PnP */
126 { "IXDF801", 0 },
127 /* Intertex 33k6 56k Voice SP EXT PnP */
128 { "IXDF901", 0 },
129 /* Kortex International */
130 /* KORTEX 28800 Externe PnP */
131 { "KOR4522", 0 },
132 /* KXPro 33.6 Vocal ASVD PnP */
133 { "KORF661", 0 },
134 /* Lasat */
135 /* LASAT Internet 33600 PnP */
136 { "LAS4040", 0 },
137 /* Lasat Safire 560 PnP */
138 { "LAS4540", 0 },
139 /* Lasat Safire 336 PnP */
140 { "LAS5440", 0 },
141 /* Microcom, Inc. */
142 /* Microcom TravelPorte FAST V.34 Plug & Play */
143 { "MNP0281", 0 },
144 /* Microcom DeskPorte V.34 FAST or FAST+ Plug & Play */
145 { "MNP0336", 0 },
146 /* Microcom DeskPorte FAST EP 28.8 Plug & Play */
147 { "MNP0339", 0 },
148 /* Microcom DeskPorte 28.8P Plug & Play */
149 { "MNP0342", 0 },
150 /* Microcom DeskPorte FAST ES 28.8 Plug & Play */
151 { "MNP0500", 0 },
152 /* Microcom DeskPorte FAST ES 28.8 Plug & Play */
153 { "MNP0501", 0 },
154 /* Microcom DeskPorte 28.8S Internal Plug & Play */
155 { "MNP0502", 0 },
156 /* Motorola */
157 /* Motorola BitSURFR Plug & Play */
158 { "MOT1105", 0 },
159 /* Motorola TA210 Plug & Play */
160 { "MOT1111", 0 },
161 /* Motorola HMTA 200 (ISDN) Plug & Play */
162 { "MOT1114", 0 },
163 /* Motorola BitSURFR Plug & Play */
164 { "MOT1115", 0 },
165 /* Motorola Lifestyle 28.8 Internal */
166 { "MOT1190", 0 },
167 /* Motorola V.3400 Plug & Play */
168 { "MOT1501", 0 },
169 /* Motorola Lifestyle 28.8 V.34 Plug & Play */
170 { "MOT1502", 0 },
171 /* Motorola Power 28.8 V.34 Plug & Play */
172 { "MOT1505", 0 },
173 /* Motorola ModemSURFR External 28.8 Plug & Play */
174 { "MOT1509", 0 },
175 /* Motorola Premier 33.6 Desktop Plug & Play */
176 { "MOT150A", 0 },
177 /* Motorola VoiceSURFR 56K External PnP */
178 { "MOT150F", 0 },
179 /* Motorola ModemSURFR 56K External PnP */
180 { "MOT1510", 0 },
181 /* Motorola ModemSURFR 56K Internal PnP */
182 { "MOT1550", 0 },
183 /* Motorola ModemSURFR Internal 28.8 Plug & Play */
184 { "MOT1560", 0 },
185 /* Motorola Premier 33.6 Internal Plug & Play */
186 { "MOT1580", 0 },
187 /* Motorola OnlineSURFR 28.8 Internal Plug & Play */
188 { "MOT15B0", 0 },
189 /* Motorola VoiceSURFR 56K Internal PnP */
190 { "MOT15F0", 0 },
191 /* Com 1 */
192 /* Deskline K56 Phone System PnP */
193 { "MVX00A1", 0 },
194 /* PC Rider K56 Phone System PnP */
195 { "MVX00F2", 0 },
196 /* NEC 98NOTE SPEAKER PHONE FAX MODEM(33600bps) */
197 { "nEC8241", 0 },
198 /* Pace 56 Voice Internal Plug & Play Modem */
199 { "PMC2430", 0 },
200 /* Generic */
201 /* Generic standard PC COM port */
202 { "PNP0500", 0 },
203 /* Generic 16550A-compatible COM port */
204 { "PNP0501", 0 },
205 /* Compaq 14400 Modem */
206 { "PNPC000", 0 },
207 /* Compaq 2400/9600 Modem */
208 { "PNPC001", 0 },
209 /* Dial-Up Networking Serial Cable between 2 PCs */
210 { "PNPC031", 0 },
211 /* Dial-Up Networking Parallel Cable between 2 PCs */
212 { "PNPC032", 0 },
213 /* Standard 9600 bps Modem */
214 { "PNPC100", 0 },
215 /* Standard 14400 bps Modem */
216 { "PNPC101", 0 },
217 /* Standard 28800 bps Modem*/
218 { "PNPC102", 0 },
219 /* Standard Modem*/
220 { "PNPC103", 0 },
221 /* Standard 9600 bps Modem*/
222 { "PNPC104", 0 },
223 /* Standard 14400 bps Modem*/
224 { "PNPC105", 0 },
225 /* Standard 28800 bps Modem*/
226 { "PNPC106", 0 },
227 /* Standard Modem */
228 { "PNPC107", 0 },
229 /* Standard 9600 bps Modem */
230 { "PNPC108", 0 },
231 /* Standard 14400 bps Modem */
232 { "PNPC109", 0 },
233 /* Standard 28800 bps Modem */
234 { "PNPC10A", 0 },
235 /* Standard Modem */
236 { "PNPC10B", 0 },
237 /* Standard 9600 bps Modem */
238 { "PNPC10C", 0 },
239 /* Standard 14400 bps Modem */
240 { "PNPC10D", 0 },
241 /* Standard 28800 bps Modem */
242 { "PNPC10E", 0 },
243 /* Standard Modem */
244 { "PNPC10F", 0 },
245 /* Standard PCMCIA Card Modem */
246 { "PNP2000", 0 },
247 /* Rockwell */
248 /* Modular Technology */
249 /* Rockwell 33.6 DPF Internal PnP */
250 /* Modular Technology 33.6 Internal PnP */
251 { "ROK0030", 0 },
252 /* Kortex International */
253 /* KORTEX 14400 Externe PnP */
254 { "ROK0100", 0 },
255 /* Rockwell 28.8 */
256 { "ROK4120", 0 },
257 /* Viking Components, Inc */
258 /* Viking 28.8 INTERNAL Fax+Data+Voice PnP */
259 { "ROK4920", 0 },
260 /* Rockwell */
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 */
266 { "RSS00A0", 0 },
267 /* Viking 56K FAX INT */
268 { "RSS0262", 0 },
269 /* K56 par,VV,Voice,Speakphone,AudioSpan,PnP */
270 { "RSS0250", 0 },
271 /* SupraExpress 28.8 Data/Fax PnP modem */
272 { "SUP1310", 0 },
Daniel Gagnon7fdd4f72009-01-15 13:30:45 +0000273 /* SupraExpress 336i PnP Voice Modem */
274 { "SUP1381", 0 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275 /* SupraExpress 33.6 Data/Fax PnP modem */
276 { "SUP1421", 0 },
277 /* SupraExpress 33.6 Data/Fax PnP modem */
278 { "SUP1590", 0 },
Baris Cicek04f03bf2005-10-14 14:32:40 +0100279 /* SupraExpress 336i Sp ASVD */
280 { "SUP1620", 0 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281 /* SupraExpress 33.6 Data/Fax PnP modem */
282 { "SUP1760", 0 },
maximilian attemsc1542cb2005-10-15 10:43:35 +0100283 /* SupraExpress 56i Sp Intl */
284 { "SUP2171", 0 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285 /* Phoebe Micro */
286 /* Phoebe Micro 33.6 Data Fax 1433VQH Plug & Play */
287 { "TEX0011", 0 },
288 /* Archtek America Corp. */
289 /* Archtek SmartLink Modem 3334BT Plug & Play */
290 { "UAC000F", 0 },
291 /* 3Com Corp. */
292 /* Gateway Telepath IIvi 33.6 */
293 { "USR0000", 0 },
294 /* U.S. Robotics Sporster 33.6K Fax INT PnP */
295 { "USR0002", 0 },
296 /* Sportster Vi 14.4 PnP FAX Voicemail */
297 { "USR0004", 0 },
298 /* U.S. Robotics 33.6K Voice INT PnP */
299 { "USR0006", 0 },
300 /* U.S. Robotics 33.6K Voice EXT PnP */
301 { "USR0007", 0 },
302 /* U.S. Robotics Courier V.Everything INT PnP */
303 { "USR0009", 0 },
304 /* U.S. Robotics 33.6K Voice INT PnP */
305 { "USR2002", 0 },
306 /* U.S. Robotics 56K Voice INT PnP */
307 { "USR2070", 0 },
308 /* U.S. Robotics 56K Voice EXT PnP */
309 { "USR2080", 0 },
310 /* U.S. Robotics 56K FAX INT */
311 { "USR3031", 0 },
312 /* U.S. Robotics 56K FAX INT */
313 { "USR3050", 0 },
314 /* U.S. Robotics 56K Voice INT PnP */
315 { "USR3070", 0 },
316 /* U.S. Robotics 56K Voice EXT PnP */
317 { "USR3080", 0 },
318 /* U.S. Robotics 56K Voice INT PnP */
319 { "USR3090", 0 },
320 /* U.S. Robotics 56K Message */
321 { "USR9100", 0 },
322 /* U.S. Robotics 56K FAX EXT PnP*/
323 { "USR9160", 0 },
324 /* U.S. Robotics 56K FAX INT PnP*/
325 { "USR9170", 0 },
326 /* U.S. Robotics 56K Voice EXT PnP*/
327 { "USR9180", 0 },
328 /* U.S. Robotics 56K Voice INT PnP*/
329 { "USR9190", 0 },
Ben Collinsb07076e2006-06-26 15:24:36 +0100330 /* Wacom tablets */
Matthew Garrett6d348552009-12-09 12:31:37 -0800331 { "WACFXXX", 0 },
Matthew Garrett75fde2e2006-10-01 19:27:38 +0100332 /* Compaq touchscreen */
333 { "FPI2002", 0 },
334 /* Fujitsu Stylistic touchscreens */
335 { "FUJ02B2", 0 },
336 { "FUJ02B3", 0 },
337 /* Fujitsu Stylistic LT touchscreens */
338 { "FUJ02B4", 0 },
339 /* Passive Fujitsu Stylistic touchscreens */
340 { "FUJ02B6", 0 },
341 { "FUJ02B7", 0 },
342 { "FUJ02B8", 0 },
343 { "FUJ02B9", 0 },
344 { "FUJ02BC", 0 },
Matthew Garrett97ea33f2009-04-06 17:32:01 +0100345 /* Fujitsu Wacom Tablet PC device */
Danny Kukawka6149dd52007-03-23 00:10:01 -0700346 { "FUJ02E5", 0 },
Matthew Garrett97ea33f2009-04-06 17:32:01 +0100347 /* Fujitsu P-series tablet PC device */
Danny Kukawka6149dd52007-03-23 00:10:01 -0700348 { "FUJ02E6", 0 },
Ping3018aa42010-01-15 17:01:07 -0800349 /* Fujitsu Wacom 2FGT Tablet PC device */
350 { "FUJ02E7", 0 },
Ping Chengd9901662010-03-22 13:40:29 -0700351 /* Fujitsu Wacom 1FGT Tablet PC device */
352 { "FUJ02E9", 0 },
Damian Jurd71054582007-11-14 16:59:04 -0800353 /*
354 * LG C1 EXPRESS DUAL (C1-PB11A3) touch screen (actually a FUJ02E6 in
355 * disguise)
356 */
357 { "LTS0001", 0 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358 /* Rockwell's (PORALiNK) 33600 INT PNP */
359 { "WCI0003", 0 },
André Goddard Rosaaf901ca2009-11-14 13:09:05 -0200360 /* Unknown PnP modems */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361 { "PNPCXXX", UNKNOWN_DEV },
André Goddard Rosaaf901ca2009-11-14 13:09:05 -0200362 /* More unknown PnP modems */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363 { "PNPDXXX", UNKNOWN_DEV },
Sean Young65ecc9c2012-09-07 19:06:24 +0100364 /* Winbond CIR port, should not be probed. We should keep track
365 of it to prevent the legacy serial driver from probing it */
366 { "WEC1022", CIR_PORT },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367 { "", 0 }
368};
369
370MODULE_DEVICE_TABLE(pnp, pnp_dev_table);
371
Bill Pembertonde88b342012-11-19 13:24:32 -0500372static char *modem_names[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373 "MODEM", "Modem", "modem", "FAX", "Fax", "fax",
374 "56K", "56k", "K56", "33.6", "28.8", "14.4",
375 "33,600", "28,800", "14,400", "33.600", "28.800", "14.400",
376 "33600", "28800", "14400", "V.90", "V.34", "V.32", NULL
377};
378
Bill Pemberton9671f092012-11-19 13:21:50 -0500379static int check_name(char *name)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700380{
381 char **tmp;
382
383 for (tmp = modem_names; *tmp; tmp++)
384 if (strstr(name, *tmp))
385 return 1;
386
387 return 0;
388}
389
Bill Pemberton9671f092012-11-19 13:21:50 -0500390static int check_resources(struct pnp_dev *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391{
Bjorn Helgaas57fd51a2008-06-27 16:57:01 -0600392 resource_size_t base[] = {0x2f8, 0x3f8, 0x2e8, 0x3e8};
393 int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394
Bjorn Helgaas57fd51a2008-06-27 16:57:01 -0600395 for (i = 0; i < ARRAY_SIZE(base); i++) {
396 if (pnp_possible_config(dev, IORESOURCE_IO, base[i], 8))
397 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398 }
399
400 return 0;
401}
402
403/*
404 * Given a complete unknown PnP device, try to use some heuristics to
405 * detect modems. Currently use such heuristic set:
406 * - dev->name or dev->bus->name must contain "modem" substring;
407 * - device must have only one IO region (8 byte long) with base address
408 * 0x2e8, 0x3e8, 0x2f8 or 0x3f8.
409 *
410 * Such detection looks very ugly, but can detect at least some of numerous
411 * PnP modems, alternatively we must hardcode all modems in pnp_devices[]
412 * table.
413 */
Bill Pemberton9671f092012-11-19 13:21:50 -0500414static int serial_pnp_guess_board(struct pnp_dev *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700415{
Alan Cox3e8d4e22008-02-04 22:27:53 -0800416 if (!(check_name(pnp_dev_name(dev)) ||
417 (dev->card && check_name(dev->card->name))))
418 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700419
Bjorn Helgaas57fd51a2008-06-27 16:57:01 -0600420 if (check_resources(dev))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421 return 0;
422
423 return -ENODEV;
424}
425
Bill Pemberton9671f092012-11-19 13:21:50 -0500426static int
Bjorn Helgaas655a0a72005-07-29 14:03:30 -0700427serial_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700428{
Alan Cox2655a2c2012-07-12 12:59:50 +0100429 struct uart_8250_port uart;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430 int ret, line, flags = dev_id->driver_data;
431
432 if (flags & UNKNOWN_DEV) {
Sean Young65ecc9c2012-09-07 19:06:24 +0100433 ret = serial_pnp_guess_board(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434 if (ret < 0)
435 return ret;
436 }
437
Alan Cox2655a2c2012-07-12 12:59:50 +0100438 memset(&uart, 0, sizeof(uart));
Bjorn Helgaase02f5f52007-11-14 16:59:59 -0800439 if (pnp_irq_valid(dev, 0))
Alan Cox2655a2c2012-07-12 12:59:50 +0100440 uart.port.irq = pnp_irq(dev, 0);
Sean Youngc12f9ea2013-04-07 20:47:18 +0100441 if ((flags & CIR_PORT) && pnp_port_valid(dev, 2)) {
442 uart.port.iobase = pnp_port_start(dev, 2);
443 uart.port.iotype = UPIO_PORT;
444 } else if (pnp_port_valid(dev, 0)) {
445 uart.port.iobase = pnp_port_start(dev, 0);
Alan Cox2655a2c2012-07-12 12:59:50 +0100446 uart.port.iotype = UPIO_PORT;
Bjorn Helgaas655a0a72005-07-29 14:03:30 -0700447 } else if (pnp_mem_valid(dev, 0)) {
Alan Cox2655a2c2012-07-12 12:59:50 +0100448 uart.port.mapbase = pnp_mem_start(dev, 0);
449 uart.port.iotype = UPIO_MEM;
450 uart.port.flags = UPF_IOREMAP;
Bjorn Helgaas655a0a72005-07-29 14:03:30 -0700451 } else
452 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700453
454#ifdef SERIAL_DEBUG_PNP
Alan Cox3e8d4e22008-02-04 22:27:53 -0800455 printk(KERN_DEBUG
456 "Setup PNP port: port %x, mem 0x%lx, irq %d, type %d\n",
Alan Cox2655a2c2012-07-12 12:59:50 +0100457 uart.port.iobase, uart.port.mapbase, uart.port.irq, uart.port.iotype);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700458#endif
Sean Young65ecc9c2012-09-07 19:06:24 +0100459 if (flags & CIR_PORT) {
460 uart.port.flags |= UPF_FIXED_PORT | UPF_FIXED_TYPE;
461 uart.port.type = PORT_8250_CIR;
462 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700463
Alan Cox2655a2c2012-07-12 12:59:50 +0100464 uart.port.flags |= UPF_SKIP_TEST | UPF_BOOT_AUTOCONF;
Bjorn Helgaascb6358e2006-07-03 00:24:12 -0700465 if (pnp_irq_flags(dev, 0) & IORESOURCE_IRQ_SHAREABLE)
Alan Cox2655a2c2012-07-12 12:59:50 +0100466 uart.port.flags |= UPF_SHARE_IRQ;
467 uart.port.uartclk = 1843200;
468 uart.port.dev = &dev->dev;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469
Alan Cox2655a2c2012-07-12 12:59:50 +0100470 line = serial8250_register_8250_port(&uart);
Sean Young65ecc9c2012-09-07 19:06:24 +0100471 if (line < 0 || (flags & CIR_PORT))
Bjorn Helgaas9b222712007-02-14 00:33:05 -0800472 return -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473
Bjorn Helgaas9b222712007-02-14 00:33:05 -0800474 pnp_set_drvdata(dev, (void *)((long)line + 1));
475 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476}
477
Bill Pembertonae8d8a12012-11-19 13:26:18 -0500478static void serial_pnp_remove(struct pnp_dev *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479{
480 long line = (long)pnp_get_drvdata(dev);
481 if (line)
482 serial8250_unregister_port(line - 1);
483}
484
Mike Galbraithf29219f2006-12-06 20:39:35 -0800485#ifdef CONFIG_PM
486static int serial_pnp_suspend(struct pnp_dev *dev, pm_message_t state)
487{
488 long line = (long)pnp_get_drvdata(dev);
489
490 if (!line)
491 return -ENODEV;
492 serial8250_suspend_port(line - 1);
493 return 0;
494}
495
496static int serial_pnp_resume(struct pnp_dev *dev)
497{
498 long line = (long)pnp_get_drvdata(dev);
499
500 if (!line)
501 return -ENODEV;
502 serial8250_resume_port(line - 1);
503 return 0;
504}
505#else
506#define serial_pnp_suspend NULL
507#define serial_pnp_resume NULL
508#endif /* CONFIG_PM */
509
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510static struct pnp_driver serial_pnp_driver = {
511 .name = "serial",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700512 .probe = serial_pnp_probe,
Bill Pemberton2d47b712012-11-19 13:21:34 -0500513 .remove = serial_pnp_remove,
Mike Galbraithf29219f2006-12-06 20:39:35 -0800514 .suspend = serial_pnp_suspend,
515 .resume = serial_pnp_resume,
516 .id_table = pnp_dev_table,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700517};
518
Sean Young835d8442012-09-07 19:06:23 +0100519int serial8250_pnp_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520{
521 return pnp_register_driver(&serial_pnp_driver);
522}
523
Sean Young835d8442012-09-07 19:06:23 +0100524void serial8250_pnp_exit(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525{
526 pnp_unregister_driver(&serial_pnp_driver);
527}
528