Re: [PATCH 08/13] HID: ft260: uart: add modem pins control via ioctl
From: Linus Walleij
Date: Tue Aug 25 2026 - 04:09:17 EST
Hi Michael,
thanks for your patch!
On Sat, Aug 22, 2026 at 11:40 PM Michael Zaidman
<michael.zaidman@xxxxxxxxx> wrote:
> Add TIOCMGET/TIOCMSET (and thus TIOCMBIS/TIOCMBIC) support so userspace
> can drive DTR/RTS when the modem pins are in GPIO mode. This enables
> programming an ESP32 over the FT260 with esptool, which resets the chip
> via those lines.
>
> Also key GPIO sysfs registration off chip_mode rather than USB interface
> number 0, and include DCD/RI in UART mode 3/4 GPIO sets so the modem
> mask matches the pins esptool needs.
>
> Signed-off-by: Michael Zaidman <michael.zaidman@xxxxxxxxx>
I'm not the authortative expert on modem control using GPIO,
but what I think you should do is to
select GPIOLIB
select SERIAL_MCTRL_GPIO
On Kconfig, so that gpiolib is always available and you can use
the generic modem control helpers for modem control over GPIO.
This can be a bit delicate in this case since the gpiochip that you
use for mctrl is also registered in this driver, so you need to
register the gpiochip *first*, then add a look-up table for the
GPIOs, then register this modem control.
I don't think this has been done before for this type of device
so it could be a bit tricky, but it is probably the right thing to
do.
#include <linux/gpio/machine.h>
#include <linux/gpio/consumer.h>
Then look in e.g. drivers/mfd/sm501.c which is an
MFD device that register a gpiochip and then consume
GPIOs from itself. In the function
sm501_register_gpio_i2c_instance() this driver registers
a table of dynamic gpios associated with a separate subdevice.
A separate subdevice probably isn't needed but
something like this will be needed, albeit with the gpiochip
spawn off the main device for FT260.
The core idea is that the serial modem control should look
up the GPIOs from its own gpiochip and use the MCTRL
library helpers, then this should result in very little and
compact code that is easy to read.
Yours,
Linus Walleij