]> git.baikalelectronics.ru Git - uboot.git/commitdiff
gpio: Get rid of gpio_hog_probe_all()
authorMarek Vasut <marex@denx.de>
Thu, 22 Sep 2022 15:53:26 +0000 (17:53 +0200)
committerTom Rini <trini@konsulko.com>
Thu, 12 Jan 2023 19:06:16 +0000 (14:06 -0500)
The gpio_hog_probe_all() functionality can be perfectly well replaced by
DM_FLAG_PROBE_AFTER_BIND DM flag, which would trigger .probe() callback
of each GPIO hog driver instance after .bind() and thus configure the
hogged GPIO accordingly.

Signed-off-by: Marek Vasut <marex@denx.de>
Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Reviewed-by: Samuel Holland <samuel@sholland.org>
common/board_r.c
common/spl/spl.c
doc/README.gpio
drivers/gpio/gpio-uclass.c
include/asm-generic/gpio.h

index 42060ee709d54be910d89327d0c66206dccc38e0..3618acad437447e466458a3d2367c138f0458bae 100644 (file)
@@ -756,9 +756,6 @@ static init_fnc_t init_sequence_r[] = {
        initr_status_led,
 #endif
        /* PPC has a udelay(20) here dating from 2002. Why? */
-#if defined(CONFIG_GPIO_HOG)
-       gpio_hog_probe_all,
-#endif
 #ifdef CONFIG_BOARD_LATE_INIT
        board_late_init,
 #endif
index 4668367b680f4cdae0acfb7aab5b31d27bb9e857..a630e798661fd2bde93acfa3af0f554f7bb273a8 100644 (file)
@@ -786,9 +786,6 @@ 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 548ff37b8cc719211b6a8e4732c22bff3b2fdbdf..d253f654fadd16810b78503f23e913a4b1a9d019 100644 (file)
@@ -2,10 +2,8 @@
 GPIO hog (CONFIG_GPIO_HOG)
 --------
 
-All the GPIO hog are initialized in gpio_hog_probe_all() function called in
-board_r.c just before board_late_init() but you can also acces directly to
-the gpio with gpio_hog_lookup_name().
-
+All the GPIO hog are initialized using DM_FLAG_PROBE_AFTER_BIND DM flag
+after bind().
 
 Example, for the device tree:
 
index 3a6ef3b01d530688b1b6dfda14dcfaff5715bb1f..dbebf3a53eb6747949a51c5ca1b63fab7b215be8 100644 (file)
@@ -311,34 +311,11 @@ static int gpio_hog_probe(struct udevice *dev)
        return 0;
 }
 
-int gpio_hog_probe_all(void)
-{
-       struct udevice *dev;
-       int ret;
-       int retval = 0;
-
-       for (uclass_first_device(UCLASS_NOP, &dev);
-            dev;
-            uclass_find_next_device(&dev)) {
-               if (dev->driver == DM_DRIVER_GET(gpio_hog)) {
-                       ret = device_probe(dev);
-                       if (ret) {
-                               printf("Failed to probe device %s err: %d\n",
-                                      dev->name, ret);
-                               retval = ret;
-                       }
-               }
-       }
-
-       return retval;
-}
-
 int gpio_hog_lookup_name(const char *name, struct gpio_desc **desc)
 {
        struct udevice *dev;
 
        *desc = NULL;
-       gpio_hog_probe_all();
        if (!uclass_get_device_by_name(UCLASS_NOP, name, &dev)) {
                struct gpio_hog_priv *priv = dev_get_priv(dev);
 
@@ -1505,9 +1482,17 @@ static int gpio_post_bind(struct udevice *dev)
                                                                 &child);
                                if (ret)
                                        return ret;
+
+                               /*
+                                * Make sure gpio-hogs are probed after bind
+                                * since hogs can be essential to the hardware
+                                * system.
+                                */
+                               dev_or_flags(child, DM_FLAG_PROBE_AFTER_BIND);
                        }
                }
        }
+
        return 0;
 }
 
index 0fcf70983fb861770917600048bdefac1f574d62..dd0bdf2315e8c1b0439a474632cce7db90096ca2 100644 (file)
@@ -461,14 +461,6 @@ int dm_gpio_lookup_name(const char *name, struct gpio_desc *desc);
  */
 int gpio_hog_lookup_name(const char *name, struct gpio_desc **desc);
 
-/**
- * gpio_hog_probe_all() - probe all gpio devices with
- * gpio-hog subnodes.
- *
- * @return:    Returns return value from device_probe()
- */
-int gpio_hog_probe_all(void);
-
 /**
  * gpio_lookup_name - Look up a GPIO name and return its details
  *