Re: [PATCH] nvmem: core: Mark nWP GPIO as non-exclusive
From: Bartosz Golaszewski
Date: Fri Jul 24 2026 - 03:31:21 EST
On Thu, 23 Jul 2026 21:35:27 +0200, Marek Vasut <marex@xxxxxxxxxxxx> said:
> On 5/12/26 12:04 PM, Bartosz Golaszewski wrote:
>> On Mon, May 11, 2026 at 6:35 PM Marek Vasut <marex@xxxxxxxxxxxx> wrote:
>>>
>>> Mark the nWP GPIO as non-exclusive, because there is hardware in the
>>> field which has multiple AT24 EEPROMs with nWP GPIO line tied to a
>>> single GPIO. This allows such hardware to be described in DT and the
>>> nWP GPIO operated via NVMEM force_ro sysfs attribute.
>>>
>>> Note that GPIOD_FLAGS_BIT_NONEXCLUSIVE is a deprecated flag and should
>>> not be used, but thus far there seems to be no replacement.
>>>
>>
>> There is a replacement now. It lives under
>> drivers/gpio/gpiolib-shared.c and drivers/gpio/gpio-shared-proxy.c.
>> Though the voting mechanism I implemented is hard-coded to drive the
>> line high if there's at least one consumer sharing the line that votes
>> high. I'm now thinking that this may be too rigid as yesterday, within
>> two hours I had two submissions wanting to do it the other way around
>> - drive the line low if there's at least one consumer that wants it
>> low.
>>
>> I'll try to modify the gpio-shared-proxy driver to take into account
>> the value set when the line is first requested and treat it as the
>> "default" in the voting mechanism. IOW: when the first user requests
>> it out-high, we'll drive it low on the first user that votes for low
>> and drive it high again when the last user drivers it high. This
>> should work for both the Qualcomm shared GPIOs for audio use-cases and
>> the WP pin here as well as the SCL recovery shared GPIO we have in
>> I2C.
>>
>> With that said: I'd prefer you not set the
>> GPIOD_FLAGS_BIT_NONEXCLUSIVE and see if you can make gpio-shared-proxy
>> work for you instead. I'll submit something soon for you to test.
>
> I'm sorry for my late reply, I was completely overwhelmed by emails.
>
> I tried to look into the gpio-shared* , but I couldn't figure out how to
> describe it in DT. Do you have any examples?
>
> Take for example this DT snippet:
>
> gpio: gpio-controller { ... };
>
> i2c {
> eeprom@0 {
> wp-gpios = <&gpio 0 0>;
> ...
> };
>
> eeprom@1 {
> wp-gpios = <&gpio 0 0>;
> ...
> };
> };
>
> I assume there has to be some new glue node between the eeproms and the
> GPIO controller somewhere ?
>
> Thank you for your help !
>
No, this is literally how you do it. If you enable HAVE_SHARED_GPIOs and
DEBUG_GPIO, you should see it being picked up in the kernel log.
Bartosz