Re: [PATCH] gpio: shared: make the voting mechanism adaptable
From: Bartosz Golaszewski
Date: Tue May 19 2026 - 05:14:23 EST
On Tue, May 19, 2026 at 10:34 AM Linus Walleij <linusw@xxxxxxxxxx> wrote:
>
> On Wed, May 13, 2026 at 11:14 AM Bartosz Golaszewski
> <bartosz.golaszewski@xxxxxxxxxxxxxxxx> 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.
> >
> > 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>
>
> I like this idea.
> Reviewed-by: Linus Walleij <linusw@xxxxxxxxxx>
>
> BTW was this "voting" system inspired by the hardware "vote" thing
> that Qualcomm is using for power management? That's the only place
> I've seen it before.
>
Really only the name, it's not much different from what we already
have in clocks or regulators IMO.
Bart