[U-Boot] [PATCH v2] arm64: zynqmp: Setup MMU map for DDR at run time
Michal Simek
michal.simek at xilinx.com
Mon Apr 30 08:55:26 UTC 2018
On 30.4.2018 09:46, Alexander Graf wrote:
>
>
> On 30.04.18 09:23, Michal Simek wrote:
>> From: Nitin Jain <nitin.jain at xilinx.com>
>>
>> This patch fills the MMU map for DDR at run time based information read
>
> based on
will fix.
>> +void mem_map_fill(void)
>> +{
>> + int banks = ZYNQMP_MEM_MAP_USED;
>> +
>> +#if defined(CONFIG_DEFINE_TCM_OCM_MMAP)
>> + zynqmp_mem_map[banks].virt = 0xffe00000UL;
>> + zynqmp_mem_map[banks].phys = 0xffe00000UL;
>> + zynqmp_mem_map[banks].size = 0x00200000UL;
>> + zynqmp_mem_map[banks].attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
>> + PTE_BLOCK_INNER_SHARE;
>> + banks = banks + 1;
>> +#endif
>> +
>> +#if !defined(CONFIG_ZYNQMP_NO_DDR)
>> + for (int i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
>> + /* Skip empty banks */
>> + if (!gd->bd->bi_dram[i].size)
>> + break;
>
> This doesn't skip, it takes empty as abort condition. That is probably
> correct, but please update the comment above to reflect reality.
Will fix comment.
>
>> +
>> + zynqmp_mem_map[banks].virt = gd->bd->bi_dram[i].start;
>> + zynqmp_mem_map[banks].phys = gd->bd->bi_dram[i].start;
>> + zynqmp_mem_map[banks].size = gd->bd->bi_dram[i].size;
>> + zynqmp_mem_map[banks].attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
>> + PTE_BLOCK_INNER_SHARE;
>> + banks = banks + 1;
>> + }
>> +#endif
>> +}
>> +
>> struct mm_region *mem_map = zynqmp_mem_map;
>>
>> u64 get_page_table_size(void)
>> diff --git a/arch/arm/include/asm/arch-zynqmp/sys_proto.h b/arch/arm/include/asm/arch-zynqmp/sys_proto.h
>> index 3daf0e81d80c..d11c0782b8dd 100644
>> --- a/arch/arm/include/asm/arch-zynqmp/sys_proto.h
>> +++ b/arch/arm/include/asm/arch-zynqmp/sys_proto.h
>> @@ -46,7 +46,7 @@ int invoke_smc(u32 pm_api_id, u32 arg0, u32 arg1, u32 arg2, u32 arg3,
>> u32 *ret_payload);
>>
>> void initialize_tcm(bool mode);
>> -
>> +void mem_map_fill(void);
>> int chip_id(unsigned char id);
>>
>> #endif /* _ASM_ARCH_SYS_PROTO_H */
>> diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c
>> index aeef0b4cdd7e..6d09a4c73139 100644
>> --- a/board/xilinx/zynqmp/zynqmp.c
>> +++ b/board/xilinx/zynqmp/zynqmp.c
>> @@ -406,7 +406,15 @@ unsigned long do_go_exec(ulong (*entry)(int, char * const []), int argc,
>> #if !defined(CONFIG_SYS_SDRAM_BASE) && !defined(CONFIG_SYS_SDRAM_SIZE)
>> int dram_init_banksize(void)
>> {
>> - return fdtdec_setup_memory_banksize();
>> + int ret;
>> +
>> + ret = fdtdec_setup_memory_banksize();
>> + if (ret)
>> + return ret;
>> +
>> + mem_map_fill();
>> +
>> + return 0;
>> }
>>
>> int dram_init(void)
>> @@ -417,6 +425,18 @@ int dram_init(void)
>> return 0;
>> }
>> #else
>> +int dram_init_banksize(void)
>> +{
>> +#if defined(CONFIG_NR_DRAM_BANKS)
>> + gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
>> + gd->bd->bi_dram[0].size = get_effective_memsize();
>> +#endif
>
> Didn't zynqmp have a split ddr window with one starting from 0 and one
> from 0x800000000? How can this span all available memory then?
There are even 3 locations above 0 (+2GB size), 32GB (+32GB size) and
768G (+256GB) but I have never seen zynqmp with more then 32GB memory.
This is for !DT case where it is expectation that you work with memory
below 4GB which is all the time just one BANK used by mini u-boot
configurations.
> Doesn't that mean your OS would not see all memory because U-Boot
> doesn't tell it about all? Both booti (via dtb patching) and bootefi
> (via efi memory tables) pass memory information to the OS from bi_dram
> fields.
These mini configurations are not used for boot OS. But if you want to
do that CONFIG_ARCH_FIXUP_FDT_MEMORY is your friend and memory map
doesn't need to be passed to OS at all.
For OF case which are standard configuration there are 2 banks wired.
Thanks,
Michal
More information about the U-Boot
mailing list