]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - common/board_f.c
Blackfin: Remove
[people/ms/u-boot.git] / common / board_f.c
index 725eb18427f7296853c499dc41dcac0e79df6972..224ba09803f159afc1055199a766884dc2624ad3 100644 (file)
@@ -13,6 +13,7 @@
 #include <common.h>
 #include <linux/compiler.h>
 #include <version.h>
+#include <console.h>
 #include <environment.h>
 #include <dm.h>
 #include <fdtdec.h>
 #include <post.h>
 #include <spi.h>
 #include <status_led.h>
+#include <timer.h>
 #include <trace.h>
+#include <video.h>
 #include <watchdog.h>
-#include <asm/errno.h>
+#include <linux/errno.h>
 #include <asm/io.h>
 #include <asm/sections.h>
 #if defined(CONFIG_X86) || defined(CONFIG_ARC)
 #include <asm/init_helpers.h>
+#endif
+#if defined(CONFIG_X86) || defined(CONFIG_ARC) || defined(CONFIG_XTENSA)
 #include <asm/relocate.h>
 #endif
 #ifdef CONFIG_SANDBOX
@@ -111,13 +116,14 @@ __weak void blue_led_off(void) {}
 #if defined(CONFIG_WATCHDOG) || defined(CONFIG_HW_WATCHDOG)
 static int init_func_watchdog_init(void)
 {
-# if defined(CONFIG_HW_WATCHDOG) && (defined(CONFIG_BLACKFIN) || \
-       defined(CONFIG_M68K) || defined(CONFIG_MICROBLAZE) || \
+# if defined(CONFIG_HW_WATCHDOG) && \
+       (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,11 @@ 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_NIOS2) || defined(CONFIG_XTENSA)
        gd->mon_len = CONFIG_SYS_MONITOR_LEN;
-#elif defined(CONFIG_NDS32)
+#elif defined(CONFIG_NDS32) || defined(CONFIG_SH)
        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 +289,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)
 {
@@ -356,6 +364,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,23 +424,63 @@ 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 */
+#  endif /* CONFIG_FB_ADDR */
+
        return 0;
 }
-#endif /* CONFIG_LCD */
+# endif /* CONFIG_LCD */
+
+# if defined(CONFIG_VIDEO) && (!defined(CONFIG_PPC) || defined(CONFIG_8xx)) && \
+               !defined(CONFIG_ARM) && !defined(CONFIG_X86) && \
+               !defined(CONFIG_M68K)
+static int reserve_legacy_video(void)
+{
+       /* reserve memory for video display (always full pages) */
+       gd->relocaddr = video_setmem(gd->relocaddr);
+       gd->fb_base = gd->relocaddr;
+
+       return 0;
+}
+# endif
+#endif /* !CONFIG_DM_VIDEO */
 
 static int reserve_trace(void)
 {
@@ -432,19 +494,6 @@ static int reserve_trace(void)
        return 0;
 }
 
-#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)
-{
-       /* reserve memory for video display (always full pages) */
-       gd->relocaddr = video_setmem(gd->relocaddr);
-       gd->fb_base = gd->relocaddr;
-
-       return 0;
-}
-#endif
-
 static int reserve_uboot(void)
 {
        /*
@@ -509,6 +558,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 +572,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;
 }
@@ -551,7 +602,8 @@ static int display_new_sp(void)
        return 0;
 }
 
-#if defined(CONFIG_PPC) || defined(CONFIG_M68K) || defined(CONFIG_MIPS)
+#if defined(CONFIG_M68K) || defined(CONFIG_MIPS) || defined(CONFIG_PPC) || \
+       defined(CONFIG_SH)
 static int setup_board_part1(void)
 {
        bd_t *bd = gd->bd;
@@ -659,12 +711,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;
 }
@@ -696,8 +750,16 @@ static int setup_reloc(void)
        return 0;
 }
 
+#ifdef CONFIG_OF_BOARD_FIXUP
+static int fix_fdt(void)
+{
+       return board_fix_fdt((void *)gd->fdt_blob);
+}
+#endif
+
 /* ARM calls relocate_code from its crt0.S */
-#if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX)
+#if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX) && \
+               !CONFIG_IS_ENABLED(X86_64)
 
 static int jump_to_copy(void)
 {
@@ -736,6 +798,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 +816,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;
 }
@@ -760,7 +836,7 @@ __weak int arch_cpu_init_dm(void)
        return 0;
 }
 
