summaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-bcm283x
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2022-06-29 09:01:05 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2022-06-29 09:01:05 +0200
commitcc9b06f0c8f11c56fc706614ff96d237eecefd45 (patch)
tree2d7505353c924ff2e526f311582b4eaabaa5d840 /arch/arm/mach-bcm283x
parent97afea15a9f2f09c3009ad6e94ca9b40cc95b33a (diff)
parent6f4f30b9c1fbd20ebf1b05843cf344fa2bb35f65 (diff)
downloadbarebox-cc9b06f0c8f11c56fc706614ff96d237eecefd45.tar.gz
barebox-cc9b06f0c8f11c56fc706614ff96d237eecefd45.tar.xz
Merge branch 'for-next/rpi4'
Diffstat (limited to 'arch/arm/mach-bcm283x')
-rw-r--r--arch/arm/mach-bcm283x/Kconfig29
-rw-r--r--arch/arm/mach-bcm283x/Makefile2
-rw-r--r--arch/arm/mach-bcm283x/core.c57
-rw-r--r--arch/arm/mach-bcm283x/include/mach/core.h23
-rw-r--r--arch/arm/mach-bcm283x/include/mach/debug_ll.h26
-rw-r--r--arch/arm/mach-bcm283x/include/mach/mbox.h4
-rw-r--r--arch/arm/mach-bcm283x/include/mach/platform.h5
-rw-r--r--arch/arm/mach-bcm283x/mbox.c26
8 files changed, 110 insertions, 62 deletions
diff --git a/arch/arm/mach-bcm283x/Kconfig b/arch/arm/mach-bcm283x/Kconfig
index 75acee8dad..48209fb5c6 100644
--- a/arch/arm/mach-bcm283x/Kconfig
+++ b/arch/arm/mach-bcm283x/Kconfig
@@ -8,30 +8,51 @@ config ARCH_TEXT_BASE
config MACH_RPI_COMMON
bool
+ select ARM_USE_COMPRESSED_DTB
+
+config MACH_RPI_AARCH_32_64
+ select MACH_RPI_COMMON
+ select CPU_V7 if 32BIT
+ select ARM_SECURE_MONITOR if 32BIT
+ select CPU_V8 if 64BIT
+ select BOARD_ARM_GENERIC_DT if 64BIT
+ bool
+ help
+ Select this from CPUs that support both AArch32 and AArch64
+ execution modes. barebox can be compiled for only one of
+ these states, depending on the value of
+ CONFIG_32BIT/CONFIG_64BIT.
menu "select Broadcom BCM283X boards to be built"
config MACH_RPI
bool "RaspberryPi (BCM2835/ARM1176JZF-S)"
+ depends on 32BIT
select CPU_V6
select MACH_RPI_COMMON
config MACH_RPI2
bool "RaspberryPi 2 (BCM2836/CORTEX-A7)"
+ depends on 32BIT
select CPU_V7
select MACH_RPI_COMMON
config MACH_RPI3
bool "RaspberryPi 3 (BCM2837/CORTEX-A53)"
- select CPU_V7
+ select MACH_RPI_AARCH_32_64
select MACH_RPI_COMMON
- select ARM_SECURE_MONITOR
+ depends on 32BIT || (64BIT && !MMU_EARLY)
config MACH_RPI_CM3
bool "RaspberryPi Compute Module 3 (BCM2837/CORTEX-A53)"
- select CPU_V7
+ select MACH_RPI_AARCH_32_64
+ select MACH_RPI_COMMON
+ depends on 32BIT || (64BIT && !MMU_EARLY)
+
+config MACH_RPI4
+ bool "RaspberryPi 4 (BCM2711/CORTEX-A72)"
+ select MACH_RPI_AARCH_32_64
select MACH_RPI_COMMON
- select ARM_SECURE_MONITOR
endmenu
diff --git a/arch/arm/mach-bcm283x/Makefile b/arch/arm/mach-bcm283x/Makefile
index e5ef78af97..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 += core.o 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
index f2528cf1f1..40882fb6d6 100644
--- a/arch/arm/mach-bcm283x/core.c
+++ b/arch/arm/mach-bcm283x/core.c
@@ -1,40 +1,29 @@
-/*
- * Author: Carlo Caione <carlo@carlocaione.org>
- *
- * Based on mach-nomadik
- * Copyright (C) 2009 Jean-Christophe PLAGNIOL-VILLARD <plagnio@jcrosoft.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- */
+// SPDX-License-Identifier: GPL-2.0-only
-#include <common.h>
-#include <init.h>
-
-#include <linux/clk.h>
-#include <linux/clkdev.h>
-#include <linux/err.h>
-
-#include <io.h>
-#include <asm/armlinux.h>
-#include <linux/sizes.h>
-
-#include <mach/platform.h>
+#include <linux/types.h>
#include <mach/core.h>
-#include <linux/amba/bus.h>
+#include <asm/system_info.h>
-void bcm2835_add_device_sdram(u32 size)
+void __iomem *bcm2835_get_mmio_base_by_cpuid(void)
{
- if (!size)
- size = get_ram_size((ulong *) BCM2835_SDRAM_BASE, SZ_128M);
+ 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);
+ }
- arm_add_mem_device("ram0", BCM2835_SDRAM_BASE, size);
+ 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 a1c47f9154..c8547351a3 100644
--- a/arch/arm/mach-bcm283x/include/mach/core.h
+++ b/arch/arm/mach-bcm283x/include/mach/core.h
@@ -1,28 +1,27 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (C) 2009 Carlo Caione <carlo@carlocaione.org>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
*/
#ifndef __BCM2835_CORE_H__
#define __BCM2835_CORE_H__
+#include <common.h>
+#include <linux/types.h>
+#include <linux/sizes.h>
+#include <asm/memory.h>
#include <mach/platform.h>
-void bcm2835_add_device_sdram(u32 size);
+static void inline bcm2835_add_device_sdram(u32 size)
+{
+ arm_add_mem_device("ram0", BCM2835_SDRAM_BASE, size);
+}
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/include/mach/debug_ll.h b/arch/arm/mach-bcm283x/include/mach/debug_ll.h
index 4bfa5abc7c..fdb63b4f5a 100644
--- a/arch/arm/mach-bcm283x/include/mach/debug_ll.h
+++ b/arch/arm/mach-bcm283x/include/mach/debug_ll.h
@@ -18,6 +18,7 @@
#define __MACH_BCM2835_DEBUG_LL_H__
#include <mach/platform.h>
+#include <io.h>
#ifdef CONFIG_DEBUG_RPI1_UART
@@ -66,6 +67,31 @@ static inline void debug_ll_init(void)
debug_ll_ns16550_init(divisor);
}
+#elif defined CONFIG_DEBUG_RPI4_MINI_UART
+
+static inline uint8_t debug_ll_read_reg(int reg)
+{
+ return readb(BCM2711_MINIUART_BASE + (reg << 2));
+}
+
+static inline void debug_ll_write_reg(int reg, uint8_t val)
+{
+ writeb(val, BCM2711_MINIUART_BASE + (reg << 2));
+}
+
+#include <debug_ll/ns16550.h>
+
+static inline void debug_ll_init(void)
+{
+ /* Configured by ROM */
+}
+
+#else
+
+static inline void debug_ll_init(void)
+{
+}
+
#endif
#endif /* __MACH_BCM2835_DEBUG_LL_H__ */
diff --git a/arch/arm/mach-bcm283x/include/mach/mbox.h b/arch/arm/mach-bcm283x/include/mach/mbox.h
index a9f06512bc..92cadba62c 100644
--- a/arch/arm/mach-bcm283x/include/mach/mbox.h
+++ b/arch/arm/mach-bcm283x/include/mach/mbox.h
@@ -171,7 +171,10 @@ struct bcm2835_mbox_tag_hdr {
#define BCM2837B0_BOARD_REV_3B_PLUS 0x0d
#define BCM2837B0_BOARD_REV_3A_PLUS 0x0e
#define BCM2837B0_BOARD_REV_CM3_PLUS 0x10
+#define BCM2711_BOARD_REV_4_B 0x11
#define BCM2837B0_BOARD_REV_ZERO_2 0x12
+#define BCM2711_BOARD_REV_400 0x13
+#define BCM2711_BOARD_REV_CM4 0x14
struct bcm2835_mbox_tag_get_board_rev {
struct bcm2835_mbox_tag_hdr tag_hdr;
@@ -273,6 +276,7 @@ struct bcm2835_mbox_tag_set_power_state {
#define BCM2835_MBOX_CLOCK_ID_SDRAM 8
#define BCM2835_MBOX_CLOCK_ID_PIXEL 9
#define BCM2835_MBOX_CLOCK_ID_PWM 10
+#define BCM2835_MBOX_CLOCK_ID_EMMC2 12
struct bcm2835_mbox_tag_get_clock_rate {
struct bcm2835_mbox_tag_hdr tag_hdr;
diff --git a/arch/arm/mach-bcm283x/include/mach/platform.h b/arch/arm/mach-bcm283x/include/mach/platform.h
index 310f2463f2..b957ac8de3 100644
--- a/arch/arm/mach-bcm283x/include/mach/platform.h
+++ b/arch/arm/mach-bcm283x/include/mach/platform.h
@@ -31,9 +31,10 @@
#define BCM2835_CACHELINE_SIZE 64
#define BCM2835_PL011_BASE 0x20201000
-#define BCM2836_PL011_BASE 0x3f201000
+#define BCM2836_PL011_BASE 0x3f201000UL
#define BCM2835_MINIUART_BASE 0x20215040
-#define BCM2836_MINIUART_BASE 0x3f215040
+#define BCM2836_MINIUART_BASE 0x3f215040UL
+#define BCM2711_MINIUART_BASE 0xfe215040UL
#endif
diff --git a/arch/arm/mach-bcm283x/mbox.c b/arch/arm/mach-bcm283x/mbox.c
index 4b14afcfe4..4959a1a652 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");
@@ -143,7 +151,7 @@ int bcm2835_mbox_call_prop(u32 chan, struct bcm2835_mbox_hdr *buffer)
ret = bcm2835_mbox_call_raw(chan, buffer, &rbuffer);
if (ret)
return ret;
- if (rbuffer != (u32)buffer) {
+ if (rbuffer != (uintptr_t)buffer) {
pr_err("mbox: Response buffer mismatch\n");
return -EIO;
}