Lines Matching +full:u +full:- +full:blox

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 */
1101 [FTX] = "FT-X",
1177 /* hi-speed baud rate is 10-bit sampling instead of 16-bit */ in ftdi_2232h_baud_base_to_divisor()
1208 struct device *dev = &port->dev; in update_mctrl()
1213 dev_dbg(dev, "%s - DTR|RTS not being set|cleared\n", __func__); in update_mctrl()
1227 rv = usb_control_msg(port->serial->dev, in update_mctrl()
1228 usb_sndctrlpipe(port->serial->dev, 0), in update_mctrl()
1231 value, priv->channel, in update_mctrl()
1240 dev_dbg(dev, "%s - DTR %s, RTS %s\n", __func__, in update_mctrl()
1244 priv->last_dtr_rts = (priv->last_dtr_rts & ~clear) | set; in update_mctrl()
1254 struct device *dev = &port->dev; in get_ftdi_divisor()
1260 dev_dbg(dev, "%s - tty_get_baud_rate reports speed %d\n", __func__, baud); in get_ftdi_divisor()
1263 * Observe deprecated async-compatible custom_divisor hack, update in get_ftdi_divisor()
1267 ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) && in get_ftdi_divisor()
1268 (priv->custom_divisor)) { in get_ftdi_divisor()
1269 baud = priv->baud_base / priv->custom_divisor; in get_ftdi_divisor()
1270 dev_dbg(dev, "%s - custom divisor %d sets baud rate to %d\n", in get_ftdi_divisor()
1271 __func__, priv->custom_divisor, baud); in get_ftdi_divisor()
1276 switch (priv->chip_type) { in get_ftdi_divisor()
1290 dev_dbg(dev, "%s - Baudrate (%d) requested is not supported\n", in get_ftdi_divisor()
1301 dev_dbg(dev, "%s - Baud rate too high!\n", __func__); in get_ftdi_divisor()
1313 port->serial->dev->descriptor.idProduct); in get_ftdi_divisor()
1324 dev_dbg(dev, "%s - Baud rate too high!\n", __func__); in get_ftdi_divisor()
1336 dev_dbg(dev, "%s - Baud rate too high!\n", __func__); in get_ftdi_divisor()
1345 dev_dbg(dev, "%s - Baud rate set to %d (divisor 0x%lX) on chip %s\n", in get_ftdi_divisor()
1347 ftdi_chip_name[priv->chip_type]); in get_ftdi_divisor()
1365 if (priv->channel) in change_speed()
1366 index = (u16)((index << 8) | priv->channel); in change_speed()
1368 rv = usb_control_msg(port->serial->dev, in change_speed()
1369 usb_sndctrlpipe(port->serial->dev, 0), in change_speed()
1380 struct usb_device *udev = port->serial->dev; in write_latency_timer()
1382 int l = priv->latency; in write_latency_timer()
1384 if (priv->chip_type == SIO || priv->chip_type == FT232A) in write_latency_timer()
1385 return -EINVAL; in write_latency_timer()
1387 if (priv->flags & ASYNC_LOW_LATENCY) in write_latency_timer()
1390 dev_dbg(&port->dev, "%s: setting latency timer = %i\n", __func__, l); in write_latency_timer()
1396 l, priv->channel, in write_latency_timer()
1399 dev_err(&port->dev, "Unable to write latency timer: %i\n", rv); in write_latency_timer()
1406 struct usb_device *udev = port->serial->dev; in _read_latency_timer()
1412 priv->channel, &buf, 1, WDR_TIMEOUT, in _read_latency_timer()
1425 if (priv->chip_type == SIO || priv->chip_type == FT232A) in read_latency_timer()
1426 return -EINVAL; in read_latency_timer()
1430 dev_err(&port->dev, "Unable to read latency timer: %i\n", rv); in read_latency_timer()
1434 priv->latency = rv; in read_latency_timer()
1441 struct usb_serial_port *port = tty->driver_data; in get_serial_info()
1444 ss->flags = priv->flags; in get_serial_info()
1445 ss->baud_base = priv->baud_base; in get_serial_info()
1446 ss->custom_divisor = priv->custom_divisor; in get_serial_info()
1451 struct usb_serial_port *port = tty->driver_data; in set_serial_info()
1455 mutex_lock(&priv->cfg_lock); in set_serial_info()
1458 if ((ss->flags ^ priv->flags) & ~ASYNC_USR_MASK) { in set_serial_info()
1459 mutex_unlock(&priv->cfg_lock); in set_serial_info()
1460 return -EPERM; in set_serial_info()
1464 old_flags = priv->flags; in set_serial_info()
1465 old_divisor = priv->custom_divisor; in set_serial_info()
1467 priv->flags = ss->flags & ASYNC_FLAGS; in set_serial_info()
1468 priv->custom_divisor = ss->custom_divisor; in set_serial_info()
1472 if ((priv->flags ^ old_flags) & ASYNC_SPD_MASK || in set_serial_info()
1473 ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST && in set_serial_info()
1474 priv->custom_divisor != old_divisor)) { in set_serial_info()
1477 if (priv->flags & ASYNC_SPD_MASK) in set_serial_info()
1478 dev_warn_ratelimited(&port->dev, "use of SPD flags is deprecated\n"); in set_serial_info()
1482 mutex_unlock(&priv->cfg_lock); in set_serial_info()
1492 if (priv->transmit_empty) in get_lsr_info()
1496 return -EFAULT; in get_lsr_info()
1503 struct usb_serial *serial = port->serial; in ftdi_determine_type()
1504 struct usb_device *udev = serial->dev; in ftdi_determine_type()
1507 version = le16_to_cpu(udev->descriptor.bcdDevice); in ftdi_determine_type()
1508 ifnum = serial->interface->cur_altsetting->desc.bInterfaceNumber; in ftdi_determine_type()
1510 /* Assume Hi-Speed type */ in ftdi_determine_type()
1511 priv->baud_base = 120000000 / 2; in ftdi_determine_type()
1512 priv->channel = CHANNEL_A + ifnum; in ftdi_determine_type()
1516 priv->chip_type = FT232A; in ftdi_determine_type()
1517 priv->baud_base = 48000000 / 2; in ftdi_determine_type()
1518 priv->channel = 0; in ftdi_determine_type()
1524 if (udev->descriptor.iSerialNumber == 0 && in ftdi_determine_type()
1526 priv->chip_type = FT232B; in ftdi_determine_type()
1530 priv->chip_type = FT232B; in ftdi_determine_type()
1531 priv->baud_base = 48000000 / 2; in ftdi_determine_type()
1532 priv->channel = 0; in ftdi_determine_type()
1535 priv->chip_type = FT2232C; in ftdi_determine_type()
1536 priv->baud_base = 48000000 / 2; in ftdi_determine_type()
1539 priv->chip_type = FT232R; in ftdi_determine_type()
1540 priv->baud_base = 48000000 / 2; in ftdi_determine_type()
1541 priv->channel = 0; in ftdi_determine_type()
1544 priv->chip_type = FT2232H; in ftdi_determine_type()
1547 priv->chip_type = FT4232H; in ftdi_determine_type()
1550 priv->chip_type = FT232H; in ftdi_determine_type()
1553 priv->chip_type = FTX; in ftdi_determine_type()
1554 priv->baud_base = 48000000 / 2; in ftdi_determine_type()
1557 priv->chip_type = FT2233HP; in ftdi_determine_type()
1560 priv->chip_type = FT4233HP; in ftdi_determine_type()
1563 priv->chip_type = FT2232HP; in ftdi_determine_type()
1566 priv->chip_type = FT4232HP; in ftdi_determine_type()
1569 priv->chip_type = FT233HP; in ftdi_determine_type()
1572 priv->chip_type = FT232HP; in ftdi_determine_type()
1575 priv->chip_type = FT4232HA; in ftdi_determine_type()
1579 priv->chip_type = SIO; in ftdi_determine_type()
1580 priv->baud_base = 12000000 / 16; in ftdi_determine_type()
1581 priv->channel = 0; in ftdi_determine_type()
1583 dev_err(&port->dev, "unknown device type: 0x%02x\n", version); in ftdi_determine_type()
1584 return -ENODEV; in ftdi_determine_type()
1588 dev_info(&udev->dev, "Detected %s\n", ftdi_chip_name[priv->chip_type]); in ftdi_determine_type()
1602 struct usb_interface *interface = port->serial->interface; in ftdi_set_max_packet_size()
1607 num_endpoints = interface->cur_altsetting->desc.bNumEndpoints; in ftdi_set_max_packet_size()
1613 * with an endpoint size of 0 - not good. In this case, we in ftdi_set_max_packet_size()
1618 ep_desc = &interface->cur_altsetting->endpoint[i].desc; in ftdi_set_max_packet_size()
1619 if (!ep_desc->wMaxPacketSize) { in ftdi_set_max_packet_size()
1620 ep_desc->wMaxPacketSize = cpu_to_le16(0x40); in ftdi_set_max_packet_size()
1621 dev_warn(&port->dev, "Overriding wMaxPacketSize on endpoint %d\n", in ftdi_set_max_packet_size()
1627 priv->max_packet_size = usb_endpoint_maxp(ep_desc); in ftdi_set_max_packet_size()
1642 if (priv->flags & ASYNC_LOW_LATENCY) in latency_timer_show()
1645 return sprintf(buf, "%u\n", priv->latency); in latency_timer_show()
1659 return -EINVAL; in latency_timer_store()
1661 priv->latency = v; in latency_timer_store()
1664 return -EIO; in latency_timer_store()
1676 struct usb_device *udev = port->serial->dev; in event_char_store()
1681 return -EINVAL; in event_char_store()
1683 dev_dbg(&port->dev, "%s: setting event char = 0x%03x\n", __func__, v); in event_char_store()
1689 v, priv->channel, in event_char_store()
1692 dev_dbg(&port->dev, "Unable to write event character: %i\n", rv); in event_char_store()
1693 return -EIO; in event_char_store()
1711 enum ftdi_chip_type type = priv->chip_type; in ftdi_is_visible()
1723 return attr->mode; in ftdi_is_visible()
1741 struct usb_serial *serial = port->serial; in ftdi_set_bitmode()
1745 result = usb_autopm_get_interface(serial->interface); in ftdi_set_bitmode()
1749 val = (mode << 8) | (priv->gpio_output << 4) | priv->gpio_value; in ftdi_set_bitmode()
1750 result = usb_control_msg(serial->dev, in ftdi_set_bitmode()
1751 usb_sndctrlpipe(serial->dev, 0), in ftdi_set_bitmode()
1754 priv->channel, NULL, 0, WDR_TIMEOUT); in ftdi_set_bitmode()
1756 dev_err(&serial->interface->dev, in ftdi_set_bitmode()
1761 usb_autopm_put_interface(serial->interface); in ftdi_set_bitmode()
1775 priv->gpio_output = 0; in ftdi_exit_cbus_mode()
1776 priv->gpio_value = 0; in ftdi_exit_cbus_mode()
1786 mutex_lock(&priv->gpio_lock); in ftdi_gpio_request()
1787 if (!priv->gpio_used) { in ftdi_gpio_request()
1789 priv->gpio_output = 0x00; in ftdi_gpio_request()
1790 priv->gpio_value = 0x00; in ftdi_gpio_request()
1793 mutex_unlock(&priv->gpio_lock); in ftdi_gpio_request()
1797 priv->gpio_used = true; in ftdi_gpio_request()
1799 mutex_unlock(&priv->gpio_lock); in ftdi_gpio_request()
1807 struct usb_serial *serial = port->serial; in ftdi_read_cbus_pins()
1811 result = usb_autopm_get_interface(serial->interface); in ftdi_read_cbus_pins()
1815 result = usb_control_msg_recv(serial->dev, 0, in ftdi_read_cbus_pins()
1818 priv->channel, &buf, 1, WDR_TIMEOUT, in ftdi_read_cbus_pins()
1823 usb_autopm_put_interface(serial->interface); in ftdi_read_cbus_pins()
1845 mutex_lock(&priv->gpio_lock); in ftdi_gpio_set()
1848 priv->gpio_value |= BIT(gpio); in ftdi_gpio_set()
1850 priv->gpio_value &= ~BIT(gpio); in ftdi_gpio_set()
1854 mutex_unlock(&priv->gpio_lock); in ftdi_gpio_set()
1878 mutex_lock(&priv->gpio_lock); in ftdi_gpio_set_multiple()
1880 priv->gpio_value &= ~(*mask); in ftdi_gpio_set_multiple()
1881 priv->gpio_value |= *bits & *mask; in ftdi_gpio_set_multiple()
1884 mutex_unlock(&priv->gpio_lock); in ftdi_gpio_set_multiple()
1892 return !(priv->gpio_output & BIT(gpio)); in ftdi_gpio_direction_get()
1901 mutex_lock(&priv->gpio_lock); in ftdi_gpio_direction_input()
1903 priv->gpio_output &= ~BIT(gpio); in ftdi_gpio_direction_input()
1906 mutex_unlock(&priv->gpio_lock); in ftdi_gpio_direction_input()
1918 mutex_lock(&priv->gpio_lock); in ftdi_gpio_direction_output()
1920 priv->gpio_output |= BIT(gpio); in ftdi_gpio_direction_output()
1922 priv->gpio_value |= BIT(gpio); in ftdi_gpio_direction_output()
1924 priv->gpio_value &= ~BIT(gpio); in ftdi_gpio_direction_output()
1928 mutex_unlock(&priv->gpio_lock); in ftdi_gpio_direction_output()
1939 unsigned long map = priv->gpio_altfunc; in ftdi_gpio_init_valid_mask()
1944 dev_dbg(&port->dev, "no CBUS pin configured for GPIO\n"); in ftdi_gpio_init_valid_mask()
1946 dev_dbg(&port->dev, "CBUS%*pbl configured for GPIO\n", ngpios, in ftdi_gpio_init_valid_mask()
1958 return -EINVAL; in ftdi_read_eeprom()
1960 return -EINVAL; in ftdi_read_eeprom()
1966 rv = usb_control_msg(serial->dev, in ftdi_read_eeprom()
1967 usb_rcvctrlpipe(serial->dev, 0), in ftdi_read_eeprom()
1974 return -EIO; in ftdi_read_eeprom()
1995 return -ENOMEM; in ftdi_gpio_init_ft232h()
1997 ret = ftdi_read_eeprom(port->serial, buf, 0x1a, 4); in ftdi_gpio_init_ft232h()
2004 * 0x1a: X- (upper nibble -> AC5) in ftdi_gpio_init_ft232h()
2005 * 0x1b: -X (lower nibble -> AC6) in ftdi_gpio_init_ft232h()
2006 * 0x1c: XX (upper nibble -> AC9 | lower nibble -> AC8) in ftdi_gpio_init_ft232h()
2010 priv->gc.ngpio = 4; in ftdi_gpio_init_ft232h()
2011 priv->gpio_altfunc = 0xff; in ftdi_gpio_init_ft232h()
2013 for (i = 0; i < priv->gc.ngpio; ++i) { in ftdi_gpio_init_ft232h()
2015 priv->gpio_altfunc &= ~BIT(i); in ftdi_gpio_init_ft232h()
2035 return -ENOMEM; in ftdi_gpio_init_ft232r()
2037 ret = ftdi_read_eeprom(port->serial, buf, 0x14, 2); in ftdi_gpio_init_ft232r()
2042 dev_dbg(&port->dev, "cbus_config = 0x%04x\n", cbus_config); in ftdi_gpio_init_ft232r()
2044 priv->gc.ngpio = 4; in ftdi_gpio_init_ft232r()
2046 priv->gpio_altfunc = 0xff; in ftdi_gpio_init_ft232r()
2047 for (i = 0; i < priv->gc.ngpio; ++i) { in ftdi_gpio_init_ft232r()
2049 priv->gpio_altfunc &= ~BIT(i); in ftdi_gpio_init_ft232r()
2061 struct usb_serial *serial = port->serial; in ftdi_gpio_init_ftx()
2070 return -ENOMEM; in ftdi_gpio_init_ftx()
2078 priv->gc.ngpio = 4; in ftdi_gpio_init_ftx()
2081 priv->gpio_altfunc = 0xff; in ftdi_gpio_init_ftx()
2082 for (i = 0; i < priv->gc.ngpio; ++i) { in ftdi_gpio_init_ftx()
2084 priv->gpio_altfunc &= ~BIT(i); in ftdi_gpio_init_ftx()
2096 struct usb_serial *serial = port->serial; in ftdi_gpio_init()
2099 switch (priv->chip_type) { in ftdi_gpio_init()
2116 mutex_init(&priv->gpio_lock); in ftdi_gpio_init()
2118 priv->gc.label = "ftdi-cbus"; in ftdi_gpio_init()
2119 priv->gc.request = ftdi_gpio_request; in ftdi_gpio_init()
2120 priv->gc.get_direction = ftdi_gpio_direction_get; in ftdi_gpio_init()
2121 priv->gc.direction_input = ftdi_gpio_direction_input; in ftdi_gpio_init()
2122 priv->gc.direction_output = ftdi_gpio_direction_output; in ftdi_gpio_init()
2123 priv->gc.init_valid_mask = ftdi_gpio_init_valid_mask; in ftdi_gpio_init()
2124 priv->gc.get = ftdi_gpio_get; in ftdi_gpio_init()
2125 priv->gc.set = ftdi_gpio_set; in ftdi_gpio_init()
2126 priv->gc.get_multiple = ftdi_gpio_get_multiple; in ftdi_gpio_init()
2127 priv->gc.set_multiple = ftdi_gpio_set_multiple; in ftdi_gpio_init()
2128 priv->gc.owner = THIS_MODULE; in ftdi_gpio_init()
2129 priv->gc.parent = &serial->interface->dev; in ftdi_gpio_init()
2130 priv->gc.base = -1; in ftdi_gpio_init()
2131 priv->gc.can_sleep = true; in ftdi_gpio_init()
2133 result = gpiochip_add_data(&priv->gc, port); in ftdi_gpio_init()
2135 priv->gpio_registered = true; in ftdi_gpio_init()
2144 if (priv->gpio_registered) { in ftdi_gpio_remove()
2145 gpiochip_remove(&priv->gc); in ftdi_gpio_remove()
2146 priv->gpio_registered = false; in ftdi_gpio_remove()
2149 if (priv->gpio_used) { in ftdi_gpio_remove()
2150 /* Exiting CBUS-mode does not reset pin states. */ in ftdi_gpio_remove()
2152 priv->gpio_used = false; in ftdi_gpio_remove()
2175 const struct ftdi_quirk *quirk = (struct ftdi_quirk *)id->driver_info; in ftdi_probe()
2177 if (quirk && quirk->probe) { in ftdi_probe()
2178 int ret = quirk->probe(serial); in ftdi_probe()
2183 usb_set_serial_data(serial, (void *)id->driver_info); in ftdi_probe()
2190 const struct ftdi_quirk *quirk = usb_get_serial_data(port->serial); in ftdi_port_probe()
2196 return -ENOMEM; in ftdi_port_probe()
2198 mutex_init(&priv->cfg_lock); in ftdi_port_probe()
2200 if (quirk && quirk->port_probe) in ftdi_port_probe()
2201 quirk->port_probe(priv); in ftdi_port_probe()
2211 priv->latency = 16; in ftdi_port_probe()
2216 dev_err(&port->serial->interface->dev, in ftdi_port_probe()
2229 /* Setup for the USB-UIRT device, which requires hardwired
2234 priv->flags |= ASYNC_SPD_CUST; in ftdi_USB_UIRT_setup()
2235 priv->custom_divisor = 77; in ftdi_USB_UIRT_setup()
2236 priv->force_baud = 38400; in ftdi_USB_UIRT_setup()
2239 /* Setup for the HE-TIRA1 device, which requires hardwired
2240 * baudrate (38400 gets mapped to 100000) and RTS-CTS enabled. */
2244 priv->flags |= ASYNC_SPD_CUST; in ftdi_HE_TIRA1_setup()
2245 priv->custom_divisor = 240; in ftdi_HE_TIRA1_setup()
2246 priv->force_baud = 38400; in ftdi_HE_TIRA1_setup()
2247 priv->force_rtscts = 1; in ftdi_HE_TIRA1_setup()
2251 * Module parameter to control latency timer for NDI FTDI-based USB devices.
2257 /* Setup for the NDI FTDI-based USB devices, which requires hardwired
2264 struct usb_device *udev = serial->dev; in ftdi_NDI_device_setup()
2272 dev_dbg(&udev->dev, "%s setting NDI device latency to %d\n", __func__, latency); in ftdi_NDI_device_setup()
2273 dev_info(&udev->dev, "NDI device with a latency value of %d\n", latency); in ftdi_NDI_device_setup()
2284 * First port on JTAG adaptors such as Olimex arm-usb-ocd or the FIC/OpenMoko
2290 struct usb_interface *intf = serial->interface; in ftdi_jtag_probe()
2291 int ifnum = intf->cur_altsetting->desc.bInterfaceNumber; in ftdi_jtag_probe()
2294 dev_info(&intf->dev, "Ignoring interface reserved for JTAG\n"); in ftdi_jtag_probe()
2295 return -ENODEV; in ftdi_jtag_probe()
2303 struct usb_device *udev = serial->dev; in ftdi_8u2232c_probe()
2305 if (udev->manufacturer && !strcmp(udev->manufacturer, "CALAO Systems")) in ftdi_8u2232c_probe()
2308 if (udev->product && in ftdi_8u2232c_probe()
2309 (!strcmp(udev->product, "Arrow USB Blaster") || in ftdi_8u2232c_probe()
2310 !strcmp(udev->product, "BeagleBone/XDS100V2") || in ftdi_8u2232c_probe()
2311 !strcmp(udev->product, "SNAP Connect E10"))) in ftdi_8u2232c_probe()
2319 * ST Micro Connect Lite are reserved for JTAG or other non-UART interfaces and
2322 * a conventional RS-232 UART.
2326 struct usb_interface *intf = serial->interface; in ftdi_stmclite_probe()
2327 int ifnum = intf->cur_altsetting->desc.bInterfaceNumber; in ftdi_stmclite_probe()
2330 dev_info(&intf->dev, "Ignoring interface reserved for JTAG\n"); in ftdi_stmclite_probe()
2331 return -ENODEV; in ftdi_stmclite_probe()
2348 struct usb_device *dev = port->serial->dev; in ftdi_open()
2356 priv->channel, NULL, 0, WDR_TIMEOUT); in ftdi_open()
2359 port->tty->termios - this would lose speed settings, etc. in ftdi_open()
2360 This is same behaviour as serial.c/rs_open() - Kuba */ in ftdi_open()
2375 if (usb_control_msg(port->serial->dev, in ftdi_dtr_rts()
2376 usb_sndctrlpipe(port->serial->dev, 0), in ftdi_dtr_rts()
2379 0, priv->channel, NULL, 0, in ftdi_dtr_rts()
2381 dev_err(&port->dev, "error from flowcontrol urb\n"); in ftdi_dtr_rts()
2407 if (priv->chip_type == SIO) { in ftdi_prepare_write_buffer()
2412 spin_lock_irqsave(&port->lock, flags); in ftdi_prepare_write_buffer()
2413 for (i = 0; i < size - 1; i += priv->max_packet_size) { in ftdi_prepare_write_buffer()
2414 len = min_t(int, size - i, priv->max_packet_size) - 1; in ftdi_prepare_write_buffer()
2415 c = kfifo_out(&port->write_fifo, &buffer[i + 1], len); in ftdi_prepare_write_buffer()
2418 port->icount.tx += c; in ftdi_prepare_write_buffer()
2422 spin_unlock_irqrestore(&port->lock, flags); in ftdi_prepare_write_buffer()
2424 count = kfifo_out_locked(&port->write_fifo, dest, size, in ftdi_prepare_write_buffer()
2425 &port->lock); in ftdi_prepare_write_buffer()
2426 port->icount.tx += count; in ftdi_prepare_write_buffer()
2443 dev_dbg(&port->dev, "malformed packet\n"); in ftdi_process_packet()
2451 if (status != priv->prev_status) { in ftdi_process_packet()
2452 char diff_status = status ^ priv->prev_status; in ftdi_process_packet()
2455 port->icount.cts++; in ftdi_process_packet()
2457 port->icount.dsr++; in ftdi_process_packet()
2459 port->icount.rng++; in ftdi_process_packet()
2463 port->icount.dcd++; in ftdi_process_packet()
2464 tty = tty_port_tty_get(&port->port); in ftdi_process_packet()
2471 wake_up_interruptible(&port->port.delta_msr_wait); in ftdi_process_packet()
2472 priv->prev_status = status; in ftdi_process_packet()
2477 priv->transmit_empty = 1; in ftdi_process_packet()
2479 priv->transmit_empty = 0; in ftdi_process_packet()
2486 * data payload to avoid over-reporting. in ftdi_process_packet()
2496 if (buf[1] & FTDI_RS_BI && buf[len - 1] == '\0') { in ftdi_process_packet()
2497 port->icount.brk++; in ftdi_process_packet()
2502 port->icount.parity++; in ftdi_process_packet()
2505 port->icount.frame++; in ftdi_process_packet()
2509 port->icount.overrun++; in ftdi_process_packet()
2510 tty_insert_flip_char(&port->port, 0, TTY_OVERRUN); in ftdi_process_packet()
2514 port->icount.rx += len - 2; in ftdi_process_packet()
2516 if (brkint || port->sysrq) { in ftdi_process_packet()
2518 if (brkint && i == len - 1) { in ftdi_process_packet()
2520 return len - 3; in ftdi_process_packet()
2525 tty_insert_flip_char(&port->port, buf[i], flag); in ftdi_process_packet()
2528 tty_insert_flip_string_fixed_flag(&port->port, buf + 2, flag, in ftdi_process_packet()
2529 len - 2); in ftdi_process_packet()
2532 return len - 2; in ftdi_process_packet()
2537 struct usb_serial_port *port = urb->context; in ftdi_process_read_urb()
2539 char *data = urb->transfer_buffer; in ftdi_process_read_urb()
2544 for (i = 0; i < urb->actual_length; i += priv->max_packet_size) { in ftdi_process_read_urb()
2545 len = min_t(int, urb->actual_length - i, priv->max_packet_size); in ftdi_process_read_urb()
2550 tty_flip_buffer_push(&port->port); in ftdi_process_read_urb()
2555 struct usb_serial_port *port = tty->driver_data; in ftdi_break_ctl()
2559 /* break_state = -1 to turn on break, and 0 to turn off break */ in ftdi_break_ctl()
2564 value = priv->last_set_data_value | FTDI_SIO_SET_BREAK; in ftdi_break_ctl()
2566 value = priv->last_set_data_value; in ftdi_break_ctl()
2568 if (usb_control_msg(port->serial->dev, in ftdi_break_ctl()
2569 usb_sndctrlpipe(port->serial->dev, 0), in ftdi_break_ctl()
2572 value, priv->channel, in ftdi_break_ctl()
2574 dev_err(&port->dev, "%s FAILED to enable/disable break state (state was %d)\n", in ftdi_break_ctl()
2578 dev_dbg(&port->dev, "%s break state is %d - urb is %d\n", __func__, in ftdi_break_ctl()
2597 /* old_termios contains the original termios settings and tty->termios contains
2605 struct usb_device *dev = port->serial->dev; in ftdi_set_termios()
2606 struct device *ddev = &port->dev; in ftdi_set_termios()
2608 struct ktermios *termios = &tty->termios; in ftdi_set_termios()
2609 unsigned int cflag = termios->c_cflag; in ftdi_set_termios()
2615 if (priv->force_baud && ((termios->c_cflag & CBAUD) != B0)) { in ftdi_set_termios()
2617 tty_encode_baud_rate(tty, priv->force_baud, in ftdi_set_termios()
2618 priv->force_baud); in ftdi_set_termios()
2621 /* Force RTS-CTS if this device requires it. */ in ftdi_set_termios()
2622 if (priv->force_rtscts) { in ftdi_set_termios()
2624 termios->c_cflag |= CRTSCTS; in ftdi_set_termios()
2644 termios->c_cflag &= ~CSIZE; in ftdi_set_termios()
2646 termios->c_cflag |= old_termios->c_cflag & CSIZE; in ftdi_set_termios()
2648 termios->c_cflag |= CS8; in ftdi_set_termios()
2651 cflag = termios->c_cflag; in ftdi_set_termios()
2656 if (old_termios->c_cflag == termios->c_cflag in ftdi_set_termios()
2657 && old_termios->c_ispeed == termios->c_ispeed in ftdi_set_termios()
2658 && old_termios->c_ospeed == termios->c_ospeed) in ftdi_set_termios()
2662 ftdi_sio_read_bulk_callback - need to examine what this means - in ftdi_set_termios()
2665 if ((old_termios->c_cflag & (CSIZE|PARODD|PARENB|CMSPAR|CSTOPB)) == in ftdi_set_termios()
2666 (termios->c_cflag & (CSIZE|PARODD|PARENB|CMSPAR|CSTOPB))) in ftdi_set_termios()
2703 - but is or'ed with this value */ in ftdi_set_termios()
2704 priv->last_set_data_value = value; in ftdi_set_termios()
2709 value, priv->channel, in ftdi_set_termios()
2722 0, priv->channel, in ftdi_set_termios()
2731 mutex_lock(&priv->cfg_lock); in ftdi_set_termios()
2734 mutex_unlock(&priv->cfg_lock); in ftdi_set_termios()
2736 if (old_termios && (old_termios->c_cflag & CBAUD) == B0) in ftdi_set_termios()
2741 /* Set hardware-assisted flow control */ in ftdi_set_termios()
2745 dev_dbg(&port->dev, "enabling rts/cts flow control\n"); in ftdi_set_termios()
2748 dev_dbg(&port->dev, "enabling xon/xoff flow control\n"); in ftdi_set_termios()
2752 dev_dbg(&port->dev, "disabling flow control\n"); in ftdi_set_termios()
2756 index |= priv->channel; in ftdi_set_termios()
2763 dev_err(&port->dev, "failed to set flow control: %d\n", ret); in ftdi_set_termios()
2767 * Get modem-control status.
2782 return -ENOMEM; in ftdi_get_modem_status()
2787 if (priv->chip_type == SIO) in ftdi_get_modem_status()
2792 ret = usb_control_msg(port->serial->dev, in ftdi_get_modem_status()
2793 usb_rcvctrlpipe(port->serial->dev, 0), in ftdi_get_modem_status()
2796 0, priv->channel, in ftdi_get_modem_status()
2801 dev_err(&port->dev, "failed to get modem status: %d\n", ret); in ftdi_get_modem_status()
2803 ret = -EIO; in ftdi_get_modem_status()
2814 dev_dbg(&port->dev, "%s - 0x%02x%02x\n", __func__, status[0], in ftdi_get_modem_status()
2824 struct usb_serial_port *port = tty->driver_data; in ftdi_tiocmget()
2837 priv->last_dtr_rts; in ftdi_tiocmget()
2845 struct usb_serial_port *port = tty->driver_data; in ftdi_tiocmset()
2853 struct usb_serial_port *port = tty->driver_data; in ftdi_ioctl()
2863 return -ENOIOCTLCMD; in ftdi_ioctl()