Merge tag 'u-boot-atmel-fixes-2020.07-a' of https://gitlab.denx.de/u-boot/custodians...
[oweals/u-boot.git] / arch / arm / mach-k3 / common.c
index 80dfa5f0fd6ab398ef96489f85a6ded11407da6a..9695b2236ecd0a6d34b5292e039ac1746e40779c 100644 (file)
@@ -8,10 +8,14 @@
 
 #include <common.h>
 #include <cpu_func.h>
+#include <image.h>
+#include <init.h>
+#include <log.h>
 #include <spl.h>
 #include "common.h"
 #include <dm.h>
 #include <remoteproc.h>
+#include <asm/cache.h>
 #include <linux/soc/ti/ti_sci_protocol.h>
 #include <fdt_support.h>
 #include <asm/arch/sys_proto.h>
@@ -406,3 +410,38 @@ void remove_fwl_configs(struct fwl_data *fwl_data, size_t fwl_data_size)
                }
        }
 }
+
+void spl_enable_dcache(void)
+{
+#if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF))
+       phys_addr_t ram_top = CONFIG_SYS_SDRAM_BASE;
+
+       dram_init_banksize();
+
+       /* reserve TLB table */
+       gd->arch.tlb_size = PGTABLE_SIZE;
+
+       ram_top += get_effective_memsize();
+       /* keep ram_top in the 32-bit address space */
+       if (ram_top >= 0x100000000)
+               ram_top = (phys_addr_t) 0x100000000;
+
+       gd->arch.tlb_addr = ram_top - gd->arch.tlb_size;
+       debug("TLB table from %08lx to %08lx\n", gd->arch.tlb_addr,
+             gd->arch.tlb_addr + gd->arch.tlb_size);
+
+       dcache_enable();
+#endif
+}
+
+#if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF))
+void spl_board_prepare_for_boot(void)
+{
+       dcache_disable();
+}
+
+void spl_board_prepare_for_boot_linux(void)
+{
+       dcache_disable();
+}
+#endif