]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - common/board_f.c
sniper: Serial number support, obtained from die ID
[karo-tx-uboot.git] / common / board_f.c
index ad2eda796a38eb798fdc4edd2186319dae3aeb86..dbbfbed39775c2628b3370bb9b4c38802baf5fdf 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);
@@ -142,7 +144,7 @@ static int init_baud_rate(void)
 
 static int display_text_info(void)
 {
-#ifndef CONFIG_SANDBOX
+#if !defined(CONFIG_SANDBOX) && !defined(CONFIG_EFI_APP)
        ulong bss_start, bss_end, text_base;
 
        bss_start = (ulong)&__bss_start;
@@ -265,7 +267,7 @@ static int setup_mon_len(void)
 {
 #if defined(__ARM__) || defined(__MICROBLAZE__)
        gd->mon_len = (ulong)&__bss_end - (ulong)_start;
-#elif defined(CONFIG_SANDBOX)
+#elif defined(CONFIG_SANDBOX) || defined(CONFIG_EFI_APP)
        gd->mon_len = (ulong)&_end - (ulong)_init;
 #elif defined(CONFIG_BLACKFIN) || defined(CONFIG_NIOS2)
        gd->mon_len = CONFIG_SYS_MONITOR_LEN;
@@ -286,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)
 {
@@ -341,34 +300,12 @@ 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 it goes past the end of our
+        * 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)
@@ -575,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.
         */
@@ -603,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();
@@ -624,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 */
 
@@ -723,6 +659,8 @@ static int setup_dram_config(void)
 
 static int reloc_fdt(void)
 {
+       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;
@@ -733,6 +671,11 @@ static int reloc_fdt(void)
 
 static int setup_reloc(void)
 {
+       if (gd->flags & GD_FLG_SKIP_RELOC) {
+               debug("Skipping relocation due to flag\n");
+               return 0;
+       }
+
 #ifdef CONFIG_SYS_TEXT_BASE
 #if defined(CONFIG_M68K)
        /*
@@ -744,6 +687,7 @@ static int setup_reloc(void)
        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));
 
@@ -760,6 +704,8 @@ static int setup_reloc(void)
 
 static int jump_to_copy(void)
 {
+       if (gd->flags & GD_FLG_SKIP_RELOC)
+               return 0;
        /*
         * x86 is special, but in a nice way. It uses a trampoline which
         * enables the dcache if possible.
@@ -768,7 +714,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
@@ -792,17 +738,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)
@@ -822,12 +757,22 @@ __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
+#if defined(CONFIG_X86) && defined(CONFIG_HAVE_FSP)
+       x86_fsp_init,
+#endif
 #ifdef CONFIG_TRACE
        trace_early_init,
 #endif
@@ -838,10 +783,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
@@ -1004,7 +947,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,
@@ -1042,13 +985,14 @@ void board_init_f(ulong boot_flags)
        if (initcall_run_list(init_sequence_f))
                hang();
 
-#if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX)
+#if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX) && \
+               !defined(CONFIG_EFI_APP)
        /* NOTREACHED - jump_to_copy() does not return */
        hang();
 #endif
 }
 
-#ifdef CONFIG_X86
+#if defined(CONFIG_X86) || defined(CONFIG_ARC)
 /*
  * For now this code is only used on x86.
  *