ARM: bcm283x: Set rpi_bcm283x_base at run-time
authorMatthias Brugger <mbrugger@suse.com>
Tue, 19 Nov 2019 15:01:04 +0000 (16:01 +0100)
committerMatthias Brugger <mbrugger@suse.com>
Sun, 24 Nov 2019 09:46:27 +0000 (10:46 +0100)
As part of the effort to create one binary for several bcm83x SoCs
we read the IO base address from device-tree.

Signed-off-by: Matthias Brugger <mbrugger@suse.com>
arch/arm/mach-bcm283x/Kconfig
arch/arm/mach-bcm283x/init.c

index b08275f5989e777dd29feb294f347c9aa2ac86a1..e8e0ff0eb4b3b7a1dcdea16daebbff2e37ab90c2 100644 (file)
@@ -202,10 +202,4 @@ config SYS_SOC
 config SYS_CONFIG_NAME
        default "rpi"
 
-config BCM283x_BASE
-       hex
-       default "0x20000000" if BCM2835
-       default "0x3f000000" if BCM2836 || BCM2837
-       default "0xfe000000" if BCM2711
-
 endmenu
index d36017e823bf0bfb2752c6f2c1b579025907ba72..b3f3dfabea8e76cc7ebae8a515b145e4455bbf49 100644 (file)
@@ -7,8 +7,10 @@
  */
 
 #include <common.h>
+#include <dm/device.h>
+#include <fdt_support.h>
 
-unsigned long rpi_bcm283x_base;
+unsigned long rpi_bcm283x_base = 0x3f000000;
 
 int arch_cpu_init(void)
 {
@@ -19,10 +21,24 @@ int arch_cpu_init(void)
 
 int mach_cpu_init(void)
 {
-       rpi_bcm283x_base = CONFIG_BCM283x_BASE;
+       int ret, soc_offset;
+       u64 io_base, size;
+
+       /* Get IO base from device tree */
+       soc_offset = fdt_path_offset(gd->fdt_blob, "/soc");
+       if (soc_offset < 0)
+               return soc_offset;
+
+       ret = fdt_read_range((void *)gd->fdt_blob, soc_offset, 0, NULL,
+                               &io_base, &size);
+       if (ret)
+               return ret;
+
+       rpi_bcm283x_base = io_base;
 
        return 0;
 }
+
 #ifdef CONFIG_ARMV7_LPAE
 void enable_caches(void)
 {