[PATCH master 2/3] ARM: rpi: look up emmc2bus by alias for dma-ranges fixup

Ahmad Fatoum a.fatoum at pengutronix.de
Thu Oct 15 01:48:30 PDT 2026


From: Ahmad Fatoum <a.fatoum at 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 at 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 at 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 at 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 at 0", "reg");
 	register_vc_property_fixup(root, "/reserved-memory/nvram at 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




More information about the barebox mailing list