Commit graph

491 commits

Author SHA1 Message Date
Linus Torvalds
d3dcbe24a0 USB/Thunderbolt changes for 6.1-rc1
Here is the big set of USB and Thunderbolt driver changes for 6.1-rc1.
 
 Nothing major in here, lots of little things with new devices supported
 and updates for a few drivers.  Highlights include:
 	- thunderbolt/USB4 devices supported a bit better than before,
 	  and some new ids to enable new hardware devices
 	- USB gadget uvc updates for newer video formats and better v4l
 	  integration (the v4l portions were acked by those maintainers)
 	- typec updates for tiny issues and more typec drivers for new
 	  chips.
 	- xhci tiny updates for minor issues
 	- big usb-serial ftdi_sio driver update to handle new devices
 	  better
 	- lots of tiny dwc3 fixes and updates for the IP block that is
 	  showing up everywhere these days
 	- dts updates for new devices being supported
 	- other tiny janitorial and cleanups fixes for lots of different
 	  USB drivers.  Full details are in the shortlog.
 
 All of these have been in linux-next for a while with no reported
 issues.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCY0BN9g8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+yljdgCdH4Fev4Nvf2Nokfv0q0krcRB3YpUAn1aZfpb/
 EbgxsxhPnTJg+mmXyLms
 =IxUy
 -----END PGP SIGNATURE-----

Merge tag 'usb-6.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb

Pull USB / Thunderbolt updates from Greg KH:
 "Here is the big set of USB and Thunderbolt driver changes for 6.1-rc1.

  Nothing major in here, lots of little things with new devices
  supported and updates for a few drivers. Highlights include:

   - thunderbolt/USB4 devices supported a bit better than before, and
     some new ids to enable new hardware devices

   - USB gadget uvc updates for newer video formats and better v4l
     integration (the v4l portions were acked by those maintainers)

   - typec updates for tiny issues and more typec drivers for new chips.

   - xhci tiny updates for minor issues

   - big usb-serial ftdi_sio driver update to handle new devices better

   - lots of tiny dwc3 fixes and updates for the IP block that is
     showing up everywhere these days

   - dts updates for new devices being supported

   - other tiny janitorial and cleanups fixes for lots of different USB
     drivers. Full details are in the shortlog.

  All of these have been in linux-next for a while with no reported
  issues"

* tag 'usb-6.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (169 commits)
  usb: gadget: uvc: don't put item still in use
  usb: gadget: uvc: Fix argument to sizeof() in uvc_register_video()
  usb: host: ehci-exynos: switch to using gpiod API
  Revert "usb: dwc3: Don't switch OTG -> peripheral if extcon is present"
  Revert "USB: fixup for merge issue with "usb: dwc3: Don't switch OTG -> peripheral if extcon is present""
  dt-bindings: usb: Convert FOTG210 to dt schema
  usb: mtu3: fix failed runtime suspend in host only mode
  USB: omap_udc: Fix spelling mistake: "tranceiver_ctrl" -> "transceiver_ctrl"
  usb: typec: ucsi_ccg: Disable UCSI ALT support on Tegra
  usb: typec: Replace custom implementation of device_match_fwnode()
  usb: typec: ucsi: Don't warn on probe deferral
  usb: add quirks for Lenovo OneLink+ Dock
  MAINTAINERS: switch dwc3 to Thinh
  usb: idmouse: fix an uninit-value in idmouse_open
  USB: PHY: JZ4770: Switch to use dev_err_probe() helper
  usb: phy: generic: Switch to use dev_err_probe() helper
  usb: ulpi: use DEFINE_SHOW_ATTRIBUTE to simplify ulpi_regs
  usb: cdns3: remove dead code
  usb: cdc-wdm: Use skb_put_data() instead of skb_put/memcpy pair
  usb: musb: sunxi: Switch to use dev_err_probe() helper
  ...
