]> git.sur5r.net Git - u-boot/blobdiff - arch/arm/lib/board.c
arm: Move fdt check earlier so that board_early_init_f() can use it
[u-boot] / arch / arm / lib / board.c
index 024646cae5a7e8f8d459c620fe595e19e7484a4d..864b53380b04490ab184ed2f1b2af4dcb0e5b23e 100644 (file)
 #include <miiphy.h>
 #endif
 
-#ifdef CONFIG_DRIVER_SMC91111
-#include "../drivers/net/smc91111.h"
-#endif
-#ifdef CONFIG_DRIVER_LAN91C96
-#include "../drivers/net/lan91c96.h"
-#endif
-
 DECLARE_GLOBAL_DATA_PTR;
 
 ulong monitor_flash_len;
@@ -224,17 +217,32 @@ 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")));
+
+int __power_init_board(void)
+{
+       return 0;
+}
+int power_init_board(void)
+       __attribute__((weak, alias("__power_init_board")));
+
 init_fnc_t *init_sequence[] = {
-#if defined(CONFIG_ARCH_CPU_INIT)
        arch_cpu_init,          /* basic arch cpu dependent setup */
+#ifdef CONFIG_OF_CONTROL
+       fdtdec_check_fdt,
 #endif
 #if defined(CONFIG_BOARD_EARLY_INIT_F)
        board_early_init_f,
-#endif
-#ifdef CONFIG_OF_CONTROL
-       fdtdec_check_fdt,
 #endif
        timer_init,             /* initialize timer */
+#ifdef CONFIG_BOARD_POSTCLK_INIT
+       board_postclk_init,
+#endif
 #ifdef CONFIG_FSL_ESDHC
        get_clocks,
 #endif
@@ -265,14 +273,11 @@ 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);
-       /* compiler optimization barrier needed for GCC >= 3.4 */
-       __asm__ __volatile__("": : :"memory");
-
        memset((void *)gd, 0, sizeof(gd_t));
 
        gd->mon_len = _bss_end_ofs;
@@ -342,13 +347,14 @@ void board_init_f(ulong bootflag)
 
 #if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF))
        /* reserve TLB table */
-       addr -= (4096 * 4);
+       gd->tlb_size = 4096 * 4;
+       addr -= gd->tlb_size;
 
        /* round down to next 64 kB limit */
        addr &= ~(0x10000 - 1);
 
        gd->tlb_addr = addr;
-       debug("TLB table at: %08lx\n", addr);
+       debug("TLB table from %08lx to %08lx\n", addr, addr + gd->tlb_size);
 #endif
 
        /* round down to next 4 kB limit */
@@ -400,6 +406,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
@@ -433,11 +455,11 @@ 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);
-
-       /* NOTREACHED - relocate_code() does not return */
 }
 
 #if !defined(CONFIG_SYS_NO_FLASH)
@@ -462,8 +484,6 @@ void board_init_r(gd_t *id, ulong dest_addr)
        ulong flash_size;
 #endif
 
-       gd = id;
-
        gd->flags |= GD_FLG_RELOC;      /* tell others: relocation done */
        bootstage_mark_name(BOOTSTAGE_ID_START_UBOOT_R, "board_init_r");
 
@@ -483,9 +503,7 @@ void board_init_r(gd_t *id, ulong dest_addr)
 #ifdef CONFIG_CLOCKS
        set_cpu_clk_info(); /* Setup clock information */
 #endif
-#ifdef CONFIG_SERIAL_MULTI
        serial_initialize();
-#endif
 
        debug("Now running in RAM - U-Boot at: %08lx\n", dest_addr);
 
@@ -500,21 +518,24 @@ 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
+       power_init_board();
+
 #if !defined(CONFIG_SYS_NO_FLASH)
        puts("Flash: ");
 
        flash_size = flash_init();
        if (flash_size > 0) {
 # ifdef CONFIG_SYS_FLASH_CHECKSUM
-               char *s = getenv("flashchecksum");
-
                print_size(flash_size, "");
                /*
                 * Compute and print flash CRC if flashchecksum is set to 'y'
                 *
                 * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
                 */
-               if (s && (*s == 'y')) {
+               if (getenv_yesno("flashchecksum") == 1) {
                        printf("  CRC: %08X", crc32(0,
                                (const unsigned char *) CONFIG_SYS_FLASH_BASE,
                                flash_size));
@@ -580,16 +601,6 @@ void board_init_r(gd_t *id, ulong dest_addr)
        /* enable exceptions */
        enable_interrupts();
 
-       /* Perform network card initialisation if necessary */
-#if defined(CONFIG_DRIVER_SMC91111) || defined (CONFIG_DRIVER_LAN91C96)
-       /* XXX: this needs to be moved to board init */
-       if (getenv("ethaddr")) {
-               uchar enetaddr[6];
-               eth_getenv_enetaddr("ethaddr", enetaddr);
-               smc_set_mac_addr(enetaddr);
-       }
-#endif /* CONFIG_DRIVER_SMC91111 || CONFIG_DRIVER_LAN91C96 */
-
        /* Initialize from environment */
        load_addr = getenv_ulong("loadaddr", 16, load_addr);