[PATCH v4 00/10] gpio: improve support for shared GPIOs
Bartosz Golaszewski
brgl at bgdev.pl
Tue Nov 18 05:21:29 PST 2025
On Tue, Nov 18, 2025 at 1:56 PM Geert Uytterhoeven <geert at linux-m68k.org> wrote:
>
> > >
> > > Thanks for your series, part of which is now present linux-next.
> > > IIUIC, this requires the direction of the GPIO to be fixed?
> > >
> > > We have a long-standing use-case on various Renesas R-Car Gen3 boards
> > > (e.g. Salvator-X(S) and ULCB[1]), where GPIOs are shared by LEDs and
> > > key switches. Basically, the GPIO is connected to:
> > > 1. A key switch connecting to GND when closed, with pull-up.
> > > 2. The gate of an N-channel MOSFET, turning on an LED when driven
> > > high.
> > >
> > > Hence:
> > > - In output mode, the LED can be controlled freely,
> > > - In input mode, the LED is on, unless the key is pressed,
> > > - Hence the switch state can only be read when the LED is turned on.
> > > If you have any idea how to handle this, feel free to reply ;-)
> >
> > How is this done currently? Even without this series and using the
> > GPIOD_FLAGS_BIT_NONEXCLUSIVE, the descriptor has a well-defined
> > direction so it's not possible for two drivers to request it as input
> > and output simultaneously. The second requester will override the
> > previous settings.
>
> We do not handle it yet:
> - arch/arm64/boot/dts/renesas/salvator-common.dtsi describes only
> the keys (key-[a-c]),
> - arch/arm64/boot/dts/renesas/ulcb.dtsi describes the first key
> (key-1), and the others as LEDs (led[56]).
>
I see. This series cannot possibly address this. Off the top of my
head: I would create an auxiliary device binding to a dedicated driver
that would be a consumer of this pin and register a LED and an input
key. By default it would set the direction to input and if the user
decided to configure the LED, it would change direction to output.
Obviously, there would be a DR quirk to handle as we already have this
described in DT as gpio-keys on salvator.
Bartosz
More information about the linux-arm-kernel
mailing list