mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH master 2/3] ARM: rpi: look up emmc2bus by alias for dma-ranges fixup
Date: Thu, 15 Oct 2026 10:48:30 +0200	[thread overview]
Message-ID: <20261015084833.4090522-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20261015084833.4090522-1-a.fatoum@pengutronix.de>

From: Ahmad Fatoum <a.fatoum@barebox.org>

The VideoCore firmware patches the dma-ranges of the eMMC2 bus to match
the BCM2711 stepping (B0 vs. C0). It finds the node via the emmc2bus
alias. Commit 3f9788433919 ("raspi: add a fixup for the `dma-ranges`
property of the `/emmc2bus` dt node") propagates that value into the
DT passed to the OS, but it looks the node up by the hardcoded path
/emmc2bus in the VideoCore DT and then creates/overwrites the node at
the same path in the DT being fixed up.

Linux commit 929dc5b3e06c ("ARM: dts: broadcom: bcm2711: Fix
'simple-bus' node names"), which came in with commit fe223ba39321
("dts: update to v7.0-rc1"), renamed /emmc2bus to /emmc2-bus@fe000000.
Since then, booting with barebox' internal DT and a firmware DT that
still uses the old name (any DT older than Linux v7.0) adds a stray
/emmc2bus node holding the dma-ranges, while the real bus keeps the
hardcoded B0 ranges.

Look up the node via the emmc2bus alias in both trees like the firmware
does, so the fixup works irrespective of the node name, and don't create
the node in the target DT if the alias is missing.

Fixes: 3f9788433919 ("raspi: add a fixup for the `dma-ranges` property of the `/emmc2bus` dt node")
Fixes: fe223ba39321 ("dts: update to v7.0-rc1")
Assisted-by: Claude:opus-5.5
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
 arch/arm/boards/raspberry-pi/rpi-common.c | 31 ++++++++++++++++++-----
 1 file changed, 24 insertions(+), 7 deletions(-)

diff --git a/arch/arm/boards/raspberry-pi/rpi-common.c b/arch/arm/boards/raspberry-pi/rpi-common.c
index fe0b11efad68..e0a4438d54e0 100644
--- a/arch/arm/boards/raspberry-pi/rpi-common.c
+++ b/arch/arm/boards/raspberry-pi/rpi-common.c
@@ -61,8 +61,9 @@ struct rpi_priv {
 };
 
 struct rpi_property_fixup_data {
-    const struct device_node* vc_node;
-    const char *propname;
+	const struct device_node* vc_node;
+	const char *propname;
+	const char *alias;
 };
 
 static void rpi_set_usbethaddr(void)
@@ -314,9 +315,23 @@ static int rpi_vc_fdt_fixup_property(struct device_node *root, void *data)
 	struct device_node *node;
 	struct property *prop;
 
-	node = of_create_node(root, fixup->vc_node->full_name);
-	if (!node)
-		return -ENOMEM;
+	if (fixup->alias) {
+		/*
+		 * The node name need not be the same in the VideoCore FDT
+		 * and in the DT we fix up (e.g. /emmc2bus was renamed to
+		 * /emmc2-bus@fe000000 in Linux v7.0), so look it up via
+		 * the alias like the firmware does and don't create it.
+		 */
+		node = of_find_node_by_alias(root, fixup->alias);
+		if (!node) {
+			pr_debug("no '%s' alias found in fdt\n", fixup->alias);
+			return 0;
+		}
+	} else {
+		node = of_create_node(root, fixup->vc_node->full_name);
+		if (!node)
+			return -ENOMEM;
+	}
 
 	prop = of_find_property(fixup->vc_node, fixup->propname, NULL);
 	if (!prop)
@@ -332,13 +347,15 @@ static int register_vc_property_fixup(struct device_node *root,
 	struct device_node *node, *tmp;
 	struct rpi_property_fixup_data* fixup_data;
 
-	node = of_find_node_by_path_from(root, path);
+	node = of_find_node_by_path_or_alias(root, path);
 	if (node) {
 		tmp = of_dup(node);
 		tmp->full_name = xstrdup(node->full_name);
 		fixup_data = xzalloc(sizeof(*fixup_data));
 		fixup_data->vc_node = tmp;
 		fixup_data->propname = xstrdup(propname);
+		if (*path != '/')
+			fixup_data->alias = xstrdup(path);
 
 		of_register_fixup(rpi_vc_fdt_fixup_property, fixup_data);
 	} else {
@@ -377,7 +394,7 @@ static void rpi_vc_fdt_parse(struct device_node *root)
 	register_vc_property_fixup(root, "/reserved-memory/nvram@0", "reg");
 	register_vc_property_fixup(root, "/reserved-memory/nvram@0", "status");
 	register_vc_fixup(root, "/hat");
-	register_vc_property_fixup(root, "/emmc2bus", "dma-ranges");
+	register_vc_property_fixup(root, "emmc2bus", "dma-ranges");
 	register_vc_fixup(root, "/chosen/bootloader");
 	chosen = register_vc_fixup(root, "/chosen");
 	if (!chosen) {
-- 
2.47.3




  reply	other threads:[~2026-10-15  8:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-15  8:48 [PATCH master 1/3] ARM: rockchip: rk3568-qnap-ts433eu: re-enable combphy0, disable sata2 Ahmad Fatoum
2026-10-15  8:48 ` Ahmad Fatoum [this message]
2026-10-15  8:48 ` [PATCH master 3/3] of: base: use default bus match table when populating /firmware Ahmad Fatoum
2026-10-15 11:36 ` [PATCH master 1/3] ARM: rockchip: rk3568-qnap-ts433eu: re-enable combphy0, disable sata2 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=20261015084833.4090522-2-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=a.fatoum@barebox.org \
    --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