X-Git-Url: https://git.karo-electronics.de/?a=blobdiff_plain;f=common%2Fboard_f.c;h=2c8859507822d7015b02deac8e8ac23b665ca347;hb=0a0e53cb2ee625f603b7e2bb0caba23946f5fe40;hp=84485e96e8c92189c4d068e7d124bbe5ff94869e;hpb=67521957605494a11fa5161dcc54757dc5b6b8a1;p=karo-tx-uboot.git diff --git a/common/board_f.c b/common/board_f.c index 84485e96e8..2c88595078 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -44,13 +45,17 @@ #include #include #include +#include #include +#include #include -#include +#include #include #include #if defined(CONFIG_X86) || defined(CONFIG_ARC) #include +#endif +#if defined(CONFIG_X86) || defined(CONFIG_ARC) || defined(CONFIG_XTENSA) #include #endif #ifdef CONFIG_SANDBOX @@ -114,10 +119,11 @@ static int init_func_watchdog_init(void) # if defined(CONFIG_HW_WATCHDOG) && (defined(CONFIG_BLACKFIN) || \ defined(CONFIG_M68K) || defined(CONFIG_MICROBLAZE) || \ defined(CONFIG_SH) || defined(CONFIG_AT91SAM9_WATCHDOG) || \ + defined(CONFIG_DESIGNWARE_WATCHDOG) || \ defined(CONFIG_IMX_WATCHDOG)) hw_watchdog_init(); -# endif puts(" Watchdog enabled\n"); +# endif WATCHDOG_RESET(); return 0; @@ -160,9 +166,6 @@ static int display_text_info(void) text_base, bss_start, bss_end); #endif -#ifdef CONFIG_MODEM_SUPPORT - debug("Modem Support enabled\n"); -#endif #ifdef CONFIG_USE_IRQ debug("IRQ Stack: %08lx\n", IRQ_STACK_START); debug("FIQ Stack: %08lx\n", FIQ_STACK_START); @@ -270,11 +273,12 @@ static int setup_mon_len(void) gd->mon_len = (ulong)&__bss_end - (ulong)_start; #elif defined(CONFIG_SANDBOX) || defined(CONFIG_EFI_APP) gd->mon_len = (ulong)&_end - (ulong)_init; -#elif defined(CONFIG_BLACKFIN) || defined(CONFIG_NIOS2) +#elif defined(CONFIG_BLACKFIN) || defined(CONFIG_NIOS2) || \ + defined(CONFIG_XTENSA) gd->mon_len = CONFIG_SYS_MONITOR_LEN; #elif defined(CONFIG_NDS32) gd->mon_len = (ulong)(&__bss_end) - (ulong)(&_start); -#else +#elif defined(CONFIG_SYS_MONITOR_BASE) /* TODO: use (ulong)&__bss_end - (ulong)&__text_start; ? */ gd->mon_len = (ulong)&__bss_end - CONFIG_SYS_MONITOR_BASE; #endif @@ -286,6 +290,11 @@ __weak int arch_cpu_init(void) return 0; } +__weak int mach_cpu_init(void) +{ + return 0; +} + #ifdef CONFIG_SANDBOX static int setup_ram_buf(void) { @@ -316,6 +325,15 @@ __weak ulong board_get_usable_ram_top(ulong total_size) return gd->ram_top; } +__weak phys_size_t board_reserve_ram_top(phys_size_t ram_size) +{ +#ifdef CONFIG_SYS_MEM_TOP_HIDE + return ram_size - CONFIG_SYS_MEM_TOP_HIDE; +#else + return ram_size; +#endif +} + static int setup_dest_addr(void) { debug("Monitor len: %08lX\n", gd->mon_len); @@ -323,19 +341,26 @@ static int setup_dest_addr(void) * Ram is setup, size stored in gd !! */ debug("Ram size: %08lX\n", (ulong)gd->ram_size); -#if defined(CONFIG_SYS_MEM_TOP_HIDE) +#ifdef CONFIG_SYS_MEM_RESERVE_SECURE + /* Reserve memory for secure MMU tables, and/or security monitor */ + gd->ram_size -= CONFIG_SYS_MEM_RESERVE_SECURE; + /* + * Record secure memory location. Need recalcuate if memory splits + * into banks, or the ram base is not zero. + */ + gd->arch.secure_ram = gd->ram_size; +#endif /* * Subtract specified amount of memory to hide so that it won't * get "touched" at all by U-Boot. By fixing up gd->ram_size * the Linux kernel should now get passed the now "corrected" - * memory size and won't touch it either. This should work - * for arch/ppc and arch/powerpc. Only Linux board ports in - * arch/powerpc with bootwrapper support, that recalculate the - * memory size from the SDRAM controller setup will have to - * get fixed. + * memory size and won't touch it either. This has been used + * by arch/powerpc exclusively. Now ARMv8 takes advantage of + * thie mechanism. If memory is split into banks, addresses + * need to be calculated. */ - gd->ram_size -= CONFIG_SYS_MEM_TOP_HIDE; -#endif + gd->ram_size = board_reserve_ram_top(gd->ram_size); + #ifdef CONFIG_SYS_SDRAM_BASE gd->ram_top = CONFIG_SYS_SDRAM_BASE; #endif @@ -356,6 +381,20 @@ static int setup_dest_addr(void) return 0; } +#if defined(CONFIG_SPARC) +static int reserve_prom(void) +{ + /* defined in arch/sparc/cpu/leon?/prom.c */ + extern void *__prom_start_reloc; + int size = 8192; /* page table = 2k, prom = 6k */ + gd->relocaddr -= size; + __prom_start_reloc = map_sysmem(gd->relocaddr + 2048, size - 2048); + debug("Reserving %dk for PROM and page table at %08lx\n", size, + gd->relocaddr); + return 0; +} +#endif + #if defined(CONFIG_LOGBUFFER) && !defined(CONFIG_ALT_LB_ADDR) static int reserve_logbuffer(void) { @@ -402,40 +441,54 @@ static int reserve_mmu(void) gd->arch.tlb_addr = gd->relocaddr; debug("TLB table from %08lx to %08lx\n", gd->arch.tlb_addr, gd->arch.tlb_addr + gd->arch.tlb_size); + +#ifdef CONFIG_SYS_MEM_RESERVE_SECURE + /* + * Record allocated tlb_addr in case gd->tlb_addr to be overwritten + * with location within secure ram. + */ + gd->arch.tlb_allocated = gd->arch.tlb_addr; +#endif + return 0; } #endif -#ifdef CONFIG_LCD +#ifdef CONFIG_DM_VIDEO +static int reserve_video(void) +{ + ulong addr; + int ret; + + addr = gd->relocaddr; + ret = video_reserve(&addr); + if (ret) + return ret; + gd->relocaddr = addr; + + return 0; +} +#else + +# ifdef CONFIG_LCD static int reserve_lcd(void) { -#ifdef CONFIG_FB_ADDR +# ifdef CONFIG_FB_ADDR gd->fb_base = CONFIG_FB_ADDR; -#else +# else /* reserve memory for LCD display (always full pages) */ gd->relocaddr = lcd_setmem(gd->relocaddr); gd->fb_base = gd->relocaddr; -#endif /* CONFIG_FB_ADDR */ - return 0; -} -#endif /* CONFIG_LCD */ - -static int reserve_trace(void) -{ -#ifdef CONFIG_TRACE - gd->relocaddr -= CONFIG_TRACE_BUFFER_SIZE; - gd->trace_buff = map_sysmem(gd->relocaddr, CONFIG_TRACE_BUFFER_SIZE); - debug("Reserving %dk for trace data at: %08lx\n", - CONFIG_TRACE_BUFFER_SIZE >> 10, gd->relocaddr); -#endif +# endif /* CONFIG_FB_ADDR */ return 0; } +# endif /* CONFIG_LCD */ -#if defined(CONFIG_VIDEO) && (!defined(CONFIG_PPC) || defined(CONFIG_8xx)) && \ +# if defined(CONFIG_VIDEO) && (!defined(CONFIG_PPC) || defined(CONFIG_8xx)) && \ !defined(CONFIG_ARM) && !defined(CONFIG_X86) && \ !defined(CONFIG_BLACKFIN) && !defined(CONFIG_M68K) -static int reserve_video(void) +static int reserve_legacy_video(void) { /* reserve memory for video display (always full pages) */ gd->relocaddr = video_setmem(gd->relocaddr); @@ -443,8 +496,21 @@ static int reserve_video(void) return 0; } +# endif +#endif /* !CONFIG_DM_VIDEO */ + +static int reserve_trace(void) +{ +#ifdef CONFIG_TRACE + gd->relocaddr -= CONFIG_TRACE_BUFFER_SIZE; + gd->trace_buff = map_sysmem(gd->relocaddr, CONFIG_TRACE_BUFFER_SIZE); + debug("Reserving %dk for trace data at: %08lx\n", + CONFIG_TRACE_BUFFER_SIZE >> 10, gd->relocaddr); #endif + return 0; +} + static int reserve_uboot(void) { /* @@ -509,6 +575,7 @@ static int reserve_global_data(void) static int reserve_fdt(void) { +#ifndef CONFIG_OF_EMBED /* * If the device tree is sitting immediately above our image then we * must relocate it. If it is embedded in the data section, then it @@ -522,6 +589,7 @@ static int reserve_fdt(void) debug("Reserving %lu Bytes for FDT at: %08lx\n", gd->fdt_size, gd->start_addr_sp); } +#endif return 0; } @@ -659,12 +727,14 @@ static int setup_dram_config(void) static int reloc_fdt(void) { +#ifndef CONFIG_OF_EMBED if (gd->flags & GD_FLG_SKIP_RELOC) return 0; if (gd->new_fdt) { memcpy(gd->new_fdt, gd->fdt_blob, gd->fdt_size); gd->fdt_blob = gd->new_fdt; } +#endif return 0; } @@ -736,6 +806,15 @@ static int mark_bootstage(void) return 0; } +static int initf_console_record(void) +{ +#if defined(CONFIG_CONSOLE_RECORD) && defined(CONFIG_SYS_MALLOC_F_LEN) + return console_record_init(); +#else + return 0; +#endif +} + static int initf_dm(void) { #if defined(CONFIG_DM) && defined(CONFIG_SYS_MALLOC_F_LEN) @@ -745,6 +824,11 @@ static int initf_dm(void) if (ret) return ret; #endif +#ifdef CONFIG_TIMER_EARLY + ret = dm_timer_init(); + if (ret) + return ret; +#endif return 0; } @@ -772,6 +856,7 @@ static init_fnc_t init_sequence_f[] = { trace_early_init, #endif initf_malloc, + initf_console_record, #if defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx) /* TODO: can this go into arch_cpu_init()? */ probecpu, @@ -780,6 +865,7 @@ static init_fnc_t init_sequence_f[] = { x86_fsp_init, #endif arch_cpu_init, /* basic arch cpu dependent setup */ + mach_cpu_init, /* SoC/machine dependent CPU setup */ initf_dm, arch_cpu_init_dm, mark_bootstage, /* need timer, go after init dm */ @@ -796,8 +882,9 @@ static init_fnc_t init_sequence_f[] = { /* TODO: can we rename this to timer_init()? */ init_timebase, #endif -#if defined(CONFIG_X86) || defined(CONFIG_ARM) || defined(CONFIG_MIPS) || \ - defined(CONFIG_BLACKFIN) || defined(CONFIG_NDS32) +#if defined(CONFIG_ARM) || defined(CONFIG_MIPS) || \ + defined(CONFIG_BLACKFIN) || defined(CONFIG_NDS32) || \ + defined(CONFIG_SPARC) timer_init, /* initialize timer */ #endif #ifdef CONFIG_SYS_ALLOC_DPRAM @@ -893,10 +980,13 @@ static init_fnc_t init_sequence_f[] = { * - board info struct */ setup_dest_addr, -#if defined(CONFIG_BLACKFIN) +#if defined(CONFIG_BLACKFIN) || defined(CONFIG_XTENSA) /* Blackfin u-boot monitor should be on top of the ram */ reserve_uboot, #endif +#if defined(CONFIG_SPARC) + reserve_prom, +#endif #if defined(CONFIG_LOGBUFFER) && !defined(CONFIG_ALT_LB_ADDR) reserve_logbuffer, #endif @@ -908,17 +998,21 @@ static init_fnc_t init_sequence_f[] = { defined(CONFIG_ARM) reserve_mmu, #endif -#ifdef CONFIG_LCD +#ifdef CONFIG_DM_VIDEO + reserve_video, +#else +# ifdef CONFIG_LCD reserve_lcd, -#endif - reserve_trace, +# endif /* TODO: Why the dependency on CONFIG_8xx? */ -#if defined(CONFIG_VIDEO) && (!defined(CONFIG_PPC) || defined(CONFIG_8xx)) && \ +# if defined(CONFIG_VIDEO) && (!defined(CONFIG_PPC) || defined(CONFIG_8xx)) && \ !defined(CONFIG_ARM) && !defined(CONFIG_X86) && \ !defined(CONFIG_BLACKFIN) && !defined(CONFIG_M68K) - reserve_video, -#endif -#if !defined(CONFIG_BLACKFIN) + reserve_legacy_video, +# endif +#endif /* CONFIG_DM_VIDEO */ + reserve_trace, +#if !defined(CONFIG_BLACKFIN) && !defined(CONFIG_XTENSA) reserve_uboot, #endif #ifndef CONFIG_SPL_BUILD @@ -951,6 +1045,9 @@ static init_fnc_t init_sequence_f[] = { clear_bss, do_elf_reloc_fixups, #endif +#if defined(CONFIG_XTENSA) + clear_bss, +#endif #if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX) jump_to_copy, #endif @@ -1020,6 +1117,13 @@ void board_init_f_r(void) if (initcall_run_list(init_sequence_f_r)) hang(); + /* + * The pre-relocation drivers may be using memory that has now gone + * away. Mark serial as unavailable - this will fall back to the debug + * UART if available. + */ + gd->flags &= ~GD_FLG_SERIAL_READY; + /* * U-Boot has been copied into SDRAM, the BSS has been cleared etc. * Transfer execution from Flash to RAM by calculating the address