-static init_fnc_t init_sequence_f[] = {
+static const init_fnc_t init_sequence_f[] = {
 #ifdef CONFIG_SANDBOX
        setup_ram_buf,
 #endif
@@ -772,17 +848,15 @@ static init_fnc_t init_sequence_f[] = {
        trace_early_init,
 #endif
        initf_malloc,
-#if defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx)
-       /* TODO: can this go into arch_cpu_init()? */
-       probecpu,
-#endif
+       initf_console_record,
 #if defined(CONFIG_X86) && defined(CONFIG_HAVE_FSP)
        x86_fsp_init,
 #endif
        arch_cpu_init,          /* basic arch cpu dependent setup */
-       mark_bootstage,
+       mach_cpu_init,          /* SoC/machine dependent CPU setup */
        initf_dm,
        arch_cpu_init_dm,
+       mark_bootstage,         /* need timer, go after init dm */
 #if defined(CONFIG_BOARD_EARLY_INIT_F)
        board_early_init_f,
 #endif
@@ -797,21 +871,14 @@ static init_fnc_t init_sequence_f[] = {
        init_timebase,
 #endif
 #if defined(CONFIG_ARM) || defined(CONFIG_MIPS) || \
-               defined(CONFIG_BLACKFIN) || defined(CONFIG_NDS32)
+               defined(CONFIG_NDS32) || defined(CONFIG_SH) || \
+               defined(CONFIG_SPARC)
        timer_init,             /* initialize timer */
 #endif
-#ifdef CONFIG_SYS_ALLOC_DPRAM
-#if !defined(CONFIG_CPM2)
-       dpram_init,
-#endif
-#endif
 #if defined(CONFIG_BOARD_POSTCLK_INIT)
        board_postclk_init,
 #endif
-#ifdef CONFIG_SYS_FSL_CLK
-       get_clocks,
-#endif
-#ifdef CONFIG_M68K
+#if defined(CONFIG_SYS_FSL_CLK) || defined(CONFIG_M68K)
        get_clocks,
 #endif
        env_init,               /* initialize environment */
@@ -827,9 +894,6 @@ static init_fnc_t init_sequence_f[] = {
        console_init_f,         /* stage 1 init of console */
 #ifdef CONFIG_SANDBOX
        sandbox_early_getopt_check,
-#endif
-#ifdef CONFIG_OF_CONTROL
-       fdtdec_prepare_fdt,
 #endif
        display_options,        /* say that we are here */
        display_text_info,      /* show debugging info if required */
@@ -840,13 +904,12 @@ static init_fnc_t init_sequence_f[] = {
 #if defined(CONFIG_MPC83xx)
        prt_83xx_rsr,
 #endif
-#if defined(CONFIG_PPC) || defined(CONFIG_M68K)
+#if defined(CONFIG_PPC) || defined(CONFIG_M68K) || defined(CONFIG_SH)
        checkcpu,
 #endif
+#if defined(CONFIG_DISPLAY_CPUINFO)
        print_cpuinfo,          /* display cpu info (and speed) */
-#if defined(CONFIG_MPC5xxx)
-       prt_mpc5xxx_clks,
-#endif /* CONFIG_MPC5xxx */
+#endif
 #if defined(CONFIG_DISPLAY_BOARDINFO)
        show_board_info,
 #endif
@@ -864,7 +927,8 @@ static init_fnc_t init_sequence_f[] = {
        announce_dram_init,
        /* TODO: unify all these dram functions? */
 #if defined(CONFIG_ARM) || defined(CONFIG_X86) || defined(CONFIG_NDS32) || \
-               defined(CONFIG_MICROBLAZE) || defined(CONFIG_AVR32)
+               defined(CONFIG_MICROBLAZE) || defined(CONFIG_AVR32) || \
+               defined(CONFIG_SH)
        dram_init,              /* configure available RAM banks */
 #endif
 #if defined(CONFIG_MIPS) || defined(CONFIG_PPC) || defined(CONFIG_M68K)
@@ -896,10 +960,13 @@ static init_fnc_t init_sequence_f[] = {
         *  - board info struct
         */
        setup_dest_addr,
-#if defined(CONFIG_BLACKFIN)
+#if 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
@@ -911,17 +978,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)
+               !defined(CONFIG_M68K)
+       reserve_legacy_video,
+# endif
+#endif /* CONFIG_DM_VIDEO */
+       reserve_trace,
+#if !defined(CONFIG_XTENSA)
        reserve_uboot,
 #endif
 #ifndef CONFIG_SPL_BUILD
@@ -935,7 +1006,8 @@ static init_fnc_t init_sequence_f[] = {
        reserve_stacks,
        setup_dram_config,
        show_dram_config,
-#if defined(CONFIG_PPC) || defined(CONFIG_M68K) || defined(CONFIG_MIPS)
+#if defined(CONFIG_M68K) || defined(CONFIG_MIPS) || defined(CONFIG_PPC) || \
+       defined(CONFIG_SH)
        setup_board_part1,
 #endif
 #if defined(CONFIG_PPC) || defined(CONFIG_M68K)
@@ -945,16 +1017,23 @@ static init_fnc_t init_sequence_f[] = {
        display_new_sp,
 #ifdef CONFIG_SYS_EXTBDINFO
        setup_board_extra,
+#endif
+#ifdef CONFIG_OF_BOARD_FIXUP
+       fix_fdt,
 #endif
        INIT_FUNC_WATCHDOG_RESET
        reloc_fdt,
        setup_reloc,
 #if defined(CONFIG_X86) || defined(CONFIG_ARC)
        copy_uboot_to_ram,
-       clear_bss,
        do_elf_reloc_fixups,
+       clear_bss,
+#endif
+#if defined(CONFIG_XTENSA)
+       clear_bss,
 #endif
-#if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX)
+#if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX) && \
+               !CONFIG_IS_ENABLED(X86_64)
        jump_to_copy,
 #endif
        NULL,
@@ -964,7 +1043,7 @@ void board_init_f(ulong boot_flags)
 {
 #ifdef CONFIG_SYS_GENERIC_GLOBAL_DATA
        /*
-        * For some archtectures, global data is initialized and used before
+        * For some architectures, global data is initialized and used before
         * calling this function. The data should be preserved. For others,
         * CONFIG_SYS_GENERIC_GLOBAL_DATA should be defined and use the stack
         * here to host global data until relocation.
@@ -976,7 +1055,7 @@ void board_init_f(ulong boot_flags)
        /*
         * Clear global data before it is accessed at debug print
         * in initcall_run_list. Otherwise the debug print probably
-        * get the wrong vaule of gd->have_console.
+        * get the wrong value of gd->have_console.
         */
        zero_global_data();
 #endif
@@ -988,7 +1067,7 @@ void board_init_f(ulong boot_flags)
                hang();
 
 #if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX) && \
-               !defined(CONFIG_EFI_APP)
+               !defined(CONFIG_EFI_APP) && !CONFIG_IS_ENABLED(X86_64)
        /* NOTREACHED - jump_to_copy() does not return */
        hang();
 #endif
@@ -1012,8 +1091,10 @@ void board_init_f(ulong boot_flags)
  * NOTE: At present only x86 uses this route, but it is intended that
  * all archs will move to this when generic relocation is implemented.
  */
-static init_fnc_t init_sequence_f_r[] = {
+static const init_fnc_t init_sequence_f_r[] = {
+#if !CONFIG_IS_ENABLED(X86_64)
        init_cache_f_r,
+#endif
 
        NULL,
 };
@@ -1023,6 +1104,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