8250_pnp.c 13 KB

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