summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arch/arm/cpu/armv8/cache_v8.c28
-rw-r--r--arch/arm/include/asm/armv8/mmu.h11
2 files changed, 39 insertions, 0 deletions
diff --git a/arch/arm/cpu/armv8/cache_v8.c b/arch/arm/cpu/armv8/cache_v8.c
index 74c78cb2fb0..9b3c37dae82 100644
--- a/arch/arm/cpu/armv8/cache_v8.c
+++ b/arch/arm/cpu/armv8/cache_v8.c
@@ -58,6 +58,34 @@ static int get_effective_el(void)
return el;
}
+int mem_map_from_dram_banks(unsigned int index, unsigned int len, u64 attrs)
+{
+ unsigned int i;
+ int ret = fdtdec_setup_memory_banksize();
+
+ if (ret) {
+ log_err("%s: Failed to setup dram banks\n", __func__);
+ return ret;
+ }
+
+ if (index + CONFIG_NR_DRAM_BANKS >= len) {
+ log_err("%s: Provided mem_map array has insufficient size for DRAM entries\n",
+ __func__);
+ return -ENOMEM;
+ }
+
+ for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
+ mem_map[index].virt = gd->bd->bi_dram[i].start;
+ mem_map[index].phys = gd->bd->bi_dram[i].start;
+ mem_map[index].size = gd->bd->bi_dram[i].size;
+ mem_map[index].attrs = attrs;
+ index++;
+ }
+
+ memset(&mem_map[index], 0, sizeof(mem_map[index]));
+
+ return 0;
+}
u64 get_tcr(u64 *pips, u64 *pva_bits)
{
int el = get_effective_el();
diff --git a/arch/arm/include/asm/armv8/mmu.h b/arch/arm/include/asm/armv8/mmu.h
index 3807c702fb6..6e7a3366844 100644
--- a/arch/arm/include/asm/armv8/mmu.h
+++ b/arch/arm/include/asm/armv8/mmu.h
@@ -194,8 +194,19 @@ struct mm_region {
u64 attrs;
};
+/* Used as the memory map for MMU configuration by mmu_setup */
extern struct mm_region *mem_map;
void setup_pgtables(void);
+
+/**
+ * mem_map_from_dram_banks() - Populate mem_map with entries corresponding to
+ * dram banks as per the gd. This should be called prior to mmu_setup.
+ *
+ * @index: The entry in mem_map to start the over-write
+ * @len: The size of mem_map
+ */
+int mem_map_from_dram_banks(unsigned int index, unsigned int len, u64 attrs);
+
u64 get_tcr(u64 *pips, u64 *pva_bits);
/**