Skip to contentSkip to conversation

gpio: Enable hogging support in SPL

PATCH Simon Glass 2 participants 2 messages Feb 4, 2022 1 message not in the archive

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive

Hi Eddie,

Quoted 18 lines · Eddie James

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.

---
 common/spl/spl.c           |  7 +++++++
 drivers/gpio/Kconfig       | 10 ++++++++++
 drivers/gpio/gpio-uclass.c | 10 ++++++----
 3 files changed, 23 insertions(+), 4 deletions(-)
common/spl/spl.c +0 -0
index 884102bdea..f667908eec 100644

common/spl/spl.c line 23

Quoted 4 lines
common/spl/spl.c +1 -0
@@ -20,6 +20,9 @@
 #include <serial.h>
 #include <spl.h>
 #include <asm/global_data.h>
+#if defined(CONFIG_SPL_GPIO_HOG)

Can you drop this ifdef?

common/spl/spl.c void board_init_r(gd_t *dummy1, ulong dummy2) · line 747

Quoted 12 lines
common/spl/spl.c +5 -0
+#include <asm/gpio.h>
+#endif
 #include <asm/u-boot.h>
 #include <nand.h>
 #include <fat.h>
@@ -739,6 +742,10 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
                }
        }
 
+#if defined(CONFIG_SPL_GPIO_HOG)
+       gpio_hog_probe_all();
+#endif

if (CONFIG_IS_ENABLED(GPIO_HOG))
...

Quoted 9 lines
common/spl/spl.c +1 -0
+
 #if CONFIG_IS_ENABLED(BOARD_INIT)
        spl_board_init();
 #endif
drivers/gpio/Kconfig +0 -0
index 305a2dc563..4da2bdc10d 100644

drivers/gpio/Kconfig config GPIO_HOG · line 62

Quoted 6 lines
drivers/gpio/Kconfig +3 -0
@@ -57,6 +57,16 @@ 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

Should it depend on GPIO_HOG? I'm not sure, just a question

Quoted 48 lines
drivers/gpio/Kconfig +7 -0
+       default n
+       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
drivers/gpio/gpio-uclass.c +6 -5
index 125ae53d61..bebba620c9 100644
@@ -1432,9 +1432,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;
@@ -1465,7 +1462,11 @@ 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);
@@ -1480,6 +1481,7 @@ static int gpio_post_bind(struct udevice *dev)
                        }
                }
        }
+#endif
        return 0;
 }
 
--

2.27.0

#2 lore raw
Quoted 15 lines · Simon Glass

Hi Eddie,

Quoted 12 lines · Eddie James

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.

---
  common/spl/spl.c           |  7 +++++++
  drivers/gpio/Kconfig       | 10 ++++++++++
  drivers/gpio/gpio-uclass.c | 10 ++++++----
  3 files changed, 23 insertions(+), 4 deletions(-)
Quoted 10 lines

common/spl/spl.c line 23

Quoted 9 lines
common/spl/spl.c +1 -0
index 884102bdea..f667908eec 100644
@@ -20,6 +20,9 @@
  #include <serial.h>
  #include <spl.h>
  #include <asm/global_data.h>
+#if defined(CONFIG_SPL_GPIO_HOG)

Can you drop this ifdef?

Sure.

Quoted 10 lines
Quoted 10 lines
common/spl/spl.c +2 -0
+#include <asm/gpio.h>
+#endif
  #include <asm/u-boot.h>
  #include <nand.h>
  #include <fat.h>
@@ -739,6 +742,10 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
                 }
         }
 
Quoted 4 lines

common/spl/spl.c void board_init_r(gd_t *dummy1, ulong dummy2) · line 747

Quoted 3 lines
common/spl/spl.c +3 -0
+#if defined(CONFIG_SPL_GPIO_HOG)
+       gpio_hog_probe_all();
+#endif

if (CONFIG_IS_ENABLED(GPIO_HOG))

Ack.

Quoted 14 lines

...

Quoted 12 lines
common/spl/spl.c +1 -0
+
  #if CONFIG_IS_ENABLED(BOARD_INIT)
         spl_board_init();
  #endif
drivers/gpio/Kconfig +0 -0
index 305a2dc563..4da2bdc10d 100644
@@ -57,6 +57,16 @@ config GPIO_HOG
           is a mechanism providing automatic GPIO request and config-
           uration as part of the gpio-controller's driver probe function.
 
Quoted 4 lines

drivers/gpio/Kconfig config GPIO_HOG · line 62

Quoted 3 lines
drivers/gpio/Kconfig +3 -0
+config SPL_GPIO_HOG
+       bool "Enable GPIO hog support in SPL"
+       depends on SPL_GPIO_SUPPORT

Should it depend on GPIO_HOG? I'm not sure, just a question

No, this way the gpio hog support can be configured for either SPL or U-Boot or both. They are the same option just in the different builds.

Thanks for the review,

Eddie

Quoted 50 lines
Quoted 50 lines
drivers/gpio/Kconfig +7 -0
+       default n
+       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
drivers/gpio/gpio-uclass.c +6 -5
index 125ae53d61..bebba620c9 100644
@@ -1432,9 +1432,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;
@@ -1465,7 +1462,11 @@ 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);
@@ -1480,6 +1481,7 @@ static int gpio_post_bind(struct udevice *dev)
                         }
                 }
         }
+#endif
         return 0;
  }
 
--

2.27.0