]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
pinctrl: Check pinconfig nodes pre-reloc status recursively
authorJonas Karlman <jonas@kwiboo.se>
Sat, 17 Feb 2024 12:08:40 +0000 (12:08 +0000)
committerTom Rini <trini@konsulko.com>
Mon, 4 Mar 2024 15:25:41 +0000 (10:25 -0500)
Pinconfig nodes normally bind recursively with PINCTRL_FULL and
PINCONF_RECURSIVE enabled. However, during U-Boot proper pre-relocation
any node marked with e.g. bootph-all will not bind unless its parent is
also marked for pre-reloc.

  group1 {
      pinconf1 {
          bootph-all;
      };
  };

This cause the following warning message to be shown during U-Boot
proper pre-reloc stage on Rockchip devices, e.g on RK3568:

  ns16550_serial serial@fe660000: pinctrl_select_state_full: uclass_get_device_by_phandle_id: err=-19

and on RK3328:

  ns16550_serial serial@ff130000: pinctrl_select_state_full: uclass_get_device_by_phandle_id: err=-19

Check pinconfig nodes pre-reloc status recursively to fix this and to
make pinconfig_post_bind work same at both U-Boot proper pre-reloc and
at TPL/SPL stage.

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Reviewed-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>
drivers/pinctrl/pinctrl-uclass.c

index 73dd7b1038bb21067d2b7c5cfcd1c82f9b118e10..fe2ba5021a786cc901e21b2454e3a6612243da48 100644 (file)
@@ -100,6 +100,22 @@ static int pinctrl_select_state_full(struct udevice *dev, const char *statename)
        return 0;
 }
 
+static bool ofnode_pre_reloc_recursive(ofnode parent)
+{
+       ofnode child;
+
+       if (ofnode_pre_reloc(parent))
+               return true;
+
+       if (CONFIG_IS_ENABLED(PINCONF_RECURSIVE)) {
+               ofnode_for_each_subnode(child, parent)
+                       if (ofnode_pre_reloc_recursive(child))
+                               return true;
+       }
+
+       return false;
+}
+
 /**
  * pinconfig_post_bind() - post binding for PINCONFIG uclass
  * Recursively bind its children as pinconfig devices.
@@ -119,7 +135,7 @@ static int pinconfig_post_bind(struct udevice *dev)
 
        dev_for_each_subnode(node, dev) {
                if (pre_reloc_only &&
-                   !ofnode_pre_reloc(node))
+                   !ofnode_pre_reloc_recursive(node))
                        continue;
                /*
                 * If this node has "compatible" property, this is not