Skip to content

HID: ft260: add UART and GPIO support, plus I2C fixes

Michael Zaidman linux-gpio linux-i2c linux-input linux-serial lkml 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest16 patches 2 repliesIn review
  2. v215 patches 2 repliesSuperseded
  3. v113 patches 25 repliesSuperseded

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/16HID: ft260: add serial driverdrivers/hid/Kconfig drivers/hid/hid-ft260.c+802 -610 replies
2/16HID: ft260: uart: fix the serial driverdrivers/hid/hid-ft260.c+233 -1760 replies
3/16HID: ft260: add GPIO supportdrivers/hid/Kconfig drivers/hid/hid-ft260.c+579 -500 replies
4/16HID: ft260: i2c: reduce driver module loading timedrivers/hid/hid-ft260.c+14 -50 replies
5/16HID: ft260: fix sysfs store failure notice for big numbersdrivers/hid/hid-ft260.c+10 -60 replies
6/16HID: ft260: i2c: reduce bus-error message severitydrivers/hid/hid-ft260.c+5 -50 replies
7/16HID: ft260: uart: enable flow controldrivers/hid/hid-ft260.c+5 -40 replies
8/16HID: ft260: uart: add modem pins control via ioctldrivers/hid/hid-ft260.c+151 -172 replies
9/16HID: ft260: group sysfs attrs per HID interfacedrivers/hid/hid-ft260.c+53 -100 replies
10/16HID: ft260: i2c: fix large write transaction failuredrivers/hid/hid-ft260.c+16 -190 replies
11/16HID: ft260: workaround for TN_189 errata endpoint STALL after enumerationdrivers/hid/hid-ft260.c+364 -20 replies
12/16HID: ft260: i2c: abort in-flight transfers with STOP before resetdrivers/hid/hid-ft260.c+36 -70 replies
13/16HID: ft260: i2c: reject an I2C clock outside the supported rangedrivers/hid/hid-ft260.c+28 -30 replies
14/16HID: ft260: i2c: fix i2c_reset sysfs store return valuedrivers/hid/hid-ft260.c+1 -10 replies
15/16HID: ft260: i2c: recover a bus held by a slavedrivers/hid/hid-ft260.c+196 -370 replies
16/16HID: ft260: use lock guardsdrivers/hid/hid-ft260.c+39 -800 replies

Reviews trailers per patch

None of the 16 patches has a Reviewed-by or Acked-by.

PatchChris Keeser
1/16
2/16
3/16
4/16
5/16
6/16
7/16
8/16
9/16
10/16T-b
11/16
12/16
13/16
14/16
15/16
16/16

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 00/16] HID: ft260: add UART and GPIO support, plus I2C fixes

Mainline supports only the FT260's I2C bridge. This series adds the UART/TTY interface and GPIO on top of it, and carries the I2C fixes made alongside them [1].

Patch 1 is Christina Quast's v4 serial driver, ported to the current I2C code. Patch 2 holds the fixes it needed on hardware and the fixes for the review findings in the patch 1 code. As agreed with Jiri, the series keeps the order in which the code was developed, and each patch keeps its own author. So the UART work is split: patches 7 and 8 add flow control and the modem pins after the GPIO and I2C patches.

The v1 and v2 threads:
https://lore.kernel.org/linux-input/[email protected]/T/#t
https://lore.kernel.org/linux-input/[email protected]/T/#t

Changes in v3:

All 21 issues Sashiko reported on v2 are fixed. The v3 note of each patch lists its changes, with the same words as below. A patch with no v3 note is unchanged from v2.

Patch 1:
Unchanged. From v3 on, review fixes for the serial driver go into patch 2 (the v3 note of patch 1 says why).

Patch 2:
Fixes for the issues reported by Sashiko:
- Wakeup timer shut down and its work cancelled in ft260_uart_port_remove(), so a tty call during removal cannot re-arm it; the probe error path also cancels the work.
- -ENODEV for an unknown chip mode, so probe does not return 0 after it frees dev.
- Port list sorted by index, so a re-added port does not get an index that is in use.
- TX from a work item, because write() may not sleep; no shared buffer, no endless loop on a FIFO reset; disabled before the FIFO is freed.
- TTY registered last, so userspace cannot open it before the UART is configured.
- UART reports passed to the tty code only on the UART interface; the I2C interface has no tty port.
- TX report limited to 60 bytes, so 61 or 62 bytes do not give the undefined report ID 0xFF.
- Unneeded ft260_uart_wakeup() prototype removed, changelog text corrected.
- port_activate() sets the wakeup workaround from the baud rate and arms the timer only when it is on, as ft260_uart_change_speed() does.