2022-10-07 16:48:26 -07:00
Johan Hovold
6b2fe3df7c USB: serial: ftdi_sio: clean up driver prefix
Drop the "sio" infix from the few remaining definitions and symbol names
that still had it.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2022-09-20 09:45:50 +02:00
Johan Hovold
a8619505a7 USB: serial: ftdi_sio: move driver structure
Move the definition of the USB serial driver structure to the end of the
file where it is used and drop the now redundant forward declarations.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2022-09-20 09:45:49 +02:00
Johan Hovold
c142bdc5c7 USB: serial: ftdi_sio: clean up attribute visibility logic
Clean up the attribute visibility logic by defaulting to attributes
being visible and explicitly listing the exceptions.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2022-09-20 09:42:38 +02:00
Jiasheng Jiang
0f6632e2e8 USB: serial: ftdi_sio: convert to use dev_groups
The driver core supports the ability to handle the creation and removal
of device-specific sysfs files in a race-free manner.

Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
[ johan: rebase on type rework, make groups static, clean up, amend
         commit message ]
Signed-off-by: Johan Hovold <johan@kernel.org>
2022-09-19 15:06:15 +02:00
Amireddy mallikarjuna reddy
cfebcd53e6 USB: serial: ftdi_sio: add support for HP and HA devices
Add the product IDs for the USB-to-Serial devices FT2233HP, FT2232HP,
FT4233HP, FT4232HP, FT233HP, FT232HP, and FT4232HA.
Also include BCD values so that the chip type can be determined.

Signed-off-by: Amireddy mallikarjuna reddy <mallikarjuna.reddy@ftdichip.com>
Link: https://lore.kernel.org/r/ac28f2c5eba23a645b3b9299c224f2755a233eef.1658385786.git.mallikarjuna.reddy@ftdichip.com
[ johan: rebase on type-handling rework, drop "Q" from automotive type
         name ]
Signed-off-by: Johan Hovold <johan@kernel.org>
2022-09-15 08:06:06 +02:00
Johan Hovold
1a0398915d USB: serial: ftdi_sio: simplify divisor handling
In preparation for adding further Hi-Speed types, assume the device type
is Hi-Speed unless it's an explicitly listed legacy type when
determining divisors.

Signed-off-by: Johan Hovold <johan@kernel.org>
2022-09-15 08:06:05 +02:00
Johan Hovold
4d50f4fc67 USB: serial: ftdi_sio: assume hi-speed type
In preparation for adding further Hi-Speed types, assume a 120 MHz clock
and set the channel index by default and instead override these values
as needed for legacy types.

Signed-off-by: Johan Hovold <johan@kernel.org>
2022-09-15 08:06:04 +02:00
Johan Hovold
a146cc4d46 USB: serial: ftdi_sio: clean up baudrate request
Multi-channel devices need to encode the channel selector in their
control requests and newer single-channel chip types use the same
request format.

Set the channel index also for these single-channel types so that the
index can be used to determine the baudrate request format instead of
listing types explicitly.

Note that FT232H and FTX accept either 0 or 1 as selector for their
single channel, presumably for backward compatibility reasons.

Signed-off-by: Johan Hovold <johan@kernel.org>
2022-09-15 08:06:01 +02:00
Johan Hovold
4d045b98fb USB: serial: ftdi_sio: clean up attribute handling
The driver exposes two attributes for all chip types but FT232A, which
doesn't have a configurable latency timer, and SIO, which (probably)
doesn't support the event-char mechanism either.

Explicitly test for the exceptions rather than list each and every
supported device type in the attribute helpers.

Signed-off-by: Johan Hovold <johan@kernel.org>
2022-09-15 08:05:59 +02:00
Johan Hovold
6fbd914257 USB: serial: ftdi_sio: clean up modem-status handling
All chip types but the original SIO (FT8U100AX) return a two-byte modem
status and there's no need to explicitly list every other type in the
handler.

Signed-off-by: Johan Hovold <johan@kernel.org>
2022-09-15 08:05:57 +02:00
Johan Hovold
f353c0d430 USB: serial: ftdi_sio: tighten device-type detection
Clean up and tighten the device-type detection, which is based on
bcdDevice.

