From 031b9963f5f5181f9f6a102e4cc0b9e12d32f2ca Mon Sep 17 00:00:00 2001 From: Eddie James Date: Mon, 7 Feb 2022 17:09:01 -0600 Subject: gpio: Enable hogging support in SPL Use the CONFIG macros to conditionally build the GPIO hogging support in either the SPL or U-Boot, or both, depending on the configuration. Also call the GPIO hog probe function in the common SPL board initialization as an equivalent to adding it to the U-Boot init sequence functions. Upstream-Status: Backport [1d99e673c752bc7d55aa25b02e050741496f7109] Signed-off-by: Eddie James Reviewed-by: Simon Glass --- common/spl/spl.c | 4 ++++ drivers/gpio/Kconfig | 9 +++++++++ drivers/gpio/gpio-uclass.c | 8 ++++---- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/common/spl/spl.c b/common/spl/spl.c index 63c48fbf33..87e6ab390b 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -637,6 +638,9 @@ void board_init_r(gd_t *dummy1, ulong dummy2) } } + if (CONFIG_IS_ENABLED(GPIO_HOG)) + gpio_hog_probe_all(); + #if CONFIG_IS_ENABLED(BOARD_INIT) spl_board_init(); #endif diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 202fcc6f47..89def55183 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -46,6 +46,15 @@ config GPIO_HOG is a mechanism providing automatic GPIO request and config- uration as part of the gpio-controller's driver probe function. +config SPL_GPIO_HOG + bool "Enable GPIO hog support in SPL" + depends on SPL_GPIO_SUPPORT + help + Enable gpio hog support in SPL + The GPIO chip may contain GPIO hog definitions. GPIO hogging + is a mechanism providing automatic GPIO request and config- + uration as part of the gpio-controller's driver probe function. + config DM_GPIO_LOOKUP_LABEL bool "Enable searching for gpio labelnames" depends on DM_GPIO diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c index 0c01413b58..4a8d556044 100644 --- a/drivers/gpio/gpio-uclass.c +++ b/drivers/gpio/gpio-uclass.c @@ -1282,9 +1282,6 @@ void devm_gpiod_put(struct udevice *dev, struct gpio_desc *desc) static int gpio_post_bind(struct udevice *dev) { - struct udevice *child; - ofnode node; - #if defined(CONFIG_NEEDS_MANUAL_RELOC) struct dm_gpio_ops *ops = (struct dm_gpio_ops *)device_get_ops(dev); static int reloc_done; @@ -1315,7 +1312,10 @@ static int gpio_post_bind(struct udevice *dev) } #endif - if (IS_ENABLED(CONFIG_GPIO_HOG)) { + if (CONFIG_IS_ENABLED(GPIO_HOG)) { + struct udevice *child; + ofnode node; + dev_for_each_subnode(node, dev) { if (ofnode_read_bool(node, "gpio-hog")) { const char *name = ofnode_get_name(node); -- cgit v1.2.3