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 switch (C_CSIZE(tty)) {
648 new_lcr |= UART_LCR_WLEN5;
651 new_lcr |= UART_LCR_WLEN6;
654 new_lcr |= UART_LCR_WLEN7;
658 new_lcr |= UART_LCR_WLEN8;
662 mutex_lock(&priv->lock);
664 new_lcr |= (priv->shadow_lcr & UART_LCR_SBC);
665 status = f81232_set_register(port, LINE_CONTROL_REGISTER, new_lcr);
667 dev_err(&port->dev, "%s failed to set LCR: %d\n",
671 priv->shadow_lcr = new_lcr;
673 mutex_unlock(&priv->lock);
676 static int f81232_tiocmget(struct tty_struct *tty)
679 struct usb_serial_port *port = tty->driver_data;
680 struct f81232_private *port_priv = usb_get_serial_port_data(port);
683 /* force get current MSR changed state */
684 f81232_read_msr(port);
686 mutex_lock(&port_priv->lock);
687 mcr = port_priv->modem_control;
688 msr = port_priv->modem_status;
689 mutex_unlock(&port_priv->lock);
691 r = (mcr & UART_MCR_DTR ? TIOCM_DTR : 0) |
692 (mcr & UART_MCR_RTS ? TIOCM_RTS : 0) |
693 (msr & UART_MSR_CTS ? TIOCM_CTS : 0) |
694 (msr & UART_MSR_DCD ? TIOCM_CAR : 0) |
695 (msr & UART_MSR_RI ? TIOCM_RI : 0) |
696 (msr & UART_MSR_DSR ? TIOCM_DSR : 0);
701 static int f81232_tiocmset(struct tty_struct *tty,
702 unsigned int set, unsigned int clear)
704 struct usb_serial_port *port = tty->driver_data;
706 return f81232_set_mctrl(port, set, clear);
709 static int f81232_open(struct tty_struct *tty, struct usb_serial_port *port)
713 result = f81232_port_enable(port);
719 f81232_set_termios(tty, port, NULL);
721 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
723 dev_err(&port->dev, "%s - failed submitting interrupt urb,"
724 " error %d\n", __func__, result);
728 result = usb_serial_generic_open(tty, port);
730 usb_kill_urb(port->interrupt_in_urb);
737 static int f81534a_open(struct tty_struct *tty, struct usb_serial_port *port)
743 val = F81534A_TRIGGER_MULTIPLE_4X | F81534A_FIFO_128BYTE;
744 mask = F81534A_TRIGGER_MASK | F81534A_FIFO_128BYTE;
746 status = f81232_set_mask_register(port, F81534A_MODE_REG, mask, val);
748 dev_err(&port->dev, "failed to set MODE_REG: %d\n", status);
752 return f81232_open(tty, port);
755 static void f81232_close(struct usb_serial_port *port)
757 struct f81232_private *port_priv = usb_get_serial_port_data(port);
759 f81232_port_disable(port);
760 usb_serial_generic_close(port);
761 usb_kill_urb(port->interrupt_in_urb);
762 flush_work(&port_priv->interrupt_work);
763 flush_work(&port_priv->lsr_work);
766 static void f81232_dtr_rts(struct usb_serial_port *port, int on)
769 f81232_set_mctrl(port, TIOCM_DTR | TIOCM_RTS, 0);
771 f81232_set_mctrl(port, 0, TIOCM_DTR | TIOCM_RTS);
774 static bool f81232_tx_empty(struct usb_serial_port *port)
779 status = f81232_get_register(port, LINE_STATUS_REGISTER, &tmp);
781 if ((tmp & UART_LSR_TEMT) != UART_LSR_TEMT)
788 static int f81232_carrier_raised(struct usb_serial_port *port)
791 struct f81232_private *priv = usb_get_serial_port_data(port);
793 mutex_lock(&priv->lock);
794 msr = priv->modem_status;
795 mutex_unlock(&priv->lock);
797 if (msr & UART_MSR_DCD)
802 static void f81232_get_serial(struct tty_struct *tty, struct serial_struct *ss)
804 struct usb_serial_port *port = tty->driver_data;
805 struct f81232_private *priv = usb_get_serial_port_data(port);
807 ss->baud_base = priv->baud_base;
810 static void f81232_interrupt_work(struct work_struct *work)
812 struct f81232_private *priv =
813 container_of(work, struct f81232_private, interrupt_work);
815 f81232_read_msr(priv->port);
818 static void f81232_lsr_worker(struct work_struct *work)
820 struct f81232_private *priv;
821 struct usb_serial_port *port;
825 priv = container_of(work, struct f81232_private, lsr_work);
828 status = f81232_get_register(port, LINE_STATUS_REGISTER, &tmp);
830 dev_warn(&port->dev, "read LSR failed: %d\n", status);
833 static int f81534a_ctrl_set_register(struct usb_interface *intf, u16 reg,
836 struct usb_device *dev = interface_to_usbdev(intf);
837 int retry = F81534A_ACCESS_REG_RETRY;
841 status = usb_control_msg_send(dev,
843 F81232_REGISTER_REQUEST,
849 USB_CTRL_SET_TIMEOUT,
852 status = usb_translate_errors(status);
861 dev_err(&intf->dev, "failed to set register 0x%x: %d\n",
868 static int f81534a_ctrl_enable_all_ports(struct usb_interface *intf, bool en)
870 unsigned char enable[2] = {0};
874 * Enable all available serial ports, define as following:
875 * bit 15 : Reset behavior (when HUB got soft reset)
876 * 0: maintain all serial port enabled state.
877 * 1: disable all serial port.
878 * bit 0~11 : Serial port enable bit.
885 status = f81534a_ctrl_set_register(intf, F81534A_CTRL_CMD_ENABLE_PORT,
886 sizeof(enable), enable);
888 dev_err(&intf->dev, "failed to enable ports: %d\n", status);
893 static int f81534a_ctrl_probe(struct usb_interface *intf,
894 const struct usb_device_id *id)
896 return f81534a_ctrl_enable_all_ports(intf, true);
899 static void f81534a_ctrl_disconnect(struct usb_interface *intf)
901 f81534a_ctrl_enable_all_ports(intf, false);
904 static int f81534a_ctrl_resume(struct usb_interface *intf)
906 return f81534a_ctrl_enable_all_ports(intf, true);
909 static int f81232_port_probe(struct usb_serial_port *port)
911 struct f81232_private *priv;
913 priv = devm_kzalloc(&port->dev, sizeof(*priv), GFP_KERNEL);
917 mutex_init(&priv->lock);
918 INIT_WORK(&priv->interrupt_work, f81232_interrupt_work);
919 INIT_WORK(&priv->lsr_work, f81232_lsr_worker);
921 usb_set_serial_port_data(port, priv);
928 static int f81534a_port_probe(struct usb_serial_port *port)
932 /* tri-state with pull-high, default RS232 Mode */
933 status = f81232_set_register(port, F81534A_GPIO_REG,
934 F81534A_GPIO_MODE2_DIR);
938 return f81232_port_probe(port);
941 static int f81232_suspend(struct usb_serial *serial, pm_message_t message)
943 struct usb_serial_port *port = serial->port[0];
944 struct f81232_private *port_priv = usb_get_serial_port_data(port);
947 for (i = 0; i < ARRAY_SIZE(port->read_urbs); ++i)
948 usb_kill_urb(port->read_urbs[i]);
950 usb_kill_urb(port->interrupt_in_urb);
953 flush_work(&port_priv->interrupt_work);
954 flush_work(&port_priv->lsr_work);
960 static int f81232_resume(struct usb_serial *serial)
962 struct usb_serial_port *port = serial->port[0];
965 if (tty_port_initialized(&port->port)) {
966 result = usb_submit_urb(port->interrupt_in_urb, GFP_NOIO);
968 dev_err(&port->dev, "submit interrupt urb failed: %d\n",
974 return usb_serial_generic_resume(serial);
977 static struct usb_serial_driver f81232_device = {
979 .owner = THIS_MODULE,
982 .id_table = f81232_id_table,
985 .bulk_out_size = 256,
987 .close = f81232_close,
988 .dtr_rts = f81232_dtr_rts,
989 .carrier_raised = f81232_carrier_raised,
990 .get_serial = f81232_get_serial,
991 .break_ctl = f81232_break_ctl,
992 .set_termios = f81232_set_termios,
993 .tiocmget = f81232_tiocmget,
994 .tiocmset = f81232_tiocmset,
995 .tiocmiwait = usb_serial_generic_tiocmiwait,
996 .tx_empty = f81232_tx_empty,
997 .process_read_urb = f81232_process_read_urb,
998 .read_int_callback = f81232_read_int_callback,
999 .port_probe = f81232_port_probe,
1000 .suspend = f81232_suspend,
1001 .resume = f81232_resume,
1004 static struct usb_serial_driver f81534a_device = {
1006 .owner = THIS_MODULE,
1009 .id_table = f81534a_id_table,
1011 .open = f81534a_open,
1012 .close = f81232_close,
1013 .dtr_rts = f81232_dtr_rts,
1014 .carrier_raised = f81232_carrier_raised,
1015 .get_serial = f81232_get_serial,
1016 .break_ctl = f81232_break_ctl,
1017 .set_termios = f81232_set_termios,
1018 .tiocmget = f81232_tiocmget,
1019 .tiocmset = f81232_tiocmset,
1020 .tiocmiwait = usb_serial_generic_tiocmiwait,
1021 .tx_empty = f81232_tx_empty,
1022 .process_read_urb = f81534a_process_read_urb,
1023 .read_int_callback = f81232_read_int_callback,
1024 .port_probe = f81534a_port_probe,
1025 .suspend = f81232_suspend,
1026 .resume = f81232_resume,
1029 static struct usb_serial_driver * const serial_drivers[] = {
1035 static struct usb_driver f81534a_ctrl_driver = {
1036 .name = "f81534a_ctrl",
1037 .id_table = f81534a_ctrl_id_table,
1038 .probe = f81534a_ctrl_probe,
1039 .disconnect = f81534a_ctrl_disconnect,
1040 .resume = f81534a_ctrl_resume,
1043 static int __init f81232_init(void)
1047 status = usb_register_driver(&f81534a_ctrl_driver, THIS_MODULE,
1052 status = usb_serial_register_drivers(serial_drivers, KBUILD_MODNAME,
1055 usb_deregister(&f81534a_ctrl_driver);
1062 static void __exit f81232_exit(void)
1064 usb_serial_deregister_drivers(serial_drivers);
1065 usb_deregister(&f81534a_ctrl_driver);
1068 module_init(f81232_init);
1069 module_exit(f81232_exit);
1071 MODULE_DESCRIPTION("Fintek F81232/532A/534A/535/536 USB to serial driver");
1074 MODULE_LICENSE("GPL v2");