Don't make assumptions about unknown (future) types (currently assumed
to be either FT2232C or FT-X depending on bNumInterfaces) and instead
log an error and refuse to bind so that we can add proper support when
needed.

Note that the bcdDevice values have been provided by FTDI.

Signed-off-by: Johan Hovold <johan@kernel.org>
2022-09-15 08:05:54 +02:00
Johan Hovold
027bf37dbe USB: serial: ftdi_sio: rename channel index
Multi-channel devices require a channel selector to be included in
control requests.

Replace "interface" with the less ambiguous "channel", which is the
terminology used for newer devices, in the corresponding defines and
variables.

Signed-off-by: Johan Hovold <johan@kernel.org>
2022-09-15 08:05:53 +02:00
Johan Hovold
64b12fdac0 USB: serial: ftdi_sio: include FT2232D in type string
Include the updated D-version in the type string for the FT2232C type.

Signed-off-by: Johan Hovold <johan@kernel.org>
2022-09-15 08:05:51 +02:00
Johan Hovold
01aeb31f3c USB: serial: ftdi_sio: rename chip types
Shorten the chip type enum and string representation for A, B and R chip
types so that they don't include the IC package type in the name.

Signed-off-by: Johan Hovold <johan@kernel.org>
2022-09-15 08:05:49 +02:00
Johan Hovold
25eb948601 USB: serial: ftdi_sio: drop redundant chip type comments
Drop redundant chip type comments.

Signed-off-by: Johan Hovold <johan@kernel.org>
2022-09-15 08:05:46 +02:00
Johan Hovold
366e89aafe USB: serial: ftdi_sio: clean up chip type enum
Clean up the chip type enum by dropping the explicit values and moving
the definition to the implementation to make it easier to add further
types.

Signed-off-by: Johan Hovold <johan@kernel.org>
2022-09-15 08:05:45 +02:00
Johan Hovold
7bd7ad3c31 USB: serial: ftdi_sio: fix 300 bps rate for SIO
The 300 bps rate of SIO devices has been mapped to 9600 bps since
2003... Let's fix the regression.

Cc: stable@vger.kernel.org
Signed-off-by: Johan Hovold <johan@kernel.org>
2022-09-15 08:05:12 +02:00
Greg Kroah-Hartman
35f2e3c267 Merge 6.0-rc4 into tty-next
We need the tty/serial fixes in here as well.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-09-05 07:59:28 +02:00
Ilpo Järvinen
f6d47fe592 usb: serial: Make ->set_termios() old ktermios const
There should be no reason to adjust old ktermios which is going to get
discarded anyway.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20220816115739.10928-8-ilpo.jarvinen@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-08-30 14:22:35 +02:00
Niek Nooijens
001047ea24 USB: serial: ftdi_sio: add Omron CS1W-CIF31 device id
works perfectly with:
modprobe ftdi_sio
echo "0590 00b2" | tee
/sys/module/ftdi_sio/drivers/usb-serial\:ftdi_sio/new_id > /dev/null

but doing this every reboot is a pain in the ass.

Signed-off-by: Niek Nooijens <niek.nooijens@omron.com>
Cc: stable@vger.kernel.org
Signed-off-by: Johan Hovold <johan@kernel.org>
2022-08-29 15:26:11 +02:00
Lucien Buchmann
7c239a071d USB: serial: ftdi_sio: add Belimo device ids
Those two product ids are known.

Signed-off-by: Lucien Buchmann <lucien.buchmann@gmx.net>
Cc: stable@vger.kernel.org
Signed-off-by: Johan Hovold <johan@kernel.org>
2022-07-13 08:20:32 +02:00
Daniels Umanovskis
1b30499ace USB: serial: ftdi_sio: clean up printk format specifier
The latency is an unsigned int and should be printed as such (even if it
only holds values in the range 0..255).

