Lines Matching +full:overrun +full:- +full:throttle +full:- +full:ms

1 // SPDX-License-Identifier: GPL-2.0+
5 * Copyright (C) 2009 - 2013
7 * Copyright (C) 1999 - 2001
8 * Greg Kroah-Hartman (greg@kroah.com)
13 * See Documentation/usb/usb-serial.rst for more information on using this
16 * See http://ftdi-usb-sio.sourceforge.net for up to date testing info
24 /* Bill Ryder - bryder@sgi.com - wrote the FTDI_SIO implementation */
28 assimilated :-) */
47 #define DRIVER_AUTHOR "Greg Kroah-Hartman <greg@kroah.com>, Bill Ryder <bryder@sgi.com>, Kuba Ober …
75 u16 last_set_data_value; /* the last data state set - needed for doing
84 speed_t force_baud; /* if non-zero, force the baud rate to
86 int force_rtscts; /* if non-zero, force RTS-CTS to always
142 * - it can support MUCH higher baudrates; up to:
146 * - it has a two byte status code.
147 * - it returns characters every 16ms (the FTDI does it every 40ms)
160 * /sys/bus/usb-serial/drivers/ftdi_sio/new_id and send a patch or report.
1051 /* ICP DAS I-756xU devices */
1072 /* U-Blox devices */
1103 [FTX] = "FT-X",
1179 /* hi-speed baud rate is 10-bit sampling instead of 16-bit */ in ftdi_2232h_baud_base_to_divisor()
1210 struct device *dev = &port->dev; in update_mctrl()
1215 dev_dbg(dev, "%s - DTR|RTS not being set|cleared\n", __func__); in update_mctrl()
1229 rv = usb_control_msg(port->serial->dev, in update_mctrl()
1230 usb_sndctrlpipe(port->serial->dev, 0), in update_mctrl()
1233 value, priv->channel, in update_mctrl()
1242 dev_dbg(dev, "%s - DTR %s, RTS %s\n", __func__, in update_mctrl()
1246 priv->last_dtr_rts = (priv->last_dtr_rts & ~clear) | set; in update_mctrl()
1256 struct device *dev = &port->dev; in get_ftdi_divisor()
1262 dev_dbg(dev, "%s - tty_get_baud_rate reports speed %d\n", __func__, baud); in get_ftdi_divisor()
1265 * Observe deprecated async-compatible custom_divisor hack, update in get_ftdi_divisor()
1269 ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) && in get_ftdi_divisor()
1270 (priv->custom_divisor)) { in get_ftdi_divisor()
1271 baud = priv->baud_base / priv->custom_divisor; in get_ftdi_divisor()
1272 dev_dbg(dev, "%s - custom divisor %d sets baud rate to %d\n", in get_ftdi_divisor()
1273 __func__, priv->custom_divisor, baud); in get_ftdi_divisor()
1278 switch (priv->chip_type) { in get_ftdi_divisor()
1292 dev_dbg(dev, "%s - Baudrate (%d) requested is not supported\n", in get_ftdi_divisor()
1303 dev_dbg(dev, "%s - Baud rate too high!\n", __func__); in get_ftdi_divisor()
1315 port->serial->dev->descriptor.idProduct); in get_ftdi_divisor()
1326 dev_dbg(dev, "%s - Baud rate too high!\n", __func__); in get_ftdi_divisor()
1338 dev_dbg(dev, "%s - Baud rate too high!\n", __func__); in get_ftdi_divisor()
1347 dev_dbg(dev, "%s - Baud rate set to %d (divisor 0x%lX) on chip %s\n", in get_ftdi_divisor()
1349 ftdi_chip_name[priv->chip_type]); in get_ftdi_divisor()
1367 if (priv->channel) in change_speed()
1368 index = (u16)((index << 8) | priv->channel); in change_speed()
1370 rv = usb_control_msg(port->serial->dev, in change_speed()
1371 usb_sndctrlpipe(port->serial->dev, 0), in change_speed()
1382 struct usb_device *udev = port->serial->dev; in write_latency_timer()
1384 int l = priv->latency; in write_latency_timer()
1386 if (priv->chip_type == SIO || priv->chip_type == FT232A) in write_latency_timer()
1387 return -EINVAL; in write_latency_timer()
1389 if (priv->flags & ASYNC_LOW_LATENCY) in write_latency_timer()
1392 dev_dbg(&port->dev, "%s: setting latency timer = %i\n", __func__, l); in write_latency_timer()
1398 l, priv->channel, in write_latency_timer()
1401 dev_err(&port->dev, "Unable to write latency timer: %i\n", rv); in write_latency_timer()
1408 struct usb_device *udev = port->serial->dev; in _read_latency_timer()
1414 priv->channel, &buf, 1, WDR_TIMEOUT, in _read_latency_timer()
1427 if (priv->chip_type == SIO || priv->chip_type == FT232A) in read_latency_timer()
1428 return -EINVAL; in read_latency_timer()
1432 dev_err(&port->dev, "Unable to read latency timer: %i\n", rv); in read_latency_timer()
1436 priv->latency = rv; in read_latency_timer()
1443 struct usb_serial_port *port = tty->driver_data; in get_serial_info()
1446 ss->flags = priv->flags; in get_serial_info()
1447 ss->baud_base = priv->baud_base; in get_serial_info()
1448 ss->custom_divisor = priv->custom_divisor; in get_serial_info()
1453 struct usb_serial_port *port = tty->driver_data; in set_serial_info()
1457 mutex_lock(&priv->cfg_lock); in set_serial_info()
1460 if ((ss->flags ^ priv->flags) & ~ASYNC_USR_MASK) { in set_serial_info()
1461 mutex_unlock(&priv->cfg_lock); in set_serial_info()
1462 return -EPERM; in set_serial_info()
1466 old_flags = priv->flags; in set_serial_info()
1467 old_divisor = priv->custom_divisor; in set_serial_info()
1469 priv->flags = ss->flags & ASYNC_FLAGS; in set_serial_info()
1470 priv->custom_divisor = ss->custom_divisor; in set_serial_info()
1474 if ((priv->flags ^ old_flags) & ASYNC_SPD_MASK || in set_serial_info()
1475 ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST && in set_serial_info()
1476 priv->custom_divisor != old_divisor)) { in set_serial_info()
1479 if (priv->flags & ASYNC_SPD_MASK) in set_serial_info()
1480 dev_warn_ratelimited(&port->dev, "use of SPD flags is deprecated\n"); in set_serial_info()
1484 mutex_unlock(&priv->cfg_lock); in set_serial_info()
1494 if (priv->transmit_empty) in get_lsr_info()
1498 return -EFAULT; in get_lsr_info()
1505 struct usb_serial *serial = port->serial; in ftdi_determine_type()
1506 struct usb_device *udev = serial->dev; in ftdi_determine_type()
1509 version = le16_to_cpu(udev->descriptor.bcdDevice); in ftdi_determine_type()
1510 ifnum = serial->interface->cur_altsetting->desc.bInterfaceNumber; in ftdi_determine_type()
1512 /* Assume Hi-Speed type */ in ftdi_determine_type()
1513 priv->baud_base = 120000000 / 2; in ftdi_determine_type()
1514 priv->channel = CHANNEL_A + ifnum; in ftdi_determine_type()
1518 priv->chip_type = FT232A; in ftdi_determine_type()
1519 priv->baud_base = 48000000 / 2; in ftdi_determine_type()
1520 priv->channel = 0; in ftdi_determine_type()
1526 if (udev->descriptor.iSerialNumber == 0 && in ftdi_determine_type()
1528 priv->chip_type = FT232B; in ftdi_determine_type()
1532 priv->chip_type = FT232B; in ftdi_determine_type()
1533 priv->baud_base = 48000000 / 2; in ftdi_determine_type()
1534 priv->channel = 0; in ftdi_determine_type()
1537 priv->chip_type = FT2232C; in ftdi_determine_type()
1538 priv->baud_base = 48000000 / 2; in ftdi_determine_type()
1541 priv->chip_type = FT232R; in ftdi_determine_type()
1542 priv->baud_base = 48000000 / 2; in ftdi_determine_type()
1543 priv->channel = 0; in ftdi_determine_type()
1546 priv->chip_type = FT2232H; in ftdi_determine_type()
1549 priv->chip_type = FT4232H; in ftdi_determine_type()
1552 priv->chip_type = FT232H; in ftdi_determine_type()
1555 priv->chip_type = FTX; in ftdi_determine_type()
1556 priv->baud_base = 48000000 / 2; in ftdi_determine_type()
1559 priv->chip_type = FT2233HP; in ftdi_determine_type()
1562 priv->chip_type = FT4233HP; in ftdi_determine_type()
1565 priv->chip_type = FT2232HP; in ftdi_determine_type()
1568 priv->chip_type = FT4232HP; in ftdi_determine_type()
1571 priv->chip_type = FT233HP; in ftdi_determine_type()
1574 priv->chip_type = FT232HP; in ftdi_determine_type()
1577 priv->chip_type = FT4232HA; in ftdi_determine_type()
1581 priv->chip_type = SIO; in ftdi_determine_type()
1582 priv->baud_base = 12000000 / 16; in ftdi_determine_type()
1583 priv->channel = 0; in ftdi_determine_type()
1585 dev_err(&port->dev, "unknown device type: 0x%02x\n", version); in ftdi_determine_type()
1586 return -ENODEV; in ftdi_determine_type()
1590 dev_info(&udev->dev, "Detected %s\n", ftdi_chip_name[priv->chip_type]); in ftdi_determine_type()
1604 struct usb_interface *interface = port->serial->interface; in ftdi_set_max_packet_size()
1609 num_endpoints = interface->cur_altsetting->desc.bNumEndpoints; in ftdi_set_max_packet_size()
1615 * with an endpoint size of 0 - not good. In this case, we in ftdi_set_max_packet_size()
1620 ep_desc = &interface->cur_altsetting->endpoint[i].desc; in ftdi_set_max_packet_size()
1621 if (!ep_desc->wMaxPacketSize) { in ftdi_set_max_packet_size()
1622 ep_desc->wMaxPacketSize = cpu_to_le16(0x40); in ftdi_set_max_packet_size()
1623 dev_warn(&port->dev, "Overriding wMaxPacketSize on endpoint %d\n", in ftdi_set_max_packet_size()
1629 priv->max_packet_size = usb_endpoint_maxp(ep_desc); in ftdi_set_max_packet_size()
1644 if (priv->flags & ASYNC_LOW_LATENCY) in latency_timer_show()
1647 return sprintf(buf, "%u\n", priv->latency); in latency_timer_show()
1661 return -EINVAL; in latency_timer_store()
1663 priv->latency = v; in latency_timer_store()
1666 return -EIO; in latency_timer_store()
1678 struct usb_device *udev = port->serial->dev; in event_char_store()
1683 return -EINVAL; in event_char_store()
1685 dev_dbg(&port->dev, "%s: setting event char = 0x%03x\n", __func__, v); in event_char_store()
1691 v, priv->channel, in event_char_store()
1694 dev_dbg(&port->dev, "Unable to write event character: %i\n", rv); in event_char_store()
1695 return -EIO; in event_char_store()
1713 enum ftdi_chip_type type = priv->chip_type; in ftdi_is_visible()
1725 return attr->mode; in ftdi_is_visible()
1743 struct usb_serial *serial = port->serial; in ftdi_set_bitmode()
1747 result = usb_autopm_get_interface(serial->interface); in ftdi_set_bitmode()
1751 val = (mode << 8) | (priv->gpio_output << 4) | priv->gpio_value; in ftdi_set_bitmode()
1752 result = usb_control_msg(serial->dev, in ftdi_set_bitmode()
1753 usb_sndctrlpipe(serial->dev, 0), in ftdi_set_bitmode()
1756 priv->channel, NULL, 0, WDR_TIMEOUT); in ftdi_set_bitmode()
1758 dev_err(&serial->interface->dev, in ftdi_set_bitmode()
1763 usb_autopm_put_interface(serial->interface); in ftdi_set_bitmode()
1777 priv->gpio_output = 0; in ftdi_exit_cbus_mode()
1778 priv->gpio_value = 0; in ftdi_exit_cbus_mode()
1788 mutex_lock(&priv->gpio_lock); in ftdi_gpio_request()
1789 if (!priv->gpio_used) { in ftdi_gpio_request()
1791 priv->gpio_output = 0x00; in ftdi_gpio_request()
1792 priv->gpio_value = 0x00; in ftdi_gpio_request()
1795 mutex_unlock(&priv->gpio_lock); in ftdi_gpio_request()
1799 priv->gpio_used = true; in ftdi_gpio_request()
1801 mutex_unlock(&priv->gpio_lock); in ftdi_gpio_request()
1809 struct usb_serial *serial = port->serial; in ftdi_read_cbus_pins()
1813 result = usb_autopm_get_interface(serial->interface); in ftdi_read_cbus_pins()
1817 result = usb_control_msg_recv(serial->dev, 0, in ftdi_read_cbus_pins()
1820 priv->channel, &buf, 1, WDR_TIMEOUT, in ftdi_read_cbus_pins()
1825 usb_autopm_put_interface(serial->interface); in ftdi_read_cbus_pins()
1847 mutex_lock(&priv->gpio_lock); in ftdi_gpio_set()
1850 priv->gpio_value |= BIT(gpio); in ftdi_gpio_set()
1852 priv->gpio_value &= ~BIT(gpio); in ftdi_gpio_set()
1856 mutex_unlock(&priv->gpio_lock); in ftdi_gpio_set()
1880 mutex_lock(&priv->gpio_lock); in ftdi_gpio_set_multiple()
1882 priv->gpio_value &= ~(*mask); in ftdi_gpio_set_multiple()
1883 priv->gpio_value |= *bits & *mask; in ftdi_gpio_set_multiple()
1886 mutex_unlock(&priv->gpio_lock); in ftdi_gpio_set_multiple()
1894 return !(priv->gpio_output & BIT(gpio)); in ftdi_gpio_direction_get()
1903 mutex_lock(&priv->gpio_lock); in ftdi_gpio_direction_input()
1905 priv->gpio_output &= ~BIT(gpio); in ftdi_gpio_direction_input()
1908 mutex_unlock(&priv->gpio_lock); in ftdi_gpio_direction_input()
1920 mutex_lock(&priv->gpio_lock); in ftdi_gpio_direction_output()
1922 priv->gpio_output |= BIT(gpio); in ftdi_gpio_direction_output()
1924 priv->gpio_value |= BIT(gpio); in ftdi_gpio_direction_output()
1926 priv->gpio_value &= ~BIT(gpio); in ftdi_gpio_direction_output()
1930 mutex_unlock(&priv->gpio_lock); in ftdi_gpio_direction_output()
1941 unsigned long map = priv->gpio_altfunc; in ftdi_gpio_init_valid_mask()
1946 dev_dbg(&port->dev, "no CBUS pin configured for GPIO\n"); in ftdi_gpio_init_valid_mask()
1948 dev_dbg(&port->dev, "CBUS%*pbl configured for GPIO\n", ngpios, in ftdi_gpio_init_valid_mask()
1960 return -EINVAL; in ftdi_read_eeprom()
1962 return -EINVAL; in ftdi_read_eeprom()
1968 rv = usb_control_msg(serial->dev, in ftdi_read_eeprom()
1969 usb_rcvctrlpipe(serial->dev, 0), in ftdi_read_eeprom()
1976 return -EIO; in ftdi_read_eeprom()
1997 return -ENOMEM; in ftdi_gpio_init_ft232h()
1999 ret = ftdi_read_eeprom(port->serial, buf, 0x1a, 4); in ftdi_gpio_init_ft232h()
2006 * 0x1a: X- (upper nibble -> AC5) in ftdi_gpio_init_ft232h()
2007 * 0x1b: -X (lower nibble -> AC6) in ftdi_gpio_init_ft232h()
2008 * 0x1c: XX (upper nibble -> AC9 | lower nibble -> AC8) in ftdi_gpio_init_ft232h()
2012 priv->gc.ngpio = 4; in ftdi_gpio_init_ft232h()
2013 priv->gpio_altfunc = 0xff; in ftdi_gpio_init_ft232h()
2015 for (i = 0; i < priv->gc.ngpio; ++i) { in ftdi_gpio_init_ft232h()
2017 priv->gpio_altfunc &= ~BIT(i); in ftdi_gpio_init_ft232h()
2037 return -ENOMEM; in ftdi_gpio_init_ft232r()
2039 ret = ftdi_read_eeprom(port->serial, buf, 0x14, 2); in ftdi_gpio_init_ft232r()
2044 dev_dbg(&port->dev, "cbus_config = 0x%04x\n", cbus_config); in ftdi_gpio_init_ft232r()
2046 priv->gc.ngpio = 4; in ftdi_gpio_init_ft232r()
2048 priv->gpio_altfunc = 0xff; in ftdi_gpio_init_ft232r()
2049 for (i = 0; i < priv->gc.ngpio; ++i) { in ftdi_gpio_init_ft232r()
2051 priv->gpio_altfunc &= ~BIT(i); in ftdi_gpio_init_ft232r()
2063 struct usb_serial *serial = port->serial; in ftdi_gpio_init_ftx()
2072 return -ENOMEM; in ftdi_gpio_init_ftx()
2080 priv->gc.ngpio = 4; in ftdi_gpio_init_ftx()
2083 priv->gpio_altfunc = 0xff; in ftdi_gpio_init_ftx()
2084 for (i = 0; i < priv->gc.ngpio; ++i) { in ftdi_gpio_init_ftx()
2086 priv->gpio_altfunc &= ~BIT(i); in ftdi_gpio_init_ftx()
2098 struct usb_serial *serial = port->serial; in ftdi_gpio_init()
2101 switch (priv->chip_type) { in ftdi_gpio_init()
2118 mutex_init(&priv->gpio_lock); in ftdi_gpio_init()
2120 priv->gc.label = "ftdi-cbus"; in ftdi_gpio_init()
2121 priv->gc.request = ftdi_gpio_request; in ftdi_gpio_init()
2122 priv->gc.get_direction = ftdi_gpio_direction_get; in ftdi_gpio_init()
2123 priv->gc.direction_input = ftdi_gpio_direction_input; in ftdi_gpio_init()
2124 priv->gc.direction_output = ftdi_gpio_direction_output; in ftdi_gpio_init()
2125 priv->gc.init_valid_mask = ftdi_gpio_init_valid_mask; in ftdi_gpio_init()
2126 priv->gc.get = ftdi_gpio_get; in ftdi_gpio_init()
2127 priv->gc.set = ftdi_gpio_set; in ftdi_gpio_init()
2128 priv->gc.get_multiple = ftdi_gpio_get_multiple; in ftdi_gpio_init()
2129 priv->gc.set_multiple = ftdi_gpio_set_multiple; in ftdi_gpio_init()
2130 priv->gc.owner = THIS_MODULE; in ftdi_gpio_init()
2131 priv->gc.parent = &serial->interface->dev; in ftdi_gpio_init()
2132 priv->gc.base = -1; in ftdi_gpio_init()
2133 priv->gc.can_sleep = true; in ftdi_gpio_init()
2135 result = gpiochip_add_data(&priv->gc, port); in ftdi_gpio_init()
2137 priv->gpio_registered = true; in ftdi_gpio_init()
2146 if (priv->gpio_registered) { in ftdi_gpio_remove()
2147 gpiochip_remove(&priv->gc); in ftdi_gpio_remove()
2148 priv->gpio_registered = false; in ftdi_gpio_remove()
2151 if (priv->gpio_used) { in ftdi_gpio_remove()
2152 /* Exiting CBUS-mode does not reset pin states. */ in ftdi_gpio_remove()
2154 priv->gpio_used = false; in ftdi_gpio_remove()
2177 const struct ftdi_quirk *quirk = (struct ftdi_quirk *)id->driver_info; in ftdi_probe()
2179 if (quirk && quirk->probe) { in ftdi_probe()
2180 int ret = quirk->probe(serial); in ftdi_probe()
2185 usb_set_serial_data(serial, (void *)id->driver_info); in ftdi_probe()
2192 const struct ftdi_quirk *quirk = usb_get_serial_data(port->serial); in ftdi_port_probe()
2198 return -ENOMEM; in ftdi_port_probe()
2200 mutex_init(&priv->cfg_lock); in ftdi_port_probe()
2202 if (quirk && quirk->port_probe) in ftdi_port_probe()
2203 quirk->port_probe(priv); in ftdi_port_probe()
2213 priv->latency = 16; in ftdi_port_probe()
2218 dev_err(&port->serial->interface->dev, in ftdi_port_probe()
2231 /* Setup for the USB-UIRT device, which requires hardwired
2236 priv->flags |= ASYNC_SPD_CUST; in ftdi_USB_UIRT_setup()
2237 priv->custom_divisor = 77; in ftdi_USB_UIRT_setup()
2238 priv->force_baud = 38400; in ftdi_USB_UIRT_setup()
2241 /* Setup for the HE-TIRA1 device, which requires hardwired
2242 * baudrate (38400 gets mapped to 100000) and RTS-CTS enabled. */
2246 priv->flags |= ASYNC_SPD_CUST; in ftdi_HE_TIRA1_setup()
2247 priv->custom_divisor = 240; in ftdi_HE_TIRA1_setup()
2248 priv->force_baud = 38400; in ftdi_HE_TIRA1_setup()
2249 priv->force_rtscts = 1; in ftdi_HE_TIRA1_setup()
2253 * Module parameter to control latency timer for NDI FTDI-based USB devices.
2255 * to 1ms.
2259 /* Setup for the NDI FTDI-based USB devices, which requires hardwired
2266 struct usb_device *udev = serial->dev; in ftdi_NDI_device_setup()
2274 dev_dbg(&udev->dev, "%s setting NDI device latency to %d\n", __func__, latency); in ftdi_NDI_device_setup()
2275 dev_info(&udev->dev, "NDI device with a latency value of %d\n", latency); in ftdi_NDI_device_setup()
2286 * First port on JTAG adaptors such as Olimex arm-usb-ocd or the FIC/OpenMoko
2292 struct usb_interface *intf = serial->interface; in ftdi_jtag_probe()
2293 int ifnum = intf->cur_altsetting->desc.bInterfaceNumber; in ftdi_jtag_probe()
2296 dev_info(&intf->dev, "Ignoring interface reserved for JTAG\n"); in ftdi_jtag_probe()
2297 return -ENODEV; in ftdi_jtag_probe()
2305 struct usb_device *udev = serial->dev; in ftdi_8u2232c_probe()
2307 if (udev->manufacturer && !strcmp(udev->manufacturer, "CALAO Systems")) in ftdi_8u2232c_probe()
2310 if (udev->product && in ftdi_8u2232c_probe()
2311 (!strcmp(udev->product, "Arrow USB Blaster") || in ftdi_8u2232c_probe()
2312 !strcmp(udev->product, "BeagleBone/XDS100V2") || in ftdi_8u2232c_probe()
2313 !strcmp(udev->product, "SNAP Connect E10"))) in ftdi_8u2232c_probe()
2321 * ST Micro Connect Lite are reserved for JTAG or other non-UART interfaces and
2324 * a conventional RS-232 UART.
2328 struct usb_interface *intf = serial->interface; in ftdi_stmclite_probe()
2329 int ifnum = intf->cur_altsetting->desc.bInterfaceNumber; in ftdi_stmclite_probe()
2332 dev_info(&intf->dev, "Ignoring interface reserved for JTAG\n"); in ftdi_stmclite_probe()
2333 return -ENODEV; in ftdi_stmclite_probe()
2350 struct usb_device *dev = port->serial->dev; in ftdi_open()
2358 priv->channel, NULL, 0, WDR_TIMEOUT); in ftdi_open()
2361 port->tty->termios - this would lose speed settings, etc. in ftdi_open()
2362 This is same behaviour as serial.c/rs_open() - Kuba */ in ftdi_open()
2377 if (usb_control_msg(port->serial->dev, in ftdi_dtr_rts()
2378 usb_sndctrlpipe(port->serial->dev, 0), in ftdi_dtr_rts()
2381 0, priv->channel, NULL, 0, in ftdi_dtr_rts()
2383 dev_err(&port->dev, "error from flowcontrol urb\n"); in ftdi_dtr_rts()
2409 if (priv->chip_type == SIO) { in ftdi_prepare_write_buffer()
2414 spin_lock_irqsave(&port->lock, flags); in ftdi_prepare_write_buffer()
2415 for (i = 0; i < size - 1; i += priv->max_packet_size) { in ftdi_prepare_write_buffer()
2416 len = min_t(int, size - i, priv->max_packet_size) - 1; in ftdi_prepare_write_buffer()
2417 c = kfifo_out(&port->write_fifo, &buffer[i + 1], len); in ftdi_prepare_write_buffer()
2420 port->icount.tx += c; in ftdi_prepare_write_buffer()
2424 spin_unlock_irqrestore(&port->lock, flags); in ftdi_prepare_write_buffer()
2426 count = kfifo_out_locked(&port->write_fifo, dest, size, in ftdi_prepare_write_buffer()
2427 &port->lock); in ftdi_prepare_write_buffer()
2428 port->icount.tx += count; in ftdi_prepare_write_buffer()
2445 dev_dbg(&port->dev, "malformed packet\n"); in ftdi_process_packet()
2453 if (status != priv->prev_status) { in ftdi_process_packet()
2454 char diff_status = status ^ priv->prev_status; in ftdi_process_packet()
2457 port->icount.cts++; in ftdi_process_packet()
2459 port->icount.dsr++; in ftdi_process_packet()
2461 port->icount.rng++; in ftdi_process_packet()
2465 port->icount.dcd++; in ftdi_process_packet()
2466 tty = tty_port_tty_get(&port->port); in ftdi_process_packet()
2473 wake_up_interruptible(&port->port.delta_msr_wait); in ftdi_process_packet()
2474 priv->prev_status = status; in ftdi_process_packet()
2479 priv->transmit_empty = 1; in ftdi_process_packet()
2481 priv->transmit_empty = 0; in ftdi_process_packet()
2488 * data payload to avoid over-reporting. in ftdi_process_packet()
2498 if (buf[1] & FTDI_RS_BI && buf[len - 1] == '\0') { in ftdi_process_packet()
2499 port->icount.brk++; in ftdi_process_packet()
2504 port->icount.parity++; in ftdi_process_packet()
2507 port->icount.frame++; in ftdi_process_packet()
2509 /* Overrun is special, not associated with a char */ in ftdi_process_packet()
2511 port->icount.overrun++; in ftdi_process_packet()
2512 tty_insert_flip_char(&port->port, 0, TTY_OVERRUN); in ftdi_process_packet()
2516 port->icount.rx += len - 2; in ftdi_process_packet()
2518 if (brkint || port->sysrq) { in ftdi_process_packet()
2520 if (brkint && i == len - 1) { in ftdi_process_packet()
2522 return len - 3; in ftdi_process_packet()
2527 tty_insert_flip_char(&port->port, buf[i], flag); in ftdi_process_packet()
2530 tty_insert_flip_string_fixed_flag(&port->port, buf + 2, flag, in ftdi_process_packet()
2531 len - 2); in ftdi_process_packet()
2534 return len - 2; in ftdi_process_packet()
2539 struct usb_serial_port *port = urb->context; in ftdi_process_read_urb()
2541 char *data = urb->transfer_buffer; in ftdi_process_read_urb()
2546 for (i = 0; i < urb->actual_length; i += priv->max_packet_size) { in ftdi_process_read_urb()
2547 len = min_t(int, urb->actual_length - i, priv->max_packet_size); in ftdi_process_read_urb()
2552 tty_flip_buffer_push(&port->port); in ftdi_process_read_urb()
2557 struct usb_serial_port *port = tty->driver_data; in ftdi_break_ctl()
2562 /* break_state = -1 to turn on break, and 0 to turn off break */ in ftdi_break_ctl()
2567 value = priv->last_set_data_value | FTDI_SIO_SET_BREAK; in ftdi_break_ctl()
2569 value = priv->last_set_data_value; in ftdi_break_ctl()
2571 ret = usb_control_msg(port->serial->dev, in ftdi_break_ctl()
2572 usb_sndctrlpipe(port->serial->dev, 0), in ftdi_break_ctl()
2575 value, priv->channel, in ftdi_break_ctl()
2578 dev_err(&port->dev, "%s FAILED to enable/disable break state (state was %d)\n", in ftdi_break_ctl()
2583 dev_dbg(&port->dev, "%s break state is %d - urb is %d\n", __func__, in ftdi_break_ctl()
2603 /* old_termios contains the original termios settings and tty->termios contains
2611 struct usb_device *dev = port->serial->dev; in ftdi_set_termios()
2612 struct device *ddev = &port->dev; in ftdi_set_termios()
2614 struct ktermios *termios = &tty->termios; in ftdi_set_termios()
2621 if (priv->force_baud && ((termios->c_cflag & CBAUD) != B0)) { in ftdi_set_termios()
2623 tty_encode_baud_rate(tty, priv->force_baud, in ftdi_set_termios()
2624 priv->force_baud); in ftdi_set_termios()
2627 /* Force RTS-CTS if this device requires it. */ in ftdi_set_termios()
2628 if (priv->force_rtscts) { in ftdi_set_termios()
2630 termios->c_cflag |= CRTSCTS; in ftdi_set_termios()
2650 termios->c_cflag &= ~CSIZE; in ftdi_set_termios()
2652 termios->c_cflag |= old_termios->c_cflag & CSIZE; in ftdi_set_termios()
2654 termios->c_cflag |= CS8; in ftdi_set_termios()
2657 cflag = termios->c_cflag; in ftdi_set_termios()
2662 if (old_termios->c_cflag == termios->c_cflag in ftdi_set_termios()
2663 && old_termios->c_ispeed == termios->c_ispeed in ftdi_set_termios()
2664 && old_termios->c_ospeed == termios->c_ospeed) in ftdi_set_termios()
2668 ftdi_sio_read_bulk_callback - need to examine what this means - in ftdi_set_termios()
2671 if ((old_termios->c_cflag & (CSIZE|PARODD|PARENB|CMSPAR|CSTOPB)) == in ftdi_set_termios()
2672 (termios->c_cflag & (CSIZE|PARODD|PARENB|CMSPAR|CSTOPB))) in ftdi_set_termios()
2709 - but is or'ed with this value */ in ftdi_set_termios()
2710 priv->last_set_data_value = value; in ftdi_set_termios()
2715 value, priv->channel, in ftdi_set_termios()
2728 0, priv->channel, in ftdi_set_termios()
2737 mutex_lock(&priv->cfg_lock); in ftdi_set_termios()
2740 mutex_unlock(&priv->cfg_lock); in ftdi_set_termios()
2742 if (old_termios && (old_termios->c_cflag & CBAUD) == B0) in ftdi_set_termios()
2747 /* Set hardware-assisted flow control */ in ftdi_set_termios()
2751 dev_dbg(&port->dev, "enabling rts/cts flow control\n"); in ftdi_set_termios()
2754 dev_dbg(&port->dev, "enabling xon/xoff flow control\n"); in ftdi_set_termios()
2758 dev_dbg(&port->dev, "disabling flow control\n"); in ftdi_set_termios()
2762 index |= priv->channel; in ftdi_set_termios()
2769 dev_err(&port->dev, "failed to set flow control: %d\n", ret); in ftdi_set_termios()
2773 * Get modem-control status.
2788 return -ENOMEM; in ftdi_get_modem_status()
2793 if (priv->chip_type == SIO) in ftdi_get_modem_status()
2798 ret = usb_control_msg(port->serial->dev, in ftdi_get_modem_status()
2799 usb_rcvctrlpipe(port->serial->dev, 0), in ftdi_get_modem_status()
2802 0, priv->channel, in ftdi_get_modem_status()
2807 dev_err(&port->dev, "failed to get modem status: %d\n", ret); in ftdi_get_modem_status()
2809 ret = -EIO; in ftdi_get_modem_status()
2820 dev_dbg(&port->dev, "%s - 0x%02x%02x\n", __func__, status[0], in ftdi_get_modem_status()
2830 struct usb_serial_port *port = tty->driver_data; in ftdi_tiocmget()
2843 priv->last_dtr_rts; in ftdi_tiocmget()
2851 struct usb_serial_port *port = tty->driver_data; in ftdi_tiocmset()
2859 struct usb_serial_port *port = tty->driver_data; in ftdi_ioctl()
2869 return -ENOIOCTLCMD; in ftdi_ioctl()
2887 .throttle = usb_serial_generic_throttle,