mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Michael Zaidman <michael.zaidman@gmail.com>
To: Linus Walleij <linusw@kernel.org>
Cc: Michael Zaidman <michael.zaidman@gmail.com>,
	Jiri Kosina <jikos@kernel.org>,
	Benjamin Tissoires <bentiss@kernel.org>,
	Bartosz Golaszewski <brgl@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiri Slaby <jirislaby@kernel.org>,
	Raman Varabets <kernel-linux-20260610-80b7ab08@raman.v1.sg>,
	Germain Hebert <germain.hebert@ca.abb.com>,
	Christina Quast <contact@christina-quast.de>,
	Rio Liu <rio@r26.me>, Bruno Giacomazzi <brunoceg1@gmail.com>,
	linux-input@vger.kernel.org, linux-serial@vger.kernel.org,
	linux-gpio@vger.kernel.org, linux-i2c@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 03/16] HID: ft260: add GPIO support
Date: Mon, 30 Nov 2026 22:46:55 +0200	[thread overview]
Message-ID: <20261130204656.8744-1-michael.zaidman@gmail.com> (raw)
In-Reply-To: <CAD++jLm3C1VZU5OSQ8OV03B-L=f=MjMnH5Sr9DF00cZ-jXKuGQ@mail.gmail.com>

Hi Linus,

