mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] ARM: psci-client: better search for existing psci node
@ 2024-12-09 10:30 Sascha Hauer
  2024-12-20  9:22 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Sascha Hauer @ 2024-12-09 10:30 UTC (permalink / raw)
  To: Barebox List

The PSCI fixup code assumes the psci node is at /psci. This is not the
case for all boards. TI AM62x upstream dtsi files have the psci node at
/firmware/psci where the current code doesn't find it and creates a new
node, so on this SoC we end up with two PSCI nodes.

Fix this by searching for a node compatible to "arm,psci-0.2" or
"arm,psci-1.0" instead of assuming a fixed location.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/cpu/psci-of.c | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/arch/arm/cpu/psci-of.c b/arch/arm/cpu/psci-of.c
index 1b6371ddd6..7c74860146 100644
--- a/arch/arm/cpu/psci-of.c
+++ b/arch/arm/cpu/psci-of.c
@@ -7,6 +7,24 @@
 #include <asm/psci.h>
 #include <linux/arm-smccc.h>
 
+static struct device_node *find_or_create_psci_node(struct device_node *root)
+{
+	struct device_node *psci;
+	const char *compat[] = {
+		"arm,psci-0.2",
+		"arm,psci-1.0"
+	};
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(compat); i++) {
+		psci = of_find_compatible_node(root, NULL, compat[i]);
+		if (psci)
+			return psci;
+	}
+
+	return of_create_node(root, "/psci");
+}
+
 int of_psci_fixup(struct device_node *root, unsigned long psci_version,
 		  const char *method)
 {
@@ -15,10 +33,6 @@ int of_psci_fixup(struct device_node *root, unsigned long psci_version,
 	const char *compat;
 	struct device_node *cpus, *cpu;
 
-	psci = of_create_node(root, "/psci");
-	if (!psci)
-		return -EINVAL;
-
 	if (psci_version >= ARM_PSCI_VER_1_0) {
 		compat = "arm,psci-1.0";
 	} else if (psci_version >= ARM_PSCI_VER_0_2) {
@@ -28,6 +42,10 @@ int of_psci_fixup(struct device_node *root, unsigned long psci_version,
 		return -EINVAL;
 	}
 
+	psci = find_or_create_psci_node(root);
+	if (!psci)
+		return -EINVAL;
+
 	cpus = of_find_node_by_path_from(root, "/cpus");
 	if (!cpus) {
 		pr_err("Cannot find /cpus node, PSCI fixup aborting\n");
-- 
2.39.5




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] ARM: psci-client: better search for existing psci node
  2024-12-09 10:30 [PATCH] ARM: psci-client: better search for existing psci node Sascha Hauer
@ 2024-12-20  9:22 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2024-12-20  9:22 UTC (permalink / raw)
  To: Barebox List, Sascha Hauer


On Mon, 09 Dec 2024 11:30:25 +0100, Sascha Hauer wrote:
> The PSCI fixup code assumes the psci node is at /psci. This is not the
> case for all boards. TI AM62x upstream dtsi files have the psci node at
> /firmware/psci where the current code doesn't find it and creates a new
> node, so on this SoC we end up with two PSCI nodes.
> 
> Fix this by searching for a node compatible to "arm,psci-0.2" or
> "arm,psci-1.0" instead of assuming a fixed location.
> 
> [...]

Applied, thanks!

[1/1] ARM: psci-client: better search for existing psci node
      https://git.pengutronix.de/cgit/barebox/commit/?id=cf7bdbf85bf8 (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-12-20  9:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-09 10:30 [PATCH] ARM: psci-client: better search for existing psci node Sascha Hauer
2024-12-20  9:22 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox