Re: [PATCH] gpio: shared: make the voting mechanism adaptable

From: Bartosz Golaszewski

Date: Tue May 19 2026 - 04:27:31 EST


On Tue, May 19, 2026 at 5:59 AM Marek Vasut <marex@xxxxxxxxxxxx> wrote:
>
> On 5/13/26 11:13 AM, Bartosz Golaszewski wrote:
> > The current voting mechanism in GPIO shared proxy assumes that "low" is
> > always the default value and users can only vote for driving the GPIO
> > "high" in which case it will remain high as long as there's at least one
> > user voting.
> >
> > This makes it impossible to use the automatic sharing management for
> > certain use-cases such as the write-protect GPIOs of EEPROMs which are
> > requested "high" and driven "low" to enable writing. In this case, if
> > the WP GPIO is shared by multiple EEPROMs, and at least one of them
> > wants to enable writing, the pin must be set to "low".
> >
> > Modify the voting heuristic to assume the value set by the first user on
> > request to be the "default" and subseqent calls to gpiod_set_value()
> > will constitute votes for a change of the value to the opposite. In the
> > wp-gpios case it will mean that the nvmem core requests the GPIO as
> > "out-high" for all EEPROMs sharing the pin, and when one of them wants
> > to write, the pin will be driven low, enabling it.
>
> Shouldn't this polarity inversion be handled by DT GPIO_ACTIVE_* flag ?
>

We could but that would require DT changes, you probably don't want
this? That's a different thing though too. Here's it's purely logical
- either we default to high and vote for low or default to low and
vote for high with at least one vote needed to switch.

> > Fixes: e992d54c6f97 ("gpio: shared-proxy: implement the shared GPIO proxy driver")
> > Reported-by: Marek Vasut <marex@xxxxxxxxxxxx>
> > Closes: https://lore.kernel.org/all/20260511163518.51104-1-marex@xxxxxxxxxxxx/
> > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxxxxxxxx>
> > ---
> > Hi Marek!
> >
> > Please see if you can make your setup work with shared GPIOs with this
> > patch. You need to enable CONFIG_HAVE_SHARED_GPIOS on your platform.
>
> Why can this shared GPIO not be enabled generically for any GPIO
> controller ?
>
> [...]

That's the plan. I enabled it in arm64 defconfig for now (via Qualcomm
platforms selecting it). It caused quite a lot of fallout and a slew
of fixes so I'm doing it slowly. But yes - eventually it should be
enabled for all OF systems and potentially also verify software node
references as there are some intel systems that have GPIOs shared by
platform devices described in ACPI *and* software nodes.

Bart