powerpc, 8xx: remove support for 8xx
[oweals/u-boot.git] / common / board_f.c
index b8c0514b0deaa41e547722ae85a9f59e62834ed1..a3f87043e275b7e602b7084cf60915afa146a147 100644 (file)
  */
 
 #include <common.h>
-#include <linux/compiler.h>
-#include <version.h>
 #include <console.h>
 #include <environment.h>
 #include <dm.h>
 #include <fdtdec.h>
 #include <fs.h>
-#if defined(CONFIG_CMD_IDE)
-#include <ide.h>
-#endif
 #include <i2c.h>
 #include <initcall.h>
+#include <init_helpers.h>
 #include <logbuff.h>
 #include <malloc.h>
 #include <mapmem.h>
-
-/* TODO: Can we move these into arch/ headers? */
-#ifdef CONFIG_8xx
-#include <mpc8xx.h>
-#endif
-#ifdef CONFIG_5xx
-#include <mpc5xx.h>
-#endif
-#ifdef CONFIG_MPC5xxx
-#include <mpc5xxx.h>
-#endif
-#if defined(CONFIG_MP) && (defined(CONFIG_MPC86xx) || defined(CONFIG_E500))
-#include <asm/mp.h>
-#endif
-
 #include <os.h>
 #include <post.h>
+#include <relocate.h>
 #include <spi.h>
 #include <status_led.h>
 #include <timer.h>
 #include <trace.h>
 #include <video.h>
 #include <watchdog.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>
+#ifdef CONFIG_MACH_TYPE
+#include <asm/mach-types.h>
 #endif
-#if defined(CONFIG_X86) || defined(CONFIG_ARC) || defined(CONFIG_XTENSA)
-#include <asm/relocate.h>
+#if defined(CONFIG_MP) && defined(CONFIG_PPC)
+#include <asm/mp.h>
 #endif
+#include <asm/io.h>
+#include <asm/sections.h>
 #include <dm/root.h>
-#include <linux/compiler.h>
+#include <linux/errno.h>
 
 /*
  * Pointer to initial global data area
@@ -106,10 +87,6 @@ __weak void blue_led_off(void) {}
  * a structure...
  */
 
-/*
- * Could the CONFIG_SPL_BUILD infection become a flag in gd?
- */
-
 #if defined(CONFIG_WATCHDOG) || defined(CONFIG_HW_WATCHDOG)
 static int init_func_watchdog_init(void)
 {
@@ -163,11 +140,6 @@ static int display_text_info(void)
                text_base, bss_start, bss_end);
 #endif
 
-#ifdef CONFIG_USE_IRQ
-       debug("IRQ Stack: %08lx\n", IRQ_STACK_START);
-       debug("FIQ Stack: %08lx\n", FIQ_STACK_START);
-#endif
-
        return 0;
 }
 
@@ -177,25 +149,6 @@ static int announce_dram_init(void)
        return 0;
 }
 
-#if defined(CONFIG_MIPS) || defined(CONFIG_PPC) || defined(CONFIG_M68K)
-static int init_func_ram(void)
-{
-#ifdef CONFIG_BOARD_TYPES
-       int board_type = gd->board_type;
-#else
-       int board_type = 0;     /* use dummy arg */
-#endif
-
-       gd->ram_size = initdram(board_type);
-
-       if (gd->ram_size > 0)
-               return 0;
-
-       puts("*** failed ***\n");
-       return 1;
-}
-#endif
-
 static int show_dram_config(void)
 {
        unsigned long long size;
@@ -224,15 +177,17 @@ static int show_dram_config(void)
        return 0;
 }
 
-__weak void dram_init_banksize(void)
+__weak int dram_init_banksize(void)
 {
 #if defined(CONFIG_NR_DRAM_BANKS) && defined(CONFIG_SYS_SDRAM_BASE)
        gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
        gd->bd->bi_dram[0].size = get_effective_memsize();
 #endif
+
+       return 0;
 }
 
-#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SYS_I2C)
+#if defined(CONFIG_SYS_I2C)
 static int init_func_i2c(void)
 {
        puts("I2C:   ");
@@ -349,13 +304,16 @@ static int setup_dest_addr(void)
        return 0;
 }
 
-#if defined(CONFIG_LOGBUFFER) && !defined(CONFIG_ALT_LB_ADDR)
+#if defined(CONFIG_LOGBUFFER)
 static int reserve_logbuffer(void)
 {
+#ifndef CONFIG_ALT_LB_ADDR
        /* reserve kernel log buffer */
        gd->relocaddr -= LOGBUFF_RESERVE;
        debug("Reserving %dk for kernel logbuffer at %08lx\n", LOGBUFF_LEN,
                gd->relocaddr);
+#endif
+
        return 0;
 }
 #endif