Signed-off-by: Daniels Umanovskis <du@axentia.se>
Link: https://lore.kernel.org/r/20220426123714.2000-1-du@axentia.se
[ johan: amend commit message ]
Signed-off-by: Johan Hovold <johan@kernel.org>
2022-05-05 14:09:31 +02:00
Cameron Williams
fbb9b194e1 USB: serial: ftdi_sio: add support for Brainboxes US-159/235/320
This patch adds support for the Brainboxes US-159, US-235 and US-320
USB-to-Serial devices.

Signed-off-by: Cameron Williams <cang1@live.co.uk>
Cc: stable@vger.kernel.org
Signed-off-by: Johan Hovold <johan@kernel.org>
2022-02-01 11:53:43 +01:00
Himadri Pandya
a738859264 USB: serial: ftdi_sio: use usb_control_msg_recv()
usb_control_msg_recv() nicely wraps usb_control_msg() and removes the
compulsion of using DMA buffers for USB messages. It also includes proper
error check for possible short read. So use the wrapper where
appropriate and remove DMA buffers from the callers.

Signed-off-by: Himadri Pandya <himadrispandya@gmail.com>
Link: https://lore.kernel.org/r/20210801203122.3515-5-himadrispandya@gmail.com
[ johan: amend commit message ]
Signed-off-by: Johan Hovold <johan@kernel.org>
2021-09-21 14:15:52 +02:00
Greg Kroah-Hartman
2037e5d6fb USB-serial updates for 5.15-rc1
Here are the USB serial updates for 5.15-rc1, including:
 
  - a couple of fixes for cp210x termios error handling
  - retrieval of fw revisions for more cp210x types
  - a switch to octal permissions for all module-parameter definitions
 
 Included are also various clean ups.
 
 All have been in linux-next with no reported issues.
 -----BEGIN PGP SIGNATURE-----
 
 iHUEABYIAB0WIQQHbPq+cpGvN/peuzMLxc3C7H1lCAUCYS4AWwAKCRALxc3C7H1l
 CJKQAQDSpM2VZDmWApiAHXvICl+SxSOonAq+Ch7giDE/eEJ+wQD/QVnacvaDplyU
 w+yySrHYsNyKXAuCnaZxp4lj4RMbxAI=
 =iEHP
 -----END PGP SIGNATURE-----

Merge tag 'usb-serial-5.15-rc1-2' of https://git.kernel.org/pub/scm/linux/kernel/git/johan/usb-serial into usb-next

Johan writes:

USB-serial updates for 5.15-rc1

Here are the USB serial updates for 5.15-rc1, including:

 - a couple of fixes for cp210x termios error handling
 - retrieval of fw revisions for more cp210x types
 - a switch to octal permissions for all module-parameter definitions

Included are also various clean ups.

All have been in linux-next with no reported issues.

* tag 'usb-serial-5.15-rc1-2' of https://git.kernel.org/pub/scm/linux/kernel/git/johan/usb-serial:
  USB: serial: replace symbolic permissions by octal permissions
  USB: serial: cp210x: determine fw version for CP2105 and CP2108
  USB: serial: cp210x: clean up type detection
  USB: serial: cp210x: clean up set-chars request
  USB: serial: cp210x: clean up control-request timeout
  USB: serial: cp210x: fix flow-control error handling
  USB: serial: cp210x: fix control-characters error handling
  USB: serial: io_edgeport: drop unused descriptor helper
2021-09-01 20:10:40 +02:00
Utkarsh Verma
a65ab973c1 USB: serial: replace symbolic permissions by octal permissions
Replace symbolic permission macros with octal permission numbers
because octal permission numbers are easier to read and understand
instead of their symbolic macro names.

No functional change.

Suggested-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Signed-off-by: Utkarsh Verma <utkarshverma294@gmail.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
2021-08-26 09:38:27 +02:00
David Bauer
8da0e55c79 USB: serial: ftdi_sio: add device ID for Auto-M3 OP-COM v2
The Auto-M3 OP-COM v2 is a OBD diagnostic device using a FTD232 for the
USB connection.

