]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - common/board_r.c
common/board_r: manual relocation for cmd table
[karo-tx-uboot.git] / common / board_r.c
index 602a239380d02951793b1d6cb34cc1c5be686f37..f7a3b55193f2829ff3913560c048b624a7d32171 100644 (file)
@@ -60,7 +60,7 @@ DECLARE_GLOBAL_DATA_PTR;
 
 ulong monitor_flash_len;
 
-int __board_flash_wp_on(void)
+__weak int board_flash_wp_on(void)
 {
        /*
         * Most flashes can't be detected when write protection is enabled,
@@ -70,16 +70,10 @@ int __board_flash_wp_on(void)
        return 0;
 }
 
-int board_flash_wp_on(void)
-       __attribute__ ((weak, alias("__board_flash_wp_on")));
-
-void __cpu_secondary_init_r(void)
+__weak void cpu_secondary_init_r(void)
 {
 }
 
-void cpu_secondary_init_r(void)
-       __attribute__ ((weak, alias("__cpu_secondary_init_r")));
-
 static int initr_secondary_cpu(void)
 {
        /*
@@ -105,7 +99,8 @@ static int initr_trace(void)
 
 static int initr_reloc(void)
 {
-       gd->flags |= GD_FLG_RELOC;      /* tell others: relocation done */
+       /* tell others: relocation done */
+       gd->flags |= GD_FLG_RELOC | GD_FLG_FULL_MALLOC_INIT;
        bootstage_mark_name(BOOTSTAGE_ID_START_UBOOT_R, "board_init_r");
 
        return 0;
@@ -133,7 +128,7 @@ static int initr_reloc_global_data(void)
 {
 #ifdef __ARM__
        monitor_flash_len = _end - __image_copy_start;
-#elif !defined(CONFIG_SANDBOX)
+#elif !defined(CONFIG_SANDBOX) && !defined(CONFIG_NIOS2)
        monitor_flash_len = (ulong)&__init_end - gd->relocaddr;
 #endif
 #if defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx)
@@ -259,6 +254,10 @@ static int initr_malloc(void)
 {
        ulong malloc_start;
 
+#ifdef CONFIG_SYS_MALLOC_F_LEN
+       debug("Pre-reloc malloc() used %#lx bytes (%ld KB)\n", gd->malloc_ptr,
+             gd->malloc_ptr / 1024);
+#endif
        /* The malloc area is immediately below the monitor copy in DRAM */
        malloc_start = gd->relocaddr - TOTAL_MALLOC_LEN;
        mem_malloc_init((ulong)map_sysmem(malloc_start, TOTAL_MALLOC_LEN),
@@ -266,30 +265,21 @@ static int initr_malloc(void)
        return 0;
 }
 
-#ifdef CONFIG_DM
-static int initr_dm(void)
+#ifdef CONFIG_SYS_NONCACHED_MEMORY
+static int initr_noncached(void)
 {
-       int ret;
-
-       ret = dm_init();
-       if (ret) {
-               debug("dm_init() failed: %d\n", ret);
-               return ret;
-       }
-       ret = dm_scan_platdata();
-       if (ret) {
-               debug("dm_scan_platdata() failed: %d\n", ret);
-               return ret;
-       }
-#ifdef CONFIG_OF_CONTROL
-       ret = dm_scan_fdt(gd->fdt_blob);
-       if (ret) {
-               debug("dm_scan_fdt() failed: %d\n", ret);
-               return ret;
-       }
+       noncached_init();
+       return 0;
+}
 #endif
 
-       return 0;
+#ifdef CONFIG_DM
+static int initr_dm(void)
+{
+       /* Save the pre-reloc driver model and start a new one */
+       gd->dm_root_f = gd->dm_root;
+       gd->dm_root = NULL;
+       return dm_init_and_scan(false);
 }
 #endif
 
@@ -304,31 +294,28 @@ static int initr_announce(void)
        return 0;
 }
 
+#ifdef CONFIG_NEEDS_MANUAL_RELOC
+static int initr_manual_reloc_cmdtable(void)
+{
+       fixup_cmdtable(ll_entry_start(cmd_tbl_t, cmd),
+                      ll_entry_count(cmd_tbl_t, cmd));
+       return 0;
+}
+#endif
+
 #if !defined(CONFIG_SYS_NO_FLASH)
 static int initr_flash(void)
 {
        ulong flash_size = 0;
        bd_t *bd = gd->bd;
-       int ok;
 
        puts("Flash: ");
 
-       if (board_flash_wp_on()) {
+       if (board_flash_wp_on())
                printf("Uninitialized - Write Protect On\n");
-               /* Since WP is on, we can't find real size.  Set to 0 */
-               ok = 1;
-       } else {
+       else
                flash_size = flash_init();
-               ok = flash_size > 0;
-       }
-       if (!ok) {
-               puts("*** failed ***\n");
-#ifdef CONFIG_PPC
-               /* Why does PPC do this? */
-               hang();
-#endif
-               return -1;
-       }
+
        print_size(flash_size, "");
 #ifdef CONFIG_SYS_FLASH_CHECKSUM
        /*
@@ -367,7 +354,7 @@ static int initr_flash(void)
 }
 #endif
 
-#ifdef CONFIG_PPC
+#if defined(CONFIG_PPC) && !defined(CONFIG_DM_SPI)
 static int initr_spi(void)
 {
        /* PPC does this here */
@@ -383,7 +370,7 @@ static int initr_spi(void)
 
 #ifdef CONFIG_CMD_NAND
 /* go init the NAND */
-int initr_nand(void)
+static int initr_nand(void)
 {
        puts("NAND:  ");
        nand_init();
@@ -393,7 +380,7 @@ int initr_nand(void)
 
 #if defined(CONFIG_CMD_ONENAND)
 /* go init the NAND */
-int initr_onenand(void)
+static int initr_onenand(void)
 {
        puts("NAND:  ");
        onenand_init();
@@ -402,7 +389,7 @@ int initr_onenand(void)
 #endif
 
 #ifdef CONFIG_GENERIC_MMC
-int initr_mmc(void)
+static int initr_mmc(void)
 {
        puts("MMC:   ");
        mmc_initialize(gd->bd);
@@ -411,7 +398,7 @@ int initr_mmc(void)
 #endif
 
 #ifdef CONFIG_HAS_DATAFLASH
-int initr_dataflash(void)
+static int initr_dataflash(void)
 {
        AT91F_DataflashInit();
        dataflash_print_info();
@@ -472,24 +459,6 @@ static int initr_env(void)
        return 0;
 }
 
-#ifdef CONFIG_HERMES
-static int initr_hermes(void)
-{
-       if ((gd->board_type >> 16) == 2)
-               gd->bd->bi_ethspeed = gd->board_type & 0xFFFF;
-       else
-               gd->bd->bi_ethspeed = 0xFFFF;
-       return 0;
-}
-
-static int initr_hermes_start(void)
-{
-       if (gd->bd->bi_ethspeed != 0xFFFF)
-               hermes_start_lxt980((int) gd->bd->bi_ethspeed);
-       return 0;
-}
-#endif
-
 #ifdef CONFIG_SC3
 /* TODO: with new initcalls, move this into the driver */
 extern void sc3_read_eeprom(void);
@@ -516,22 +485,6 @@ static int initr_api(void)
 }
 #endif
 
-#ifdef CONFIG_DISPLAY_BOARDINFO_LATE
-static int show_model_r(void)
-{
-       /* Put this here so it appears on the LCD, now it is ready */
-# ifdef CONFIG_OF_CONTROL
-       const char *model;
-
-       model = (char *)fdt_getprop(gd->fdt_blob, 0, "model", NULL);
-       printf("Model: %s\n", model ? model : "<unknown>");
-# else
-       checkboard();
-# endif
-       return 0;
-}
-#endif
-
 /* enable exceptions */
 #ifdef CONFIG_ARM
 static int initr_enable_interrupts(void)
@@ -588,21 +541,19 @@ static int initr_status_led(void)
 #if defined(CONFIG_CMD_SCSI)
 static int initr_scsi(void)
 {
-       /* Not supported properly on ARM yet */
-#ifndef CONFIG_ARM
        puts("SCSI:  ");
        scsi_init();
-#endif
 
        return 0;
 }
-#endif /* CONFIG_CMD_NET */
+#endif
 
 #if defined(CONFIG_CMD_DOC)
 static int initr_doc(void)
 {
        puts("DOC:   ");
        doc_init();
+       return 0;
 }
 #endif
 
@@ -679,7 +630,7 @@ int initr_mem(void)
        /* Also take the logbuffer into account (pram is in kB) */
        pram += (LOGBUFF_LEN + LOGBUFF_OVERHEAD) / 1024;
 # endif
-       sprintf(memsz, "%ldk", (gd->ram_size / 1024) - pram);
+       sprintf(memsz, "%ldk", (long int) ((gd->ram_size / 1024) - pram));
        setenv("mem", memsz);
 
        return 0;
@@ -730,6 +681,21 @@ init_fnc_t init_sequence_r[] = {
        /* TODO: could x86/PPC have this also perhaps? */
 #ifdef CONFIG_ARM
        initr_caches,
+#endif
+       initr_reloc_global_data,
+#if defined(CONFIG_SYS_INIT_RAM_LOCK) && defined(CONFIG_E500)
+       initr_unlock_ram_in_cache,
+#endif
+       initr_barrier,
+       initr_malloc,
+#ifdef CONFIG_SYS_NONCACHED_MEMORY
+       initr_noncached,
+#endif
+       bootstage_relocate,
+#ifdef CONFIG_DM
+       initr_dm,
+#endif
+#ifdef CONFIG_ARM
        board_init,     /* Setup chipselects */
 #endif
        /*
@@ -741,10 +707,13 @@ init_fnc_t init_sequence_r[] = {
 #ifdef CONFIG_CLOCKS
        set_cpu_clk_info, /* Setup clock information */
 #endif
-       initr_reloc_global_data,
+       stdio_init_tables,
        initr_serial,
        initr_announce,
        INIT_FUNC_WATCHDOG_RESET
+#ifdef CONFIG_NEEDS_MANUAL_RELOC
+       initr_manual_reloc_cmdtable,
+#endif
 #ifdef CONFIG_PPC
        initr_trap,
 #endif
@@ -765,9 +734,6 @@ init_fnc_t init_sequence_r[] = {
 #ifdef CONFIG_SYS_DELAYED_ICACHE
        initr_icache_enable,
 #endif
-#if defined(CONFIG_SYS_INIT_RAM_LOCK) && defined(CONFIG_E500)
-       initr_unlock_ram_in_cache,
-#endif
 #if defined(CONFIG_PCI) && defined(CONFIG_SYS_EARLY_PCI_INIT)
        /*
         * Do early PCI configuration _before_ the flash gets initialised,
@@ -777,12 +743,6 @@ init_fnc_t init_sequence_r[] = {
 #endif
 #ifdef CONFIG_WINBOND_83C553
        initr_w83c553f,
-#endif
-       initr_barrier,
-       initr_malloc,
-       bootstage_relocate,
-#ifdef CONFIG_DM
-       initr_dm,
 #endif
 #ifdef CONFIG_ARCH_EARLY_INIT_R
        arch_early_init_r,
@@ -792,7 +752,7 @@ init_fnc_t init_sequence_r[] = {
        initr_flash,
 #endif
        INIT_FUNC_WATCHDOG_RESET
-#if defined(CONFIG_PPC) || defined(CONFIG_X86)
+#if defined(CONFIG_PPC)
        /* initialize higher level parts of CPU like time base and timers */
        cpu_init_r,
 #endif
@@ -820,9 +780,6 @@ init_fnc_t init_sequence_r[] = {
 #ifdef CONFIG_SC3
        initr_sc3_read_eeprom,
 #endif
-#ifdef CONFIG_HERMES
-       initr_hermes,
-#endif
 #if defined(CONFIG_ID_EEPROM) || defined(CONFIG_SYS_I2C_MAC_OFFSET)
        mac_read_from_eeprom,
 #endif
@@ -833,33 +790,27 @@ init_fnc_t init_sequence_r[] = {
         */
        initr_pci,
 #endif
-       stdio_init,
+       stdio_add_devices,
        initr_jumptable,
 #ifdef CONFIG_API
        initr_api,
 #endif
        console_init_r,         /* fully init console as a device */
 #ifdef CONFIG_DISPLAY_BOARDINFO_LATE
-       show_model_r,
+       show_board_info,
 #endif
 #ifdef CONFIG_ARCH_MISC_INIT
        arch_misc_init,         /* miscellaneous arch-dependent init */
 #endif
 #ifdef CONFIG_MISC_INIT_R
        misc_init_r,            /* miscellaneous platform-dependent init */
-#endif
-#ifdef CONFIG_HERMES
-       initr_hermes_start,
 #endif
        INIT_FUNC_WATCHDOG_RESET
 #ifdef CONFIG_CMD_KGDB
        initr_kgdb,
-#endif
-#ifdef CONFIG_X86
-       board_early_init_r,
 #endif
        interrupt_init,
-#if defined(CONFIG_ARM) || defined(CONFIG_x86)
+#if defined(CONFIG_ARM)
        initr_enable_interrupts,
 #endif
 #ifdef CONFIG_X86
@@ -927,7 +878,7 @@ void board_init_r(gd_t *new_gd, ulong dest_addr)
        int i;
 #endif
 
-#ifndef CONFIG_X86
+#if !defined(CONFIG_X86) && !defined(CONFIG_ARM) && !defined(CONFIG_ARM64)
        gd = new_gd;
 #endif