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: k3: am625: fixup Linux device tree
Date: Wed, 29 Jan 2025 16:31:19 +0100	[thread overview]
Message-ID: <20250129153119.3455028-1-s.hauer@pengutronix.de> (raw)

The AM625 comes in variants without GPU, without PRU and with less than
4 cores. Disable the features we do not have in the Linux device tree.
The code is based on the corresponding U-Boot code.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/mach-k3/common.c | 50 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c
index 766c6529bd..9ca41ac89d 100644
--- a/arch/arm/mach-k3/common.c
+++ b/arch/arm/mach-k3/common.c
@@ -5,6 +5,7 @@
 #include <init.h>
 #include <envfs.h>
 #include <fs.h>
+#include <stdio.h>
 #include <xfuncs.h>
 #include <malloc.h>
 #include <pm_domain.h>
@@ -161,6 +162,53 @@ void am625_get_bootsource(enum bootsource *src, int *instance)
 	k3_get_bootsource(devstat, src, instance);
 }
 
+static void of_delete_node_path(struct device_node *root, const char *path)
+{
+	struct device_node *np;
+
+	np = of_find_node_by_path_from(root, path);
+	of_delete_node(np);
+}
+
+#define CTRLMMR_WKUP_JTAG_DEVICE_ID	(AM625_WKUP_CTRL_MMR0_BASE + 0x18)
+
+#define JTAG_DEV_CORE_NR		GENMASK(21, 19)
+#define JTAG_DEV_GPU			BIT(18)
+#define JTAG_DEV_FEATURES		GENMASK(17, 13)
+#define JTAG_DEV_FEATURE_NO_PRU		0x4
+
+static int am625_of_fixup(struct device_node *root, void *unused)
+{
+	u32 full_devid = readl(CTRLMMR_WKUP_JTAG_DEVICE_ID);
+	u32 feature_mask = FIELD_GET(JTAG_DEV_FEATURES, full_devid);
+	int num_cores = FIELD_GET(JTAG_DEV_CORE_NR, full_devid);
+	bool has_gpu = full_devid & JTAG_DEV_GPU;
+	bool has_pru = !(feature_mask & JTAG_DEV_FEATURE_NO_PRU);
+	char path[32];
+	int i;
+
+        for (i = num_cores; i < 4; i++) {
+		snprintf(path, sizeof(path), "/cpus/cpu@%d", i);
+		of_delete_node_path(root, path);
+
+		snprintf(path, sizeof(path), "/cpus/cpu-map/cluster0/core%d", i);
+		of_delete_node_path(root, path);
+
+		snprintf(path, sizeof(path), "/bus@f0000/watchdog@e0%d0000", i);
+		of_delete_node_path(root, path);
+	}
+
+        if (!has_gpu) {
+		of_delete_node_path(root, "/bus@f0000/gpu@fd00000");
+		of_delete_node_path(root, "/bus@f0000/watchdog@e0f0000");
+	}
+
+	if (!has_pru)
+		of_delete_node_path(root, "/bus@f0000/pruss@30040000");
+
+	return 0;
+}
+
 static int am625_init(void)
 {
 	enum bootsource src = BOOTSOURCE_UNKNOWN;
@@ -181,6 +229,8 @@ static int am625_init(void)
 
 	genpd_activate();
 
+	of_register_fixup(am625_of_fixup, NULL);
+
 	return 0;
 }
 postcore_initcall(am625_init);
-- 
2.39.5




             reply	other threads:[~2025-01-29 15:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-29 15:31 Sascha Hauer [this message]
2025-01-31 13:20 ` 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=20250129153119.3455028-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