Patch 3:
Fixes for the issues reported by Sashiko:
- The gpiochip is registered without devm and removed in ft260_remove(), so a GPIO write that races an unbind does not use the freed dev.
- The uart_dcd_ri setting is kept across UART mode changes, so a mode change does not give GPIO4 and GPIO5 back to the GPIO function while they are DCD and RI.

Struct gpio_chip embedded in ft260_device, label from devm_kasprintf(), the "initialize gpio chip" messages dropped and "enabled GPIOs" moved to debug output (Bartosz Golaszewski).

Patch 5:
Subject reworded after the original out-of-tree commit, "Get rid of sysfs store big numbers failure notice". The v2 subject read as if the patch hid big values. No i2c: prefix, because FT260_ATTR_STORE serves all store attributes, not only the I2C ones.

Patch 8:
Fixes for the issues reported by Sashiko:
- gpio_en checked under port->lock in tiocmget() and tiocmset(), so a termios or sysfs change cannot switch the pins between the check and the GPIO report.
- tiocmget() and tiocmset() return -ENODEV after ft260_remove(), so they do not use hdev after hid_hw_stop().
- tiocmget() cannot run before dev->gc is set, because ft260_uart_probe() registers the TTY last since patch 2.

Patch 9:
The err_register_tty path, which patch 3 adds to ft260_uart_probe(), removes the UART attribute group of patch 9.

Patch 11:
Fixes for the issues reported by Sashiko:
- One reset per chip: struct ft260_chip, shared by the two interfaces, is added here, so a reset queued by the second interface does not tear down the chip that the first reset has recovered.
- Interfaces unbound before the USB reset, not after, so the reset does not run while a failing probe stops usbhid and frees its URBs.
- -ENOMEM from usb_control_msg() returned as it is, not turned into -ENODEV and a reset.

Patch 15:
Recovery info per adapter in struct ft260_device, not one static copy, because i2c_init_recovery() writes into it for each adapter.

Fix for the issue reported by Sashiko:
- GPIO report lock in the ft260_chip, shared by the I2C and UART interfaces of one chip, so a GPIO write from one interface is not lost by a write from the other; tiocmset() reads the report.

Patch 16:
New patch (suggested by Bartosz Golaszewski). It is the last patch, so the out-of-tree driver for kernels older than 6.5, which do not have linux/cleanup.h, can leave it out.

Testing:

The kernel is built from hid/for-next 720806515cb6 with KASAN, PROVE_LOCKING and DEBUG_ATOMIC_SLEEP, and booted with kasan_multi_shot. The driver is built as a module from the last patch.

The pytest suite [2] of 206 tests passed, with no KASAN or lockdep report. The v2 driver on the same kernel fails the new gpiochip unbind test with the KASAN report that patch 3 fixes.

For the TN_189 workaround, a HW setup that resets the FT260 chip by its RESETN pin ran 7,781 cycles. 101 of them hit the endpoint STALL, and each of these recovered with one USB reset (details in patch 11).

Every patch builds with W=1 without warnings. checkpatch --strict reports no errors. It warns once, in patch 15, for a quoted kernel log line.

[1] https://github.com/MichaelZaidman/hid-ft260
[2] https://github.com/MichaelZaidman/hid-ft260/tree/main/tests

Christina Quast (1):
HID: ft260: add serial driver

Michael Zaidman (15):
HID: ft260: uart: fix the serial driver
HID: ft260: add GPIO support
HID: ft260: i2c: reduce driver module loading time
HID: ft260: fix sysfs store failure notice for big numbers
HID: ft260: i2c: reduce bus-error message severity
HID: ft260: uart: enable flow control
HID: ft260: uart: add modem pins control via ioctl
HID: ft260: group sysfs attrs per HID interface
HID: ft260: i2c: fix large write transaction failure
HID: ft260: workaround for TN_189 errata endpoint STALL after
enumeration
HID: ft260: i2c: abort in-flight transfers with STOP before reset
HID: ft260: i2c: reject an I2C clock outside the supported range
HID: ft260: i2c: fix i2c_reset sysfs store return value
HID: ft260: i2c: recover a bus held by a slave
HID: ft260: use lock guards

 drivers/hid/Kconfig     |   10 +-
 drivers/hid/hid-ft260.c | 2579 +++++++++++++++++++++++++++++++++++----
 2 files changed, 2319 insertions(+), 270 deletions(-)

base-commit: 720806515cb6921ab05caaa6f470f7054b56385e

Signature · 1 line
2.43.0