keyspan_pda.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * USB Keyspan PDA / Xircom / Entrega Converter driver
  4. *
  5. * Copyright (C) 1999 - 2001 Greg Kroah-Hartman <[email protected]>
  6. * Copyright (C) 1999, 2000 Brian Warner <[email protected]>
  7. * Copyright (C) 2000 Al Borchers <[email protected]>
  8. * Copyright (C) 2020 Johan Hovold <[email protected]>
  9. *
  10. * See Documentation/usb/usb-serial.rst for more information on using this
  11. * driver
  12. */
  13. #include <linux/kernel.h>
  14. #include <linux/errno.h>
  15. #include <linux/slab.h>
  16. #include <linux/tty.h>
  17. #include <linux/tty_driver.h>
  18. #include <linux/tty_flip.h>
  19. #include <linux/module.h>
  20. #include <linux/spinlock.h>
  21. #include <linux/workqueue.h>
  22. #include <linux/uaccess.h>
  23. #include <linux/usb.h>
  24. #include <linux/usb/serial.h>
  25. #include <linux/usb/ezusb.h>
  26. #define DRIVER_AUTHOR "Brian Warner <[email protected]>, Johan Hovold <[email protected]>"
  27. #define DRIVER_DESC "USB Keyspan PDA Converter driver"
  28. #define KEYSPAN_TX_THRESHOLD 128
  29. struct keyspan_pda_private {
  30. int tx_room;
  31. struct work_struct unthrottle_work;
  32. struct usb_serial *serial;
  33. struct usb_serial_port *port;
  34. };
  35. static int keyspan_pda_write_start(struct usb_serial_port *port);
  36. #define KEYSPAN_VENDOR_ID 0x06cd
  37. #define KEYSPAN_PDA_FAKE_ID 0x0103
  38. #define KEYSPAN_PDA_ID 0x0104 /* no clue */
  39. /* For Xircom PGSDB9 and older Entrega version of the same device */
  40. #define XIRCOM_VENDOR_ID 0x085a
  41. #define XIRCOM_FAKE_ID 0x8027
  42. #define XIRCOM_FAKE_ID_2 0x8025 /* "PGMFHUB" serial */
  43. #define ENTREGA_VENDOR_ID 0x1645
  44. #define ENTREGA_FAKE_ID 0x8093
  45. static const struct usb_device_id id_table_combined[] = {
  46. { USB_DEVICE(KEYSPAN_VENDOR_ID, KEYSPAN_PDA_FAKE_ID) },
  47. { USB_DEVICE(XIRCOM_VENDOR_ID, XIRCOM_FAKE_ID) },
  48. { USB_DEVICE(XIRCOM_VENDOR_ID, XIRCOM_FAKE_ID_2) },
  49. { USB_DEVICE(ENTREGA_VENDOR_ID, ENTREGA_FAKE_ID) },
  50. { USB_DEVICE(KEYSPAN_VENDOR_ID, KEYSPAN_PDA_ID) },
  51. { } /* Terminating entry */
  52. };
  53. MODULE_DEVICE_TABLE(usb, id_table_combined);
  54. static const struct usb_device_id id_table_std[] = {
  55. { USB_DEVICE(KEYSPAN_VENDOR_ID, KEYSPAN_PDA_ID) },
  56. { } /* Terminating entry */
  57. };
  58. static const struct usb_device_id id_table_fake[] = {
  59. { USB_DEVICE(KEYSPAN_VENDOR_ID, KEYSPAN_PDA_FAKE_ID) },
  60. { USB_DEVICE(XIRCOM_VENDOR_ID, XIRCOM_FAKE_ID) },
  61. { USB_DEVICE(XIRCOM_VENDOR_ID, XIRCOM_FAKE_ID_2) },
  62. { USB_DEVICE(ENTREGA_VENDOR_ID, ENTREGA_FAKE_ID) },
  63. { } /* Terminating entry */
  64. };
  65. static int keyspan_pda_get_write_room(struct keyspan_pda_private *priv)
  66. {
  67. struct usb_serial_port *port = priv->port;
  68. struct usb_serial *serial = port->serial;
  69. u8 room;
  70. int rc;
  71. rc = usb_control_msg_recv(serial->dev,
  72. 0,
  73. 6, /* write_room */
  74. USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_IN,
  75. 0, /* value: 0 means "remaining room" */
  76. 0, /* index */
  77. &room,
  78. 1,
  79. 2000,
  80. GFP_KERNEL);
  81. if (rc) {
  82. dev_dbg(&port->dev, "roomquery failed: %d\n", rc);
  83. return rc;
  84. }
  85. dev_dbg(&port->dev, "roomquery says %d\n", room);
  86. return room;
  87. }
  88. static void keyspan_pda_request_unthrottle(struct work_struct *work)
  89. {
  90. struct keyspan_pda_private *priv =
  91. container_of(work, struct keyspan_pda_private, unthrottle_work);
  92. struct usb_serial_port *port = priv->port;
  93. struct usb_serial *serial = port->serial;
  94. unsigned long flags;
  95. int result;
  96. dev_dbg(&port->dev, "%s\n", __func__);
  97. /*
  98. * Ask the device to tell us when the tx buffer becomes
  99. * sufficiently empty.
  100. */
  101. result = usb_control_msg(serial->dev,
  102. usb_sndctrlpipe(serial->dev, 0),
  103. 7, /* request_unthrottle */
  104. USB_TYPE_VENDOR | USB_RECIP_INTERFACE
  105. | USB_DIR_OUT,
  106. KEYSPAN_TX_THRESHOLD,
  107. 0, /* index */
  108. NULL,
  109. 0,
  110. 2000);
  111. if (result < 0)
  112. dev_dbg(&serial->dev->dev, "%s - error %d from usb_control_msg\n",
  113. __func__, result);
  114. /*
  115. * Need to check available space after requesting notification in case
  116. * buffer is already empty so that no notification is sent.
  117. */
  118. result = keyspan_pda_get_write_room(priv);
  119. if (result > KEYSPAN_TX_THRESHOLD) {
  120. spin_lock_irqsave(&port->lock, flags);
  121. priv->tx_room = max(priv->tx_room, result);
  122. spin_unlock_irqrestore(&port->lock, flags);
  123. usb_serial_port_softint(port);
  124. }
  125. }
  126. static void keyspan_pda_rx_interrupt(struct urb *urb)
  127. {
  128. struct usb_serial_port *port = urb->context;
  129. unsigned char *data = urb->transfer_buffer;
  130. unsigned int len = urb->actual_length;
  131. int retval;
  132. int status = urb->status;
  133. struct keyspan_pda_private *priv;
  134. unsigned long flags;
  135. priv = usb_get_serial_port_data(port);
  136. switch (status) {
  137. case 0:
  138. /* success */
  139. break;
  140. case -ECONNRESET:
  141. case -ENOENT:
  142. case -ESHUTDOWN:
  143. /* this urb is terminated, clean up */
  144. dev_dbg(&urb->dev->dev, "%s - urb shutting down with status: %d\n", __func__, status);
  145. return;
  146. default:
  147. dev_dbg(&urb->dev->dev, "%s - nonzero urb status received: %d\n", __func__, status);
  148. goto exit;
  149. }
  150. if (len < 1) {
  151. dev_warn(&port->dev, "short message received\n");
  152. goto exit;
  153. }
  154. /* see if the message is data or a status interrupt */
  155. switch (data[0]) {
  156. case 0:
  157. /* rest of message is rx data */
  158. if (len < 2)
  159. break;
  160. tty_insert_flip_string(&port->port, data + 1, len - 1);
  161. tty_flip_buffer_push(&port->port);
  162. break;
  163. case 1:
  164. /* status interrupt */
  165. if (len < 2) {
  166. dev_warn(&port->dev, "short interrupt message received\n");
  167. break;
  168. }
  169. dev_dbg(&port->dev, "rx int, d1=%d\n", data[1]);
  170. switch (data[1]) {
  171. case 1: /* modemline change */
  172. break;
  173. case 2: /* tx unthrottle interrupt */
  174. spin_lock_irqsave(&port->lock, flags);
  175. priv->tx_room = max(priv->tx_room, KEYSPAN_TX_THRESHOLD);
  176. spin_unlock_irqrestore(&port->lock, flags);
  177. keyspan_pda_write_start(port);
  178. usb_serial_port_softint(port);
  179. break;
  180. default:
  181. break;
  182. }
  183. break;
  184. default:
  185. break;
  186. }
  187. exit:
  188. retval = usb_submit_urb(urb, GFP_ATOMIC);
  189. if (retval)
  190. dev_err(&port->dev,
  191. "%s - usb_submit_urb failed with result %d\n",
  192. __func__, retval);
  193. }
  194. static void keyspan_pda_rx_throttle(struct tty_struct *tty)
  195. {
  196. struct usb_serial_port *port = tty->driver_data;
  197. /*
  198. * Stop receiving characters. We just turn off the URB request, and
  199. * let chars pile up in the device. If we're doing hardware
  200. * flowcontrol, the device will signal the other end when its buffer
  201. * fills up. If we're doing XON/XOFF, this would be a good time to
  202. * send an XOFF, although it might make sense to foist that off upon
  203. * the device too.
  204. */
  205. usb_kill_urb(port->interrupt_in_urb);
  206. }
  207. static void keyspan_pda_rx_unthrottle(struct tty_struct *tty)
  208. {
  209. struct usb_serial_port *port = tty->driver_data;
  210. /* just restart the receive interrupt URB */
  211. if (usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL))
  212. dev_dbg(&port->dev, "usb_submit_urb(read urb) failed\n");
  213. }
  214. static speed_t keyspan_pda_setbaud(struct usb_serial *serial, speed_t baud)
  215. {
  216. int rc;
  217. int bindex;
  218. switch (baud) {
  219. case 110:
  220. bindex = 0;
  221. break;
  222. case 300:
  223. bindex = 1;
  224. break;
  225. case 1200:
  226. bindex = 2;
  227. break;
  228. case 2400:
  229. bindex = 3;
  230. break;
  231. case 4800:
  232. bindex = 4;
  233. break;
  234. case 9600:
  235. bindex = 5;
  236. break;
  237. case 19200:
  238. bindex = 6;
  239. break;
  240. case 38400:
  241. bindex = 7;
  242. break;
  243. case 57600:
  244. bindex = 8;
  245. break;
  246. case 115200:
  247. bindex = 9;
  248. break;
  249. default:
  250. bindex = 5; /* Default to 9600 */
  251. baud = 9600;
  252. }
  253. rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
  254. 0, /* set baud */
  255. USB_TYPE_VENDOR
  256. | USB_RECIP_INTERFACE
  257. | USB_DIR_OUT, /* type */
  258. bindex, /* value */
  259. 0, /* index */
  260. NULL, /* &data */
  261. 0, /* size */
  262. 2000); /* timeout */
  263. if (rc < 0)
  264. return 0;
  265. return baud;
  266. }
  267. static void keyspan_pda_break_ctl(struct tty_struct *tty, int break_state)
  268. {
  269. struct usb_serial_port *port = tty->driver_data;
  270. struct usb_serial *serial = port->serial;
  271. int value;
  272. int result;
  273. if (break_state == -1)
  274. value = 1; /* start break */
  275. else
  276. value = 0; /* clear break */
  277. result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
  278. 4, /* set break */
  279. USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT,
  280. value, 0, NULL, 0, 2000);
  281. if (result < 0)
  282. dev_dbg(&port->dev, "%s - error %d from usb_control_msg\n",
  283. __func__, result);
  284. }
  285. static void keyspan_pda_set_termios(struct tty_struct *tty,
  286. struct usb_serial_port *port,
  287. const struct ktermios *old_termios)
  288. {
  289. struct usb_serial *serial = port->serial;
  290. speed_t speed;
  291. /*
  292. * cflag specifies lots of stuff: number of stop bits, parity, number
  293. * of data bits, baud. What can the device actually handle?:
  294. * CSTOPB (1 stop bit or 2)
  295. * PARENB (parity)
  296. * CSIZE (5bit .. 8bit)
  297. * There is minimal hw support for parity (a PSW bit seems to hold the
  298. * parity of whatever is in the accumulator). The UART either deals
  299. * with 10 bits (start, 8 data, stop) or 11 bits (start, 8 data,
  300. * 1 special, stop). So, with firmware changes, we could do:
  301. * 8N1: 10 bit
  302. * 8N2: 11 bit, extra bit always (mark?)
  303. * 8[EOMS]1: 11 bit, extra bit is parity
  304. * 7[EOMS]1: 10 bit, b0/b7 is parity
  305. * 7[EOMS]2: 11 bit, b0/b7 is parity, extra bit always (mark?)
  306. *
  307. * HW flow control is dictated by the tty->termios.c_cflags & CRTSCTS
  308. * bit.
  309. *
  310. * For now, just do baud.
  311. */
  312. speed = tty_get_baud_rate(tty);
  313. speed = keyspan_pda_setbaud(serial, speed);
  314. if (speed == 0) {
  315. dev_dbg(&port->dev, "can't handle requested baud rate\n");
  316. /* It hasn't changed so.. */
  317. speed = tty_termios_baud_rate(old_termios);
  318. }
  319. /*
  320. * Only speed can change so copy the old h/w parameters then encode
  321. * the new speed.
  322. */
  323. tty_termios_copy_hw(&tty->termios, old_termios);
  324. tty_encode_baud_rate(tty, speed, speed);
  325. }
  326. /*
  327. * Modem control pins: DTR and RTS are outputs and can be controlled.
  328. * DCD, RI, DSR, CTS are inputs and can be read. All outputs can also be
  329. * read. The byte passed is: DTR(b7) DCD RI DSR CTS RTS(b2) unused unused.
  330. */
  331. static int keyspan_pda_get_modem_info(struct usb_serial *serial,
  332. unsigned char *value)
  333. {
  334. int rc;
  335. u8 data;
  336. rc = usb_control_msg_recv(serial->dev, 0,
  337. 3, /* get pins */
  338. USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_IN,
  339. 0,
  340. 0,
  341. &data,
  342. 1,
  343. 2000,
  344. GFP_KERNEL);
  345. if (rc == 0)
  346. *value = data;
  347. return rc;
  348. }
  349. static int keyspan_pda_set_modem_info(struct usb_serial *serial,
  350. unsigned char value)
  351. {
  352. int rc;
  353. rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
  354. 3, /* set pins */
  355. USB_TYPE_VENDOR|USB_RECIP_INTERFACE|USB_DIR_OUT,
  356. value, 0, NULL, 0, 2000);
  357. return rc;
  358. }
  359. static int keyspan_pda_tiocmget(struct tty_struct *tty)
  360. {
  361. struct usb_serial_port *port = tty->driver_data;
  362. struct usb_serial *serial = port->serial;
  363. int rc;
  364. unsigned char status;
  365. int value;
  366. rc = keyspan_pda_get_modem_info(serial, &status);
  367. if (rc < 0)
  368. return rc;
  369. value = ((status & BIT(7)) ? TIOCM_DTR : 0) |
  370. ((status & BIT(6)) ? TIOCM_CAR : 0) |
  371. ((status & BIT(5)) ? TIOCM_RNG : 0) |
  372. ((status & BIT(4)) ? TIOCM_DSR : 0) |
  373. ((status & BIT(3)) ? TIOCM_CTS : 0) |
  374. ((status & BIT(2)) ? TIOCM_RTS : 0);
  375. return value;
  376. }
  377. static int keyspan_pda_tiocmset(struct tty_struct *tty,
  378. unsigned int set, unsigned int clear)
  379. {
  380. struct usb_serial_port *port = tty->driver_data;
  381. struct usb_serial *serial = port->serial;
  382. int rc;
  383. unsigned char status;
  384. rc = keyspan_pda_get_modem_info(serial, &status);
  385. if (rc < 0)
  386. return rc;
  387. if (set & TIOCM_RTS)
  388. status |= BIT(2);
  389. if (set & TIOCM_DTR)
  390. status |= BIT(7);
  391. if (clear & TIOCM_RTS)
  392. status &= ~BIT(2);
  393. if (clear & TIOCM_DTR)
  394. status &= ~BIT(7);
  395. rc = keyspan_pda_set_modem_info(serial, status);
  396. return rc;
  397. }
  398. static int keyspan_pda_write_start(struct usb_serial_port *port)
  399. {
  400. struct keyspan_pda_private *priv = usb_get_serial_port_data(port);
  401. unsigned long flags;
  402. struct urb *urb;
  403. int count;
  404. int room;
  405. int rc;
  406. /*
  407. * Guess how much room is left in the device's ring buffer. If our
  408. * write will result in no room left, ask the device to give us an
  409. * interrupt when the room available rises above a threshold but also
  410. * query how much room is currently available (in case our guess was
  411. * too conservative and the buffer is already empty when the
  412. * unthrottle work is scheduled).
  413. */
  414. /*
  415. * We might block because of:
  416. * the TX urb is in-flight (wait until it completes)
  417. * the device is full (wait until it says there is room)
  418. */
  419. spin_lock_irqsave(&port->lock, flags);
  420. room = priv->tx_room;
  421. count = kfifo_len(&port->write_fifo);
  422. if (!test_bit(0, &port->write_urbs_free) || count == 0 || room == 0) {
  423. spin_unlock_irqrestore(&port->lock, flags);
  424. return 0;
  425. }
  426. __clear_bit(0, &port->write_urbs_free);
  427. if (count > room)
  428. count = room;
  429. if (count > port->bulk_out_size)
  430. count = port->bulk_out_size;
  431. urb = port->write_urb;
  432. count = kfifo_out(&port->write_fifo, urb->transfer_buffer, count);
  433. urb->transfer_buffer_length = count;
  434. port->tx_bytes += count;
  435. priv->tx_room -= count;
  436. spin_unlock_irqrestore(&port->lock, flags);
  437. dev_dbg(&port->dev, "%s - count = %d, txroom = %d\n", __func__, count, room);
  438. rc = usb_submit_urb(urb, GFP_ATOMIC);
  439. if (rc) {
  440. dev_dbg(&port->dev, "usb_submit_urb(write bulk) failed\n");
  441. spin_lock_irqsave(&port->lock, flags);
  442. port->tx_bytes -= count;
  443. priv->tx_room = max(priv->tx_room, room + count);
  444. __set_bit(0, &port->write_urbs_free);
  445. spin_unlock_irqrestore(&port->lock, flags);
  446. return rc;
  447. }
  448. if (count == room)
  449. schedule_work(&priv->unthrottle_work);
  450. return count;
  451. }
  452. static void keyspan_pda_write_bulk_callback(struct urb *urb)
  453. {
  454. struct usb_serial_port *port = urb->context;
  455. unsigned long flags;
  456. spin_lock_irqsave(&port->lock, flags);
  457. port->tx_bytes -= urb->transfer_buffer_length;
  458. __set_bit(0, &port->write_urbs_free);
  459. spin_unlock_irqrestore(&port->lock, flags);
  460. keyspan_pda_write_start(port);
  461. usb_serial_port_softint(port);
  462. }
  463. static int keyspan_pda_write(struct tty_struct *tty, struct usb_serial_port *port,
  464. const unsigned char *buf, int count)
  465. {
  466. int rc;
  467. dev_dbg(&port->dev, "%s - count = %d\n", __func__, count);
  468. if (!count)
  469. return 0;
  470. count = kfifo_in_locked(&port->write_fifo, buf, count, &port->lock);
  471. rc = keyspan_pda_write_start(port);
  472. if (rc)
  473. return rc;
  474. return count;
  475. }
  476. static void keyspan_pda_dtr_rts(struct usb_serial_port *port, int on)
  477. {
  478. struct usb_serial *serial = port->serial;
  479. if (on)
  480. keyspan_pda_set_modem_info(serial, BIT(7) | BIT(2));
  481. else
  482. keyspan_pda_set_modem_info(serial, 0);
  483. }
  484. static int keyspan_pda_open(struct tty_struct *tty,
  485. struct usb_serial_port *port)
  486. {
  487. struct keyspan_pda_private *priv = usb_get_serial_port_data(port);
  488. int rc;
  489. /* find out how much room is in the Tx ring */
  490. rc = keyspan_pda_get_write_room(priv);
  491. if (rc < 0)
  492. return rc;
  493. spin_lock_irq(&port->lock);
  494. priv->tx_room = rc;
  495. spin_unlock_irq(&port->lock);
  496. rc = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
  497. if (rc) {
  498. dev_dbg(&port->dev, "%s - usb_submit_urb(read int) failed\n", __func__);
  499. return rc;
  500. }
  501. return 0;
  502. }
  503. static void keyspan_pda_close(struct usb_serial_port *port)
  504. {
  505. struct keyspan_pda_private *priv = usb_get_serial_port_data(port);
  506. /*
  507. * Stop the interrupt URB first as its completion handler may submit
  508. * the write URB.
  509. */
  510. usb_kill_urb(port->interrupt_in_urb);
  511. usb_kill_urb(port->write_urb);
  512. cancel_work_sync(&priv->unthrottle_work);
  513. spin_lock_irq(&port->lock);
  514. kfifo_reset(&port->write_fifo);
  515. spin_unlock_irq(&port->lock);
  516. }
  517. /* download the firmware to a "fake" device (pre-renumeration) */
  518. static int keyspan_pda_fake_startup(struct usb_serial *serial)
  519. {
  520. unsigned int vid = le16_to_cpu(serial->dev->descriptor.idVendor);
  521. const char *fw_name;
  522. /* download the firmware here ... */
  523. ezusb_fx1_set_reset(serial->dev, 1);
  524. switch (vid) {
  525. case KEYSPAN_VENDOR_ID:
  526. fw_name = "keyspan_pda/keyspan_pda.fw";
  527. break;
  528. case XIRCOM_VENDOR_ID:
  529. case ENTREGA_VENDOR_ID:
  530. fw_name = "keyspan_pda/xircom_pgs.fw";
  531. break;
  532. default:
  533. dev_err(&serial->dev->dev, "%s: unknown vendor, aborting.\n",
  534. __func__);
  535. return -ENODEV;
  536. }
  537. if (ezusb_fx1_ihex_firmware_download(serial->dev, fw_name) < 0) {
  538. dev_err(&serial->dev->dev, "failed to load firmware \"%s\"\n",
  539. fw_name);
  540. return -ENOENT;
  541. }
  542. /*
  543. * After downloading firmware renumeration will occur in a moment and
  544. * the new device will bind to the real driver.
  545. */
  546. /* We want this device to fail to have a driver assigned to it. */
  547. return 1;
  548. }
  549. MODULE_FIRMWARE("keyspan_pda/keyspan_pda.fw");
  550. MODULE_FIRMWARE("keyspan_pda/xircom_pgs.fw");
  551. static int keyspan_pda_port_probe(struct usb_serial_port *port)
  552. {
  553. struct keyspan_pda_private *priv;
  554. priv = kmalloc(sizeof(struct keyspan_pda_private), GFP_KERNEL);
  555. if (!priv)
  556. return -ENOMEM;
  557. INIT_WORK(&priv->unthrottle_work, keyspan_pda_request_unthrottle);
  558. priv->port = port;
  559. usb_set_serial_port_data(port, priv);
  560. return 0;
  561. }
  562. static void keyspan_pda_port_remove(struct usb_serial_port *port)
  563. {
  564. struct keyspan_pda_private *priv;
  565. priv = usb_get_serial_port_data(port);
  566. kfree(priv);
  567. }
  568. static struct usb_serial_driver keyspan_pda_fake_device = {
  569. .driver = {
  570. .owner = THIS_MODULE,
  571. .name = "keyspan_pda_pre",
  572. },
  573. .description = "Keyspan PDA - (prerenumeration)",
  574. .id_table = id_table_fake,
  575. .num_ports = 1,
  576. .attach = keyspan_pda_fake_startup,
  577. };
  578. static struct usb_serial_driver keyspan_pda_device = {
  579. .driver = {
  580. .owner = THIS_MODULE,
  581. .name = "keyspan_pda",
  582. },
  583. .description = "Keyspan PDA",
  584. .id_table = id_table_std,
  585. .num_ports = 1,
  586. .num_bulk_out = 1,
  587. .num_interrupt_in = 1,
  588. .dtr_rts = keyspan_pda_dtr_rts,
  589. .open = keyspan_pda_open,
  590. .close = keyspan_pda_close,
  591. .write = keyspan_pda_write,
  592. .write_bulk_callback = keyspan_pda_write_bulk_callback,
  593. .read_int_callback = keyspan_pda_rx_interrupt,
  594. .throttle = keyspan_pda_rx_throttle,
  595. .unthrottle = keyspan_pda_rx_unthrottle,
  596. .set_termios = keyspan_pda_set_termios,
  597. .break_ctl = keyspan_pda_break_ctl,
  598. .tiocmget = keyspan_pda_tiocmget,
  599. .tiocmset = keyspan_pda_tiocmset,
  600. .port_probe = keyspan_pda_port_probe,
  601. .port_remove = keyspan_pda_port_remove,
  602. };
  603. static struct usb_serial_driver * const serial_drivers[] = {
  604. &keyspan_pda_device,
  605. &keyspan_pda_fake_device,
  606. NULL
  607. };
  608. module_usb_serial_driver(serial_drivers, id_table_combined);
  609. MODULE_AUTHOR(DRIVER_AUTHOR);
  610. MODULE_DESCRIPTION(DRIVER_DESC);
  611. MODULE_LICENSE("GPL");