]> git.sur5r.net Git - u-boot/blobdiff - arch/arm/lib/board.c
arm: fdt: Relocate fdt along with other data
[u-boot] / arch / arm / lib / board.c
index bae2892373e8d81f398c12adb2198a98b4a6630e..99cb54b8d8c88e1ef4a7e81e8a8b72e747169a29 100644 (file)
@@ -73,16 +73,11 @@ extern int  AT91F_DataflashInit(void);
 extern void dataflash_print_info(void);
 #endif
 
-#ifdef CONFIG_DRIVER_RTL8019
-extern void rtl8019_get_enetaddr (uchar * addr);
-#endif
-
 #if defined(CONFIG_HARD_I2C) || \
     defined(CONFIG_SOFT_I2C)
 #include <i2c.h>
 #endif
 
-
 /************************************************************************
  * Coloured LED functionality
  ************************************************************************
@@ -229,10 +224,16 @@ void __dram_init_banksize(void)
 void dram_init_banksize(void)
        __attribute__((weak, alias("__dram_init_banksize")));
 
+int __arch_cpu_init(void)
+{
+       return 0;
+}
+int arch_cpu_init(void)
+       __attribute__((weak, alias("__arch_cpu_init")));
+
 init_fnc_t *init_sequence[] = {
-#if defined(CONFIG_ARCH_CPU_INIT)
        arch_cpu_init,          /* basic arch cpu dependent setup */
-#endif
+
 #if defined(CONFIG_BOARD_EARLY_INIT_F)
        board_early_init_f,
 #endif
@@ -240,6 +241,9 @@ init_fnc_t *init_sequence[] = {
        fdtdec_check_fdt,
 #endif
        timer_init,             /* initialize timer */
+#ifdef CONFIG_BOARD_POSTCLK_INIT
+       board_postclk_init,
+#endif
 #ifdef CONFIG_FSL_ESDHC
        get_clocks,
 #endif
@@ -270,6 +274,10 @@ void board_init_f(ulong bootflag)
 #ifdef CONFIG_PRAM
        ulong reg;
 #endif
+       void *new_fdt = NULL;
+       size_t fdt_size = 0;
+
+       bootstage_mark_name(BOOTSTAGE_ID_START_UBOOT_F, "board_init_f");
 
        /* Pointer is writable since we allocated a register for it */
        gd = (gd_t *) ((CONFIG_SYS_INIT_SP_ADDR) & ~0x07);
@@ -296,6 +304,14 @@ void board_init_f(ulong bootflag)
                }
        }
 
+#ifdef CONFIG_OF_CONTROL
+       /* For now, put this check after the console is ready */
+       if (fdtdec_prepare_fdt()) {
+               panic("** CONFIG_OF_CONTROL defined but no FDT - please see "
+                       "doc/README.fdt-control");
+       }
+#endif
+
        debug("monitor len: %08lX\n", gd->mon_len);
        /*
         * Ram is setup, size stored in gd !!
@@ -395,6 +411,22 @@ void board_init_f(ulong bootflag)
        debug("Reserving %zu Bytes for Global Data at: %08lx\n",
                        sizeof (gd_t), addr_sp);
 
+#if defined(CONFIG_OF_SEPARATE) && defined(CONFIG_OF_CONTROL)
+       /*
+        * If the device tree is sitting immediate above our image then we
+        * must relocate it. If it is embedded in the data section, then it
+        * will be relocated with other data.
+        */
+       if (gd->fdt_blob) {
+               fdt_size = ALIGN(fdt_totalsize(gd->fdt_blob) + 0x1000, 32);
+
+               addr_sp -= fdt_size;
+               new_fdt = (void *)addr_sp;
+               debug("Reserving %zu Bytes for FDT at: %08lx\n",
+                     fdt_size, addr_sp);
+       }
+#endif
+
        /* setup stackpointer for exeptions */
        gd->irq_sp = addr_sp;
 #ifdef CONFIG_USE_IRQ
@@ -428,6 +460,10 @@ void board_init_f(ulong bootflag)
        gd->start_addr_sp = addr_sp;
        gd->reloc_off = addr - _TEXT_BASE;
        debug("relocation Offset is: %08lx\n", gd->reloc_off);
+       if (new_fdt) {
+               memcpy(new_fdt, gd->fdt_blob, fdt_size);
+               gd->fdt_blob = new_fdt;
+       }
        memcpy(id, (void *)gd, sizeof(gd_t));
 
        relocate_code(addr_sp, id, addr);
@@ -460,6 +496,7 @@ void board_init_r(gd_t *id, ulong dest_addr)
        gd = id;
 
        gd->flags |= GD_FLG_RELOC;      /* tell others: relocation done */
+       bootstage_mark_name(BOOTSTAGE_ID_START_UBOOT_R, "board_init_r");
 
        monitor_flash_len = _end_ofs;
 
@@ -468,10 +505,16 @@ void board_init_r(gd_t *id, ulong dest_addr)
 
        debug("monitor flash len: %08lX\n", monitor_flash_len);
        board_init();   /* Setup chipselects */
-
-#ifdef CONFIG_SERIAL_MULTI
-       serial_initialize();
+       /*
+        * TODO: printing of the clock inforamtion of the board is now
+        * implemented as part of bdinfo command. Currently only support for
+        * davinci SOC's is added. Remove this check once all the board
+        * implement this.
+        */
+#ifdef CONFIG_CLOCKS
+       set_cpu_clk_info(); /* Setup clock information */
 #endif
+       serial_initialize();
 
        debug("Now running in RAM - U-Boot at: %08lx\n", dest_addr);
 
@@ -486,6 +529,10 @@ void board_init_r(gd_t *id, ulong dest_addr)
        malloc_start = dest_addr - TOTAL_MALLOC_LEN;
        mem_malloc_init (malloc_start, TOTAL_MALLOC_LEN);
 
+#ifdef CONFIG_ARCH_EARLY_INIT_R
+       arch_early_init_r();
+#endif
+
 #if !defined(CONFIG_SYS_NO_FLASH)
        puts("Flash: ");
 
@@ -541,9 +588,6 @@ void board_init_r(gd_t *id, ulong dest_addr)
        arm_pci_init();
 #endif
 
-       /* IP Address */
-       gd->bd->bi_ip_addr = getenv_IPaddr("ipaddr");
-
        stdio_init();   /* get the devices list going. */
 
        jumptable_init();
@@ -581,16 +625,8 @@ void board_init_r(gd_t *id, ulong dest_addr)
 
        /* Initialize from environment */
        load_addr = getenv_ulong("loadaddr", 16, load_addr);
-#if defined(CONFIG_CMD_NET)
-       {
-               char *s = getenv("bootfile");
-
-               if (s != NULL)
-                       copy_filename(BootFile, s, sizeof(BootFile));
-       }
-#endif
 
-#ifdef BOARD_LATE_INIT
+#ifdef CONFIG_BOARD_LATE_INIT
        board_late_init();
 #endif