diff options
author | Tom Rini <trini@konsulko.com> | 2021-01-06 00:20:26 +0300 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2021-01-06 00:20:26 +0300 |
commit | 720620e6916ba40b9a173bb07706d2c73f3c23e7 (patch) | |
tree | b085821f1d1137d80e9bb73f405ea0680db338b9 /arch/x86/cpu/tangier/sdram.c | |
parent | c86b18074c9d40bfa63cda1068b6dfb810d4377d (diff) | |
parent | 62b07b5173e3d04fabfac42cf1f4779d021f94ad (diff) | |
download | u-boot-720620e6916ba40b9a173bb07706d2c73f3c23e7.tar.xz |
Merge tag 'v2021.01-rc5' into next
Prepare v2021.01-rc5
Signed-off-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'arch/x86/cpu/tangier/sdram.c')
-rw-r--r-- | arch/x86/cpu/tangier/sdram.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/arch/x86/cpu/tangier/sdram.c b/arch/x86/cpu/tangier/sdram.c index df3b9e4ec9..afb08476ed 100644 --- a/arch/x86/cpu/tangier/sdram.c +++ b/arch/x86/cpu/tangier/sdram.c @@ -196,6 +196,49 @@ unsigned int install_e820_map(unsigned int max_entries, return sfi_setup_e820(max_entries, entries); } +/* + * This function looks for the highest region of memory lower than 2GB which + * has enough space for U-Boot where U-Boot is aligned on a page boundary. It + * overrides the default implementation found elsewhere which simply picks the + * end of RAM, wherever that may be. The location of the stack, the relocation + * address, and how far U-Boot is moved by relocation are set in the global + * data structure. + */ +ulong board_get_usable_ram_top(ulong total_size) +{ + struct sfi_table_simple *sb; + struct sfi_mem_entry *mentry; + ulong dest_addr = 0; + u32 i; + + sb = sfi_search_mmap(); + if (!sb) + panic("No available memory found for relocation"); + + sfi_for_each_mentry(i, sb, mentry) { + unsigned long long start, end; + + if (mentry->type != SFI_MEM_CONV) + continue; + + start = mentry->phys_start; + end = start + (mentry->pages << 12); + + /* Filter memory over 2GB. */ + if (end > 0x7fffffffULL) + end = 0x80000000ULL; + /* Skip this region if it's too small. */ + if (end - start < total_size) + continue; + + /* Use this address if it's the largest so far. */ + if (end > dest_addr) + dest_addr = end; + } + + return dest_addr; +} + int dram_init_banksize(void) { sfi_get_bank_size(); |