Skip to contentSkip to conversation

pinctrl: Check pinconfig nodes pre-reloc status recursively

PATCH In review Jonas Karlman 3 participants 3 messages Feb 17, 2024 – Mar 4, 2024 Pin control

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 pinctrl: Check pinconfig nodes pre-reloc status recursively

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.

---
v2:
- No change

A recent change to fdtgrep was believed to solve this however, fdtgrep is only applied to control fdt for xPL so this issue still exist at U-Boot proper pre-reloc stage.

Link to v1: https://patchwork.ozlabs.org/patch/1817296/

---
 drivers/pinctrl/pinctrl-uclass.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
drivers/pinctrl/pinctrl-uclass.c +17 -1
index 73dd7b1038bb..fe2ba5021a78 100644
@@ -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
Signature · 1 line
2.43.0
Reviewed-by on v2 1/1
#1 lore raw

Hi Jonas,

Quoted 44 lines · Jonas Karlman

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.

---
v2:
- No change

A recent change to fdtgrep was believed to solve this however, fdtgrep is only applied to control fdt for xPL so this issue still exist at U-Boot proper pre-reloc stage.

Link to v1: https://patchwork.ozlabs.org/patch/1817296/

---
  drivers/pinctrl/pinctrl-uclass.c | 18 +++++++++++++++++-
  1 file changed, 17 insertions(+), 1 deletion(-)
drivers/pinctrl/pinctrl-uclass.c +0 -0
index 73dd7b1038bb..fe2ba5021a78 100644
@@ -100,6 +100,22 @@ static int pinctrl_select_state_full(struct udevice *dev, const char *statename)
  	return 0;

drivers/pinctrl/pinctrl-uclass.c static int pinctrl_select_state_full(struct udevice *dev, const char *statename) · line 110

Quoted 10 lines
drivers/pinctrl/pinctrl-uclass.c +8 -0
  }
 
+static bool ofnode_pre_reloc_recursive(ofnode parent)
+{
+	ofnode child;
+
+	if (ofnode_pre_reloc(parent))
+		return true;
+
+	if (CONFIG_IS_ENABLED(PINCONF_RECURSIVE)) {

You could move the ofnode child declaration here for limiting the scope.

I also got confused by "parent" name, as it isn't actually the parent we're looking at right now, but the node itself, so it was a bit misleading. I would have kept "node" and the "child" one is explicit enough.

In any case,

Thanks,
Quentin

#2 lore raw
In reply to Jonas Karlman
Quoted 18 lines · Jonas Karlman

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:

Quoted 7 lines

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.

Applied to u-boot/next, thanks!

Signature · 1 line
Tom