diff options
-rw-r--r-- | arch/arm/lib/board.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c index 2f34677e873..c3dcbba1ee9 100644 --- a/arch/arm/lib/board.c +++ b/arch/arm/lib/board.c @@ -271,6 +271,8 @@ void board_init_f (ulong bootflag) init_fnc_t **init_fnc_ptr; gd_t *id; ulong addr, addr_sp; + void *new_fdt = NULL; + size_t fdt_size = 0; #ifdef CONFIG_OF_EMBED extern u8 _binary_dt_dtb_start[]; #endif @@ -404,6 +406,22 @@ void board_init_f (ulong bootflag) debug ("Reserving %zu Bytes for Global Data at: %08lx\n", sizeof (gd_t), addr_sp); +#ifdef CONFIG_OF_SEPARATE + /* + * If the device tree is sitting immediate above our image then we + * must relocate it. If it is embedded in the data section, then it + * will be relocated with other data. + */ + if (gd->blob) { + fdt_size = ALIGN(fdt_totalsize(gd->blob) + 0x1000, 32); + + addr_sp -= fdt_size; + new_fdt = (void *)addr_sp; + debug ("Reserving %zu Bytes for FDT at: %08lx\n", + fdt_size, addr_sp); + } +#endif + /* setup stackpointer for exeptions */ gd->irq_sp = addr_sp; #ifdef CONFIG_USE_IRQ @@ -435,11 +453,16 @@ void board_init_f (ulong bootflag) #ifdef CONFIG_SYS_SKIP_ARM_RELOCATION addr = _TEXT_BASE; + debug("Code relocation disabled by CONFIG_SYS_SKIP_ARM_RELOCATION\n"); #endif gd->relocaddr = addr; gd->start_addr_sp = addr_sp; gd->reloc_off = addr - _TEXT_BASE; debug ("relocation Offset is: %08lx\n", gd->reloc_off); + if (new_fdt) { + memcpy(new_fdt, gd->blob, fdt_size); + gd->blob = new_fdt; + } memcpy (id, (void *)gd, sizeof (gd_t)); relocate_code (addr_sp, id, addr); |