gpiolib: implement low-level, shared GPIO support

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>
This commit is contained in:
Bartosz Golaszewski
2025-11-12 14:55:32 +01:00
parent d4340ff75e
commit a060b8c511
4 changed files with 620 additions and 0 deletions

View File

@@ -6,6 +6,9 @@
config GPIOLIB_LEGACY
def_bool y
config HAVE_SHARED_GPIOS
bool
menuconfig GPIOLIB
bool "GPIO Support"
help
@@ -50,6 +53,11 @@ config OF_GPIO_MM_GPIOCHIP
this symbol, but new drivers should use the generic gpio-regmap
infrastructure instead.
config GPIO_SHARED
def_bool y
depends on HAVE_SHARED_GPIOS || COMPILE_TEST
select AUXILIARY_BUS
config DEBUG_GPIO
bool "Debug GPIO calls"
depends on DEBUG_KERNEL