[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <DDN63XH3EQ2Q.1BKBHJTQQASHO@kernel.org>
Date: Mon, 20 Oct 2025 15:02:03 +0200
From: "Michael Walle" <mwalle@...nel.org>
To: "Sander Vanheule" <sander@...nheule.net>, "Linus Walleij"
<linus.walleij@...aro.org>, "Bartosz Golaszewski" <brgl@...ev.pl>,
<linux-gpio@...r.kernel.org>
Cc: <linux-kernel@...r.kernel.org>
Subject: Re: [RFC PATCH 1/2] gpio: regmap: Force writes for aliased data
regs
Hi Sander,
On Mon Oct 20, 2025 at 1:56 PM CEST, Sander Vanheule wrote:
> GPIO chips often have data input and output fields aliased to the same
> offset. Since gpio-regmap performs a value update before the direction
> update (to prevent glitches), a pin currently configured as input may
> cause regmap_update_bits() to not perform a write.
>
> This may cause unexpected line states when the current input state
> equals the requested output state:
>
> OUT IN OUT
> DIR ''''''\...|.../''''''
>
> pin ....../'''|'''\......
> (1) (2) (3)
>
> 1. Line was configurad as out-low, but is reconfigured to input.
> External logic results in high value.
> 2. Set output value high. regmap_update_bits() sees the value is
> already high and discards the register write.
> 3. Line is switched to output, maintaining the stale output config
> (low) instead of the requested config (high).
>
> By switching to regmap_write_bits(), a write of the requested output
> value can be forced, irrespective of the read state. Do this only for
> aliased registers, so the more efficient regmap_update_bits() can still
> be used for distinct registers.
Have you looked at the .volatile_reg callback of the regmap api?
You might use the same heuristics, i.e. .reg_dat_base == .reg_set_base
to implement that callback. That way you'd just have to
(unconditionally) set that callback in gpio_regmap_register() and
regmap should take care of the rest.
-michael
Download attachment "signature.asc" of type "application/pgp-signature" (298 bytes)
Powered by blists - more mailing lists