[PATCH v2 2/3] rpi5: initial support

Dmitry Malkin dmitry at bedrocksystems.com
Tue Nov 21 23:54:37 CET 2023


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

MBOX on RPI5/bcm2712 has a different offset. Find it via
"brcm,bcm2835-mbox" node.

Signed-off-by: Dmitry Malkin <dmitry at bedrocksystems.com>
---
v2:
      new patch
---
 arch/arm/mach-bcm283x/include/mach/base.h |  1 +
 arch/arm/mach-bcm283x/include/mach/mbox.h |  4 ++--
 arch/arm/mach-bcm283x/init.c              | 12 +++++++++++-
 3 files changed, 14 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 362838e9b9..aef3a31f29 100644
--- a/arch/arm/mach-bcm283x/init.c
+++ b/arch/arm/mach-bcm283x/init.c
@@ -145,6 +145,11 @@ static void rpi_update_mem_map(void) {}

 unsigned long rpi_bcm283x_base = 0x3f000000;

+/* This is intialized before relocation. Enforce .data section usage.
+ * Otherwise it's going to .bss and will be zero after relocation.
+ */
+unsigned long __section(".data") rpi_bcm283x_mbox_addr;
+
 int arch_cpu_init(void)
 {
     icache_enable();
@@ -154,7 +159,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();
@@ -170,6 +175,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 > soc_offset)
+        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