Signed-off-by: David Bauer <mail@david-bauer.net>
Cc: stable@vger.kernel.org
Signed-off-by: Johan Hovold <johan@kernel.org>
2021-08-05 09:47:25 +02:00
George McCollister
bc96c72df3 USB: serial: ftdi_sio: add NovaTech OrionMX product ID
Add PID for the NovaTech OrionMX so it can be automatically detected.

Signed-off-by: George McCollister <george.mccollister@gmail.com>
Cc: stable@vger.kernel.org
Signed-off-by: Johan Hovold <johan@kernel.org>
2021-06-05 12:26:01 +02:00
Dominik Andreas Schorpp
c5a80540e4 USB: serial: ftdi_sio: add IDs for IDS GmbH Products
Add the IDS GmbH Vendor ID and the Product IDs for SI31A (2xRS232)
and CM31A (LoRaWAN Modem).

Signed-off-by: Dominik Andreas Schorpp <dominik.a.schorpp@ids.de>
Signed-off-by: Juergen Borleis <jbe@pengutronix.de>
Cc: stable@vger.kernel.org
Signed-off-by: Johan Hovold <johan@kernel.org>
2021-05-10 10:59:31 +02:00
Johan Hovold
0428bf6807 USB: serial: ftdi_sio: clean up TIOCSSERIAL
The TIOCSSERIAL implementation needs to compare the old flag and divisor
settings with the new to detect ASYNC_SPD changes, but there's no need
to copy all driver state to the stack for that.

While at it, unbreak the function parameter list.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2021-04-08 09:46:04 +02:00
Johan Hovold
c12860c0f6 USB: serial: ftdi_sio: simplify TIOCGSERIAL permission check
Changing the deprecated custom_divisor field is an unprivileged
operation so after verifying that flag field does not contain any
privileged changes both updates can be carried out by any user.

Combine the two branches and drop the erroneous comment.

Note that private flags field is only used for ASYNC flags so there's no
need to try to retain any other bits when updating the flags.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2021-04-08 09:46:03 +02:00
Johan Hovold
9378379b15 USB: serial: ftdi_sio: ignore baud_base changes
The TIOCSSERIAL error handling is inconsistent at best, but drivers tend
to ignore requests to change parameters which cannot be changed rather
than return an error.

The FTDI driver ignores change requests for all immutable parameters but
baud_base so return success also in this case for consistency.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2021-04-08 09:46:03 +02:00
Johan Hovold
01fd45f676 USB: serial: add generic support for TIOCSSERIAL
TIOCSSERIAL is a horrid, underspecified, legacy interface which for most
serial devices is only useful for setting the close_delay and
closing_wait parameters.

The closing_wait parameter determines how long to wait for the transfer
buffers to drain during close and the default timeout of 30 seconds may
not be sufficient at low line speeds. In other cases, when for example
flow is stopped, the default timeout may instead be too long.

Add generic support for TIOCSSERIAL and TIOCGSERIAL with handling of the
three common parameters close_delay, closing_wait and line for the
benefit of all USB serial drivers while still allowing drivers to
implement further functionality through the existing callbacks.

This currently includes a few drivers that report their base baud clock
rate even if that is really only of interest when setting custom
divisors through the deprecated ASYNC_SPD_CUST interface; an interface
which only the FTDI driver actually implements.

Some drivers have also been reporting back a fake UART type, something
which should no longer be needed and will be dropped by a follow-on
patch.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2021-04-08 09:46:02 +02:00
Johan Hovold
2ab5836101 USB: serial: ftdi_sio: fix TIOCGSERIAL implementation
TIOCSSERIAL is a horrid, underspecified, legacy interface which for most
serial devices is only useful for setting the close_delay and
closing_wait parameters.

The FTDI driver is the only USB serial driver supporting the deprecated
ASYNC_SPD flags, which are reported back as they should by TIOCGSERIAL,
but the returned parameters did not include the line number.

