]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - common/board_f.c
CPCI4052: Remove CONFIG_SYS_LONGHELP
[karo-tx-uboot.git] / common / board_f.c
index b54ff2320ee97926ad7cc3ac650260014e7ed2b7..0c9e5d11fafb37cba06ed4bcb5810d9618e59095 100644 (file)
@@ -23,6 +23,8 @@
 #include <i2c.h>
 #include <initcall.h>
 #include <logbuff.h>
+#include <malloc.h>
+#include <mapmem.h>
 
 /* TODO: Can we move these into arch/ headers? */
 #ifdef CONFIG_8xx
@@ -47,7 +49,7 @@
 #include <asm/errno.h>
 #include <asm/io.h>
 #include <asm/sections.h>
-#ifdef CONFIG_X86
+#if defined(CONFIG_X86) || defined(CONFIG_ARC)
 #include <asm/init_helpers.h>
 #include <asm/relocate.h>
 #endif
@@ -71,7 +73,7 @@ DECLARE_GLOBAL_DATA_PTR;
 #endif
 
 /*
- * sjg: IMO this code should be
+ * TODO(sjg@chromium.org): IMO this code should be
  * refactored to a single function, something like:
  *
  * void led_set_state(enum led_colour_t colour, int on);
@@ -111,7 +113,8 @@ 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_SH) || defined(CONFIG_AT91SAM9_WATCHDOG) || \
+       defined(CONFIG_IMX_WATCHDOG))
        hw_watchdog_init();
 # endif
        puts("       Watchdog enabled\n");
@@ -174,7 +177,7 @@ static int announce_dram_init(void)
        return 0;
 }
 
-#if defined(CONFIG_MIPS) || defined(CONFIG_PPC)
+#if defined(CONFIG_MIPS) || defined(CONFIG_PPC) || defined(CONFIG_M68K)
 static int init_func_ram(void)
 {
 #ifdef CONFIG_BOARD_TYPES
@@ -285,49 +288,6 @@ __weak unsigned long get_timer_masked(void)
        return get_timer(0);
 }
 
-#ifdef CONFIG_OF_HOSTFILE
-
-static int read_fdt_from_file(void)
-{
-       struct sandbox_state *state = state_get_current();
-       const char *fname = state->fdt_fname;
-       void *blob;
-       loff_t size;
-       int err;
-       int fd;
-
-       blob = map_sysmem(CONFIG_SYS_FDT_LOAD_ADDR, 0);
-       if (!state->fdt_fname) {
-               err = fdt_create_empty_tree(blob, 256);
-               if (!err)
-                       goto done;
-               printf("Unable to create empty FDT: %s\n", fdt_strerror(err));
-               return -EINVAL;
-       }
-
-       err = os_get_filesize(fname, &size);
-       if (err < 0) {
-               printf("Failed to file FDT file '%s'\n", fname);
-               return err;
-       }
-       fd = os_open(fname, OS_O_RDONLY);
-       if (fd < 0) {
-               printf("Failed to open FDT file '%s'\n", fname);
-               return -EACCES;
-       }
-       if (os_read(fd, blob, size) != size) {
-               os_close(fd);
-               return -EIO;
-       }
-       os_close(fd);
-
-done:
-       gd->fdt_blob = blob;
-
-       return 0;
-}
-#endif
-
 #ifdef CONFIG_SANDBOX
 static int setup_ram_buf(void)
 {
@@ -340,31 +300,21 @@ static int setup_ram_buf(void)
 }
 #endif
 
-static int setup_fdt(void)
-{
-#ifdef CONFIG_OF_CONTROL
-# ifdef CONFIG_OF_EMBED
-       /* Get a pointer to the FDT */
-       gd->fdt_blob = __dtb_dt_begin;
-# elif defined CONFIG_OF_SEPARATE
-       /* FDT is at end of image */
-       gd->fdt_blob = (ulong *)&_end;
-# elif defined(CONFIG_OF_HOSTFILE)
-       if (read_fdt_from_file()) {
-               puts("Failed to read control FDT\n");
-               return -1;
-       }
-# endif
-       /* Allow the early environment to override the fdt address */
-       gd->fdt_blob = (void *)getenv_ulong("fdtcontroladdr", 16,
-                                               (uintptr_t)gd->fdt_blob);
-#endif
-       return 0;
-}
-
 /* Get the top of usable RAM */
 __weak ulong board_get_usable_ram_top(ulong total_size)
 {
+#ifdef CONFIG_SYS_SDRAM_BASE
+       /*
+        * Detect whether we have so much RAM that it goes past the end of our
+        * 32-bit address space. If so, clip the usable RAM so it doesn't.
+        */
+       if (gd->ram_top < CONFIG_SYS_SDRAM_BASE)
+               /*
+                * Will wrap back to top of 32-bit space when reservations
+                * are made.
+                */
+               return 0;
+#endif
        return gd->ram_top;
 }
 