On Mon, Nov 30, 2026 at 12:15:36AM +0100, Linus Walleij wrote:
> > +/* Multi-function pin functions */
> > +enum {
> > +       FT260_MFPIN_GPIO                = 0x00,
> > +       FT260_MFPIN_SUSPOUT             = 0x01,
> [...]
>
> This is clearly pin multiplexing, by the textbook.

Yes. These are the values of the FT260 HID reports that select the
function of the pins GPIO2, GPIOA and GPIOG.

> > +FT260_SSTAT_ATTR_SHOW(gpio2_func);
> > +FT260_BYTE_ATTR_STORE(gpio2_func, ft260_set_gpio2_func_report,
> > +                     FT260_SELECT_GPIO2_FUNC, ft260_gpio_en_update);
> > +static DEVICE_ATTR_RW(gpio2_func);
> [...]
>
> Is this a custom sysfs to expose and set pin multiplexing?

Yes, for four files. gpio2_func, gpioa_func and gpiog_func select the
function of these three pins. uart_dcd_ri switches GPIO4 and GPIO5
between GPIO and the UART DCD and RI lines.

The other files in the hunk, i2c_enable, uart_mode, clock_ctl and
clock, are in mainline since v5.13. The patch only adds a callback
argument to their store macro. For i2c_enable and uart_mode, the
callback updates the mask of the GPIO lines.

> I think this hacking needs to stop.
>
> This driver needs to be using proper pin control.
>
> If I was doing this I would spawn a new platform device,
> figure out some transport mechanism and create a new
> combined pin control and GPIO driver in drivers/pinctrl/* for this.

This fits the MFD split that we discussed in the v1 thread, with the
pin control and GPIO driver as one child device. There I wrote that I
would land the current driver first, and do the MFD split as its own
series once this one is in the tree [1]. I keep that plan.

> 1. Do what I did in
>   commit 200e6c6e94fa786e36e4fe33eebf16b822181b99
>   "HID: mcp2221: Add module parameter to enfoce GPIO mode"
>   and control the mode with a module parameters instead
>   of custom sysfs files.

For the FT260 this removes functions that the files have now:

- A parameter like gpio_mode_enforce has one value for all FT260
  chips in the system. The sysfs files set each chip on its own.
- It can only switch a pin to GPIO. The three pins have more
  functions: GPIOA can be TX_ACTIVE or TX_LED, GPIO2 can be
  SUSPOUT_N, SUSPOUT or PWREN_N, and GPIOG can be BCD_DET, RX_LED or
  PWREN_N. To select one of these, the user would have to program
  the eFUSE or an EEPROM with the FTDI tool FT_PROG.

The out-of-tree driver has had the three *_func files since December
2022, and uart_dcd_ri since March 2024.

> 2. Bite the bullet and implement some standardized
>   sysfs ABI for pin control for selected groups and functions
>   of a pin controller from userspace. No custom stuff.
>   This to be done after moving the driver over to
>   drivers/pinctrl.

Documentation/driver-api/pin-control.rst describes no such interface.
For userspace it has only the debugfs file pinmux-select. As you say,
this work comes after the move to drivers/pinctrl, so it belongs to
the MFD series.

For v5 I propose this:

- Patch 3 adds the gpiochip without the four files. The gpiochip uses
  the pin functions that the chip reports at probe.
- The four files move to a separate patch at the end of the series,
  with an entry in Documentation/ABI/testing/. No other patch
  depends on it.

Without that patch the driver loses functions that users of the
out-of-tree driver have today. With the chip defaults, GPIO2, GPIOA
and GPIOG are not GPIO lines, and the driver gives no other way to
make them GPIO lines. For example, in [2] a user writes 0 to
gpio2_func to get GPIO2 as a GPIO line.

Jiri, Benjamin, the separate patch lets you decide on it apart from
the rest of the series. When the MFD series moves the pins to a pin
control driver, the files go to Documentation/ABI/obsolete/.

[1] https://lore.kernel.org/all/20260926183136.25146-1-michael.zaidman@gmail.com/
[2] https://github.com/MichaelZaidman/hid-ft260/issues/9

Thanks,
Michael

  reply	other threads:[~2026-11-30 20:47 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 20:04 [PATCH v4 00/16] HID: ft260: add UART and GPIO support, plus I2C fixes Michael Zaidman
2026-11-17 20:04 ` [PATCH v4 01/16] HID: ft260: add serial driver Michael Zaidman
2026-11-18  7:21   ` Jiri Slaby
2026-11-18 16:38     ` Michael Zaidman
2026-11-17 20:04 ` [PATCH v4 02/16] HID: ft260: uart: fix " Michael Zaidman
2026-11-17 20:04 ` [PATCH v4 03/16] HID: ft260: add GPIO support Michael Zaidman
2026-11-29 23:15   ` Linus Walleij
2026-11-30 20:46     ` Michael Zaidman [this message]
2026-11-17 20:04 ` [PATCH v4 04/16] HID: ft260: i2c: reduce driver module loading time Michael Zaidman
2026-11-17 20:04 ` [PATCH v4 05/16] HID: ft260: fix sysfs store failure notice for big numbers Michael Zaidman
2026-11-17 20:04 ` [PATCH v4 06/16] HID: ft260: i2c: reduce bus-error message severity Michael Zaidman
2026-11-17 20:04 ` [PATCH v4 07/16] HID: ft260: uart: enable flow control Michael Zaidman
2026-11-17 20:04 ` [PATCH v4 08/16] HID: ft260: uart: add modem pins control via ioctl Michael Zaidman
2026-11-17 23:56   ` Maarten Brock
2026-11-18 16:40     ` Michael Zaidman
2026-11-17 20:04 ` [PATCH v4 09/16] HID: ft260: group sysfs attrs per HID interface Michael Zaidman
2026-11-17 20:04 ` [PATCH v4 10/16] HID: ft260: i2c: fix large write transaction failure Michael Zaidman
2026-11-17 20:04 ` [PATCH v4 11/16] HID: ft260: workaround for TN_189 errata endpoint STALL after enumeration Michael Zaidman
2026-11-17 20:04 ` [PATCH v4 12/16] HID: ft260: i2c: abort in-flight transfers with STOP before reset Michael Zaidman
2026-11-17 20:04 ` [PATCH v4 13/16] HID: ft260: i2c: reject an I2C clock outside the supported range Michael Zaidman
2026-11-17 20:04 ` [PATCH v4 14/16] HID: ft260: i2c: fix i2c_reset sysfs store return value Michael Zaidman
2026-11-17 20:04 ` [PATCH v4 15/16] HID: ft260: i2c: recover a bus held by a slave Michael Zaidman
2026-11-17 20:04 ` [PATCH v4 16/16] HID: ft260: use lock guards Michael Zaidman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261130204656.8744-1-michael.zaidman@gmail.com \
    --to=michael.zaidman@gmail.com \
    --cc=bentiss@kernel.org \
    --cc=brgl@kernel.org \
    --cc=brunoceg1@gmail.com \
    --cc=contact@christina-quast.de \
    --cc=germain.hebert@ca.abb.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jikos@kernel.org \
    --cc=jirislaby@kernel.org \
    --cc=kernel-linux-20260610-80b7ab08@raman.v1.sg \
    --cc=linusw@kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=rio@r26.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®