2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2017-11-25 22:24:01 +00:00
|
|
|
/*
|
|
|
|
* Renesas RCar Gen3 memory map tables
|
|
|
|
*
|
|
|
|
* Copyright (C) 2017 Marek Vasut <marek.vasut@gmail.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <asm/armv8/mmu.h>
|
|
|
|
|
2018-10-31 14:06:50 +00:00
|
|
|
#define GEN3_NR_REGIONS 16
|
|
|
|
|
|
|
|
static struct mm_region gen3_mem_map[GEN3_NR_REGIONS] = {
|
2017-11-25 22:24:01 +00:00
|
|
|
{
|
|
|
|
.virt = 0x0UL,
|
|
|
|
.phys = 0x0UL,
|
2018-02-15 12:19:33 +00:00
|
|
|
.size = 0x40000000UL,
|
2017-11-25 22:24:01 +00:00
|
|
|
.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
|
|
|
|
PTE_BLOCK_NON_SHARE |
|
|
|
|
PTE_BLOCK_PXN | PTE_BLOCK_UXN
|
|
|
|
}, {
|
2018-02-15 12:19:33 +00:00
|
|
|
.virt = 0x40000000UL,
|
|
|
|
.phys = 0x40000000UL,
|
|
|
|
.size = 0x80000000UL,
|
2017-10-08 18:52:52 +00:00
|
|
|
.attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
|
|
|
|
PTE_BLOCK_INNER_SHARE
|
|
|
|
}, {
|
2018-02-15 12:19:33 +00:00
|
|
|
.virt = 0xc0000000UL,
|
|
|
|
.phys = 0xc0000000UL,
|
|
|
|
.size = 0x40000000UL,
|
2017-10-08 18:52:52 +00:00
|
|
|
.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
|
|
|
|
PTE_BLOCK_NON_SHARE |
|
|
|
|
PTE_BLOCK_PXN | PTE_BLOCK_UXN
|
2018-10-02 19:42:49 +00:00
|
|
|
}, {
|
|
|
|
.virt = 0x100000000UL,
|
|
|
|
.phys = 0x100000000UL,
|
|
|
|
.size = 0xf00000000UL,
|
|
|
|
.attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
|
|
|
|
PTE_BLOCK_INNER_SHARE
|
2017-10-08 18:52:52 +00:00
|
|
|
}, {
|
|
|
|
/* List terminator */
|
|
|
|
0,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-02-15 12:19:33 +00:00
|
|
|
struct mm_region *mem_map = gen3_mem_map;
|
2018-10-31 14:06:50 +00:00
|
|
|
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
|
|
|
void enable_caches(void)
|
|
|
|
{
|
|
|
|
u64 start, size;
|
|
|
|
int bank, i = 0;
|
|
|
|
|
|
|
|
/* Create map for RPC access */
|
|
|
|
gen3_mem_map[i].virt = 0x0ULL;
|
|
|
|
gen3_mem_map[i].phys = 0x0ULL;
|
|
|
|
gen3_mem_map[i].size = 0x40000000ULL;
|
|
|
|
gen3_mem_map[i].attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
|
|
|
|
PTE_BLOCK_NON_SHARE |
|
|
|
|
PTE_BLOCK_PXN | PTE_BLOCK_UXN;
|
|
|
|
i++;
|
|
|
|
|
|
|
|
/* Generate entires for DRAM in 32bit address space */
|
|
|
|
for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
|
|
|
|
start = gd->bd->bi_dram[bank].start;
|
|
|
|
size = gd->bd->bi_dram[bank].size;
|
|
|
|
|
|
|
|
/* Skip empty DRAM banks */
|
|
|
|
if (!size)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* Skip DRAM above 4 GiB */
|
|
|
|
if (start >> 32ULL)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* Mark memory reserved by ATF as cacheable too. */
|
|
|
|
if (start == 0x48000000) {
|
|
|
|
start = 0x40000000ULL;
|
|
|
|
size += 0x08000000ULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
gen3_mem_map[i].virt = start;
|
|
|
|
gen3_mem_map[i].phys = start;
|
|
|
|
gen3_mem_map[i].size = size;
|
|
|
|
gen3_mem_map[i].attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
|
|
|
|
PTE_BLOCK_INNER_SHARE;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create map for register access */
|
|
|
|
gen3_mem_map[i].virt = 0xc0000000ULL;
|
|
|
|
gen3_mem_map[i].phys = 0xc0000000ULL;
|
|
|
|
gen3_mem_map[i].size = 0x40000000ULL;
|
|
|
|
gen3_mem_map[i].attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
|
|
|
|
PTE_BLOCK_NON_SHARE |
|
|
|
|
PTE_BLOCK_PXN | PTE_BLOCK_UXN;
|
|
|
|
i++;
|
|
|
|
|
|
|
|
/* Generate entires for DRAM in 64bit address space */
|
|
|
|
for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
|
|
|
|
start = gd->bd->bi_dram[bank].start;
|
|
|
|
size = gd->bd->bi_dram[bank].size;
|
|
|
|
|
|
|
|
/* Skip empty DRAM banks */
|
|
|
|
if (!size)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* Skip DRAM below 4 GiB */
|
|
|
|
if (!(start >> 32ULL))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
gen3_mem_map[i].virt = start;
|
|
|
|
gen3_mem_map[i].phys = start;
|
|
|
|
gen3_mem_map[i].size = size;
|
|
|
|
gen3_mem_map[i].attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
|
|
|
|
PTE_BLOCK_INNER_SHARE;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Zero out the remaining regions. */
|
|
|
|
for (; i < GEN3_NR_REGIONS; i++) {
|
|
|
|
gen3_mem_map[i].virt = 0;
|
|
|
|
gen3_mem_map[i].phys = 0;
|
|
|
|
gen3_mem_map[i].size = 0;
|
|
|
|
gen3_mem_map[i].attrs = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
icache_enable();
|
|
|
|
dcache_enable();
|
|
|
|
}
|