gpio: Enable hogging support in SPL
authorEddie James <eajames@linux.ibm.com>
Mon, 7 Feb 2022 23:09:01 +0000 (17:09 -0600)
committerTom Rini <trini@konsulko.com>
Sat, 9 Apr 2022 02:51:48 +0000 (22:51 -0400)
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.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
common/spl/spl.c
drivers/gpio/Kconfig
drivers/gpio/gpio-uclass.c

index b452d4f..c9750ee 100644 (file)
@@ -20,6 +20,7 @@
 #include <serial.h>
 #include <spl.h>
 #include <asm/global_data.h>
+#include <asm-generic/gpio.h>
 #include <asm/u-boot.h>
 #include <nand.h>
 #include <fat.h>
@@ -743,6 +744,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
index a55e368..89068c7 100644 (file)
@@ -57,6 +57,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
index be00a1f..0ed32b7 100644 (file)
@@ -1458,9 +1458,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;
@@ -1491,7 +1488,10 @@ static int gpio_post_bind(struct udevice *dev)
        }
 #endif
 
-       if (CONFIG_IS_ENABLED(OF_REAL) && 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);