]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - common/board_r.c
Merge branch 'master' of git://www.denx.de/git/u-boot-imx
[karo-tx-uboot.git] / common / board_r.c
index f5649c95f16f5291cecee4dc5fdf70e56fb4c759..f9647e13583f262a0fd78a389405027bc2108adb 100644 (file)
@@ -7,23 +7,7 @@
  * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
  * Marius Groeger <mgroeger@sysgo.de>
  *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
@@ -34,6 +18,7 @@
 #ifdef CONFIG_HAS_DATAFLASH
 #include <dataflash.h>
 #endif
+#include <dm.h>
 #include <environment.h>
 #include <fdtdec.h>
 #if defined(CONFIG_CMD_IDE)
@@ -58,6 +43,7 @@
 #include <serial.h>
 #include <spi.h>
 #include <stdio_dev.h>
+#include <trace.h>
 #include <watchdog.h>
 #ifdef CONFIG_ADDR_MAP
 #include <asm/mmu.h>
@@ -66,7 +52,9 @@
 #ifdef CONFIG_X86
 #include <asm/init_helpers.h>
 #endif
+#include <dm/root.h>
 #include <linux/compiler.h>
+#include <linux/err.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -106,6 +94,15 @@ static int initr_secondary_cpu(void)
        return 0;
 }
 
+static int initr_trace(void)
+{
+#ifdef CONFIG_TRACE
+       trace_init(gd->trace_buff, CONFIG_TRACE_BUFFER_SIZE);
+#endif
+
+       return 0;
+}
+
 static int initr_reloc(void)
 {
        gd->flags |= GD_FLG_RELOC;      /* tell others: relocation done */
@@ -134,9 +131,9 @@ __weak int fixup_cpu(void)
 
 static int initr_reloc_global_data(void)
 {
-#ifdef CONFIG_SYS_SYM_OFFSETS
-       monitor_flash_len = _end_ofs;
-#elif !defined(CONFIG_SANDBOX)
+#ifdef __ARM__
+       monitor_flash_len = _end - __image_copy_start;
+#elif !defined(CONFIG_SANDBOX) && !defined(CONFIG_NIOS2)
        monitor_flash_len = (ulong)&__init_end - gd->relocaddr;
 #endif
 #if defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx)
@@ -262,6 +259,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),
@@ -269,6 +270,16 @@ static int initr_malloc(void)
        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
+
 __weak int power_init_board(void)
 {
        return 0;
@@ -504,6 +515,7 @@ static int show_model_r(void)
 # else
        checkboard();
 # endif
+       return 0;
 }
 #endif
 
@@ -563,21 +575,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,17 +689,6 @@ static int initr_kbd(void)
 }
 #endif
 
-#ifdef CONFIG_MODEM_SUPPORT
-static int initr_modem(void)
-{
-       /* TODO: with new initcalls, move this into the driver */
-       extern int do_mdm_init;
-
-       do_mdm_init = gd->do_mdm_init;
-       return 0;
-}
-#endif
-
 static int run_main_loop(void)
 {
 #ifdef CONFIG_SANDBOX
@@ -711,6 +710,7 @@ static int run_main_loop(void)
  * TODO: perhaps reset the watchdog in the initcall function after each call?
  */
 init_fnc_t init_sequence_r[] = {
+       initr_trace,
        initr_reloc,
        /* TODO: could x86/PPC have this also perhaps? */
 #ifdef CONFIG_ARM
@@ -766,6 +766,9 @@ init_fnc_t init_sequence_r[] = {
        initr_barrier,
        initr_malloc,
        bootstage_relocate,
+#ifdef CONFIG_DM
+       initr_dm,
+#endif
 #ifdef CONFIG_ARCH_EARLY_INIT_R
        arch_early_init_r,
 #endif
@@ -899,18 +902,25 @@ init_fnc_t init_sequence_r[] = {
 #endif
 #ifdef CONFIG_PS2KBD
        initr_kbd,
-#endif
-#ifdef CONFIG_MODEM_SUPPORT
-       initr_modem,
 #endif
        run_main_loop,
 };
 
 void board_init_r(gd_t *new_gd, ulong dest_addr)
 {
+#ifdef CONFIG_NEEDS_MANUAL_RELOC
+       int i;
+#endif
+
 #ifndef CONFIG_X86
        gd = new_gd;
 #endif
+
+#ifdef CONFIG_NEEDS_MANUAL_RELOC
+       for (i = 0; i < ARRAY_SIZE(init_sequence_r); i++)
+               init_sequence_r[i] += gd->reloc_off;
+#endif
+
        if (initcall_run_list(init_sequence_r))
                hang();