summaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-bcm283x
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2022-06-09 07:59:05 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2022-06-17 08:28:55 +0200
commitda06dbb18d57b6f77beab5ea41423a639b4384f5 (patch)
treec1af4a65ab97ed495b5156bc7fbd0dd28e20315c /arch/arm/mach-bcm283x
parent47740c32087930089fc9e0a07fd254676780554a (diff)
downloadbarebox-da06dbb18d57b6f77beab5ea41423a639b4384f5.tar.gz
barebox-da06dbb18d57b6f77beab5ea41423a639b4384f5.tar.xz
ARM: rpi: support PBL use of mbox
barebox uses DT to find out the base address of the mailbox. For the generic image, we need to use the mailbox interface to find out which DT to use. Resolve the chicken-egg problem by hardcoding a list of mailbox base addresses and selecting the correct one by looking up the CPU ID and using that to deduce the Raspberry Pi SoC type. Note that this is incompatible with arm_peri_high=1. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220609055922.667016-5-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/mach-bcm283x')
-rw-r--r--arch/arm/mach-bcm283x/Makefile2
-rw-r--r--arch/arm/mach-bcm283x/core.c29
-rw-r--r--arch/arm/mach-bcm283x/include/mach/core.h2
-rw-r--r--arch/arm/mach-bcm283x/mbox.c24
4 files changed, 48 insertions, 9 deletions
diff --git a/arch/arm/mach-bcm283x/Makefile b/arch/arm/mach-bcm283x/Makefile
index d681764413..53343cec8c 100644
--- a/arch/arm/mach-bcm283x/Makefile
+++ b/arch/arm/mach-bcm283x/Makefile
@@ -1,3 +1,3 @@
# SPDX-License-Identifier: GPL-2.0-only
-obj-y += mbox.o
+obj-pbl-y += mbox.o core.o
diff --git a/arch/arm/mach-bcm283x/core.c b/arch/arm/mach-bcm283x/core.c
new file mode 100644
index 0000000000..40882fb6d6
--- /dev/null
+++ b/arch/arm/mach-bcm283x/core.c
@@ -0,0 +1,29 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include <linux/types.h>
+#include <mach/core.h>
+#include <asm/system_info.h>
+
+void __iomem *bcm2835_get_mmio_base_by_cpuid(void)
+{
+ static u32 cpuid;
+
+ if (!cpuid) {
+ cpuid = read_cpuid_id();
+ pr_debug("ARM CPUID: %08x\n", cpuid);
+ }
+
+ /* We know ARM1167, Cortex A-7, A-53 and A-72 CPUID mask is identical */
+ switch(cpuid & CPU_IS_ARM1176_MASK) {
+ case CPU_IS_ARM1176: /* bcm2835 */
+ return IOMEM(0x20000000);
+ case CPU_IS_CORTEX_A7: /* bcm2836 */
+ case CPU_IS_CORTEX_A53: /* bcm2837 */
+ return IOMEM(0x3f000000);
+ case CPU_IS_CORTEX_A72: /* bcm2711 */
+ return IOMEM(0xfe000000);
+ }
+
+ pr_err("Couldn't determine rpi by CPUID %08x\n", cpuid);
+ return NULL;
+}
diff --git a/arch/arm/mach-bcm283x/include/mach/core.h b/arch/arm/mach-bcm283x/include/mach/core.h
index bd272b925d..c8547351a3 100644
--- a/arch/arm/mach-bcm283x/include/mach/core.h
+++ b/arch/arm/mach-bcm283x/include/mach/core.h
@@ -22,4 +22,6 @@ static void inline bcm2835_register_fb(void)
add_generic_device("bcm2835_fb", 0, NULL, 0, 0, 0, NULL);
}
+void __iomem *bcm2835_get_mmio_base_by_cpuid(void);
+
#endif
diff --git a/arch/arm/mach-bcm283x/mbox.c b/arch/arm/mach-bcm283x/mbox.c
index 4b14afcfe4..b77065ab30 100644
--- a/arch/arm/mach-bcm283x/mbox.c
+++ b/arch/arm/mach-bcm283x/mbox.c
@@ -14,13 +14,20 @@
#include <init.h>
#include <io.h>
#include <of_address.h>
+#include <pbl.h>
#include <mach/mbox.h>
+#include <mach/core.h>
#define TIMEOUT (MSECOND * 1000)
static void __iomem *mbox_base;
+#ifdef __PBL__
+#define is_timeout_non_interruptible(start, timeout) ((void)start, 0)
+#define get_time_ns() 0
+#endif
+
static int bcm2835_mbox_call_raw(u32 chan, struct bcm2835_mbox_hdr *buffer,
u32 *recv)
{
@@ -109,19 +116,20 @@ static void dump_buf(struct bcm2835_mbox_hdr *buffer)
}
#endif
-static int bcm2835_mbox_probe(void)
+static void __iomem *bcm2835_mbox_probe(void)
{
struct device_node *mbox_node;
+ if (IN_PBL)
+ return bcm2835_get_mmio_base_by_cpuid() + 0xb880;
+
mbox_node = of_find_compatible_node(NULL, NULL, "brcm,bcm2835-mbox");
if (!mbox_node) {
pr_err("Missing mbox node\n");
- return -ENOENT;
+ return NULL;
}
- mbox_base = of_iomap(mbox_node, 0);
-
- return 0;
+ return of_iomap(mbox_node, 0);
}
int bcm2835_mbox_call_prop(u32 chan, struct bcm2835_mbox_hdr *buffer)
@@ -132,9 +140,9 @@ int bcm2835_mbox_call_prop(u32 chan, struct bcm2835_mbox_hdr *buffer)
int tag_index;
if (!mbox_base) {
- ret = bcm2835_mbox_probe();
- if (ret)
- return ret;
+ mbox_base = bcm2835_mbox_probe();
+ if (!mbox_base)
+ return -ENOENT;
}
pr_debug("mbox: TX buffer\n");