From: "Pali Rohár" <pali@kernel.org>
To: Stefan Roese <sr@denx.de>, Marek Behun <marek.behun@nic.cz>
Cc: u-boot@lists.denx.de
Subject: [PATCH 2/5] arm: mvebu: Move internal registers in arch_very_early_init() function
Date: Fri, 6 May 2022 11:05:14 +0200 [thread overview]
Message-ID: <20220506090517.5935-3-pali@kernel.org> (raw)
In-Reply-To: <20220506090517.5935-1-pali@kernel.org>
Moving of internal registers from INTREG_BASE_ADDR_REG to SOC_REGS_PHY_BASE
needs to be done very early, prior calling any function which may touch
internal registers, like debug_uart_init().
So do it earlier in arch_very_early_init() instead of arch_cpu_init().
Movement is done in proper U-Boot, not in SPL. SPL may return to bootrom
and bootrom requires internal registers at (old) expected location.
Signed-off-by: Pali Rohár <pali@kernel.org>
---
arch/arm/mach-mvebu/Kconfig | 1 +
arch/arm/mach-mvebu/Makefile | 1 +
arch/arm/mach-mvebu/cpu.c | 31 -------------------------------
arch/arm/mach-mvebu/lowlevel.S | 27 +++++++++++++++++++++++++++
4 files changed, 29 insertions(+), 31 deletions(-)
create mode 100644 arch/arm/mach-mvebu/lowlevel.S
diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig
index a3f273f4f949..98b13d1e336d 100644
--- a/arch/arm/mach-mvebu/Kconfig
+++ b/arch/arm/mach-mvebu/Kconfig
@@ -16,6 +16,7 @@ config ARMADA_32BIT
select SUPPORT_SPL
select TRANSLATION_OFFSET
select SPL_SYS_NO_VECTOR_TABLE if SPL
+ select ARCH_VERY_EARLY_INIT
config ARMADA_64BIT
bool
diff --git a/arch/arm/mach-mvebu/Makefile b/arch/arm/mach-mvebu/Makefile
index 1b451889d242..8bd2246325ca 100644
--- a/arch/arm/mach-mvebu/Makefile
+++ b/arch/arm/mach-mvebu/Makefile
@@ -21,6 +21,7 @@ else # CONFIG_ARCH_KIRKWOOD
obj-y = cpu.o
obj-y += dram.o
+obj-y += lowlevel.o
obj-$(CONFIG_DM_RESET) += system-controller.o
ifndef CONFIG_SPL_BUILD
obj-$(CONFIG_ARMADA_375) += ../../../drivers/ddr/marvell/axp/xor.o
diff --git a/arch/arm/mach-mvebu/cpu.c b/arch/arm/mach-mvebu/cpu.c
index 1e893777b292..173d95a760a3 100644
--- a/arch/arm/mach-mvebu/cpu.c
+++ b/arch/arm/mach-mvebu/cpu.c
@@ -413,20 +413,7 @@ static void update_sdram_window_sizes(void)
}
}
-void mmu_disable(void)
-{
- asm volatile(
- "mrc p15, 0, r0, c1, c0, 0\n"
- "bic r0, #1\n"
- "mcr p15, 0, r0, c1, c0, 0\n");
-}
-
#ifdef CONFIG_ARCH_CPU_INIT
-static void set_cbar(u32 addr)
-{
- asm("mcr p15, 4, %0, c15, c0" : : "r" (addr));
-}
-
#define MV_USB_PHY_BASE (MVEBU_AXP_USB_BASE + 0x800)
#define MV_USB_PHY_PLL_REG(reg) (MV_USB_PHY_BASE | (((reg) & 0xF) << 2))
#define MV_USB_X3_BASE(addr) (MVEBU_AXP_USB_BASE | BIT(11) | \
@@ -476,24 +463,6 @@ int arch_cpu_init(void)
struct pl310_regs *const pl310 =
(struct pl310_regs *)CONFIG_SYS_PL310_BASE;
- /*
- * Only with disabled MMU its possible to switch the base
- * register address on Armada 38x. Without this the SDRAM
- * located at >= 0x4000.0000 is also not accessible, as its
- * still locked to cache.
- */
- mmu_disable();
-
- /* Linux expects the internal registers to be at 0xf1000000 */
- writel(SOC_REGS_PHY_BASE, INTREG_BASE_ADDR_REG);
- set_cbar(SOC_REGS_PHY_BASE + 0xC000);
-
- /*
- * From this stage on, the SoC detection is working. As we have
- * configured the internal register base to the value used
- * in the macros / defines in the U-Boot header (soc.h).
- */
-
if (mvebu_soc_family() == MVEBU_SOC_A38X) {
/*
* To fully release / unlock this area from cache, we need
diff --git a/arch/arm/mach-mvebu/lowlevel.S b/arch/arm/mach-mvebu/lowlevel.S
new file mode 100644
index 000000000000..2491310eb0c1
--- /dev/null
+++ b/arch/arm/mach-mvebu/lowlevel.S
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+
+#include <config.h>
+#include <linux/linkage.h>
+
+ENTRY(arch_very_early_init)
+#ifdef CONFIG_ARMADA_38X
+ /*
+ * Only with disabled MMU its possible to switch the base
+ * register address on Armada 38x. Without this the SDRAM
+ * located at >= 0x4000.0000 is also not accessible, as its
+ * still locked to cache.
+ */
+ mrc p15, 0, r0, c1, c0, 0
+ bic r0, #1
+ mcr p15, 0, r0, c1, c0, 0
+#endif
+
+ /* Move internal registers from INTREG_BASE_ADDR_REG to SOC_REGS_PHY_BASE */
+ ldr r0, =SOC_REGS_PHY_BASE
+ ldr r1, =INTREG_BASE_ADDR_REG
+ str r0, [r1]
+ add r0, r0, #0xC000
+ mcr p15, 4, r0, c15, c0
+
+ bx lr
+ENDPROC(arch_very_early_init)
--
2.20.1
next prev parent reply other threads:[~2022-05-06 9:06 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-06 9:05 [PATCH 0/5] arm: mvebu: turris_omnia: Fix hangup in debug UART Pali Rohár
2022-05-06 9:05 ` [PATCH 1/5] arm: Add new config option ARCH_VERY_EARLY_INIT Pali Rohár
2022-05-16 6:37 ` Stefan Roese
2022-05-06 9:05 ` Pali Rohár [this message]
2022-05-06 12:04 ` [PATCH 2/5] arm: mvebu: Move internal registers in arch_very_early_init() function Stefan Roese
2022-05-06 12:09 ` Pali Rohár
2022-05-06 12:16 ` Stefan Roese
2022-05-06 12:35 ` Stefan Roese
2022-05-06 12:44 ` Pali Rohár
2022-06-01 10:27 ` Pali Rohár
2022-06-01 10:44 ` Stefan Roese
2022-06-01 10:54 ` Pali Rohár
2022-08-16 18:41 ` Fix KWBOOT_MSG_RSP_TIMEO_AXP in kwboot for Armada XP Pali Rohár
2022-08-19 7:30 ` Stefan Roese
2022-08-19 7:34 ` Pali Rohár
2022-05-16 6:37 ` [PATCH 2/5] arm: mvebu: Move internal registers in arch_very_early_init() function Stefan Roese
2022-05-06 9:05 ` [PATCH 3/5] serial: Add new config option SPL_DEBUG_UART_BASE Pali Rohár
2022-05-16 6:37 ` Stefan Roese
2022-05-06 9:05 ` [PATCH 4/5] serial: ns16550: Add support for SPL_DEBUG_UART_BASE Pali Rohár
2022-05-16 6:38 ` Stefan Roese
2022-05-06 9:05 ` [PATCH 5/5] arm: mvebu: turris_omnia: Fix DEBUG_UART_BASE Pali Rohár
2022-05-06 12:21 ` Stefan Roese
2022-05-06 12:30 ` Pali Rohár
2022-05-09 18:18 ` Pali Rohár
2022-05-16 6:38 ` Stefan Roese
2022-05-09 18:17 ` [PATCH 6/5] arm: mvebu: Fix DEBUG_UART_BASE for all 32-bit boards Pali Rohár
2022-05-16 6:39 ` Stefan Roese
2022-05-16 14:52 ` [PATCH 0/5] arm: mvebu: turris_omnia: Fix hangup in debug UART Stefan Roese
2022-05-16 16:50 ` Pali Rohár
2022-05-16 16:49 ` [PATCH 7/5] serial: Add new config option TPL_DEBUG_UART_BASE Pali Rohár
2022-05-17 7:51 ` Stefan Roese
2022-05-17 7:53 ` [PATCH 0/5] arm: mvebu: turris_omnia: Fix hangup in debug UART Stefan Roese
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220506090517.5935-3-pali@kernel.org \
--to=pali@kernel.org \
--cc=marek.behun@nic.cz \
--cc=sr@denx.de \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox