summaryrefslogtreecommitdiff
path: root/arch/arm/mach-k3/common.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-k3/common.c')
-rw-r--r--arch/arm/mach-k3/common.c72
1 files changed, 72 insertions, 0 deletions
diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c
index 5483ac9906c..760aaad0341 100644
--- a/arch/arm/mach-k3/common.c
+++ b/arch/arm/mach-k3/common.c
@@ -30,6 +30,9 @@
#include <soc.h>
#include <dm/uclass-internal.h>
#include <dm/device-internal.h>
+#include <asm/armv8/mmu.h>
+#include <mach/k3-common-fdt.h>
+#include <mach/k3-ddr.h>
#define PROC_BOOT_CTRL_FLAG_R5_CORE_HALT 0x00000001
#define PROC_BOOT_STATUS_FLAG_R5_WFI 0x00000002
@@ -258,6 +261,47 @@ void board_prep_linux(struct bootm_headers *images)
ROUND(images->os.end,
CONFIG_SYS_CACHELINE_SIZE));
}
+
+void enable_caches(void)
+{
+ void *fdt = (void *)gd->fdt_blob;
+ int ret;
+
+ ret = mem_map_from_dram_banks(K3_MEM_MAP_FIRST_BANK_IDX, K3_MEM_MAP_LEN,
+ PTE_BLOCK_MEMTYPE(MT_NORMAL) |
+ PTE_BLOCK_INNER_SHARE);
+ if (ret)
+ debug("%s: Failed to setup dram banks\n", __func__);
+
+ mmu_setup();
+
+ if (CONFIG_K3_ATF_LOAD_ADDR >= CFG_SYS_SDRAM_BASE) {
+ ret = fdt_fixup_reserved(fdt, "tfa", CONFIG_K3_ATF_LOAD_ADDR,
+ 0x80000);
+ if (ret)
+ printf("%s: Failed to perform tfa fixups (%s)\n",
+ __func__, fdt_strerror(ret));
+ ret = mmu_unmap_reserved_mem("tfa", true);
+ if (ret)
+ printf("%s: Failed to unmap tfa reserved mem (%d)\n",
+ __func__, ret);
+ }
+
+ if (CONFIG_K3_OPTEE_LOAD_ADDR >= CFG_SYS_SDRAM_BASE) {
+ ret = fdt_fixup_reserved(fdt, "optee",
+ CONFIG_K3_OPTEE_LOAD_ADDR, 0x1800000);
+ if (ret)
+ printf("%s: Failed to perform optee fixups (%s)\n",
+ __func__, fdt_strerror(ret));
+ ret = mmu_unmap_reserved_mem("optee", true);
+ if (ret)
+ printf("%s: Failed to unmap optee reserved mem (%d)\n",
+ __func__, ret);
+ }
+
+ icache_enable();
+ dcache_enable();
+}
#endif
void spl_enable_cache(void)
@@ -267,6 +311,7 @@ void spl_enable_cache(void)
int ret = 0;
dram_init();
+ dram_init_banksize();
/* reserve TLB table */
gd->arch.tlb_size = PGTABLE_SIZE;
@@ -303,8 +348,27 @@ static __maybe_unused void k3_dma_remove(void)
pr_warn("DMA Device not found (err=%d)\n", rc);
}
+void spl_perform_arch_fixups(struct spl_image_info *spl_image)
+{
+ void *fdt = spl_image_fdt_addr(spl_image);
+
+ if (!fdt)
+ return;
+
+ fdt_fixup_reserved(fdt, "tfa", CONFIG_K3_ATF_LOAD_ADDR, 0x80000);
+ fdt_fixup_reserved(fdt, "optee", CONFIG_K3_OPTEE_LOAD_ADDR, 0x1800000);
+}
+
void spl_board_prepare_for_boot(void)
{
+#if IS_ENABLED(CONFIG_SPL_OS_BOOT_SECURE) && !IS_ENABLED(CONFIG_ARM64)
+ int ret;
+
+ ret = k3_r5_falcon_prep();
+ if (ret)
+ panic("%s: Failed to boot in falcon mode: %d\n", __func__, ret);
+#endif /* falcon mode on R5 SPL */
+
#if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF))
dcache_disable();
#endif
@@ -425,3 +489,11 @@ release_proc_ctrl:
proc_ops->proc_release(ti_sci, PROC_ID_MCU_R5FSS0_CORE1);
return ret;
}
+
+#if IS_ENABLED(CONFIG_ARM64) && IS_ENABLED(CONFIG_SPL_OS_BOOT_SECURE)
+int spl_start_uboot(void)
+{
+ /* Always boot to linux on Cortex-A SPL with CONFIG_SPL_OS_BOOT set */
+ return 0;
+}
+#endif