13 #include <linux/kernel.h>
14 #include <linux/errno.h>
16 #include <linux/slab.h>
17 #include <linux/tty.h>
20 #include <linux/serial.h>
21 #include <linux/module.h>
29 { USB_DEVICE(0x1934, 0x0706) },
34 #define CONTROL_DTR 0x01
35 #define CONTROL_RTS 0x02
37 #define UART_STATE 0x08
38 #define UART_STATE_TRANSIENT_MASK 0x74
41 #define UART_BREAK_ERROR 0x04
42 #define UART_RING 0x08
43 #define UART_FRAME_ERROR 0x10
44 #define UART_PARITY_ERROR 0x20
45 #define UART_OVERRUN_ERROR 0x40
57 unsigned int actual_length)
61 static void f81232_read_int_callback(
struct urb *
urb)
64 unsigned char *
data = urb->transfer_buffer;
65 unsigned int actual_length = urb->actual_length;
77 dev_dbg(&port->
dev,
"%s - urb shutting down with status: %d\n",
81 dev_dbg(&port->
dev,
"%s - nonzero urb status received: %d\n",
86 usb_serial_debug_data(&port->
dev, __func__,
87 urb->actual_length, urb->transfer_buffer);
89 f81232_update_line_status(port, data, actual_length);
95 "%s - usb_submit_urb failed with result %d\n",
99 static void f81232_process_read_urb(
struct urb *urb)
104 unsigned char *data = urb->transfer_buffer;
114 spin_unlock_irqrestore(&priv->
lock, flags);
117 if (!urb->actual_length)
132 dev_dbg(&port->
dev,
"%s - tty_flag = %d\n", __func__, tty_flag);
139 for (i = 0; i < urb->actual_length; ++
i)
141 tty_insert_flip_char(tty, data[i], tty_flag);
151 static int set_control_lines(
struct usb_device *
dev,
u8 value)
157 static void f81232_break_ctl(
struct tty_struct *tty,
int break_state)
168 static void f81232_set_termios(
struct tty_struct *tty,
181 static int f81232_tiocmget(
struct tty_struct *tty)
187 static int f81232_tiocmset(
struct tty_struct *tty,
188 unsigned int set,
unsigned int clear)
201 f81232_set_termios(tty, port, &tmp_termios);
205 dev_err(&port->
dev,
"%s - failed submitting interrupt urb,"
206 " error %d\n", __func__, result);
216 port->
port.drain_delay = 256;
239 spin_unlock_irqrestore(&priv->
lock, flags);
240 set_control_lines(port->
serial->dev, control);
255 unsigned int prevstatus;
261 spin_unlock_irqrestore(&priv->
lock, flags);
271 spin_unlock_irqrestore(&priv->
lock, flags);
273 changed = prevstatus ^
status;
287 static int f81232_ioctl(
struct tty_struct *tty,
288 unsigned int cmd,
unsigned long arg)
293 dev_dbg(&port->
dev,
"%s (%d) cmd = 0x%04x\n", __func__,
302 ser.baud_base = 460800;
310 dev_dbg(&port->
dev,
"%s (%d) TIOCMIWAIT\n", __func__,
312 return wait_modem_info(port, arg);
314 dev_dbg(&port->
dev,
"%s not supported = 0x%04x\n",
332 usb_set_serial_port_data(port, priv);
341 priv = usb_get_serial_port_data(port);
355 .bulk_out_size = 256,
357 .close = f81232_close,
358 .dtr_rts = f81232_dtr_rts,
359 .carrier_raised = f81232_carrier_raised,
360 .ioctl = f81232_ioctl,
361 .break_ctl = f81232_break_ctl,
362 .set_termios = f81232_set_termios,
363 .tiocmget = f81232_tiocmget,
364 .tiocmset = f81232_tiocmset,
365 .process_read_urb = f81232_process_read_urb,
366 .read_int_callback = f81232_read_int_callback,
367 .port_probe = f81232_port_probe,
368 .port_remove = f81232_port_remove,