The close_delay and closing_wait parameters returned by TIOCGSERIAL are
specified in centiseconds. The driver does not yet support changing
these, but let's report back the default values actually used (0.5 and
30 seconds, respectively).

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2021-04-08 09:45:53 +02:00
Uwe Kleine-König
c5d1448fa3 USB: serial: make remove callback return void
All usb_serial drivers return 0 in their remove callbacks and driver
core ignores the value returned by usb_serial_device_remove(). So change
the remove callback to return void and return 0 unconditionally in
usb_serial_device_remove().

Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
Link: https://lore.kernel.org/r/20210208143149.963644-2-uwe@kleine-koenig.org
Signed-off-by: Johan Hovold <johan@kernel.org>
2021-02-09 13:13:58 +01:00
Johan Hovold
1ef268039b USB: serial: ftdi_sio: restore divisor-encoding comments
Add back a few explanatory comments related to the divisor encoding
which got lost in a coding-style clean up many years ago.

Signed-off-by: Johan Hovold <johan@kernel.org>
2021-02-01 14:06:27 +01:00
Johan Hovold
528222d0c8 USB: serial: ftdi_sio: fix FTX sub-integer prescaler
The most-significant bit of the sub-integer-prescaler index is set in
the high byte of the baudrate request wIndex also for FTX devices.

This fixes rates like 1152000 which got mapped to 1.2 MBd.

Reported-by: Vladimir <svv75@mail.ru>
Link: https://bugzilla.kernel.org/show_bug.cgi?id=210351
Cc: stable@vger.kernel.org
Signed-off-by: Johan Hovold <johan@kernel.org>
2021-02-01 14:06:11 +01:00
Marc Zyngier
fddd408ad4 USB: serial: ftdi_sio: log the CBUS GPIO validity
The validity of the ftdi CBUS GPIO is pretty hidden so far,
and finding out *why* some GPIOs don't work is sometimes
hard to identify. So let's help the user by displaying the
map of the CBUS pins that are valid for a GPIO.

Suggested-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20201204164739.781812-4-maz@kernel.org
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
[johan: demote to KERN_DEBUG, rephrase messages, drop ftx-prog warning]
Signed-off-by: Johan Hovold <johan@kernel.org>
2020-12-09 18:07:03 +01:00
Marc Zyngier
5d47c887cc USB: serial: ftdi_sio: drop GPIO line checking dead code
Now that gpiolib can track the validity of GPIO pins, there is no need
to check whether the line is valid in request().

Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20201204164739.781812-5-maz@kernel.org
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
[johan: amend commit message]
Signed-off-by: Johan Hovold <johan@kernel.org>
2020-12-09 18:06:45 +01:00
Marc Zyngier
11fb08cffb USB: serial: ftdi_sio: report the valid GPIO lines to gpiolib
Since it is pretty common for only some of the CBUS lines to be
valid as GPIO lines, let's report such validity to the rest of
the kernel.

Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20201204164739.781812-3-maz@kernel.org
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2020-12-09 18:06:30 +01:00
Mychaela N. Falconia
711a37813a USB: serial: ftdi_sio: use cur_altsetting for consistency
ftdi_determine_type() function had this construct in it to get the
number of the interface it is operating on:

  inter = serial->interface->altsetting->desc.bInterfaceNumber;

Elsewhere in this driver cur_altsetting is used instead for this
purpose.  Change ftdi_determine_type() to use cur_altsetting
for consistency.

Signed-off-by: Mychaela N. Falconia <falcon@freecalypso.org>
[ johan: fix old style issues; drop braces and random white space ]
Signed-off-by: Johan Hovold <johan@kernel.org>
2020-10-05 13:01:09 +02:00
Johan Hovold
75240ac439 USB: serial: ftdi_sio: clean up jtag quirks
Drivers should not assume that interface descriptors have been parsed in
any particular order so match on interface number instead when rejecting
JTAG interfaces.