@@ -381,10 +339,10 @@ static int reserve_round_4k(void)
        return 0;
 }
 
-#if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF)) && \
-               defined(CONFIG_ARM)
+#ifdef CONFIG_ARM
 static int reserve_mmu(void)
 {
+#if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF))
        /* reserve TLB table */
        gd->arch.tlb_size = PGTABLE_SIZE;
        gd->relocaddr -= gd->arch.tlb_size;
@@ -402,15 +360,16 @@ static int reserve_mmu(void)
         * with location within secure ram.
         */
        gd->arch.tlb_allocated = gd->arch.tlb_addr;
+#endif
 #endif
 
        return 0;
 }
 #endif
 
-#ifdef CONFIG_DM_VIDEO
 static int reserve_video(void)
 {
+#ifdef CONFIG_DM_VIDEO
        ulong addr;
        int ret;
 
@@ -419,14 +378,7 @@ static int reserve_video(void)
        if (ret)
                return ret;
        gd->relocaddr = addr;
-
-       return 0;
-}
-#else
-
-# ifdef CONFIG_LCD
-static int reserve_lcd(void)
-{
+#elif defined(CONFIG_LCD)
 #  ifdef CONFIG_FB_ADDR
        gd->fb_base = CONFIG_FB_ADDR;
 #  else
@@ -434,24 +386,17 @@ static int reserve_lcd(void)
        gd->relocaddr = lcd_setmem(gd->relocaddr);
        gd->fb_base = gd->relocaddr;
 #  endif /* CONFIG_FB_ADDR */
-
-       return 0;
-}
-# endif /* CONFIG_LCD */
-
-# if defined(CONFIG_VIDEO) && (!defined(CONFIG_PPC) || defined(CONFIG_8xx)) && \
+#elif defined(CONFIG_VIDEO) && \
+               (!defined(CONFIG_PPC)) && \
                !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;
+#endif
 
        return 0;
 }
-# endif
-#endif /* !CONFIG_DM_VIDEO */
 
 static int reserve_trace(void)
 {
@@ -486,7 +431,6 @@ static int reserve_uboot(void)
        return 0;
 }
 
-#ifndef CONFIG_SPL_BUILD
 /* reserve memory for malloc() area */
 static int reserve_malloc(void)
 {
@@ -508,7 +452,6 @@ static int reserve_board(void)
        }
        return 0;
 }
-#endif
 
 static int setup_machine(void)
 {
@@ -548,6 +491,20 @@ static int reserve_fdt(void)
        return 0;
 }
 
+static int reserve_bootstage(void)
+{
+#ifdef CONFIG_BOOTSTAGE
+       int size = bootstage_get_size();
+
+       gd->start_addr_sp -= size;
+       gd->new_bootstage = map_sysmem(gd->start_addr_sp, size);
+       debug("Reserving %#x Bytes for bootstage at: %08lx\n", size,
+             gd->start_addr_sp);
+#endif
+
+       return 0;
+}
+
 int arch_reserve_stacks(void)
 {
        return 0;
@@ -590,7 +547,7 @@ static int setup_board_part1(void)
        bd->bi_sramsize = CONFIG_SYS_SRAM_SIZE;         /* size  of SRAM */
 #endif
 
-#if defined(CONFIG_8xx) || defined(CONFIG_MPC8260) || defined(CONFIG_5xx) || \
+#if defined(CONFIG_MPC8260) || defined(CONFIG_5xx) || \
                defined(CONFIG_E500) || defined(CONFIG_MPC86xx)
        bd->bi_immr_base = CONFIG_SYS_IMMR;     /* base  of IMMR register     */
 #endif
@@ -638,30 +595,6 @@ static int setup_board_part2(void)
 }
 #endif
 
-#ifdef CONFIG_SYS_EXTBDINFO
-static int setup_board_extra(void)
-{
-       bd_t *bd = gd->bd;
-
-       strncpy((char *) bd->bi_s_version, "1.2", sizeof(bd->bi_s_version));
-       strncpy((char *) bd->bi_r_version, U_BOOT_VERSION,
-               sizeof(bd->bi_r_version));
-
-       bd->bi_procfreq = gd->cpu_clk;  /* Processor Speed, In Hz */
-       bd->bi_plb_busfreq = gd->bus_clk;
-#if defined(CONFIG_405GP) || defined(CONFIG_405EP) || \
-               defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
-               defined(CONFIG_440EPX) || defined(CONFIG_440GRX)
-       bd->bi_pci_busfreq = get_PCI_freq();
-       bd->bi_opbfreq = get_OPB_freq();
-#elif defined(CONFIG_XILINX_405)
-       bd->bi_pci_busfreq = get_PCI_freq();
-#endif
-
-       return 0;
-}
-#endif
-
 #ifdef CONFIG_POST
 static int init_post(void)
 {
@@ -672,14 +605,6 @@ static int init_post(void)
 }
 #endif
 
