Skip to content

Commit a060b8c

Browse files
author
Bartosz Golaszewski
committed
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>
1 parent d4340ff commit a060b8c

4 files changed

Lines changed: 620 additions & 0 deletions

File tree

drivers/gpio/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
config GPIOLIB_LEGACY
77
def_bool y
88

9+
config HAVE_SHARED_GPIOS
10+
bool
11+
912
menuconfig GPIOLIB
1013
bool "GPIO Support"
1114
help
@@ -50,6 +53,11 @@ config OF_GPIO_MM_GPIOCHIP
5053
this symbol, but new drivers should use the generic gpio-regmap
5154
infrastructure instead.
5255

56+
config GPIO_SHARED
57+
def_bool y
58+
depends on HAVE_SHARED_GPIOS || COMPILE_TEST
59+
select AUXILIARY_BUS
60+
5361
config DEBUG_GPIO
5462
bool "Debug GPIO calls"
5563
depends on DEBUG_KERNEL

drivers/gpio/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ obj-$(CONFIG_GPIO_SYSFS) += gpiolib-sysfs.o
1212
obj-$(CONFIG_GPIO_ACPI) += gpiolib-acpi.o
1313
gpiolib-acpi-y := gpiolib-acpi-core.o gpiolib-acpi-quirks.o
1414
obj-$(CONFIG_GPIOLIB) += gpiolib-swnode.o
15+
obj-$(CONFIG_GPIO_SHARED) += gpiolib-shared.o
1516

1617
# Device drivers. Generally keep list sorted alphabetically
1718
obj-$(CONFIG_GPIO_REGMAP) += gpio-regmap.o

0 commit comments

Comments
 (0)