Also use the interface struct device for notifications so that the
interface number is included.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2020-10-01 09:37:16 +02:00
Mychaela N. Falconia
6cf87e5edd USB: serial: ftdi_sio: add support for FreeCalypso JTAG+UART adapters
There exist many FT2232-based JTAG+UART adapter designs in which
FT2232 Channel A is used for JTAG and Channel B is used for UART.
The best way to handle them in Linux is to have the ftdi_sio driver
create a ttyUSB device only for Channel B and not for Channel A:
a ttyUSB device for Channel A would be bogus and will disappear as
soon as the user runs OpenOCD or other applications that access
Channel A for JTAG from userspace, causing undesirable noise for
users.  The ftdi_sio driver already has a dedicated quirk for such
JTAG+UART FT2232 adapters, and it requires assigning custom USB IDs
to such adapters and adding these IDs to the driver with the
ftdi_jtag_quirk applied.

Boutique hardware manufacturer Falconia Partners LLC has created a
couple of JTAG+UART adapter designs (one buffered, one unbuffered)
as part of FreeCalypso project, and this hardware is specifically made
to be used with Linux hosts, with the intent that Channel A will be
accessed only from userspace via appropriate applications, and that
Channel B will be supported by the ftdi_sio kernel driver, presenting
a standard ttyUSB device to userspace.  Toward this end the hardware
manufacturer will be programming FT2232 EEPROMs with custom USB IDs,
specifically with the intent that these IDs will be recognized by
the ftdi_sio driver with the ftdi_jtag_quirk applied.

Signed-off-by: Mychaela N. Falconia <falcon@freecalypso.org>
[johan: insert in PID order and drop unused define]
Cc: stable@vger.kernel.org
Signed-off-by: Johan Hovold <johan@kernel.org>
2020-09-29 09:40:11 +02:00
Patrick Riphagen
6ccc48e0eb USB: serial: ftdi_sio: add IDs for Xsens Mti USB converter
The device added has an FTDI chip inside.
The device is used to connect Xsens USB Motion Trackers.

Cc: stable@vger.kernel.org
Signed-off-by: Patrick Riphagen <patrick.riphagen@xsens.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
2020-08-24 10:18:30 +02:00
Johan Hovold
eb0c68ea42 USB: serial: drop redundant transfer-buffer casts
Drop redundant URB transfer-buffer casts.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2020-07-09 09:20:17 +02:00
Johan Hovold
37ae231554 USB: serial: only set sysrq timestamp for consoles
Only set the sysrq timestamp for console ports to avoid having every
driver also check the console flag when processing incoming data.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2020-07-09 09:19:54 +02:00
Johan Hovold
733fff6794 USB: serial: ftdi_sio: fix break and sysrq handling
Only the last NUL in a packet should be flagged as a break character,
for example, to avoid dropping unrelated characters when IGNBRK is set.

Also make sysrq work by consuming the break character instead of having
it immediately cancel the sysrq request, and by not processing it
prematurely to avoid triggering a sysrq based on an unrelated character
received in the same packet (which was received *before* the break).

Note that the break flag can be left set also for a packet received
immediately following a break and that and an ending NUL in such a
packet will continue to be reported as a break as there's no good way to
tell it apart from an actual break.

Tested on FT232R and FT232H.

Fixes: 72fda3ca6f ("USB: serial: ftd_sio: implement sysrq handling on break")
Fixes: 1da177e4c3 ("Linux-2.6.12-rc2")
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2020-07-09 09:19:45 +02:00
Johan Hovold
ce054039ba USB: serial: ftdi_sio: clean up receive processing
Clean up receive processing by dropping the character pointer and
keeping the length argument unchanged throughout the function.

Also make it more apparent that sysrq processing can consume a
characters by adding an explicit continue.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2020-07-09 09:19:42 +02:00
Johan Hovold
ab4cc4ef67 USB: serial: ftdi_sio: make process-packet buffer unsigned
Use an unsigned type for the process-packet buffer argument and give it
a more apt name.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
2020-07-09 09:19:25 +02:00