mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH] ARM: psci-client: better search for existing psci node
Date: Mon,  9 Dec 2024 11:30:25 +0100	[thread overview]
Message-ID: <20241209103025.359093-1-s.hauer@pengutronix.de> (raw)

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




             reply	other threads:[~2024-12-09 10:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-09 10:30 Sascha Hauer [this message]
2024-12-20  9:22 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241209103025.359093-1-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox