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

From: Marek Vasut

Date: Mon May 18 2026 - 23:59:52 EST


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 ?

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 ?

[...]