[PATCH] gpio: uclass: Introduce gpio-hog-optional property

Nate Drude nate.d at variscite.com
Mon Sep 12 19:55:13 CEST 2022


gpio_hog_probe_all is invoked by init_sequence_r in board_r.c.
If device_probe fails for any gpio-hog, boot hangs with the following error:

> initcall sequence 00000000fffc8e18 failed at call 000000004023b320 (err=-121)
> ### ERROR ### Please RESET the board ###

gpio-hog-optional allows the boot sequence to continue if device_probe
fails for optional gpio-hog(s).

Signed-off-by: Nate Drude <nate.d at variscite.com>
---
 doc/device-tree-bindings/gpio/gpio.txt | 1 +
 drivers/gpio/gpio-uclass.c             | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/doc/device-tree-bindings/gpio/gpio.txt b/doc/device-tree-bindings/gpio/gpio.txt
index 1481ed607d..02d296316b 100644
--- a/doc/device-tree-bindings/gpio/gpio.txt
+++ b/doc/device-tree-bindings/gpio/gpio.txt
@@ -189,6 +189,7 @@ gpio-controller's driver probe function.
 Each GPIO hog definition is represented as a child node of the GPIO controller.
 Required properties:
 - gpio-hog:   A property specifying that this child node represents a GPIO hog.
+- gpio-hog-optional: A property specifying to continue boot when device_probe fails in gpio_hog_probe_all
 - gpios:      Store the GPIO information (id, flags, ...) for each GPIO to
 	      affect. Shall contain an integer multiple of the number of cells
 	      specified in its parent node (GPIO controller node).
diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
index 0ed32b7217..7ef9f4abc8 100644
--- a/drivers/gpio/gpio-uclass.c
+++ b/drivers/gpio/gpio-uclass.c
@@ -329,7 +329,9 @@ int gpio_hog_probe_all(void)
 			if (ret) {
 				printf("Failed to probe device %s err: %d\n",
 				       dev->name, ret);
-				retval = ret;
+				if (!dev_read_bool(dev, "gpio-hog-optional")) {
+					retval = ret;
+				}
 			}
 		}
 	}
-- 
2.37.3



More information about the U-Boot mailing list