-static int setup_dram_config(void)
-{
-       /* Ram is board specific, so move it to board code ... */
-       dram_init_banksize();
-
-       return 0;
-}
-
 static int reloc_fdt(void)
 {
 #ifndef CONFIG_OF_EMBED
@@ -694,6 +619,24 @@ static int reloc_fdt(void)
        return 0;
 }
 
+static int reloc_bootstage(void)
+{
+#ifdef CONFIG_BOOTSTAGE
+       if (gd->flags & GD_FLG_SKIP_RELOC)
+               return 0;
+       if (gd->new_bootstage) {
+               int size = bootstage_get_size();
+
+               debug("Copying bootstage from %p to %p, size %x\n",
+                     gd->bootstage, gd->new_bootstage, size);
+               memcpy(gd->new_bootstage, gd->bootstage, size);
+               gd->bootstage = gd->new_bootstage;
+       }
+#endif
+
+       return 0;
+}
+
 static int setup_reloc(void)
 {
        if (gd->flags & GD_FLG_SKIP_RELOC) {
@@ -762,8 +705,29 @@ static int jump_to_copy(void)
 #endif
 
 /* Record the board_init_f() bootstage (after arch_cpu_init()) */
-static int mark_bootstage(void)
+static int initf_bootstage(void)
 {
+#if defined(CONFIG_SPL_BOOTSTAGE) && defined(CONFIG_BOOTSTAGE_STASH)
+       bool from_spl = true;
+#else
+       bool from_spl = false;
+#endif
+       int ret;
+
+       ret = bootstage_init(!from_spl);
+       if (ret)
+               return ret;
+       if (from_spl) {
+               const void *stash = map_sysmem(CONFIG_BOOTSTAGE_STASH_ADDR,
+                                              CONFIG_BOOTSTAGE_STASH_SIZE);
+
+               ret = bootstage_unstash(stash, CONFIG_BOOTSTAGE_STASH_SIZE);
+               if (ret && ret != -ENOENT) {
+                       debug("Failed to unstash bootstage: err=%d\n", ret);
+                       return ret;
+               }
+       }
+
        bootstage_mark_name(BOOTSTAGE_ID_START_UBOOT_F, "board_init_f");
 
        return 0;
@@ -783,7 +747,9 @@ static int initf_dm(void)
 #if defined(CONFIG_DM) && defined(CONFIG_SYS_MALLOC_F_LEN)
        int ret;
 
+       bootstage_start(BOOTSTATE_ID_ACCUM_DM_F, "dm_f");
        ret = dm_init_and_scan(true);
+       bootstage_accum(BOOTSTATE_ID_ACCUM_DM_F);
        if (ret)
                return ret;
 #endif
@@ -816,6 +782,7 @@ static const init_fnc_t init_sequence_f[] = {
        trace_early_init,
 #endif
        initf_malloc,
+       initf_bootstage,        /* uses its own timer, so does not need DM */
        initf_console_record,
 #if defined(CONFIG_HAVE_FSP)
        arch_fsp_init,
@@ -824,54 +791,27 @@ static const init_fnc_t init_sequence_f[] = {
        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
-       /* TODO: can any of this go into arch_cpu_init()? */
-#if defined(CONFIG_PPC) && !defined(CONFIG_8xx_CPUCLK_DEFAULT)
+#if defined(CONFIG_PPC) || defined(CONFIG_SYS_FSL_CLK) || defined(CONFIG_M68K)
+       /* get CPU and bus clocks according to the environment variable */
        get_clocks,             /* get CPU and bus clocks (etc.) */
-#if defined(CONFIG_TQM8xxL) && !defined(CONFIG_TQM866M) \
-               && !defined(CONFIG_TQM885D)
-       adjust_sdram_tbs_8xx,
-#endif
-       /* TODO: can we rename this to timer_init()? */
-       init_timebase,
 #endif
-#if defined(CONFIG_ARM) || defined(CONFIG_MIPS) || \
-               defined(CONFIG_NDS32) || defined(CONFIG_SH)
+#if !defined(CONFIG_M68K)
        timer_init,             /* initialize timer */
 #endif
 #if defined(CONFIG_BOARD_POSTCLK_INIT)
        board_postclk_init,
-#endif
-#if defined(CONFIG_SYS_FSL_CLK) || defined(CONFIG_M68K)
-       get_clocks,
 #endif
        env_init,               /* initialize environment */
-#if defined(CONFIG_8xx_CPUCLK_DEFAULT)
-       /* get CPU and bus clocks according to the environment variable */
-       get_clocks_866,
-       /* adjust sdram refresh rate according to the new clock */
-       sdram_adjust_866,
-       init_timebase,
-#endif
        init_baud_rate,         /* initialze baudrate settings */
        serial_init,            /* serial communications setup */
        console_init_f,         /* stage 1 init of console */
-#ifdef CONFIG_SANDBOX
-       sandbox_early_getopt_check,
-#endif
        display_options,        /* say that we are here */
        display_text_info,      /* show debugging info if required */
-#if defined(CONFIG_MPC8260)
-       prt_8260_rsr,
-       prt_8260_clks,
-#endif /* CONFIG_MPC8260 */
-#if defined(CONFIG_MPC83xx)
-       prt_83xx_rsr,
-#endif
-#if defined(CONFIG_PPC) || defined(CONFIG_M68K) || defined(CONFIG_SH)
+#if defined(CONFIG_PPC) || defined(CONFIG_M68K) || defined(CONFIG_SH) || \
+               defined(CONFIG_X86)
        checkcpu,
 #endif
 #if defined(CONFIG_DISPLAY_CPUINFO)
@@ -885,22 +825,14 @@ static const init_fnc_t init_sequence_f[] = {
        misc_init_f,
 #endif
        INIT_FUNC_WATCHDOG_RESET
-#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SYS_I2C)
+#if defined(CONFIG_SYS_I2C)
        init_func_i2c,
 #endif
 #if defined(CONFIG_HARD_SPI)
        init_func_spi,
 #endif
        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_SH)
        dram_init,              /* configure available RAM banks */
-#endif
-#if defined(CONFIG_MIPS) || defined(CONFIG_PPC) || defined(CONFIG_M68K)
-       init_func_ram,
-#endif
 #ifdef CONFIG_POST
        post_init_f,
 #endif
@@ -927,48 +859,28 @@ static const init_fnc_t init_sequence_f[] = {
         *  - board info struct
         */
        setup_dest_addr,
-#if defined(CONFIG_XTENSA)
-       /* Blackfin u-boot monitor should be on top of the ram */
-       reserve_uboot,
-#endif
-#if defined(CONFIG_LOGBUFFER) && !defined(CONFIG_ALT_LB_ADDR)
+#if defined(CONFIG_LOGBUFFER)
        reserve_logbuffer,
 #endif
 #ifdef CONFIG_PRAM
        reserve_pram,
 #endif
        reserve_round_4k,
-#if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF)) && \
-               defined(CONFIG_ARM)
+#ifdef CONFIG_ARM
        reserve_mmu,
 #endif
-#ifdef CONFIG_DM_VIDEO
        reserve_video,
-#else
-# ifdef CONFIG_LCD
-       reserve_lcd,
-# endif
-       /* TODO: Why the dependency on CONFIG_8xx? */
-# if defined(CONFIG_VIDEO) && (!defined(CONFIG_PPC) || defined(CONFIG_8xx)) && \
-               !defined(CONFIG_ARM) && !defined(CONFIG_X86) && \
-               !defined(CONFIG_M68K)
-       reserve_legacy_video,
-# endif
-#endif /* CONFIG_DM_VIDEO */
        reserve_trace,
-#if !defined(CONFIG_XTENSA)
        reserve_uboot,
-#endif
-#ifndef CONFIG_SPL_BUILD
        reserve_malloc,
        reserve_board,
-#endif
        setup_machine,
        reserve_global_data,
        reserve_fdt,
+       reserve_bootstage,
        reserve_arch,
        reserve_stacks,
-       setup_dram_config,
+       dram_init_banksize,
        show_dram_config,
 #if defined(CONFIG_M68K) || defined(CONFIG_MIPS) || defined(CONFIG_PPC) || \
        defined(CONFIG_SH)
@@ -987,6 +899,7 @@ static const init_fnc_t init_sequence_f[] = {
 #endif
        INIT_FUNC_WATCHDOG_RESET
        reloc_fdt,
+       reloc_bootstage,
        setup_reloc,
 #if defined(CONFIG_X86) || defined(CONFIG_ARC)
        copy_uboot_to_ram,