There's an unexpected interaction between the reset-gpio driver and the
shared GPIO support. The reset-gpio device is an auxiliary device that's
created dynamically and fulfills a similar role to the gpio-shared-proxy
driver but is limited in scope to just supporting the "reset-gpios"
property.
The shared GPIO core code does not take into account that the machine
lookup entry we create when scanning the device-tree must connect the
reset-gpio device - that is the actual consumer of the GPIO and not the
consumer defined on the device tree, which in turn consumes the shared
reset control exposed by the reset-gpio device - to the GPIO controller.
We also must not skip the gpio-shared-proxy driver as it's possible that
a shared GPIO may be used by one consumer as a reset-gpios going through
the reset-gpio device and another that uses GPIOLIB.
We need to make it a special case handled in gpiolib-shared.c. Add a new
function - gpio_shared_dev_is_reset_gpio() - whose role it is to verify
if a non-matching consumer of a shared pin is a reset-gpio device and
make sure it's the right one for this pin. To that end make sure that
its parent is the GPIO controller in question and that the fwnode we
identified as sharing the pin references that controller via the
"reset-gpios" property.
Only include that code if the reset-gpio driver is enabled.
Fixes: a060b8c511 ("gpiolib: implement low-level, shared GPIO support")
Reported-by: Val Packett <val@packett.cool>
Closes: https://lore.kernel.org/all/3b5d9df5-934d-4591-8827-6c9573a6f7ba@packett.cool/
Tested-by: Val Packett <val@packett.cool>
Tested-by: Abel Vesa <abel.vesa@linaro.org>
Link: https://lore.kernel.org/r/20251125-gpiolib-shared-reset-gpio-fix-v2-1-4eb6fa41f1dd@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Add better support for GPIOs shared by multiple consumers.
-----BEGIN PGP SIGNATURE-----
iQIzBAABCgAdFiEEkeUTLeW1Rh17omX8BZ0uy/82hMMFAmka6jYACgkQBZ0uy/82
hMOiqg//WzGyo1GeTC0Q/xruNMG1Q1dty0O6pQXO0wncg5wa457KBSaDBM8K7xnx
Fmu6gJlyeW8Bgvt4WkMFQPXuKMAGzSuI6buVW4Ncz+cdEYqSCqTV0NLNDottAZgW
HW3jDbGjiKihM4BAweAmH3zutanPw+ZIhVM2EDqRIhWv87oVvxJSMQxrUMzc2E+/
6xGxyPzjukiPM+8hotspP9r6siXdzYSiojiLL7xCalsunz3B3RIrivbHnoWCETcP
Yg0NCjPe/kUjGGuXpB73ZjutzMROpI8lmCY11P1+6PEcQlUIp6UX/YXdHwBLb6bk
ZxpO1x4AkM6YKah2ocY0jQo/u/fKxzTpu8o2hCTUfmqROmM5rrlzXM7NYt/avN6E
ip8dZo+x71GHrjdm7dRN7OSrVL6OFK1AiUPVhuIx0KE7aiKi05thVRknYxA+IYu7
+fatQ2x739ibISvpG6wf9nRPijMXKX2ONU5HKAqtpTAsgsbs07c9ziry/3YBdDWk
YGSenEzlYEPyhzUWQ6gVfbmoCkiG7UUU8WoMfAMpsJhH95VrOAS7WcEhZoq7fDMQ
QMovFUiMbXpBcBu7AFQR3+fKxBXWHdG3Nicsvl5zGyhG3TKv/96umhAYN85J2Dwy
KSJrCLRZg6xN4Ocd1R2Y1NYeJy6LAqx5XgKRD07aqrWnTK8r/uk=
=fa8j
-----END PGP SIGNATURE-----
Merge tag 'gpio/shared-gpios-for-v6.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux.git into gpio/for-next
Immutable branch between the GPIO, ASoC and regulator trees for v6.19-rc1
Add better support for GPIOs shared by multiple consumers.
Provide an interface allowing consumers to check if a GPIO descriptor
represents a GPIO that can potentially be shared by multiple consumers
at the same time. This is exposed to allow subsystems that already
work around the limitations of the current non-exclusive GPIO handling
in some ways, to gradually convert to relying on the new shared GPIO
feature of GPIOLIB.
Extend the gpiolib-shared module to mark the GPIO shared proxy
descriptors with a flag checked by the new interface.
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20251112-gpio-shared-v4-6-b51f97b1abd8@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
This module scans the device tree (for now only OF nodes are supported
but care is taken to make other fwnode implementations easy to
integrate) and determines which GPIO lines are shared by multiple users.
It stores that information in memory. When the GPIO chip exposing shared
lines is registered, the shared GPIO descriptors it exposes are marked
as shared and virtual "proxy" devices that mediate access to the shared
lines are created. When a consumer of a shared GPIO looks it up, its
fwnode lookup is redirected to a just-in-time machine lookup that points
to this proxy device.
This code can be compiled out on platforms which don't use shared GPIOs.
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20251112-gpio-shared-v4-3-b51f97b1abd8@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>