@@ -486,7 +436,7 @@ static int reserve_trace(void)
 
 #if defined(CONFIG_VIDEO) && (!defined(CONFIG_PPC) || defined(CONFIG_8xx)) && \
                !defined(CONFIG_ARM) && !defined(CONFIG_X86) && \
-               !defined(CONFIG_BLACKFIN)
+               !defined(CONFIG_BLACKFIN) && !defined(CONFIG_M68K)
 static int reserve_video(void)
 {
        /* reserve memory for video display (always full pages) */
@@ -562,7 +512,7 @@ static int reserve_global_data(void)
 static int reserve_fdt(void)
 {
        /*
-        * If the device tree is sitting immediate above our image then we
+        * 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
         * will be relocated with other data.
         */
@@ -590,7 +540,7 @@ static int reserve_stacks(void)
        gd->start_addr_sp &= ~0xf;
 
        /*
-        * let the architecture specific code tailor gd->start_addr_sp and
+        * let the architecture-specific code tailor gd->start_addr_sp and
         * gd->irq_sp
         */
        return arch_reserve_stacks();
@@ -603,7 +553,7 @@ static int display_new_sp(void)
        return 0;
 }
 
-#ifdef CONFIG_PPC
+#if defined(CONFIG_PPC) || defined(CONFIG_M68K)
 static int setup_board_part1(void)
 {
        bd_t *bd = gd->bd;
@@ -611,7 +561,6 @@ static int setup_board_part1(void)
        /*
         * Save local variables to board info struct
         */
-
        bd->bi_memstart = CONFIG_SYS_SDRAM_BASE;        /* start of memory */
        bd->bi_memsize = gd->ram_size;                  /* size in bytes */
 
@@ -624,7 +573,7 @@ static int setup_board_part1(void)
                defined(CONFIG_E500) || defined(CONFIG_MPC86xx)
        bd->bi_immr_base = CONFIG_SYS_IMMR;     /* base  of IMMR register     */
 #endif
-#if defined(CONFIG_MPC5xxx)
+#if defined(CONFIG_MPC5xxx) || defined(CONFIG_M68K)
        bd->bi_mbar_base = CONFIG_SYS_MBAR;     /* base of internal registers */
 #endif
 #if defined(CONFIG_MPC83xx)
@@ -653,6 +602,14 @@ static int setup_board_part2(void)
        bd->bi_ipbfreq = gd->arch.ipb_clk;
        bd->bi_pcifreq = gd->pci_clk;
 #endif /* CONFIG_MPC5xxx */
+#if defined(CONFIG_M68K) && defined(CONFIG_PCI)
+       bd->bi_pcifreq = gd->pci_clk;
+#endif
+#if defined(CONFIG_EXTRA_CLOCK)
+       bd->bi_inpfreq = gd->arch.inp_clk;      /* input Freq in Hz */
+       bd->bi_vcofreq = gd->arch.vco_clk;      /* vco Freq in Hz */
+       bd->bi_flbfreq = gd->arch.flb_clk;      /* flexbus Freq in Hz */
+#endif
 
        return 0;
 }
@@ -713,10 +670,16 @@ static int reloc_fdt(void)
 static int setup_reloc(void)
 {
 #ifdef CONFIG_SYS_TEXT_BASE
-#ifndef CONFIG_ARM
-       gd->reloc_off = gd->relocaddr - CONFIG_SYS_TEXT_BASE;
-#else
+#if defined(CONFIG_M68K)
+       /*
+        * On all ColdFire arch cpu, monitor code starts always
+        * just after the default vector table location, so at 0x400
+        */
+       gd->reloc_off = gd->relocaddr - (CONFIG_SYS_TEXT_BASE + 0x400);
+#elif defined(CONFIG_ARM)
        gd->reloc_off = gd->relocaddr - (unsigned long)__image_copy_start;
+#else
+       gd->reloc_off = gd->relocaddr - CONFIG_SYS_TEXT_BASE;
 #endif
 #endif
        memcpy(gd->new_gd, (char *)gd, sizeof(gd_t));
@@ -742,7 +705,7 @@ static int jump_to_copy(void)
         * similarly for all archs. When we do generic relocation, hopefully
         * we can make all archs enable the dcache prior to relocation.
         */
-#ifdef CONFIG_X86
+#if defined(CONFIG_X86) || defined(CONFIG_ARC)
        /*
         * SDRAM and console are now initialised. The final stack can now
         * be setup in SDRAM. Code execution will continue in Flash, but
@@ -766,17 +729,6 @@ static int mark_bootstage(void)
        return 0;
 }
 
-static int initf_malloc(void)
-{
-#ifdef CONFIG_SYS_MALLOC_F_LEN
-       assert(gd->malloc_base);        /* Set up by crt0.S */
-       gd->malloc_limit = gd->malloc_base + CONFIG_SYS_MALLOC_F_LEN;
-       gd->malloc_ptr = 0;
-#endif
-
-       return 0;
-}
-
 static int initf_dm(void)
 {
 #if defined(CONFIG_DM) && defined(CONFIG_SYS_MALLOC_F_LEN)
@@ -796,12 +748,19 @@ __weak int reserve_arch(void)
        return 0;
 }
 
+__weak int arch_cpu_init_dm(void)
+{
+       return 0;
+}
+
 static init_fnc_t init_sequence_f[] = {
 #ifdef CONFIG_SANDBOX
        setup_ram_buf,
 #endif
        setup_mon_len,
-       setup_fdt,
+#ifdef CONFIG_OF_CONTROL
+       fdtdec_setup,
+#endif
 #ifdef CONFIG_TRACE
        trace_early_init,
 #endif
@@ -812,10 +771,8 @@ static init_fnc_t init_sequence_f[] = {
 #endif
        arch_cpu_init,          /* basic arch cpu dependent setup */
        mark_bootstage,
-#ifdef CONFIG_OF_CONTROL
-       fdtdec_check_fdt,
-#endif
        initf_dm,
+       arch_cpu_init_dm,
 #if defined(CONFIG_BOARD_EARLY_INIT_F)
        board_early_init_f,
 #endif
@@ -842,6 +799,9 @@ static init_fnc_t init_sequence_f[] = {
 #endif
 #ifdef CONFIG_FSL_ESDHC
        get_clocks,
+#endif
+#ifdef CONFIG_M68K
+       get_clocks,
 #endif
        env_init,               /* initialize environment */
 #if defined(CONFIG_8xx_CPUCLK_DEFAULT)
@@ -869,7 +829,7 @@ static init_fnc_t init_sequence_f[] = {
 #if defined(CONFIG_MPC83xx)
        prt_83xx_rsr,
 #endif
-#ifdef CONFIG_PPC
+#if defined(CONFIG_PPC) || defined(CONFIG_M68K)
        checkcpu,
 #endif
        print_cpuinfo,          /* display cpu info (and speed) */
@@ -895,7 +855,7 @@ static init_fnc_t init_sequence_f[] = {
 #if defined(CONFIG_ARM) || defined(CONFIG_X86) || defined(CONFIG_MICROBLAZE) || defined(CONFIG_AVR32)
        dram_init,              /* configure available RAM banks */
 #endif
-#if defined(CONFIG_MIPS) || defined(CONFIG_PPC)
+#if defined(CONFIG_MIPS) || defined(CONFIG_PPC) || defined(CONFIG_M68K)
        init_func_ram,
 #endif
 #ifdef CONFIG_POST
@@ -946,7 +906,7 @@ static init_fnc_t init_sequence_f[] = {
        /* 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_BLACKFIN)
+               !defined(CONFIG_BLACKFIN) && !defined(CONFIG_M68K)
        reserve_video,
 #endif
 #if !defined(CONFIG_BLACKFIN) && !defined(CONFIG_NIOS2)
@@ -963,7 +923,7 @@ static init_fnc_t init_sequence_f[] = {
        reserve_stacks,
        setup_dram_config,
        show_dram_config,
-#ifdef CONFIG_PPC
+#if defined(CONFIG_PPC) || defined(CONFIG_M68K)
        setup_board_part1,
        INIT_FUNC_WATCHDOG_RESET
        setup_board_part2,
@@ -975,7 +935,7 @@ static init_fnc_t init_sequence_f[] = {
        INIT_FUNC_WATCHDOG_RESET
        reloc_fdt,
        setup_reloc,
-#ifdef CONFIG_X86
+#if defined(CONFIG_X86) || defined(CONFIG_ARC)
        copy_uboot_to_ram,
        clear_bss,
        do_elf_reloc_fixups,
@@ -1019,7 +979,7 @@ void board_init_f(ulong boot_flags)
 #endif
 }
 
-#ifdef CONFIG_X86
+#if defined(CONFIG_X86) || defined(CONFIG_ARC)
 /*
  * For now this code is only used on x86.
  *
@@ -1053,12 +1013,14 @@ void board_init_f_r(void)
         * Transfer execution from Flash to RAM by calculating the address
         * of the in-RAM copy of board_init_r() and calling it
         */
-       (board_init_r + gd->reloc_off)(gd, gd->relocaddr);
+       (board_init_r + gd->reloc_off)((gd_t *)gd, gd->relocaddr);
 
        /* NOTREACHED - board_init_r() does not return */
        hang();
 }
-#else
+#endif /* CONFIG_X86 */
+
+#ifndef CONFIG_X86
 ulong board_init_f_mem(ulong top)
 {
        /* Leave space for the stack we are running with now */
@@ -1076,4 +1038,4 @@ ulong board_init_f_mem(ulong top)
 
        return top;
 }
-#endif /* CONFIG_X86 */
+#endif /* !CONFIG_X86 */