3 * Graeme Russ, <graeme.russ@gmail.com>
5 * SPDX-License-Identifier: GPL-2.0+
11 #include <asm/sections.h>
13 DECLARE_GLOBAL_DATA_PTR;
15 /* Get the top of usable RAM */
16 __weak ulong board_get_usable_ram_top(ulong total_size)
21 int calculate_relocation_address(void)
23 const ulong uboot_size = (uintptr_t)&__bss_end -
24 (uintptr_t)&__text_start;
29 #if defined(CONFIG_OF_SEPARATE) && defined(CONFIG_OF_CONTROL)
31 fdt_size = ALIGN(fdt_totalsize(gd->fdt_blob) + 0x1000, 32);
33 total_size = ALIGN(uboot_size, 1 << 12) + CONFIG_SYS_MALLOC_LEN +
34 CONFIG_SYS_STACK_SIZE + fdt_size;
36 dest_addr = board_get_usable_ram_top(total_size);
38 * NOTE: All destination address are rounded down to 16-byte
39 * boundary to satisfy various worst-case alignment
44 #if defined(CONFIG_OF_SEPARATE) && defined(CONFIG_OF_CONTROL)
46 * If the device tree is sitting immediate above our image then we
47 * must relocate it. If it is embedded in the data section, then it
48 * will be relocated with other data.
51 dest_addr -= fdt_size;
52 gd->new_fdt = (void *)dest_addr;
56 /* U-Boot is below the FDT */
57 dest_addr -= uboot_size;
58 dest_addr &= ~((1 << 12) - 1);
59 gd->relocaddr = dest_addr;
60 gd->reloc_off = dest_addr - (uintptr_t)&__text_start;
62 /* Stack is at the bottom, so it can grow down */
63 gd->start_addr_sp = dest_addr - CONFIG_SYS_MALLOC_LEN;
68 int init_cache_f_r(void)
70 #if defined(CONFIG_X86_RESET_VECTOR) & !defined(CONFIG_HAVE_FSP)
73 ret = mtrr_commit(false);
77 /* Initialise the CPU cache(s) */
83 int init_bd_struct_r(void)
86 memset(gd->bd, 0, sizeof(bd_t));
91 int init_func_spi(void)