ch341.c 16 KB

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