ch341.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright 2007, Frank A Kingswood <frank@kingswood-consulting.co.uk>
  4. * Copyright 2007, Werner Cornelius <werner@cornelius-consult.de>
  5. * Copyright 2009, Boris Hajduk <boris@hajduk.org>
  6. *
  7. * ch341.c implements a serial port driver for the Winchiphead CH341.
  8. *
  9. * The CH341 device can be used to implement an RS232 asynchronous
  10. * serial port, an IEEE-1284 parallel printer port or a memory-like
  11. * interface. In all cases the CH341 supports an I2C interface as well.
  12. * This driver only supports the asynchronous serial interface.
  13. */
  14. #include <linux/kernel.h>
  15. #include <linux/tty.h>
  16. #include <linux/module.h>
  17. #include <linux/slab.h>
  18. #include <linux/usb.h>
  19. #include <linux/usb/serial.h>
  20. #include <linux/serial.h>
  21. #include <asm/unaligned.h>
  22. #define DEFAULT_BAUD_RATE 9600
  23. #define DEFAULT_TIMEOUT 1000
  24. /* flags for IO-Bits */
  25. #define CH341_BIT_RTS (1 << 6)
  26. #define CH341_BIT_DTR (1 << 5)
  27. /******************************/
  28. /* interrupt pipe definitions */
  29. /******************************/
  30. /* always 4 interrupt bytes */
  31. /* first irq byte normally 0x08 */
  32. /* second irq byte base 0x7d + below */
  33. /* third irq byte base 0x94 + below */
  34. /* fourth irq byte normally 0xee */
  35. /* second interrupt byte */
  36. #define CH341_MULT_STAT 0x04 /* multiple status since last interrupt event */
  37. /* status returned in third interrupt answer byte, inverted in data
  38. from irq */
  39. #define CH341_BIT_CTS 0x01
  40. #define CH341_BIT_DSR 0x02
  41. #define CH341_BIT_RI 0x04
  42. #define CH341_BIT_DCD 0x08
  43. #define CH341_BITS_MODEM_STAT 0x0f /* all bits */
  44. /*******************************/
  45. /* baudrate calculation factor */
  46. /*******************************/
  47. #define CH341_BAUDBASE_FACTOR 1532620800
  48. #define CH341_BAUDBASE_DIVMAX 3
  49. /* Break support - the information used to implement this was gleaned from
  50. * the Net/FreeBSD uchcom.c driver by Takanori Watanabe. Domo arigato.
  51. */
  52. #define CH341_REQ_READ_VERSION 0x5F
  53. #define CH341_REQ_WRITE_REG 0x9A
  54. #define CH341_REQ_READ_REG 0x95
  55. #define CH341_REQ_SERIAL_INIT 0xA1
  56. #define CH341_REQ_MODEM_CTRL 0xA4
  57. #define CH341_REG_BREAK 0x05
  58. #define CH341_REG_LCR 0x18
  59. #define CH341_NBREAK_BITS 0x01
  60. #define CH341_LCR_ENABLE_RX 0x80
  61. #define CH341_LCR_ENABLE_TX 0x40
  62. #define CH341_LCR_MARK_SPACE 0x20
  63. #define CH341_LCR_PAR_EVEN 0x10
  64. #define CH341_LCR_ENABLE_PAR 0x08
  65. #define CH341_LCR_STOP_BITS_2 0x04
  66. #define CH341_LCR_CS8 0x03
  67. #define CH341_LCR_CS7 0x02
  68. #define CH341_LCR_CS6 0x01
  69. #define CH341_LCR_CS5 0x00
  70. static const struct usb_device_id id_table[] = {
  71. { USB_DEVICE(0x4348, 0x5523) },
  72. { USB_DEVICE(0x1a86, 0x7523) },
  73. { USB_DEVICE(0x1a86, 0x5523) },
  74. { },
  75. };
  76. MODULE_DEVICE_TABLE(usb, id_table);
  77. struct ch341_private {
  78. spinlock_t lock; /* access lock */
  79. unsigned baud_rate; /* set baud rate */
  80. u8 mcr;
  81. u8 msr;
  82. u8 lcr;
  83. };
  84. static void ch341_set_termios(struct tty_struct *tty,
  85. struct usb_serial_port *port,
  86. struct ktermios *old_termios);
  87. static int ch341_control_out(struct usb_device *dev, u8 request,
  88. u16 value, u16 index)
  89. {
  90. int r;
  91. dev_dbg(&dev->dev, "%s - (%02x,%04x,%04x)\n", __func__,
  92. request, value, index);
  93. r = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), request,
  94. USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
  95. value, index, NULL, 0, DEFAULT_TIMEOUT);
  96. if (r < 0)
  97. dev_err(&dev->dev, "failed to send control message: %d\n", r);
  98. return r;
  99. }
  100. static int ch341_control_in(struct usb_device *dev,
  101. u8 request, u16 value, u16 index,
  102. char *buf, unsigned bufsize)
  103. {
  104. int r;
  105. dev_dbg(&dev->dev, "%s - (%02x,%04x,%04x,%u)\n", __func__,
  106. request, value, index, bufsize);
  107. r = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), request,
  108. USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
  109. value, index, buf, bufsize, DEFAULT_TIMEOUT);
  110. if (r < (int)bufsize) {
  111. if (r >= 0) {
  112. dev_err(&dev->dev,
  113. "short control message received (%d < %u)\n",
  114. r, bufsize);
  115. r = -EIO;
  116. }
  117. dev_err(&dev->dev, "failed to receive control message: %d\n",
  118. r);
  119. return r;
  120. }
  121. return 0;
  122. }
  123. static int ch341_set_baudrate_lcr(struct usb_device *dev,
  124. struct ch341_private *priv, u8 lcr)
  125. {
  126. short a;
  127. int r;
  128. unsigned long factor;
  129. short divisor;
  130. if (!priv->baud_rate)
  131. return -EINVAL;
  132. factor = (CH341_BAUDBASE_FACTOR / priv->baud_rate);
  133. divisor = CH341_BAUDBASE_DIVMAX;
  134. while ((factor > 0xfff0) && divisor) {
  135. factor >>= 3;
  136. divisor--;
  137. }
  138. if (factor > 0xfff0)
  139. return -EINVAL;
  140. factor = 0x10000 - factor;
  141. a = (factor & 0xff00) | divisor;
  142. /*
  143. * CH341A buffers data until a full endpoint-size packet (32 bytes)
  144. * has been received unless bit 7 is set.
  145. */
  146. a |= BIT(7);
  147. r = ch341_control_out(dev, CH341_REQ_WRITE_REG, 0x1312, a);
  148. if (r)
  149. return r;
  150. r = ch341_control_out(dev, CH341_REQ_WRITE_REG, 0x2518, lcr);
  151. if (r)
  152. return r;
  153. return r;
  154. }
  155. static int ch341_set_handshake(struct usb_device *dev, u8 control)
  156. {
  157. return ch341_control_out(dev, CH341_REQ_MODEM_CTRL, ~control, 0);
  158. }
  159. static int ch341_get_status(struct usb_device *dev, struct ch341_private *priv)
  160. {
  161. const unsigned int size = 2;
  162. char *buffer;
  163. int r;
  164. unsigned long flags;
  165. buffer = kmalloc(size, GFP_KERNEL);
  166. if (!buffer)
  167. return -ENOMEM;
  168. r = ch341_control_in(dev, CH341_REQ_READ_REG, 0x0706, 0, buffer, size);
  169. if (r < 0)
  170. goto out;
  171. spin_lock_irqsave(&priv->lock, flags);
  172. priv->msr = (~(*buffer)) & CH341_BITS_MODEM_STAT;
  173. spin_unlock_irqrestore(&priv->lock, flags);
  174. out: kfree(buffer);
  175. return r;
  176. }
  177. /* -------------------------------------------------------------------------- */
  178. static int ch341_configure(struct usb_device *dev, struct ch341_private *priv)
  179. {
  180. const unsigned int size = 2;
  181. char *buffer;
  182. int r;
  183. buffer = kmalloc(size, GFP_KERNEL);
  184. if (!buffer)
  185. return -ENOMEM;
  186. /* expect two bytes 0x27 0x00 */
  187. r = ch341_control_in(dev, CH341_REQ_READ_VERSION, 0, 0, buffer, size);
  188. if (r < 0)
  189. goto out;
  190. dev_dbg(&dev->dev, "Chip version: 0x%02x\n", buffer[0]);
  191. r = ch341_control_out(dev, CH341_REQ_SERIAL_INIT, 0, 0);
  192. if (r < 0)
  193. goto out;
  194. r = ch341_set_baudrate_lcr(dev, priv, priv->lcr);
  195. if (r < 0)
  196. goto out;
  197. r = ch341_set_handshake(dev, priv->mcr);
  198. out: kfree(buffer);
  199. return r;
  200. }
  201. static int ch341_port_probe(struct usb_serial_port *port)
  202. {
  203. struct ch341_private *priv;
  204. int r;
  205. priv = kzalloc(sizeof(struct ch341_private), GFP_KERNEL);
  206. if (!priv)
  207. return -ENOMEM;
  208. spin_lock_init(&priv->lock);
  209. priv->baud_rate = DEFAULT_BAUD_RATE;
  210. /*
  211. * Some CH340 devices appear unable to change the initial LCR
  212. * settings, so set a sane 8N1 default.
  213. */
  214. priv->lcr = CH341_LCR_ENABLE_RX | CH341_LCR_ENABLE_TX | CH341_LCR_CS8;
  215. r = ch341_configure(port->serial->dev, priv);
  216. if (r < 0)
  217. goto error;
  218. usb_set_serial_port_data(port, priv);
  219. return 0;
  220. error: kfree(priv);
  221. return r;
  222. }
  223. static int ch341_port_remove(struct usb_serial_port *port)
  224. {
  225. struct ch341_private *priv;
  226. priv = usb_get_serial_port_data(port);
  227. kfree(priv);
  228. return 0;
  229. }
  230. static int ch341_carrier_raised(struct usb_serial_port *port)
  231. {
  232. struct ch341_private *priv = usb_get_serial_port_data(port);
  233. if (priv->msr & CH341_BIT_DCD)
  234. return 1;
  235. return 0;
  236. }
  237. static void ch341_dtr_rts(struct usb_serial_port *port, int on)
  238. {
  239. struct ch341_private *priv = usb_get_serial_port_data(port);
  240. unsigned long flags;
  241. /* drop DTR and RTS */
  242. spin_lock_irqsave(&priv->lock, flags);
  243. if (on)
  244. priv->mcr |= CH341_BIT_RTS | CH341_BIT_DTR;
  245. else
  246. priv->mcr &= ~(CH341_BIT_RTS | CH341_BIT_DTR);
  247. spin_unlock_irqrestore(&priv->lock, flags);
  248. ch341_set_handshake(port->serial->dev, priv->mcr);
  249. }
  250. static void ch341_close(struct usb_serial_port *port)
  251. {
  252. usb_serial_generic_close(port);
  253. usb_kill_urb(port->interrupt_in_urb);
  254. }
  255. /* open this device, set default parameters */
  256. static int ch341_open(struct tty_struct *tty, struct usb_serial_port *port)
  257. {
  258. struct ch341_private *priv = usb_get_serial_port_data(port);
  259. int r;
  260. if (tty)
  261. ch341_set_termios(tty, port, NULL);
  262. dev_dbg(&port->dev, "%s - submitting interrupt urb\n", __func__);
  263. r = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
  264. if (r) {
  265. dev_err(&port->dev, "%s - failed to submit interrupt urb: %d\n",
  266. __func__, r);
  267. return r;
  268. }
  269. r = ch341_get_status(port->serial->dev, priv);
  270. if (r < 0) {
  271. dev_err(&port->dev, "failed to read modem status: %d\n", r);
  272. goto err_kill_interrupt_urb;
  273. }
  274. r = usb_serial_generic_open(tty, port);
  275. if (r)
  276. goto err_kill_interrupt_urb;
  277. return 0;
  278. err_kill_interrupt_urb:
  279. usb_kill_urb(port->interrupt_in_urb);
  280. return r;
  281. }
  282. /* Old_termios contains the original termios settings and
  283. * tty->termios contains the new setting to be used.
  284. */
  285. static void ch341_set_termios(struct tty_struct *tty,
  286. struct usb_serial_port *port, struct ktermios *old_termios)
  287. {
  288. struct ch341_private *priv = usb_get_serial_port_data(port);
  289. unsigned baud_rate;
  290. unsigned long flags;
  291. u8 lcr;
  292. int r;
  293. /* redundant changes may cause the chip to lose bytes */
  294. if (old_termios && !tty_termios_hw_change(&tty->termios, old_termios))
  295. return;
  296. baud_rate = tty_get_baud_rate(tty);
  297. lcr = CH341_LCR_ENABLE_RX | CH341_LCR_ENABLE_TX;
  298. switch (C_CSIZE(tty)) {
  299. case CS5:
  300. lcr |= CH341_LCR_CS5;
  301. break;
  302. case CS6:
  303. lcr |= CH341_LCR_CS6;
  304. break;
  305. case CS7:
  306. lcr |= CH341_LCR_CS7;
  307. break;
  308. case CS8:
  309. lcr |= CH341_LCR_CS8;
  310. break;
  311. }
  312. if (C_PARENB(tty)) {
  313. lcr |= CH341_LCR_ENABLE_PAR;
  314. if (C_PARODD(tty) == 0)
  315. lcr |= CH341_LCR_PAR_EVEN;
  316. if (C_CMSPAR(tty))
  317. lcr |= CH341_LCR_MARK_SPACE;
  318. }
  319. if (C_CSTOPB(tty))
  320. lcr |= CH341_LCR_STOP_BITS_2;
  321. if (baud_rate) {
  322. priv->baud_rate = baud_rate;
  323. r = ch341_set_baudrate_lcr(port->serial->dev, priv, lcr);
  324. if (r < 0 && old_termios) {
  325. priv->baud_rate = tty_termios_baud_rate(old_termios);
  326. tty_termios_copy_hw(&tty->termios, old_termios);
  327. } else if (r == 0) {
  328. priv->lcr = lcr;
  329. }
  330. }
  331. spin_lock_irqsave(&priv->lock, flags);
  332. if (C_BAUD(tty) == B0)
  333. priv->mcr &= ~(CH341_BIT_DTR | CH341_BIT_RTS);
  334. else if (old_termios && (old_termios->c_cflag & CBAUD) == B0)
  335. priv->mcr |= (CH341_BIT_DTR | CH341_BIT_RTS);
  336. spin_unlock_irqrestore(&priv->lock, flags);
  337. ch341_set_handshake(port->serial->dev, priv->mcr);
  338. }
  339. static void ch341_break_ctl(struct tty_struct *tty, int break_state)
  340. {
  341. const uint16_t ch341_break_reg =
  342. ((uint16_t) CH341_REG_LCR << 8) | CH341_REG_BREAK;
  343. struct usb_serial_port *port = tty->driver_data;
  344. int r;
  345. uint16_t reg_contents;
  346. uint8_t *break_reg;
  347. break_reg = kmalloc(2, GFP_KERNEL);
  348. if (!break_reg)
  349. return;
  350. r = ch341_control_in(port->serial->dev, CH341_REQ_READ_REG,
  351. ch341_break_reg, 0, break_reg, 2);
  352. if (r < 0) {
  353. dev_err(&port->dev, "%s - USB control read error (%d)\n",
  354. __func__, r);
  355. goto out;
  356. }
  357. dev_dbg(&port->dev, "%s - initial ch341 break register contents - reg1: %x, reg2: %x\n",
  358. __func__, break_reg[0], break_reg[1]);
  359. if (break_state != 0) {
  360. dev_dbg(&port->dev, "%s - Enter break state requested\n", __func__);
  361. break_reg[0] &= ~CH341_NBREAK_BITS;
  362. break_reg[1] &= ~CH341_LCR_ENABLE_TX;
  363. } else {
  364. dev_dbg(&port->dev, "%s - Leave break state requested\n", __func__);
  365. break_reg[0] |= CH341_NBREAK_BITS;
  366. break_reg[1] |= CH341_LCR_ENABLE_TX;
  367. }
  368. dev_dbg(&port->dev, "%s - New ch341 break register contents - reg1: %x, reg2: %x\n",
  369. __func__, break_reg[0], break_reg[1]);
  370. reg_contents = get_unaligned_le16(break_reg);
  371. r = ch341_control_out(port->serial->dev, CH341_REQ_WRITE_REG,
  372. ch341_break_reg, reg_contents);
  373. if (r < 0)
  374. dev_err(&port->dev, "%s - USB control write error (%d)\n",
  375. __func__, r);
  376. out:
  377. kfree(break_reg);
  378. }
  379. static int ch341_tiocmset(struct tty_struct *tty,
  380. unsigned int set, unsigned int clear)
  381. {
  382. struct usb_serial_port *port = tty->driver_data;
  383. struct ch341_private *priv = usb_get_serial_port_data(port);
  384. unsigned long flags;
  385. u8 control;
  386. spin_lock_irqsave(&priv->lock, flags);
  387. if (set & TIOCM_RTS)
  388. priv->mcr |= CH341_BIT_RTS;
  389. if (set & TIOCM_DTR)
  390. priv->mcr |= CH341_BIT_DTR;
  391. if (clear & TIOCM_RTS)
  392. priv->mcr &= ~CH341_BIT_RTS;
  393. if (clear & TIOCM_DTR)
  394. priv->mcr &= ~CH341_BIT_DTR;
  395. control = priv->mcr;
  396. spin_unlock_irqrestore(&priv->lock, flags);
  397. return ch341_set_handshake(port->serial->dev, control);
  398. }
  399. static void ch341_update_status(struct usb_serial_port *port,
  400. unsigned char *data, size_t len)
  401. {
  402. struct ch341_private *priv = usb_get_serial_port_data(port);
  403. struct tty_struct *tty;
  404. unsigned long flags;
  405. u8 status;
  406. u8 delta;
  407. if (len < 4)
  408. return;
  409. status = ~data[2] & CH341_BITS_MODEM_STAT;
  410. spin_lock_irqsave(&priv->lock, flags);
  411. delta = status ^ priv->msr;
  412. priv->msr = status;
  413. spin_unlock_irqrestore(&priv->lock, flags);
  414. if (data[1] & CH341_MULT_STAT)
  415. dev_dbg(&port->dev, "%s - multiple status change\n", __func__);
  416. if (!delta)
  417. return;
  418. if (delta & CH341_BIT_CTS)
  419. port->icount.cts++;
  420. if (delta & CH341_BIT_DSR)
  421. port->icount.dsr++;
  422. if (delta & CH341_BIT_RI)
  423. port->icount.rng++;
  424. if (delta & CH341_BIT_DCD) {
  425. port->icount.dcd++;
  426. tty = tty_port_tty_get(&port->port);
  427. if (tty) {
  428. usb_serial_handle_dcd_change(port, tty,
  429. status & CH341_BIT_DCD);
  430. tty_kref_put(tty);
  431. }
  432. }
  433. wake_up_interruptible(&port->port.delta_msr_wait);
  434. }
  435. static void ch341_read_int_callback(struct urb *urb)
  436. {
  437. struct usb_serial_port *port = urb->context;
  438. unsigned char *data = urb->transfer_buffer;
  439. unsigned int len = urb->actual_length;
  440. int status;
  441. switch (urb->status) {
  442. case 0:
  443. /* success */
  444. break;
  445. case -ECONNRESET:
  446. case -ENOENT:
  447. case -ESHUTDOWN:
  448. /* this urb is terminated, clean up */
  449. dev_dbg(&urb->dev->dev, "%s - urb shutting down: %d\n",
  450. __func__, urb->status);
  451. return;
  452. default:
  453. dev_dbg(&urb->dev->dev, "%s - nonzero urb status: %d\n",
  454. __func__, urb->status);
  455. goto exit;
  456. }
  457. usb_serial_debug_data(&port->dev, __func__, len, data);
  458. ch341_update_status(port, data, len);
  459. exit:
  460. status = usb_submit_urb(urb, GFP_ATOMIC);
  461. if (status) {
  462. dev_err(&urb->dev->dev, "%s - usb_submit_urb failed: %d\n",
  463. __func__, status);
  464. }
  465. }
  466. static int ch341_tiocmget(struct tty_struct *tty)
  467. {
  468. struct usb_serial_port *port = tty->driver_data;
  469. struct ch341_private *priv = usb_get_serial_port_data(port);
  470. unsigned long flags;
  471. u8 mcr;
  472. u8 status;
  473. unsigned int result;
  474. spin_lock_irqsave(&priv->lock, flags);
  475. mcr = priv->mcr;
  476. status = priv->msr;
  477. spin_unlock_irqrestore(&priv->lock, flags);
  478. result = ((mcr & CH341_BIT_DTR) ? TIOCM_DTR : 0)
  479. | ((mcr & CH341_BIT_RTS) ? TIOCM_RTS : 0)
  480. | ((status & CH341_BIT_CTS) ? TIOCM_CTS : 0)
  481. | ((status & CH341_BIT_DSR) ? TIOCM_DSR : 0)
  482. | ((status & CH341_BIT_RI) ? TIOCM_RI : 0)
  483. | ((status & CH341_BIT_DCD) ? TIOCM_CD : 0);
  484. dev_dbg(&port->dev, "%s - result = %x\n", __func__, result);
  485. return result;
  486. }
  487. static int ch341_reset_resume(struct usb_serial *serial)
  488. {
  489. struct usb_serial_port *port = serial->port[0];
  490. struct ch341_private *priv;
  491. int ret;
  492. priv = usb_get_serial_port_data(port);
  493. if (!priv)
  494. return 0;
  495. /* reconfigure ch341 serial port after bus-reset */
  496. ch341_configure(serial->dev, priv);
  497. if (tty_port_initialized(&port->port)) {
  498. ret = usb_submit_urb(port->interrupt_in_urb, GFP_NOIO);
  499. if (ret) {
  500. dev_err(&port->dev, "failed to submit interrupt urb: %d\n",
  501. ret);
  502. return ret;
  503. }
  504. ret = ch341_get_status(port->serial->dev, priv);
  505. if (ret < 0) {
  506. dev_err(&port->dev, "failed to read modem status: %d\n",
  507. ret);
  508. }
  509. }
  510. return usb_serial_generic_resume(serial);
  511. }
  512. static struct usb_serial_driver ch341_device = {
  513. .driver = {
  514. .owner = THIS_MODULE,
  515. .name = "ch341-uart",
  516. },
  517. .id_table = id_table,
  518. .num_ports = 1,
  519. .open = ch341_open,
  520. .dtr_rts = ch341_dtr_rts,
  521. .carrier_raised = ch341_carrier_raised,
  522. .close = ch341_close,
  523. .set_termios = ch341_set_termios,
  524. .break_ctl = ch341_break_ctl,
  525. .tiocmget = ch341_tiocmget,
  526. .tiocmset = ch341_tiocmset,
  527. .tiocmiwait = usb_serial_generic_tiocmiwait,
  528. .read_int_callback = ch341_read_int_callback,
  529. .port_probe = ch341_port_probe,
  530. .port_remove = ch341_port_remove,
  531. .reset_resume = ch341_reset_resume,
  532. };
  533. static struct usb_serial_driver * const serial_drivers[] = {
  534. &ch341_device, NULL
  535. };
  536. module_usb_serial_driver(serial_drivers, id_table);
  537. MODULE_LICENSE("GPL v2");