]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - common/board_r.c
karo: tx6: enable FDT support for MFG U-Boot build
[karo-tx-uboot.git] / common / board_r.c
index c57ae5cace163dcd578e91612d309bf87db2ac7c..86ca1cbbd4e118ee6b8779476fa37964805fa1d3 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>
 #include <serial.h>
 #include <spi.h>
 #include <stdio_dev.h>
+#include <trace.h>
 #include <watchdog.h>
 #ifdef CONFIG_ADDR_MAP
 #include <asm/mmu.h>
 #endif
 #include <asm/sections.h>
+#ifdef CONFIG_X86
+#include <asm/init_helpers.h>
+#endif
 #include <linux/compiler.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -103,6 +91,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 */
@@ -133,8 +130,8 @@ static int initr_reloc_global_data(void)
 {
 #ifdef CONFIG_SYS_SYM_OFFSETS
        monitor_flash_len = _end_ofs;
-#else
-       monitor_flash_len = (ulong)&__init_end - gd->dest_addr;
+#elif !defined(CONFIG_SANDBOX)
+       monitor_flash_len = (ulong)&__init_end - gd->relocaddr;
 #endif
 #if defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx)
        /*
@@ -142,7 +139,7 @@ static int initr_reloc_global_data(void)
         * We need to update it to point to the same CPU entry in RAM.
         * TODO: why not just add gd->reloc_ofs?
         */
-       gd->arch.cpu += gd->dest_addr - CONFIG_SYS_MONITOR_BASE;
+       gd->arch.cpu += gd->relocaddr - CONFIG_SYS_MONITOR_BASE;
 
        /*
         * If we didn't know the cpu mask & # cores, we can save them of
@@ -158,7 +155,7 @@ static int initr_reloc_global_data(void)
         * in SRAM mode and initialize that cache from SRAM mode back to being
         * a cache in cpu_init_r.
         */
-       gd->env_addr += gd->dest_addr - CONFIG_SYS_MONITOR_BASE;
+       gd->env_addr += gd->relocaddr - CONFIG_SYS_MONITOR_BASE;
 #endif
        return 0;
 }
@@ -175,7 +172,7 @@ static int initr_trap(void)
        /*
         * Setup trap handlers
         */
-       trap_init(gd->dest_addr);
+       trap_init(gd->relocaddr);
 
        return 0;
 }
@@ -260,8 +257,9 @@ static int initr_malloc(void)
        ulong malloc_start;
 
        /* The malloc area is immediately below the monitor copy in DRAM */
-       malloc_start = gd->dest_addr - TOTAL_MALLOC_LEN;
-       mem_malloc_init(malloc_start, TOTAL_MALLOC_LEN);
+       malloc_start = gd->relocaddr - TOTAL_MALLOC_LEN;
+       mem_malloc_init((ulong)map_sysmem(malloc_start, TOTAL_MALLOC_LEN),
+                       TOTAL_MALLOC_LEN);
        return 0;
 }
 
@@ -272,7 +270,7 @@ __weak int power_init_board(void)
 
 static int initr_announce(void)
 {
-       debug("Now running in RAM - U-Boot at: %08lx\n", gd->dest_addr);
+       debug("Now running in RAM - U-Boot at: %08lx\n", gd->relocaddr);
        return 0;
 }
 
@@ -504,11 +502,13 @@ static int show_model_r(void)
 #endif
 
 /* enable exceptions */
+#ifdef CONFIG_ARM
 static int initr_enable_interrupts(void)
 {
        enable_interrupts();
        return 0;
 }
+#endif
 
 #ifdef CONFIG_CMD_NET
 static int initr_ethaddr(void)
@@ -686,6 +686,9 @@ static int initr_modem(void)
 
 static int run_main_loop(void)
 {
+#ifdef CONFIG_SANDBOX
+       sandbox_main_loop_init();
+#endif
        /* main_loop() can return to retry autoboot, if so just run it again */
        for (;;)
                main_loop();
@@ -702,6 +705,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
@@ -756,6 +760,7 @@ init_fnc_t init_sequence_r[] = {
 #endif
        initr_barrier,
        initr_malloc,
+       bootstage_relocate,
 #ifdef CONFIG_ARCH_EARLY_INIT_R
        arch_early_init_r,
 #endif
@@ -764,11 +769,16 @@ init_fnc_t init_sequence_r[] = {
        initr_flash,
 #endif
        INIT_FUNC_WATCHDOG_RESET
-#ifdef CONFIG_PPC
+#if defined(CONFIG_PPC) || defined(CONFIG_X86)
        /* initialize higher level parts of CPU like time base and timers */
        cpu_init_r,
+#endif
+#ifdef CONFIG_PPC
        initr_spi,
 #endif
+#if defined(CONFIG_X86) && defined(CONFIG_SPI)
+       init_func_spi,
+#endif
 #ifdef CONFIG_CMD_NAND
        initr_nand,
 #endif
@@ -821,11 +831,17 @@ init_fnc_t init_sequence_r[] = {
        INIT_FUNC_WATCHDOG_RESET
 #ifdef CONFIG_CMD_KGDB
        initr_kgdb,
+#endif
+#ifdef CONFIG_X86
+       board_early_init_r,
 #endif
        interrupt_init,
-#ifdef CONFIG_ARM
+#if defined(CONFIG_ARM) || defined(CONFIG_x86)
        initr_enable_interrupts,
 #endif
+#ifdef CONFIG_X86
+       timer_init,             /* initialize timer */
+#endif
 #if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
        initr_status_led,
 #endif
@@ -887,7 +903,9 @@ init_fnc_t init_sequence_r[] = {
 
 void board_init_r(gd_t *new_gd, ulong dest_addr)
 {
+#ifndef CONFIG_X86
        gd = new_gd;
+#endif
        if (initcall_run_list(init_sequence_r))
                hang();