[RFC PATCH 1/2] rpi5: initial support

Dmitry Malkin dmitry at bedrocksystems.com
Sat Nov 18 17:41:43 CET 2023


rpi5: add alternative way to get MBOX address via FDT node

MBOX on RPI5/bcm2712 has a different offset. Find it via the
"brcm,bcm2835-mbox" node.
---
 arch/arm/mach-bcm283x/include/mach/base.h | 1 +
 arch/arm/mach-bcm283x/include/mach/mbox.h | 4 ++--
 arch/arm/mach-bcm283x/init.c              | 8 +++++++-
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-bcm283x/include/mach/base.h
b/arch/arm/mach-bcm283x/include/mach/base.h
index 4ccaf69693..8cd224921e 100644
--- a/arch/arm/mach-bcm283x/include/mach/base.h
+++ b/arch/arm/mach-bcm283x/include/mach/base.h
@@ -7,6 +7,7 @@
 #define _BCM283x_BASE_H_

 extern unsigned long rpi_bcm283x_base;
+extern unsigned long rpi_bcm283x_mbox_addr;

 #ifdef CONFIG_ARMV7_LPAE
 #ifdef CONFIG_TARGET_RPI_4_32B
diff --git a/arch/arm/mach-bcm283x/include/mach/mbox.h
b/arch/arm/mach-bcm283x/include/mach/mbox.h
index 490664f878..ad086be467 100644
--- a/arch/arm/mach-bcm283x/include/mach/mbox.h
+++ b/arch/arm/mach-bcm283x/include/mach/mbox.h
@@ -38,8 +38,8 @@

 /* Raw mailbox HW */

-#define BCM2835_MBOX_PHYSADDR ({ BUG_ON(!rpi_bcm283x_base); \
-                 rpi_bcm283x_base + 0x0000b880; })
+#define BCM2835_MBOX_PHYSADDR ({ BUG_ON(!rpi_bcm283x_mbox_addr); \
+                 rpi_bcm283x_mbox_addr; })

 struct bcm2835_mbox_regs {
     u32 read;
diff --git a/arch/arm/mach-bcm283x/init.c b/arch/arm/mach-bcm283x/init.c
index 7265faf6ce..d76c8e5eb2 100644
--- a/arch/arm/mach-bcm283x/init.c
+++ b/arch/arm/mach-bcm283x/init.c
@@ -116,6 +116,7 @@ static void rpi_update_mem_map(void) {}
 #endif

 unsigned long rpi_bcm283x_base = 0x3f000000;
+unsigned long rpi_bcm283x_mbox_addr;

 int arch_cpu_init(void)
 {
@@ -126,7 +127,7 @@ int arch_cpu_init(void)

 int mach_cpu_init(void)
 {
-    int ret, soc_offset;
+    int ret, soc_offset, mbox_offset;
     u64 io_base, size;

     rpi_update_mem_map();
@@ -142,6 +143,11 @@ int mach_cpu_init(void)
         return ret;

     rpi_bcm283x_base = io_base;
+    rpi_bcm283x_mbox_addr = rpi_bcm283x_base + 0xb880;
+
+    mbox_offset = fdt_node_offset_by_compatible((void*)gd->fdt_blob,
soc_offset, "brcm,bcm2835-mbox");
+    if (mbox_offset > 0)
+        rpi_bcm283x_mbox_addr =
fdt_get_base_address((void*)gd->fdt_blob, mbox_offset);

     return 0;
 }
-- 
2.40.1


More information about the U-Boot mailing list