Lines Matching +full:dsr +full:- +full:override

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 */
1117 [FTX] = "FT-X",
1193 /* hi-speed baud rate is 10-bit sampling instead of 16-bit */ in ftdi_2232h_baud_base_to_divisor()
1224 struct device *dev = &port->dev; in update_mctrl()
1229 dev_dbg(dev, "%s - DTR|RTS not being set|cleared\n", __func__); in update_mctrl()
1243 rv = usb_control_msg(port->serial->dev, in update_mctrl()
1244 usb_sndctrlpipe(port->serial->dev, 0), in update_mctrl()
1247 value, priv->channel, in update_mctrl()
1256 dev_dbg(dev, "%s - DTR %s, RTS %s\n", __func__, in update_mctrl()
1260 priv->last_dtr_rts = (priv->last_dtr_rts & ~clear) | set; in update_mctrl()
1270 struct device *dev = &port->dev; in get_ftdi_divisor()
1276 dev_dbg(dev, "%s - tty_get_baud_rate reports speed %d\n", __func__, baud); in get_ftdi_divisor()
1279 * Observe deprecated async-compatible custom_divisor hack, update in get_ftdi_divisor()
1283 ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) && in get_ftdi_divisor()
1284 (priv->custom_divisor)) { in get_ftdi_divisor()
1285 baud = priv->baud_base / priv->custom_divisor; in get_ftdi_divisor()
1286 dev_dbg(dev, "%s - custom divisor %d sets baud rate to %d\n", in get_ftdi_divisor()
1287 __func__, priv->custom_divisor, baud); in get_ftdi_divisor()
1292 switch (priv->chip_type) { in get_ftdi_divisor()
1306 dev_dbg(dev, "%s - Baudrate (%d) requested is not supported\n", in get_ftdi_divisor()
1317 dev_dbg(dev, "%s - Baud rate too high!\n", __func__); in get_ftdi_divisor()
1329 port->serial->dev->descriptor.idProduct); in get_ftdi_divisor()
1340 dev_dbg(dev, "%s - Baud rate too high!\n", __func__); in get_ftdi_divisor()
1352 dev_dbg(dev, "%s - Baud rate too high!\n", __func__); in get_ftdi_divisor()
1361 dev_dbg(dev, "%s - Baud rate set to %d (divisor 0x%lX) on chip %s\n", in get_ftdi_divisor()
1363 ftdi_chip_name[priv->chip_type]); in get_ftdi_divisor()
1381 if (priv->channel) in change_speed()
1382 index = (u16)((index << 8) | priv->channel); in change_speed()
1384 rv = usb_control_msg(port->serial->dev, in change_speed()
1385 usb_sndctrlpipe(port->serial->dev, 0), in change_speed()
1396 struct usb_device *udev = port->serial->dev; in write_latency_timer()
1398 int l = priv->latency; in write_latency_timer()
1400 if (priv->chip_type == SIO || priv->chip_type == FT232A) in write_latency_timer()
1401 return -EINVAL; in write_latency_timer()
1403 if (priv->flags & ASYNC_LOW_LATENCY) in write_latency_timer()
1406 dev_dbg(&port->dev, "%s: setting latency timer = %i\n", __func__, l); in write_latency_timer()
1412 l, priv->channel, in write_latency_timer()
1415 dev_err(&port->dev, "Unable to write latency timer: %i\n", rv); in write_latency_timer()
1422 struct usb_device *udev = port->serial->dev; in _read_latency_timer()
1428 priv->channel, &buf, 1, WDR_TIMEOUT, in _read_latency_timer()
1441 if (priv->chip_type == SIO || priv->chip_type == FT232A) in read_latency_timer()
1442 return -EINVAL; in read_latency_timer()
1446 dev_err(&port->dev, "Unable to read latency timer: %i\n", rv); in read_latency_timer()
1450 priv->latency = rv; in read_latency_timer()
1457 struct usb_serial_port *port = tty->driver_data; in get_serial_info()
1460 ss->flags = priv->flags; in get_serial_info()
1461 ss->baud_base = priv->baud_base; in get_serial_info()
1462 ss->custom_divisor = priv->custom_divisor; in get_serial_info()
1467 struct usb_serial_port *port = tty->driver_data; in set_serial_info()
1471 mutex_lock(&priv->cfg_lock); in set_serial_info()
1474 if ((ss->flags ^ priv->flags) & ~ASYNC_USR_MASK) { in set_serial_info()
1475 mutex_unlock(&priv->cfg_lock); in set_serial_info()
1476 return -EPERM; in set_serial_info()
1480 old_flags = priv->flags; in set_serial_info()
1481 old_divisor = priv->custom_divisor; in set_serial_info()
1483 priv->flags = ss->flags & ASYNC_FLAGS; in set_serial_info()
1484 priv->custom_divisor = ss->custom_divisor; in set_serial_info()
1488 if ((priv->flags ^ old_flags) & ASYNC_SPD_MASK || in set_serial_info()
1489 ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST && in set_serial_info()
1490 priv->custom_divisor != old_divisor)) { in set_serial_info()
1493 if (priv->flags & ASYNC_SPD_MASK) in set_serial_info()
1494 dev_warn_ratelimited(&port->dev, "use of SPD flags is deprecated\n"); in set_serial_info()
1498 mutex_unlock(&priv->cfg_lock); in set_serial_info()
1508 if (priv->transmit_empty) in get_lsr_info()
1512 return -EFAULT; in get_lsr_info()
1519 struct usb_serial *serial = port->serial; in ftdi_determine_type()
1520 struct usb_device *udev = serial->dev; in ftdi_determine_type()
1523 version = le16_to_cpu(udev->descriptor.bcdDevice); in ftdi_determine_type()
1524 ifnum = serial->interface->cur_altsetting->desc.bInterfaceNumber; in ftdi_determine_type()
1526 /* Assume Hi-Speed type */ in ftdi_determine_type()
1527 priv->baud_base = 120000000 / 2; in ftdi_determine_type()
1528 priv->channel = CHANNEL_A + ifnum; in ftdi_determine_type()
1532 priv->chip_type = FT232A; in ftdi_determine_type()
1533 priv->baud_base = 48000000 / 2; in ftdi_determine_type()
1534 priv->channel = 0; in ftdi_determine_type()
1540 if (udev->descriptor.iSerialNumber == 0 && in ftdi_determine_type()
1542 priv->chip_type = FT232B; in ftdi_determine_type()
1546 priv->chip_type = FT232B; in ftdi_determine_type()
1547 priv->baud_base = 48000000 / 2; in ftdi_determine_type()
1548 priv->channel = 0; in ftdi_determine_type()
1551 priv->chip_type = FT2232C; in ftdi_determine_type()
1552 priv->baud_base = 48000000 / 2; in ftdi_determine_type()
1555 priv->chip_type = FT232R; in ftdi_determine_type()
1556 priv->baud_base = 48000000 / 2; in ftdi_determine_type()
1557 priv->channel = 0; in ftdi_determine_type()
1560 priv->chip_type = FT2232H; in ftdi_determine_type()
1563 priv->chip_type = FT4232H; in ftdi_determine_type()
1566 priv->chip_type = FT232H; in ftdi_determine_type()
1569 priv->chip_type = FTX; in ftdi_determine_type()
1570 priv->baud_base = 48000000 / 2; in ftdi_determine_type()
1573 priv->chip_type = FT2233HP; in ftdi_determine_type()
1576 priv->chip_type = FT4233HP; in ftdi_determine_type()
1579 priv->chip_type = FT2232HP; in ftdi_determine_type()
1582 priv->chip_type = FT4232HP; in ftdi_determine_type()
1585 priv->chip_type = FT233HP; in ftdi_determine_type()
1588 priv->chip_type = FT232HP; in ftdi_determine_type()
1591 priv->chip_type = FT4232HA; in ftdi_determine_type()
1595 priv->chip_type = SIO; in ftdi_determine_type()
1596 priv->baud_base = 12000000 / 16; in ftdi_determine_type()
1597 priv->channel = 0; in ftdi_determine_type()
1599 dev_err(&port->dev, "unknown device type: 0x%02x\n", version); in ftdi_determine_type()
1600 return -ENODEV; in ftdi_determine_type()
1604 dev_info(&udev->dev, "Detected %s\n", ftdi_chip_name[priv->chip_type]); in ftdi_determine_type()
1618 struct usb_interface *interface = port->serial->interface; in ftdi_set_max_packet_size()
1623 num_endpoints = interface->cur_altsetting->desc.bNumEndpoints; in ftdi_set_max_packet_size()
1629 * with an endpoint size of 0 - not good. In this case, we in ftdi_set_max_packet_size()
1630 * want to override the endpoint descriptor setting and use a in ftdi_set_max_packet_size()
1634 ep_desc = &interface->cur_altsetting->endpoint[i].desc; in ftdi_set_max_packet_size()
1635 if (!ep_desc->wMaxPacketSize) { in ftdi_set_max_packet_size()
1636 ep_desc->wMaxPacketSize = cpu_to_le16(0x40); in ftdi_set_max_packet_size()
1637 dev_warn(&port->dev, "Overriding wMaxPacketSize on endpoint %d\n", in ftdi_set_max_packet_size()
1643 priv->max_packet_size = usb_endpoint_maxp(ep_desc); in ftdi_set_max_packet_size()
1658 if (priv->flags & ASYNC_LOW_LATENCY) in latency_timer_show()
1661 return sprintf(buf, "%u\n", priv->latency); in latency_timer_show()
1675 return -EINVAL; in latency_timer_store()
1677 priv->latency = v; in latency_timer_store()
1680 return -EIO; in latency_timer_store()
1692 struct usb_device *udev = port->serial->dev; in event_char_store()
1697 return -EINVAL; in event_char_store()
1699 dev_dbg(&port->dev, "%s: setting event char = 0x%03x\n", __func__, v); in event_char_store()
1705 v, priv->channel, in event_char_store()
1708 dev_dbg(&port->dev, "Unable to write event character: %i\n", rv); in event_char_store()
1709 return -EIO; in event_char_store()
1727 enum ftdi_chip_type type = priv->chip_type; in ftdi_is_visible()
1739 return attr->mode; in ftdi_is_visible()
1757 struct usb_serial *serial = port->serial; in ftdi_set_bitmode()
1761 result = usb_autopm_get_interface(serial->interface); in ftdi_set_bitmode()
1765 val = (mode << 8) | (priv->gpio_output << 4) | priv->gpio_value; in ftdi_set_bitmode()
1766 result = usb_control_msg(serial->dev, in ftdi_set_bitmode()
1767 usb_sndctrlpipe(serial->dev, 0), in ftdi_set_bitmode()
1770 priv->channel, NULL, 0, WDR_TIMEOUT); in ftdi_set_bitmode()
1772 dev_err(&serial->interface->dev, in ftdi_set_bitmode()
1777 usb_autopm_put_interface(serial->interface); in ftdi_set_bitmode()
1791 priv->gpio_output = 0; in ftdi_exit_cbus_mode()
1792 priv->gpio_value = 0; in ftdi_exit_cbus_mode()
1802 mutex_lock(&priv->gpio_lock); in ftdi_gpio_request()
1803 if (!priv->gpio_used) { in ftdi_gpio_request()
1805 priv->gpio_output = 0x00; in ftdi_gpio_request()
1806 priv->gpio_value = 0x00; in ftdi_gpio_request()
1809 mutex_unlock(&priv->gpio_lock); in ftdi_gpio_request()
1813 priv->gpio_used = true; in ftdi_gpio_request()
1815 mutex_unlock(&priv->gpio_lock); in ftdi_gpio_request()
1823 struct usb_serial *serial = port->serial; in ftdi_read_cbus_pins()
1827 result = usb_autopm_get_interface(serial->interface); in ftdi_read_cbus_pins()
1831 result = usb_control_msg_recv(serial->dev, 0, in ftdi_read_cbus_pins()
1834 priv->channel, &buf, 1, WDR_TIMEOUT, in ftdi_read_cbus_pins()
1839 usb_autopm_put_interface(serial->interface); in ftdi_read_cbus_pins()
1861 mutex_lock(&priv->gpio_lock); in ftdi_gpio_set()
1864 priv->gpio_value |= BIT(gpio); in ftdi_gpio_set()
1866 priv->gpio_value &= ~BIT(gpio); in ftdi_gpio_set()
1870 mutex_unlock(&priv->gpio_lock); in ftdi_gpio_set()
1894 mutex_lock(&priv->gpio_lock); in ftdi_gpio_set_multiple()
1896 priv->gpio_value &= ~(*mask); in ftdi_gpio_set_multiple()
1897 priv->gpio_value |= *bits & *mask; in ftdi_gpio_set_multiple()
1900 mutex_unlock(&priv->gpio_lock); in ftdi_gpio_set_multiple()
1908 return !(priv->gpio_output & BIT(gpio)); in ftdi_gpio_direction_get()
1917 mutex_lock(&priv->gpio_lock); in ftdi_gpio_direction_input()
1919 priv->gpio_output &= ~BIT(gpio); in ftdi_gpio_direction_input()
1922 mutex_unlock(&priv->gpio_lock); in ftdi_gpio_direction_input()
1934 mutex_lock(&priv->gpio_lock); in ftdi_gpio_direction_output()
1936 priv->gpio_output |= BIT(gpio); in ftdi_gpio_direction_output()
1938 priv->gpio_value |= BIT(gpio); in ftdi_gpio_direction_output()
1940 priv->gpio_value &= ~BIT(gpio); in ftdi_gpio_direction_output()
1944 mutex_unlock(&priv->gpio_lock); in ftdi_gpio_direction_output()
1955 unsigned long map = priv->gpio_altfunc; in ftdi_gpio_init_valid_mask()
1960 dev_dbg(&port->dev, "no CBUS pin configured for GPIO\n"); in ftdi_gpio_init_valid_mask()
1962 dev_dbg(&port->dev, "CBUS%*pbl configured for GPIO\n", ngpios, in ftdi_gpio_init_valid_mask()
1974 return -EINVAL; in ftdi_read_eeprom()
1976 return -EINVAL; in ftdi_read_eeprom()
1982 rv = usb_control_msg(serial->dev, in ftdi_read_eeprom()
1983 usb_rcvctrlpipe(serial->dev, 0), in ftdi_read_eeprom()
1990 return -EIO; in ftdi_read_eeprom()
2011 return -ENOMEM; in ftdi_gpio_init_ft232h()
2013 ret = ftdi_read_eeprom(port->serial, buf, 0x1a, 4); in ftdi_gpio_init_ft232h()
2020 * 0x1a: X- (upper nibble -> AC5) in ftdi_gpio_init_ft232h()
2021 * 0x1b: -X (lower nibble -> AC6) in ftdi_gpio_init_ft232h()
2022 * 0x1c: XX (upper nibble -> AC9 | lower nibble -> AC8) in ftdi_gpio_init_ft232h()
2026 priv->gc.ngpio = 4; in ftdi_gpio_init_ft232h()
2027 priv->gpio_altfunc = 0xff; in ftdi_gpio_init_ft232h()
2029 for (i = 0; i < priv->gc.ngpio; ++i) { in ftdi_gpio_init_ft232h()
2031 priv->gpio_altfunc &= ~BIT(i); in ftdi_gpio_init_ft232h()
2051 return -ENOMEM; in ftdi_gpio_init_ft232r()
2053 ret = ftdi_read_eeprom(port->serial, buf, 0x14, 2); in ftdi_gpio_init_ft232r()
2058 dev_dbg(&port->dev, "cbus_config = 0x%04x\n", cbus_config); in ftdi_gpio_init_ft232r()
2060 priv->gc.ngpio = 4; in ftdi_gpio_init_ft232r()
2062 priv->gpio_altfunc = 0xff; in ftdi_gpio_init_ft232r()
2063 for (i = 0; i < priv->gc.ngpio; ++i) { in ftdi_gpio_init_ft232r()
2065 priv->gpio_altfunc &= ~BIT(i); in ftdi_gpio_init_ft232r()
2077 struct usb_serial *serial = port->serial; in ftdi_gpio_init_ftx()
2086 return -ENOMEM; in ftdi_gpio_init_ftx()
2094 priv->gc.ngpio = 4; in ftdi_gpio_init_ftx()
2097 priv->gpio_altfunc = 0xff; in ftdi_gpio_init_ftx()
2098 for (i = 0; i < priv->gc.ngpio; ++i) { in ftdi_gpio_init_ftx()
2100 priv->gpio_altfunc &= ~BIT(i); in ftdi_gpio_init_ftx()
2112 struct usb_serial *serial = port->serial; in ftdi_gpio_init()
2115 switch (priv->chip_type) { in ftdi_gpio_init()
2132 mutex_init(&priv->gpio_lock); in ftdi_gpio_init()
2134 priv->gc.label = "ftdi-cbus"; in ftdi_gpio_init()
2135 priv->gc.request = ftdi_gpio_request; in ftdi_gpio_init()
2136 priv->gc.get_direction = ftdi_gpio_direction_get; in ftdi_gpio_init()
2137 priv->gc.direction_input = ftdi_gpio_direction_input; in ftdi_gpio_init()
2138 priv->gc.direction_output = ftdi_gpio_direction_output; in ftdi_gpio_init()
2139 priv->gc.init_valid_mask = ftdi_gpio_init_valid_mask; in ftdi_gpio_init()
2140 priv->gc.get = ftdi_gpio_get; in ftdi_gpio_init()
2141 priv->gc.set = ftdi_gpio_set; in ftdi_gpio_init()
2142 priv->gc.get_multiple = ftdi_gpio_get_multiple; in ftdi_gpio_init()
2143 priv->gc.set_multiple = ftdi_gpio_set_multiple; in ftdi_gpio_init()
2144 priv->gc.owner = THIS_MODULE; in ftdi_gpio_init()
2145 priv->gc.parent = &serial->interface->dev; in ftdi_gpio_init()
2146 priv->gc.base = -1; in ftdi_gpio_init()
2147 priv->gc.can_sleep = true; in ftdi_gpio_init()
2149 result = gpiochip_add_data(&priv->gc, port); in ftdi_gpio_init()
2151 priv->gpio_registered = true; in ftdi_gpio_init()
2160 if (priv->gpio_registered) { in ftdi_gpio_remove()
2161 gpiochip_remove(&priv->gc); in ftdi_gpio_remove()
2162 priv->gpio_registered = false; in ftdi_gpio_remove()
2165 if (priv->gpio_used) { in ftdi_gpio_remove()
2166 /* Exiting CBUS-mode does not reset pin states. */ in ftdi_gpio_remove()
2168 priv->gpio_used = false; in ftdi_gpio_remove()
2191 const struct ftdi_quirk *quirk = (struct ftdi_quirk *)id->driver_info; in ftdi_probe()
2193 if (quirk && quirk->probe) { in ftdi_probe()
2194 int ret = quirk->probe(serial); in ftdi_probe()
2199 usb_set_serial_data(serial, (void *)id->driver_info); in ftdi_probe()
2206 const struct ftdi_quirk *quirk = usb_get_serial_data(port->serial); in ftdi_port_probe()
2212 return -ENOMEM; in ftdi_port_probe()
2214 mutex_init(&priv->cfg_lock); in ftdi_port_probe()
2216 if (quirk && quirk->port_probe) in ftdi_port_probe()
2217 quirk->port_probe(priv); in ftdi_port_probe()
2227 priv->latency = 16; in ftdi_port_probe()
2232 dev_err(&port->serial->interface->dev, in ftdi_port_probe()
2245 /* Setup for the USB-UIRT device, which requires hardwired
2250 priv->flags |= ASYNC_SPD_CUST; in ftdi_USB_UIRT_setup()
2251 priv->custom_divisor = 77; in ftdi_USB_UIRT_setup()
2252 priv->force_baud = 38400; in ftdi_USB_UIRT_setup()
2255 /* Setup for the HE-TIRA1 device, which requires hardwired
2256 * baudrate (38400 gets mapped to 100000) and RTS-CTS enabled. */
2260 priv->flags |= ASYNC_SPD_CUST; in ftdi_HE_TIRA1_setup()
2261 priv->custom_divisor = 240; in ftdi_HE_TIRA1_setup()
2262 priv->force_baud = 38400; in ftdi_HE_TIRA1_setup()
2263 priv->force_rtscts = 1; in ftdi_HE_TIRA1_setup()
2267 * Module parameter to control latency timer for NDI FTDI-based USB devices.
2273 /* Setup for the NDI FTDI-based USB devices, which requires hardwired
2280 struct usb_device *udev = serial->dev; in ftdi_NDI_device_setup()
2288 dev_dbg(&udev->dev, "%s setting NDI device latency to %d\n", __func__, latency); in ftdi_NDI_device_setup()
2289 dev_info(&udev->dev, "NDI device with a latency value of %d\n", latency); in ftdi_NDI_device_setup()
2300 * First port on JTAG adaptors such as Olimex arm-usb-ocd or the FIC/OpenMoko
2306 struct usb_interface *intf = serial->interface; in ftdi_jtag_probe()
2307 int ifnum = intf->cur_altsetting->desc.bInterfaceNumber; in ftdi_jtag_probe()
2310 dev_info(&intf->dev, "Ignoring interface reserved for JTAG\n"); in ftdi_jtag_probe()
2311 return -ENODEV; in ftdi_jtag_probe()
2319 struct usb_device *udev = serial->dev; in ftdi_8u2232c_probe()
2321 if (udev->manufacturer && !strcmp(udev->manufacturer, "CALAO Systems")) in ftdi_8u2232c_probe()
2324 if (udev->product && in ftdi_8u2232c_probe()
2325 (!strcmp(udev->product, "Arrow USB Blaster") || in ftdi_8u2232c_probe()
2326 !strcmp(udev->product, "BeagleBone/XDS100V2") || in ftdi_8u2232c_probe()
2327 !strcmp(udev->product, "SNAP Connect E10"))) in ftdi_8u2232c_probe()
2335 * ST Micro Connect Lite are reserved for JTAG or other non-UART interfaces and
2338 * a conventional RS-232 UART.
2342 struct usb_interface *intf = serial->interface; in ftdi_stmclite_probe()
2343 int ifnum = intf->cur_altsetting->desc.bInterfaceNumber; in ftdi_stmclite_probe()
2346 dev_info(&intf->dev, "Ignoring interface reserved for JTAG\n"); in ftdi_stmclite_probe()
2347 return -ENODEV; in ftdi_stmclite_probe()
2364 struct usb_device *dev = port->serial->dev; in ftdi_open()
2372 priv->channel, NULL, 0, WDR_TIMEOUT); in ftdi_open()
2375 port->tty->termios - this would lose speed settings, etc. in ftdi_open()
2376 This is same behaviour as serial.c/rs_open() - Kuba */ in ftdi_open()
2391 if (usb_control_msg(port->serial->dev, in ftdi_dtr_rts()
2392 usb_sndctrlpipe(port->serial->dev, 0), in ftdi_dtr_rts()
2395 0, priv->channel, NULL, 0, in ftdi_dtr_rts()
2397 dev_err(&port->dev, "error from flowcontrol urb\n"); in ftdi_dtr_rts()
2423 if (priv->chip_type == SIO) { in ftdi_prepare_write_buffer()
2428 spin_lock_irqsave(&port->lock, flags); in ftdi_prepare_write_buffer()
2429 for (i = 0; i < size - 1; i += priv->max_packet_size) { in ftdi_prepare_write_buffer()
2430 len = min_t(int, size - i, priv->max_packet_size) - 1; in ftdi_prepare_write_buffer()
2431 c = kfifo_out(&port->write_fifo, &buffer[i + 1], len); in ftdi_prepare_write_buffer()
2434 port->icount.tx += c; in ftdi_prepare_write_buffer()
2438 spin_unlock_irqrestore(&port->lock, flags); in ftdi_prepare_write_buffer()
2440 count = kfifo_out_locked(&port->write_fifo, dest, size, in ftdi_prepare_write_buffer()
2441 &port->lock); in ftdi_prepare_write_buffer()
2442 port->icount.tx += count; in ftdi_prepare_write_buffer()
2459 dev_dbg(&port->dev, "malformed packet\n"); in ftdi_process_packet()
2467 if (status != priv->prev_status) { in ftdi_process_packet()
2468 char diff_status = status ^ priv->prev_status; in ftdi_process_packet()
2471 port->icount.cts++; in ftdi_process_packet()
2473 port->icount.dsr++; in ftdi_process_packet()
2475 port->icount.rng++; in ftdi_process_packet()
2479 port->icount.dcd++; in ftdi_process_packet()
2480 tty = tty_port_tty_get(&port->port); in ftdi_process_packet()
2487 wake_up_interruptible(&port->port.delta_msr_wait); in ftdi_process_packet()
2488 priv->prev_status = status; in ftdi_process_packet()
2493 priv->transmit_empty = 1; in ftdi_process_packet()
2495 priv->transmit_empty = 0; in ftdi_process_packet()
2502 * data payload to avoid over-reporting. in ftdi_process_packet()
2512 if (buf[1] & FTDI_RS_BI && buf[len - 1] == '\0') { in ftdi_process_packet()
2513 port->icount.brk++; in ftdi_process_packet()
2518 port->icount.parity++; in ftdi_process_packet()
2521 port->icount.frame++; in ftdi_process_packet()
2525 port->icount.overrun++; in ftdi_process_packet()
2526 tty_insert_flip_char(&port->port, 0, TTY_OVERRUN); in ftdi_process_packet()
2530 port->icount.rx += len - 2; in ftdi_process_packet()
2532 if (brkint || port->sysrq) { in ftdi_process_packet()
2534 if (brkint && i == len - 1) { in ftdi_process_packet()
2536 return len - 3; in ftdi_process_packet()
2541 tty_insert_flip_char(&port->port, buf[i], flag); in ftdi_process_packet()
2544 tty_insert_flip_string_fixed_flag(&port->port, buf + 2, flag, in ftdi_process_packet()
2545 len - 2); in ftdi_process_packet()
2548 return len - 2; in ftdi_process_packet()
2553 struct usb_serial_port *port = urb->context; in ftdi_process_read_urb()
2555 char *data = urb->transfer_buffer; in ftdi_process_read_urb()
2560 for (i = 0; i < urb->actual_length; i += priv->max_packet_size) { in ftdi_process_read_urb()
2561 len = min_t(int, urb->actual_length - i, priv->max_packet_size); in ftdi_process_read_urb()
2566 tty_flip_buffer_push(&port->port); in ftdi_process_read_urb()
2571 struct usb_serial_port *port = tty->driver_data; in ftdi_break_ctl()
2576 /* break_state = -1 to turn on break, and 0 to turn off break */ in ftdi_break_ctl()
2581 value = priv->last_set_data_value | FTDI_SIO_SET_BREAK; in ftdi_break_ctl()
2583 value = priv->last_set_data_value; in ftdi_break_ctl()
2585 ret = usb_control_msg(port->serial->dev, in ftdi_break_ctl()
2586 usb_sndctrlpipe(port->serial->dev, 0), in ftdi_break_ctl()
2589 value, priv->channel, in ftdi_break_ctl()
2592 dev_err(&port->dev, "%s FAILED to enable/disable break state (state was %d)\n", in ftdi_break_ctl()
2597 dev_dbg(&port->dev, "%s break state is %d - urb is %d\n", __func__, in ftdi_break_ctl()
2617 /* old_termios contains the original termios settings and tty->termios contains
2625 struct usb_device *dev = port->serial->dev; in ftdi_set_termios()
2626 struct device *ddev = &port->dev; in ftdi_set_termios()
2628 struct ktermios *termios = &tty->termios; in ftdi_set_termios()
2629 unsigned int cflag = termios->c_cflag; in ftdi_set_termios()
2635 if (priv->force_baud && ((termios->c_cflag & CBAUD) != B0)) { in ftdi_set_termios()
2637 tty_encode_baud_rate(tty, priv->force_baud, in ftdi_set_termios()
2638 priv->force_baud); in ftdi_set_termios()
2641 /* Force RTS-CTS if this device requires it. */ in ftdi_set_termios()
2642 if (priv->force_rtscts) { in ftdi_set_termios()
2644 termios->c_cflag |= CRTSCTS; in ftdi_set_termios()
2664 termios->c_cflag &= ~CSIZE; in ftdi_set_termios()
2666 termios->c_cflag |= old_termios->c_cflag & CSIZE; in ftdi_set_termios()
2668 termios->c_cflag |= CS8; in ftdi_set_termios()
2671 cflag = termios->c_cflag; in ftdi_set_termios()
2676 if (old_termios->c_cflag == termios->c_cflag in ftdi_set_termios()
2677 && old_termios->c_ispeed == termios->c_ispeed in ftdi_set_termios()
2678 && old_termios->c_ospeed == termios->c_ospeed) in ftdi_set_termios()
2682 ftdi_sio_read_bulk_callback - need to examine what this means - in ftdi_set_termios()
2685 if ((old_termios->c_cflag & (CSIZE|PARODD|PARENB|CMSPAR|CSTOPB)) == in ftdi_set_termios()
2686 (termios->c_cflag & (CSIZE|PARODD|PARENB|CMSPAR|CSTOPB))) in ftdi_set_termios()
2723 - but is or'ed with this value */ in ftdi_set_termios()
2724 priv->last_set_data_value = value; in ftdi_set_termios()
2729 value, priv->channel, in ftdi_set_termios()
2742 0, priv->channel, in ftdi_set_termios()
2751 mutex_lock(&priv->cfg_lock); in ftdi_set_termios()
2754 mutex_unlock(&priv->cfg_lock); in ftdi_set_termios()
2756 if (old_termios && (old_termios->c_cflag & CBAUD) == B0) in ftdi_set_termios()
2761 /* Set hardware-assisted flow control */ in ftdi_set_termios()
2765 dev_dbg(&port->dev, "enabling rts/cts flow control\n"); in ftdi_set_termios()
2768 dev_dbg(&port->dev, "enabling xon/xoff flow control\n"); in ftdi_set_termios()
2772 dev_dbg(&port->dev, "disabling flow control\n"); in ftdi_set_termios()
2776 index |= priv->channel; in ftdi_set_termios()
2783 dev_err(&port->dev, "failed to set flow control: %d\n", ret); in ftdi_set_termios()
2787 * Get modem-control status.
2802 return -ENOMEM; in ftdi_get_modem_status()
2807 if (priv->chip_type == SIO) in ftdi_get_modem_status()
2812 ret = usb_control_msg(port->serial->dev, in ftdi_get_modem_status()
2813 usb_rcvctrlpipe(port->serial->dev, 0), in ftdi_get_modem_status()
2816 0, priv->channel, in ftdi_get_modem_status()
2821 dev_err(&port->dev, "failed to get modem status: %d\n", ret); in ftdi_get_modem_status()
2823 ret = -EIO; in ftdi_get_modem_status()
2834 dev_dbg(&port->dev, "%s - 0x%02x%02x\n", __func__, status[0], in ftdi_get_modem_status()
2844 struct usb_serial_port *port = tty->driver_data; in ftdi_tiocmget()
2857 priv->last_dtr_rts; in ftdi_tiocmget()
2865 struct usb_serial_port *port = tty->driver_data; in ftdi_tiocmset()
2873 struct usb_serial_port *port = tty->driver_data; in ftdi_ioctl()
2883 return -ENOIOCTLCMD; in ftdi_ioctl()
2928 MODULE_PARM_DESC(ndi_latency_timer, "NDI device latency timer override");