]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
arm: armv8: mmu: move mmu enablement out of mmu_setup
authorAnshul Dalal <anshuld@ti.com>
Wed, 20 May 2026 02:51:49 +0000 (08:21 +0530)
committerTom Rini <trini@konsulko.com>
Mon, 25 May 2026 15:29:50 +0000 (09:29 -0600)
Currently mmu_setup for ARMv8 performs two functions, first it sets up
the page tables based the memory map provided by the board and then it
enables the MMU.

However for some platforms runtime fixes to the generated page tables
are required before the MMU can be enabled, such as K3 family of SoCs.

Therefore this patch moves the enablement of the MMU out of mmu_setup
and to a standalone mmu_enable function to give more granular control to
the platforms.

Note that no functional changes are intended from this patch.

Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: Anshul Dalal <anshuld@ti.com>
arch/arm/cpu/armv8/cache_v8.c
arch/arm/include/asm/armv8/mmu.h
arch/arm/mach-k3/common.c

index 39479df7b21fdd85b8ffea59d7c08985c68396f8..7c0e3f6d055e42a23a0ed132a478d0639afea030 100644 (file)
@@ -810,8 +810,10 @@ __weak void mmu_setup(void)
        el = current_el();
        set_ttbr_tcr_mair(el, gd->arch.tlb_addr, get_tcr(NULL, NULL),
                          MEMORY_ATTRIBUTES);
+}
 
-       /* enable the mmu */
+void mmu_enable(void)
+{
        set_sctlr(get_sctlr() | CR_M);
 }
 
@@ -881,6 +883,7 @@ void dcache_enable(void)
        if (!mmu_status()) {
                __asm_invalidate_tlb_all();
                mmu_setup();
+               mmu_enable();
        }
 
        /* Set up page tables only once (it is done also by mmu_setup()) */
index 8aa5f9721c4a98a9d992e5e7cf152cde82202be0..5359b2ad87bbc26023148b63cbc428fd7e7101be 100644 (file)
@@ -222,6 +222,11 @@ u64 get_tcr(u64 *pips, u64 *pva_bits);
  * mmu_setup() - Sets up the mmu page tables as per mem_map
  */
 void mmu_setup(void);
+
+/**
+ * mmu_enable() - Enable the MMU by setting 'M' bit in SCTLR register
+ */
+void mmu_enable(void);
 #endif
 
 #endif /* _ASM_ARMV8_MMU_H_ */
index b0a759887147ec4aa7a38749f29d6f28d007f74c..396018b7a7aec5a1d9ee7017153c220520e9c0d4 100644 (file)
@@ -279,6 +279,7 @@ void enable_caches(void)
                       __func__, fdt_strerror(ret));
 
        mmu_setup();
+       mmu_enable();
 
        if (CONFIG_K3_ATF_LOAD_ADDR >= CFG_SYS_SDRAM_BASE) {
                ret = mmu_unmap_reserved_mem("tfa", true);