8250_pnp.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  1. /*
  2. * linux/drivers/char/8250_pnp.c
  3. *
  4. * Probe module for 8250/16550-type ISAPNP serial ports.
  5. *
  6. * Based on drivers/char/serial.c, by Linus Torvalds, Theodore Ts'o.
  7. *
  8. * Copyright (C) 2001 Russell King, All Rights Reserved.
  9. *
  10. * Ported to the Linux PnP Layer - (C) Adam Belay.
  11. *
  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.
  15. */
  16. #include <linux/module.h>
  17. #include <linux/init.h>
  18. #include <linux/pci.h>
  19. #include <linux/pnp.h>
  20. #include <linux/string.h>
  21. #include <linux/kernel.h>
  22. #include <linux/serial_core.h>
  23. #include <linux/bitops.h>
  24. #include <asm/byteorder.h>
  25. #include "8250.h"
  26. #define UNKNOWN_DEV 0x3000
  27. static const struct pnp_device_id pnp_dev_table[] = {
  28. /* Archtek America Corp. */
  29. /* Archtek SmartLink Modem 3334BT Plug & Play */
  30. { "AAC000F", 0 },
  31. /* Anchor Datacomm BV */
  32. /* SXPro 144 External Data Fax Modem Plug & Play */
  33. { "ADC0001", 0 },
  34. /* SXPro 288 External Data Fax Modem Plug & Play */
  35. { "ADC0002", 0 },
  36. /* PROLiNK 1456VH ISA PnP K56flex Fax Modem */
  37. { "AEI0250", 0 },
  38. /* Actiontec ISA PNP 56K X2 Fax Modem */
  39. { "AEI1240", 0 },
  40. /* Rockwell 56K ACF II Fax+Data+Voice Modem */
  41. { "AKY1021", 0 /*SPCI_FL_NO_SHIRQ*/ },
  42. /* AZT3005 PnP SOUND DEVICE */
  43. { "AZT4001", 0 },
  44. /* Best Data Products Inc. Smart One 336F PnP Modem */
  45. { "BDP3336", 0 },
  46. /* Boca Research */
  47. /* Boca Complete Ofc Communicator 14.4 Data-FAX */
  48. { "BRI0A49", 0 },
  49. /* Boca Research 33,600 ACF Modem */
  50. { "BRI1400", 0 },
  51. /* Boca 33.6 Kbps Internal FD34FSVD */
  52. { "BRI3400", 0 },
  53. /* Boca 33.6 Kbps Internal FD34FSVD */
  54. { "BRI0A49", 0 },
  55. /* Best Data Products Inc. Smart One 336F PnP Modem */
  56. { "BDP3336", 0 },
  57. /* Computer Peripherals Inc */
  58. /* EuroViVa CommCenter-33.6 SP PnP */
  59. { "CPI4050", 0 },
  60. /* Creative Labs */
  61. /* Creative Labs Phone Blaster 28.8 DSVD PnP Voice */
  62. { "CTL3001", 0 },
  63. /* Creative Labs Modem Blaster 28.8 DSVD PnP Voice */
  64. { "CTL3011", 0 },
  65. /* Davicom ISA 33.6K Modem */
  66. { "DAV0336", 0 },
  67. /* Creative */
  68. /* Creative Modem Blaster Flash56 DI5601-1 */
  69. { "DMB1032", 0 },
  70. /* Creative Modem Blaster V.90 DI5660 */
  71. { "DMB2001", 0 },
  72. /* E-Tech */
  73. /* E-Tech CyberBULLET PC56RVP */
  74. { "ETT0002", 0 },
  75. /* FUJITSU */
  76. /* Fujitsu 33600 PnP-I2 R Plug & Play */
  77. { "FUJ0202", 0 },
  78. /* Fujitsu FMV-FX431 Plug & Play */
  79. { "FUJ0205", 0 },
  80. /* Fujitsu 33600 PnP-I4 R Plug & Play */
  81. { "FUJ0206", 0 },
  82. /* Fujitsu Fax Voice 33600 PNP-I5 R Plug & Play */
  83. { "FUJ0209", 0 },
  84. /* Archtek America Corp. */
  85. /* Archtek SmartLink Modem 3334BT Plug & Play */
  86. { "GVC000F", 0 },
  87. /* Archtek SmartLink Modem 3334BRV 33.6K Data Fax Voice */
  88. { "GVC0303", 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. /* Rockwell 28.8 */
  251. { "ROK4120", 0 },
  252. /* Viking Components, Inc */
  253. /* Viking 28.8 INTERNAL Fax+Data+Voice PnP */
  254. { "ROK4920", 0 },
  255. /* Rockwell */
  256. /* British Telecom */
  257. /* Modular Technology */
  258. /* Rockwell 33.6 DPF External PnP */
  259. /* BT Prologue 33.6 External PnP */
  260. /* Modular Technology 33.6 External PnP */
  261. { "RSS00A0", 0 },
  262. /* Viking 56K FAX INT */
  263. { "RSS0262", 0 },
  264. /* K56 par,VV,Voice,Speakphone,AudioSpan,PnP */
  265. { "RSS0250", 0 },
  266. /* SupraExpress 28.8 Data/Fax PnP modem */
  267. { "SUP1310", 0 },
  268. /* SupraExpress 33.6 Data/Fax PnP modem */
  269. { "SUP1421", 0 },
  270. /* SupraExpress 33.6 Data/Fax PnP modem */
  271. { "SUP1590", 0 },
  272. /* SupraExpress 336i Sp ASVD */
  273. { "SUP1620", 0 },
  274. /* SupraExpress 33.6 Data/Fax PnP modem */
  275. { "SUP1760", 0 },
  276. /* SupraExpress 56i Sp Intl */
  277. { "SUP2171", 0 },
  278. /* Phoebe Micro */
  279. /* Phoebe Micro 33.6 Data Fax 1433VQH Plug & Play */
  280. { "TEX0011", 0 },
  281. /* Archtek America Corp. */
  282. /* Archtek SmartLink Modem 3334BT Plug & Play */
  283. { "UAC000F", 0 },
  284. /* 3Com Corp. */
  285. /* Gateway Telepath IIvi 33.6 */
  286. { "USR0000", 0 },
  287. /* U.S. Robotics Sporster 33.6K Fax INT PnP */
  288. { "USR0002", 0 },
  289. /* Sportster Vi 14.4 PnP FAX Voicemail */
  290. { "USR0004", 0 },
  291. /* U.S. Robotics 33.6K Voice INT PnP */
  292. { "USR0006", 0 },
  293. /* U.S. Robotics 33.6K Voice EXT PnP */
  294. { "USR0007", 0 },
  295. /* U.S. Robotics Courier V.Everything INT PnP */
  296. { "USR0009", 0 },
  297. /* U.S. Robotics 33.6K Voice INT PnP */
  298. { "USR2002", 0 },
  299. /* U.S. Robotics 56K Voice INT PnP */
  300. { "USR2070", 0 },
  301. /* U.S. Robotics 56K Voice EXT PnP */
  302. { "USR2080", 0 },
  303. /* U.S. Robotics 56K FAX INT */
  304. { "USR3031", 0 },
  305. /* U.S. Robotics 56K FAX INT */
  306. { "USR3050", 0 },
  307. /* U.S. Robotics 56K Voice INT PnP */
  308. { "USR3070", 0 },
  309. /* U.S. Robotics 56K Voice EXT PnP */
  310. { "USR3080", 0 },
  311. /* U.S. Robotics 56K Voice INT PnP */
  312. { "USR3090", 0 },
  313. /* U.S. Robotics 56K Message */
  314. { "USR9100", 0 },
  315. /* U.S. Robotics 56K FAX EXT PnP*/
  316. { "USR9160", 0 },
  317. /* U.S. Robotics 56K FAX INT PnP*/
  318. { "USR9170", 0 },
  319. /* U.S. Robotics 56K Voice EXT PnP*/
  320. { "USR9180", 0 },
  321. /* U.S. Robotics 56K Voice INT PnP*/
  322. { "USR9190", 0 },
  323. /* Wacom tablets */
  324. { "WACF004", 0 },
  325. { "WACF005", 0 },
  326. { "WACF006", 0 },
  327. { "WACF007", 0 },
  328. { "WACF008", 0 },
  329. /* Compaq touchscreen */
  330. { "FPI2002", 0 },
  331. /* Fujitsu Stylistic touchscreens */
  332. { "FUJ02B2", 0 },
  333. { "FUJ02B3", 0 },
  334. /* Fujitsu Stylistic LT touchscreens */
  335. { "FUJ02B4", 0 },
  336. /* Passive Fujitsu Stylistic touchscreens */
  337. { "FUJ02B6", 0 },
  338. { "FUJ02B7", 0 },
  339. { "FUJ02B8", 0 },
  340. { "FUJ02B9", 0 },
  341. { "FUJ02BC", 0 },
  342. /* Fujitsu Wacom Tablet PC devices */
  343. { "FUJ02E5", 0 },
  344. { "FUJ02E6", 0 },
  345. /*
  346. * LG C1 EXPRESS DUAL (C1-PB11A3) touch screen (actually a FUJ02E6 in
  347. * disguise)
  348. */
  349. { "LTS0001", 0 },
  350. /* Rockwell's (PORALiNK) 33600 INT PNP */
  351. { "WCI0003", 0 },
  352. /* Unkown PnP modems */
  353. { "PNPCXXX", UNKNOWN_DEV },
  354. /* More unkown PnP modems */
  355. { "PNPDXXX", UNKNOWN_DEV },
  356. { "", 0 }
  357. };
  358. MODULE_DEVICE_TABLE(pnp, pnp_dev_table);
  359. static char *modem_names[] __devinitdata = {
  360. "MODEM", "Modem", "modem", "FAX", "Fax", "fax",
  361. "56K", "56k", "K56", "33.6", "28.8", "14.4",
  362. "33,600", "28,800", "14,400", "33.600", "28.800", "14.400",
  363. "33600", "28800", "14400", "V.90", "V.34", "V.32", NULL
  364. };
  365. static int __devinit check_name(char *name)
  366. {
  367. char **tmp;
  368. for (tmp = modem_names; *tmp; tmp++)
  369. if (strstr(name, *tmp))
  370. return 1;
  371. return 0;
  372. }
  373. static int __devinit check_resources(struct pnp_dev *dev)
  374. {
  375. resource_size_t base[] = {0x2f8, 0x3f8, 0x2e8, 0x3e8};
  376. int i;
  377. for (i = 0; i < ARRAY_SIZE(base); i++) {
  378. if (pnp_possible_config(dev, IORESOURCE_IO, base[i], 8))
  379. return 1;
  380. }
  381. return 0;
  382. }
  383. /*
  384. * Given a complete unknown PnP device, try to use some heuristics to
  385. * detect modems. Currently use such heuristic set:
  386. * - dev->name or dev->bus->name must contain "modem" substring;
  387. * - device must have only one IO region (8 byte long) with base address
  388. * 0x2e8, 0x3e8, 0x2f8 or 0x3f8.
  389. *
  390. * Such detection looks very ugly, but can detect at least some of numerous
  391. * PnP modems, alternatively we must hardcode all modems in pnp_devices[]
  392. * table.
  393. */
  394. static int __devinit serial_pnp_guess_board(struct pnp_dev *dev, int *flags)
  395. {
  396. if (!(check_name(pnp_dev_name(dev)) ||
  397. (dev->card && check_name(dev->card->name))))
  398. return -ENODEV;
  399. if (check_resources(dev))
  400. return 0;
  401. return -ENODEV;
  402. }
  403. static int __devinit
  404. serial_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
  405. {
  406. struct uart_port port;
  407. 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;
  412. }
  413. memset(&port, 0, sizeof(struct uart_port));
  414. if (pnp_irq_valid(dev, 0))
  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;
  425. #ifdef SERIAL_DEBUG_PNP
  426. printk(KERN_DEBUG
  427. "Setup PNP port: port %x, mem 0x%lx, irq %d, type %d\n",
  428. port.iobase, port.mapbase, port.irq, port.iotype);
  429. #endif
  430. port.flags |= UPF_SKIP_TEST | UPF_BOOT_AUTOCONF;
  431. if (pnp_irq_flags(dev, 0) & IORESOURCE_IRQ_SHAREABLE)
  432. port.flags |= UPF_SHARE_IRQ;
  433. port.uartclk = 1843200;
  434. port.dev = &dev->dev;
  435. line = serial8250_register_port(&port);
  436. if (line < 0)
  437. return -ENODEV;
  438. pnp_set_drvdata(dev, (void *)((long)line + 1));
  439. return 0;
  440. }
  441. static void __devexit serial_pnp_remove(struct pnp_dev *dev)
  442. {
  443. long line = (long)pnp_get_drvdata(dev);
  444. if (line)
  445. serial8250_unregister_port(line - 1);
  446. }
  447. #ifdef CONFIG_PM
  448. static int serial_pnp_suspend(struct pnp_dev *dev, pm_message_t state)
  449. {
  450. long line = (long)pnp_get_drvdata(dev);
  451. if (!line)
  452. return -ENODEV;
  453. serial8250_suspend_port(line - 1);
  454. return 0;
  455. }
  456. static int serial_pnp_resume(struct pnp_dev *dev)
  457. {
  458. long line = (long)pnp_get_drvdata(dev);
  459. if (!line)
  460. return -ENODEV;
  461. serial8250_resume_port(line - 1);
  462. return 0;
  463. }
  464. #else
  465. #define serial_pnp_suspend NULL
  466. #define serial_pnp_resume NULL
  467. #endif /* CONFIG_PM */
  468. static struct pnp_driver serial_pnp_driver = {
  469. .name = "serial",
  470. .probe = serial_pnp_probe,
  471. .remove = __devexit_p(serial_pnp_remove),
  472. .suspend = serial_pnp_suspend,
  473. .resume = serial_pnp_resume,
  474. .id_table = pnp_dev_table,
  475. };
  476. static int __init serial8250_pnp_init(void)
  477. {
  478. return pnp_register_driver(&serial_pnp_driver);
  479. }
  480. static void __exit serial8250_pnp_exit(void)
  481. {
  482. pnp_unregister_driver(&serial_pnp_driver);
  483. }
  484. module_init(serial8250_pnp_init);
  485. module_exit(serial8250_pnp_exit);
  486. MODULE_LICENSE("GPL");
  487. MODULE_DESCRIPTION("Generic 8250/16x50 PnP serial driver");