1 // SPDX-License-Identifier: GPL-2.0
3 * Fintek F81232 USB to serial adaptor driver
4 * Fintek F81532A/534A/535/536 USB to 2/4/8/12 serial adaptor driver
7 * Copyright (C) 2012 Linux Foundation
10 #include <linux/kernel.h>
11 #include <linux/errno.h>
12 #include <linux/slab.h>
13 #include <linux/tty.h>
14 #include <linux/tty_driver.h>
15 #include <linux/tty_flip.h>
16 #include <linux/serial.h>
17 #include <linux/module.h>
18 #include <linux/moduleparam.h>
19 #include <linux/mutex.h>
20 #include <linux/uaccess.h>
21 #include <linux/usb.h>
22 #include <linux/usb/serial.h>
23 #include <linux/serial_reg.h>
26 { USB_DEVICE(0x1934, 0x0706) } /* 1 port UART device */
28 #define F81534A_SERIES_ID \
29 { USB_DEVICE(0x2c42, 0x1602) }, /* In-Box 2 port UART device */ \
30 { USB_DEVICE(0x2c42, 0x1604) }, /* In-Box 4 port UART device */ \
31 { USB_DEVICE(0x2c42, 0x1605) }, /* In-Box 8 port UART device */ \
32 { USB_DEVICE(0x2c42, 0x1606) }, /* In-Box 12 port UART device */ \
33 { USB_DEVICE(0x2c42, 0x1608) }, /* Non-Flash type */ \
34 { USB_DEVICE(0x2c42, 0x1632) }, /* 2 port UART device */ \
35 { USB_DEVICE(0x2c42, 0x1634) }, /* 4 port UART device */ \
36 { USB_DEVICE(0x2c42, 0x1635) }, /* 8 port UART device */ \
37 { USB_DEVICE(0x2c42, 0x1636) } /* 12 port UART device */
39 #define F81534A_CTRL_ID \
40 { USB_DEVICE(0x2c42, 0x16f8) } /* Global control device */
42 static const struct usb_device_id f81232_id_table[] = {
44 { } /* Terminating entry */
47 static const struct usb_device_id f81534a_id_table[] = {
49 { } /* Terminating entry */
52 static const struct usb_device_id f81534a_ctrl_id_table[] = {
54 { } /* Terminating entry */
57 static const struct usb_device_id combined_id_table[] = {
61 { } /* Terminating entry */
63 MODULE_DEVICE_TABLE(usb, combined_id_table);
65 /* Maximum baudrate for F81232 */
66 #define F81232_MAX_BAUDRATE 1500000
67 #define F81232_DEF_BAUDRATE 9600
69 /* USB Control EP parameter */
70 #define F81232_REGISTER_REQUEST 0xa0
71 #define F81232_GET_REGISTER 0xc0
72 #define F81232_SET_REGISTER 0x40
73 #define F81534A_ACCESS_REG_RETRY 2
75 #define SERIAL_BASE_ADDRESS 0x0120
76 #define RECEIVE_BUFFER_REGISTER (0x00 + SERIAL_BASE_ADDRESS)
77 #define INTERRUPT_ENABLE_REGISTER (0x01 + SERIAL_BASE_ADDRESS)
78 #define FIFO_CONTROL_REGISTER (0x02 + SERIAL_BASE_ADDRESS)
79 #define LINE_CONTROL_REGISTER (0x03 + SERIAL_BASE_ADDRESS)
80 #define MODEM_CONTROL_REGISTER (0x04 + SERIAL_BASE_ADDRESS)
81 #define LINE_STATUS_REGISTER (0x05 + SERIAL_BASE_ADDRESS)
82 #define MODEM_STATUS_REGISTER (0x06 + SERIAL_BASE_ADDRESS)
85 * F81232 Clock registers (106h)
87 * Bit1-0: Clock source selector
93 #define F81232_CLK_REGISTER 0x106
94 #define F81232_CLK_1_846_MHZ 0
95 #define F81232_CLK_18_46_MHZ BIT(0)
96 #define F81232_CLK_24_MHZ BIT(1)
97 #define F81232_CLK_14_77_MHZ (BIT(1) | BIT(0))
98 #define F81232_CLK_MASK GENMASK(1, 0)
100 #define F81534A_MODE_REG 0x107
101 #define F81534A_TRIGGER_MASK GENMASK(3, 2)
102 #define F81534A_TRIGGER_MULTIPLE_4X BIT(3)
103 #define F81534A_FIFO_128BYTE (BIT(1) | BIT(0))
105 /* Serial port self GPIO control, 2bytes [control&output data][input data] */
106 #define F81534A_GPIO_REG 0x10e
107 #define F81534A_GPIO_MODE2_DIR BIT(6) /* 1: input, 0: output */
108 #define F81534A_GPIO_MODE1_DIR BIT(5)
109 #define F81534A_GPIO_MODE0_DIR BIT(4)
110 #define F81534A_GPIO_MODE2_OUTPUT BIT(2)
111 #define F81534A_GPIO_MODE1_OUTPUT BIT(1)
112 #define F81534A_GPIO_MODE0_OUTPUT BIT(0)
114 #define F81534A_CTRL_CMD_ENABLE_PORT 0x116
116 struct f81232_private {
122 struct work_struct lsr_work;
123 struct work_struct interrupt_work;
124 struct usb_serial_port *port;
127 static u32 const baudrate_table[] = { 115200, 921600, 1152000, 1500000 };
128 static u8 const clock_table[] = { F81232_CLK_1_846_MHZ, F81232_CLK_14_77_MHZ,
129 F81232_CLK_18_46_MHZ, F81232_CLK_24_MHZ };
131 static int calc_baud_divisor(speed_t baudrate, speed_t clockrate)
136 return DIV_ROUND_CLOSEST(clockrate, baudrate);
139 static int f81232_get_register(struct usb_serial_port *port, u16 reg, u8 *val)
142 struct usb_device *dev = port->serial->dev;
144 status = usb_control_msg_recv(dev,
146 F81232_REGISTER_REQUEST,
152 USB_CTRL_GET_TIMEOUT,
155 dev_err(&port->dev, "%s failed status: %d\n", __func__, status);
156 status = usb_translate_errors(status);
162 static int f81232_set_register(struct usb_serial_port *port, u16 reg, u8 val)
165 struct usb_device *dev = port->serial->dev;
167 status = usb_control_msg_send(dev,
169 F81232_REGISTER_REQUEST,
175 USB_CTRL_SET_TIMEOUT,
178 dev_err(&port->dev, "%s failed status: %d\n", __func__, status);
179 status = usb_translate_errors(status);
185 static int f81232_set_mask_register(struct usb_serial_port *port, u16 reg,
191 status = f81232_get_register(port, reg, &tmp);
195 tmp = (tmp & ~mask) | (val & mask);
197 return f81232_set_register(port, reg, tmp);
200 static void f81232_read_msr(struct usb_serial_port *port)
204 struct tty_struct *tty;
205 struct f81232_private *priv = usb_get_serial_port_data(port);
207 mutex_lock(&priv->lock);
208 status = f81232_get_register(port, MODEM_STATUS_REGISTER,
211 dev_err(&port->dev, "%s fail, status: %d\n", __func__, status);
212 mutex_unlock(&priv->lock);
216 if (!(current_msr & UART_MSR_ANY_DELTA)) {
217 mutex_unlock(&priv->lock);
221 priv->modem_status = current_msr;
223 if (current_msr & UART_MSR_DCTS)
225 if (current_msr & UART_MSR_DDSR)
227 if (current_msr & UART_MSR_TERI)
229 if (current_msr & UART_MSR_DDCD) {
231 tty = tty_port_tty_get(&port->port);
233 usb_serial_handle_dcd_change(port, tty,
234 current_msr & UART_MSR_DCD);
240 wake_up_interruptible(&port->port.delta_msr_wait);
241 mutex_unlock(&priv->lock);
244 static int f81232_set_mctrl(struct usb_serial_port *port,
245 unsigned int set, unsigned int clear)
249 struct f81232_private *priv = usb_get_serial_port_data(port);
251 if (((set | clear) & (TIOCM_DTR | TIOCM_RTS)) == 0)
252 return 0; /* no change */
254 /* 'set' takes precedence over 'clear' */
257 /* force enable interrupt with OUT2 */
258 mutex_lock(&priv->lock);
259 val = UART_MCR_OUT2 | priv->modem_control;
261 if (clear & TIOCM_DTR)
262 val &= ~UART_MCR_DTR;
264 if (clear & TIOCM_RTS)
265 val &= ~UART_MCR_RTS;
273 dev_dbg(&port->dev, "%s new:%02x old:%02x\n", __func__,
274 val, priv->modem_control);
276 status = f81232_set_register(port, MODEM_CONTROL_REGISTER, val);
278 dev_err(&port->dev, "%s set MCR status < 0\n", __func__);
279 mutex_unlock(&priv->lock);
283 priv->modem_control = val;
284 mutex_unlock(&priv->lock);
289 static void f81232_update_line_status(struct usb_serial_port *port,
291 size_t actual_length)
293 struct f81232_private *priv = usb_get_serial_port_data(port);
298 switch (data[0] & 0x07) {
299 case 0x00: /* msr change */
300 dev_dbg(&port->dev, "IIR: MSR Change: %02x\n", data[0]);
301 schedule_work(&priv->interrupt_work);
303 case 0x02: /* tx-empty */
305 case 0x04: /* rx data available */
307 case 0x06: /* lsr change */
308 /* we can forget it. the LSR will read from bulk-in */
309 dev_dbg(&port->dev, "IIR: LSR Change: %02x\n", data[0]);
314 static void f81232_read_int_callback(struct urb *urb)
316 struct usb_serial_port *port = urb->context;
317 unsigned char *data = urb->transfer_buffer;
318 unsigned int actual_length = urb->actual_length;
319 int status = urb->status;
329 /* this urb is terminated, clean up */
330 dev_dbg(&port->dev, "%s - urb shutting down with status: %d\n",
334 dev_dbg(&port->dev, "%s - nonzero urb status received: %d\n",
339 usb_serial_debug_data(&port->dev, __func__,
340 urb->actual_length, urb->transfer_buffer);
342 f81232_update_line_status(port, data, actual_length);
345 retval = usb_submit_urb(urb, GFP_ATOMIC);
347 dev_err(&urb->dev->dev,
348 "%s - usb_submit_urb failed with result %d\n",
352 static char f81232_handle_lsr(struct usb_serial_port *port, u8 lsr)
354 struct f81232_private *priv = usb_get_serial_port_data(port);
355 char tty_flag = TTY_NORMAL;
357 if (!(lsr & UART_LSR_BRK_ERROR_BITS))
360 if (lsr & UART_LSR_BI) {
361 tty_flag = TTY_BREAK;
363 usb_serial_handle_break(port);
364 } else if (lsr & UART_LSR_PE) {
365 tty_flag = TTY_PARITY;
366 port->icount.parity++;
367 } else if (lsr & UART_LSR_FE) {
368 tty_flag = TTY_FRAME;
369 port->icount.frame++;
372 if (lsr & UART_LSR_OE) {
373 port->icount.overrun++;
374 schedule_work(&priv->lsr_work);
375 tty_insert_flip_char(&port->port, 0, TTY_OVERRUN);
381 static void f81232_process_read_urb(struct urb *urb)
383 struct usb_serial_port *port = urb->context;
384 unsigned char *data = urb->transfer_buffer;
390 * When opening the port we get a 1-byte packet with the current LSR,
393 if ((urb->actual_length < 2) || (urb->actual_length % 2))
396 /* bulk-in data: [LSR(1Byte)+DATA(1Byte)][LSR(1Byte)+DATA(1Byte)]... */
398 for (i = 0; i < urb->actual_length; i += 2) {
400 tty_flag = f81232_handle_lsr(port, lsr);
403 if (usb_serial_handle_sysrq_char(port, data[i + 1]))
407 tty_insert_flip_char(&port->port, data[i + 1], tty_flag);
410 tty_flip_buffer_push(&port->port);
413 static void f81534a_process_read_urb(struct urb *urb)
415 struct usb_serial_port *port = urb->context;
416 unsigned char *data = urb->transfer_buffer;
422 if (urb->actual_length < 3) {
423 dev_err(&port->dev, "short message received: %d\n",
429 if (len != urb->actual_length) {
430 dev_err(&port->dev, "malformed message received: %d (%d)\n",
431 urb->actual_length, len);
435 /* bulk-in data: [LEN][Data.....][LSR] */
437 tty_flag = f81232_handle_lsr(port, lsr);
440 for (i = 1; i < len - 1; ++i) {
441 if (!usb_serial_handle_sysrq_char(port, data[i])) {
442 tty_insert_flip_char(&port->port, data[i],
447 tty_insert_flip_string_fixed_flag(&port->port, &data[1],
451 tty_flip_buffer_push(&port->port);
454 static void f81232_break_ctl(struct tty_struct *tty, int break_state)
456 struct usb_serial_port *port = tty->driver_data;
457 struct f81232_private *priv = usb_get_serial_port_data(port);
460 mutex_lock(&priv->lock);
463 priv->shadow_lcr |= UART_LCR_SBC;
465 priv->shadow_lcr &= ~UART_LCR_SBC;
467 status = f81232_set_register(port, LINE_CONTROL_REGISTER,
470 dev_err(&port->dev, "set break failed: %d\n", status);
472 mutex_unlock(&priv->lock);
475 static int f81232_find_clk(speed_t baudrate)
479 for (idx = 0; idx < ARRAY_SIZE(baudrate_table); ++idx) {
480 if (baudrate <= baudrate_table[idx] &&
481 baudrate_table[idx] % baudrate == 0)
488 static void f81232_set_baudrate(struct tty_struct *tty,
489 struct usb_serial_port *port, speed_t baudrate,
490 speed_t old_baudrate)
492 struct f81232_private *priv = usb_get_serial_port_data(port);
498 speed_t baud_list[] = { baudrate, old_baudrate, F81232_DEF_BAUDRATE };
500 for (i = 0; i < ARRAY_SIZE(baud_list); ++i) {
501 idx = f81232_find_clk(baud_list[i]);
503 baudrate = baud_list[i];
504 tty_encode_baud_rate(tty, baudrate, baudrate);
512 priv->baud_base = baudrate_table[idx];
513 divisor = calc_baud_divisor(baudrate, priv->baud_base);
515 status = f81232_set_mask_register(port, F81232_CLK_REGISTER,
516 F81232_CLK_MASK, clock_table[idx]);
518 dev_err(&port->dev, "%s failed to set CLK_REG: %d\n",
523 status = f81232_get_register(port, LINE_CONTROL_REGISTER,
526 dev_err(&port->dev, "%s failed to get LCR: %d\n",
531 status = f81232_set_register(port, LINE_CONTROL_REGISTER,
532 lcr | UART_LCR_DLAB); /* Enable DLAB */
534 dev_err(&port->dev, "%s failed to set DLAB: %d\n",
539 status = f81232_set_register(port, RECEIVE_BUFFER_REGISTER,
540 divisor & 0x00ff); /* low */
542 dev_err(&port->dev, "%s failed to set baudrate MSB: %d\n",
547 status = f81232_set_register(port, INTERRUPT_ENABLE_REGISTER,
548 (divisor & 0xff00) >> 8); /* high */
550 dev_err(&port->dev, "%s failed to set baudrate LSB: %d\n",
555 status = f81232_set_register(port, LINE_CONTROL_REGISTER,
556 lcr & ~UART_LCR_DLAB);
558 dev_err(&port->dev, "%s failed to set DLAB: %d\n",
563 static int f81232_port_enable(struct usb_serial_port *port)
568 /* fifo on, trigger8, clear TX/RX*/
569 val = UART_FCR_TRIGGER_8 | UART_FCR_ENABLE_FIFO | UART_FCR_CLEAR_RCVR |
572 status = f81232_set_register(port, FIFO_CONTROL_REGISTER, val);
574 dev_err(&port->dev, "%s failed to set FCR: %d\n",
579 /* MSR Interrupt only, LSR will read from Bulk-in odd byte */
580 status = f81232_set_register(port, INTERRUPT_ENABLE_REGISTER,
583 dev_err(&port->dev, "%s failed to set IER: %d\n",
591 static int f81232_port_disable(struct usb_serial_port *port)
595 status = f81232_set_register(port, INTERRUPT_ENABLE_REGISTER, 0);
597 dev_err(&port->dev, "%s failed to set IER: %d\n",
605 static void f81232_set_termios(struct tty_struct *tty,
606 struct usb_serial_port *port, struct ktermios *old_termios)
608 struct f81232_private *priv = usb_get_serial_port_data(port);
614 /* Don't change anything if nothing has changed */
615 if (old_termios && !tty_termios_hw_change(&tty->termios, old_termios))
618 if (C_BAUD(tty) == B0)
619 f81232_set_mctrl(port, 0, TIOCM_DTR | TIOCM_RTS);
620 else if (old_termios && (old_termios->c_cflag & CBAUD) == B0)
621 f81232_set_mctrl(port, TIOCM_DTR | TIOCM_RTS, 0);
623 baudrate = tty_get_baud_rate(tty);
626 old_baud = tty_termios_baud_rate(old_termios);
628 old_baud = F81232_DEF_BAUDRATE;
630 f81232_set_baudrate(tty, port, baudrate, old_baud);
634 new_lcr |= UART_LCR_PARITY;
637 new_lcr |= UART_LCR_EPAR;
640 new_lcr |= UART_LCR_SPAR;
644 new_lcr |= UART_LCR_STOP;
646 new_lcr |= UART_LCR_WLEN(tty_get_char_size(tty->termios.c_cflag));
648 mutex_lock(&priv->lock);
650 new_lcr |= (priv->shadow_lcr & UART_LCR_SBC);
651 status = f81232_set_register(port, LINE_CONTROL_REGISTER, new_lcr);
653 dev_err(&port->dev, "%s failed to set LCR: %d\n",
657 priv->shadow_lcr = new_lcr;
659 mutex_unlock(&priv->lock);
662 static int f81232_tiocmget(struct tty_struct *tty)
665 struct usb_serial_port *port = tty->driver_data;
666 struct f81232_private *port_priv = usb_get_serial_port_data(port);
669 /* force get current MSR changed state */
670 f81232_read_msr(port);
672 mutex_lock(&port_priv->lock);
673 mcr = port_priv->modem_control;
674 msr = port_priv->modem_status;
675 mutex_unlock(&port_priv->lock);
677 r = (mcr & UART_MCR_DTR ? TIOCM_DTR : 0) |
678 (mcr & UART_MCR_RTS ? TIOCM_RTS : 0) |
679 (msr & UART_MSR_CTS ? TIOCM_CTS : 0) |
680 (msr & UART_MSR_DCD ? TIOCM_CAR : 0) |
681 (msr & UART_MSR_RI ? TIOCM_RI : 0) |
682 (msr & UART_MSR_DSR ? TIOCM_DSR : 0);
687 static int f81232_tiocmset(struct tty_struct *tty,
688 unsigned int set, unsigned int clear)
690 struct usb_serial_port *port = tty->driver_data;
692 return f81232_set_mctrl(port, set, clear);
695 static int f81232_open(struct tty_struct *tty, struct usb_serial_port *port)
699 result = f81232_port_enable(port);
705 f81232_set_termios(tty, port, NULL);
707 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
709 dev_err(&port->dev, "%s - failed submitting interrupt urb,"
710 " error %d\n", __func__, result);
714 result = usb_serial_generic_open(tty, port);
716 usb_kill_urb(port->interrupt_in_urb);
723 static int f81534a_open(struct tty_struct *tty, struct usb_serial_port *port)
729 val = F81534A_TRIGGER_MULTIPLE_4X | F81534A_FIFO_128BYTE;
730 mask = F81534A_TRIGGER_MASK | F81534A_FIFO_128BYTE;
732 status = f81232_set_mask_register(port, F81534A_MODE_REG, mask, val);
734 dev_err(&port->dev, "failed to set MODE_REG: %d\n", status);
738 return f81232_open(tty, port);
741 static void f81232_close(struct usb_serial_port *port)
743 struct f81232_private *port_priv = usb_get_serial_port_data(port);
745 f81232_port_disable(port);
746 usb_serial_generic_close(port);
747 usb_kill_urb(port->interrupt_in_urb);
748 flush_work(&port_priv->interrupt_work);
749 flush_work(&port_priv->lsr_work);
752 static void f81232_dtr_rts(struct usb_serial_port *port, int on)
755 f81232_set_mctrl(port, TIOCM_DTR | TIOCM_RTS, 0);
757 f81232_set_mctrl(port, 0, TIOCM_DTR | TIOCM_RTS);
760 static bool f81232_tx_empty(struct usb_serial_port *port)
765 status = f81232_get_register(port, LINE_STATUS_REGISTER, &tmp);
767 if ((tmp & UART_LSR_TEMT) != UART_LSR_TEMT)
774 static int f81232_carrier_raised(struct usb_serial_port *port)
777 struct f81232_private *priv = usb_get_serial_port_data(port);
779 mutex_lock(&priv->lock);
780 msr = priv->modem_status;
781 mutex_unlock(&priv->lock);
783 if (msr & UART_MSR_DCD)
788 static void f81232_get_serial(struct tty_struct *tty, struct serial_struct *ss)
790 struct usb_serial_port *port = tty->driver_data;
791 struct f81232_private *priv = usb_get_serial_port_data(port);
793 ss->baud_base = priv->baud_base;
796 static void f81232_interrupt_work(struct work_struct *work)
798 struct f81232_private *priv =
799 container_of(work, struct f81232_private, interrupt_work);
801 f81232_read_msr(priv->port);
804 static void f81232_lsr_worker(struct work_struct *work)
806 struct f81232_private *priv;
807 struct usb_serial_port *port;
811 priv = container_of(work, struct f81232_private, lsr_work);
814 status = f81232_get_register(port, LINE_STATUS_REGISTER, &tmp);
816 dev_warn(&port->dev, "read LSR failed: %d\n", status);
819 static int f81534a_ctrl_set_register(struct usb_interface *intf, u16 reg,
822 struct usb_device *dev = interface_to_usbdev(intf);
823 int retry = F81534A_ACCESS_REG_RETRY;
827 status = usb_control_msg_send(dev,
829 F81232_REGISTER_REQUEST,
835 USB_CTRL_SET_TIMEOUT,
838 status = usb_translate_errors(status);
847 dev_err(&intf->dev, "failed to set register 0x%x: %d\n",
854 static int f81534a_ctrl_enable_all_ports(struct usb_interface *intf, bool en)
856 unsigned char enable[2] = {0};
860 * Enable all available serial ports, define as following:
861 * bit 15 : Reset behavior (when HUB got soft reset)
862 * 0: maintain all serial port enabled state.
863 * 1: disable all serial port.
864 * bit 0~11 : Serial port enable bit.
871 status = f81534a_ctrl_set_register(intf, F81534A_CTRL_CMD_ENABLE_PORT,
872 sizeof(enable), enable);
874 dev_err(&intf->dev, "failed to enable ports: %d\n", status);
879 static int f81534a_ctrl_probe(struct usb_interface *intf,
880 const struct usb_device_id *id)
882 return f81534a_ctrl_enable_all_ports(intf, true);
885 static void f81534a_ctrl_disconnect(struct usb_interface *intf)
887 f81534a_ctrl_enable_all_ports(intf, false);
890 static int f81534a_ctrl_resume(struct usb_interface *intf)
892 return f81534a_ctrl_enable_all_ports(intf, true);
895 static int f81232_port_probe(struct usb_serial_port *port)
897 struct f81232_private *priv;
899 priv = devm_kzalloc(&port->dev, sizeof(*priv), GFP_KERNEL);
903 mutex_init(&priv->lock);
904 INIT_WORK(&priv->interrupt_work, f81232_interrupt_work);
905 INIT_WORK(&priv->lsr_work, f81232_lsr_worker);
907 usb_set_serial_port_data(port, priv);
914 static int f81534a_port_probe(struct usb_serial_port *port)
918 /* tri-state with pull-high, default RS232 Mode */
919 status = f81232_set_register(port, F81534A_GPIO_REG,
920 F81534A_GPIO_MODE2_DIR);
924 return f81232_port_probe(port);
927 static int f81232_suspend(struct usb_serial *serial, pm_message_t message)
929 struct usb_serial_port *port = serial->port[0];
930 struct f81232_private *port_priv = usb_get_serial_port_data(port);
933 for (i = 0; i < ARRAY_SIZE(port->read_urbs); ++i)
934 usb_kill_urb(port->read_urbs[i]);
936 usb_kill_urb(port->interrupt_in_urb);
939 flush_work(&port_priv->interrupt_work);
940 flush_work(&port_priv->lsr_work);
946 static int f81232_resume(struct usb_serial *serial)
948 struct usb_serial_port *port = serial->port[0];
951 if (tty_port_initialized(&port->port)) {
952 result = usb_submit_urb(port->interrupt_in_urb, GFP_NOIO);
954 dev_err(&port->dev, "submit interrupt urb failed: %d\n",
960 return usb_serial_generic_resume(serial);
963 static struct usb_serial_driver f81232_device = {
965 .owner = THIS_MODULE,
968 .id_table = f81232_id_table,
971 .bulk_out_size = 256,
973 .close = f81232_close,
974 .dtr_rts = f81232_dtr_rts,
975 .carrier_raised = f81232_carrier_raised,
976 .get_serial = f81232_get_serial,
977 .break_ctl = f81232_break_ctl,
978 .set_termios = f81232_set_termios,
979 .tiocmget = f81232_tiocmget,
980 .tiocmset = f81232_tiocmset,
981 .tiocmiwait = usb_serial_generic_tiocmiwait,
982 .tx_empty = f81232_tx_empty,
983 .process_read_urb = f81232_process_read_urb,
984 .read_int_callback = f81232_read_int_callback,
985 .port_probe = f81232_port_probe,
986 .suspend = f81232_suspend,
987 .resume = f81232_resume,
990 static struct usb_serial_driver f81534a_device = {
992 .owner = THIS_MODULE,
995 .id_table = f81534a_id_table,
997 .open = f81534a_open,
998 .close = f81232_close,
999 .dtr_rts = f81232_dtr_rts,
1000 .carrier_raised = f81232_carrier_raised,
1001 .get_serial = f81232_get_serial,
1002 .break_ctl = f81232_break_ctl,
1003 .set_termios = f81232_set_termios,
1004 .tiocmget = f81232_tiocmget,
1005 .tiocmset = f81232_tiocmset,
1006 .tiocmiwait = usb_serial_generic_tiocmiwait,
1007 .tx_empty = f81232_tx_empty,
1008 .process_read_urb = f81534a_process_read_urb,
1009 .read_int_callback = f81232_read_int_callback,
1010 .port_probe = f81534a_port_probe,
1011 .suspend = f81232_suspend,
1012 .resume = f81232_resume,
1015 static struct usb_serial_driver * const serial_drivers[] = {
1021 static struct usb_driver f81534a_ctrl_driver = {
1022 .name = "f81534a_ctrl",
1023 .id_table = f81534a_ctrl_id_table,
1024 .probe = f81534a_ctrl_probe,
1025 .disconnect = f81534a_ctrl_disconnect,
1026 .resume = f81534a_ctrl_resume,
1029 static int __init f81232_init(void)
1033 status = usb_register_driver(&f81534a_ctrl_driver, THIS_MODULE,
1038 status = usb_serial_register_drivers(serial_drivers, KBUILD_MODNAME,
1041 usb_deregister(&f81534a_ctrl_driver);
1048 static void __exit f81232_exit(void)
1050 usb_serial_deregister_drivers(serial_drivers);
1051 usb_deregister(&f81534a_ctrl_driver);
1054 module_init(f81232_init);
1055 module_exit(f81232_exit);
1057 MODULE_DESCRIPTION("Fintek F81232/532A/534A/535/536 USB to serial driver");
1060 MODULE_LICENSE("GPL v2");