diff mbox series

[U-Boot,v3,03/16] armv7R: K3: j721e: Unlock all applicable control MMR registers

Message ID 20190613045957.25133-4-lokeshvutla@ti.com
State Accepted
Commit b73fcbced9dfa1345ffcafbcfd84dfad7c291915
Delegated to: Tom Rini
Headers show
Series arm: k3: arm64: Initial support for Texas Instrument's J721E Platform | expand

Commit Message

Lokesh Vutla June 13, 2019, 4:59 a.m. UTC
From: Andreas Dannenberg <dannenberg@ti.com>

To access various control MMR functionality the registers need to
be unlocked. Do that for all control MMR regions in the MCU and MAIN
domains. We may want to go back later and limit the unlocking that's
being done.

Signed-off-by: Andreas Dannenberg <dannenberg@ti.com>
---
 arch/arm/mach-k3/j721e_init.c | 43 ++++++++++++++++++++++++++++++++++-
 1 file changed, 42 insertions(+), 1 deletion(-)

Comments

Tom Rini July 28, 2019, 9:47 p.m. UTC | #1
On Thu, Jun 13, 2019 at 10:29:44AM +0530, Lokesh Vutla wrote:

> From: Andreas Dannenberg <dannenberg@ti.com>
> 
> To access various control MMR functionality the registers need to
> be unlocked. Do that for all control MMR regions in the MCU and MAIN
> domains. We may want to go back later and limit the unlocking that's
> being done.
> 
> Signed-off-by: Andreas Dannenberg <dannenberg@ti.com>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/arch/arm/mach-k3/j721e_init.c b/arch/arm/mach-k3/j721e_init.c
index 80e88dd185..ba6a1cf0e6 100644
--- a/arch/arm/mach-k3/j721e_init.c
+++ b/arch/arm/mach-k3/j721e_init.c
@@ -14,14 +14,55 @@ 
 #include "common.h"
 
 #ifdef CONFIG_SPL_BUILD
+static void mmr_unlock(u32 base, u32 partition)
+{
+	/* Translate the base address */
+	phys_addr_t part_base = base + partition * CTRL_MMR0_PARTITION_SIZE;
+
+	/* Unlock the requested partition if locked using two-step sequence */
+	writel(CTRLMMR_LOCK_KICK0_UNLOCK_VAL, part_base + CTRLMMR_LOCK_KICK0);
+	writel(CTRLMMR_LOCK_KICK1_UNLOCK_VAL, part_base + CTRLMMR_LOCK_KICK1);
+}
+
+static void ctrl_mmr_unlock(void)
+{
+	/* Unlock all WKUP_CTRL_MMR0 module registers */
+	mmr_unlock(WKUP_CTRL_MMR0_BASE, 0);
+	mmr_unlock(WKUP_CTRL_MMR0_BASE, 1);
+	mmr_unlock(WKUP_CTRL_MMR0_BASE, 2);
+	mmr_unlock(WKUP_CTRL_MMR0_BASE, 3);
+	mmr_unlock(WKUP_CTRL_MMR0_BASE, 4);
+	mmr_unlock(WKUP_CTRL_MMR0_BASE, 6);
+	mmr_unlock(WKUP_CTRL_MMR0_BASE, 7);
+
+	/* Unlock all MCU_CTRL_MMR0 module registers */
+	mmr_unlock(MCU_CTRL_MMR0_BASE, 0);
+	mmr_unlock(MCU_CTRL_MMR0_BASE, 1);
+	mmr_unlock(MCU_CTRL_MMR0_BASE, 2);
+	mmr_unlock(MCU_CTRL_MMR0_BASE, 3);
+	mmr_unlock(MCU_CTRL_MMR0_BASE, 4);
+
+	/* Unlock all CTRL_MMR0 module registers */
+	mmr_unlock(CTRL_MMR0_BASE, 0);
+	mmr_unlock(CTRL_MMR0_BASE, 1);
+	mmr_unlock(CTRL_MMR0_BASE, 2);
+	mmr_unlock(CTRL_MMR0_BASE, 3);
+	mmr_unlock(CTRL_MMR0_BASE, 4);
+	mmr_unlock(CTRL_MMR0_BASE, 5);
+	mmr_unlock(CTRL_MMR0_BASE, 6);
+	mmr_unlock(CTRL_MMR0_BASE, 7);
+}
+
 void board_init_f(ulong dummy)
 {
 	/*
 	 * ToDo:
 	 * - Store boot rom index.
-	 * - unlock mmr.
 	 */
 
+	/* Make all control module registers accessible */
+	ctrl_mmr_unlock();
+
 #ifdef CONFIG_CPU_V7R
 	setup_k3_mpu_regions();
 #endif