2002-11-03 09:24:07 +09:00
|
|
|
/*
|
2006-01-30 03:12:41 +09:00
|
|
|
* (C) Copyright 2002-2006
|
2002-11-03 09:24:07 +09:00
|
|
|
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
|
|
|
*
|
|
|
|
* (C) Copyright 2002
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2006-01-30 03:12:41 +09:00
|
|
|
/*
|
|
|
|
* To match the U-Boot user interface on ARM platforms to the U-Boot
|
|
|
|
* standard (as on PPC platforms), some messages with debug character
|
|
|
|
* are removed from the default U-Boot build.
|
|
|
|
*
|
|
|
|
* Define DEBUG here if you want additional info as shown below
|
|
|
|
* printed upon startup:
|
|
|
|
*
|
|
|
|
* U-Boot code: 00F00000 -> 00F3C774 BSS: -> 00FC3274
|
|
|
|
* IRQ Stack: 00ebff7c
|
|
|
|
* FIQ Stack: 00ebef7c
|
|
|
|
*/
|
|
|
|
|
2002-11-03 09:24:07 +09:00
|
|
|
#include <common.h>
|
|
|
|
#include <command.h>
|
2003-06-23 02:18:28 +09:00
|
|
|
#include <malloc.h>
|
2009-05-16 19:14:54 +09:00
|
|
|
#include <stdio_dev.h>
|
2002-11-03 09:24:07 +09:00
|
|
|
#include <version.h>
|
|
|
|
#include <net.h>
|
2008-05-01 16:05:26 +09:00
|
|
|
#include <serial.h>
|
2008-05-23 00:49:46 +09:00
|
|
|
#include <nand.h>
|
|
|
|
#include <onenand_uboot.h>
|
2009-06-08 09:12:50 +09:00
|
|
|
#include <mmc.h>
|
2011-10-25 04:15:33 +09:00
|
|
|
#include <libfdt.h>
|
|
|
|
#include <fdtdec.h>
|
2011-09-02 13:59:03 +09:00
|
|
|
#include <post.h>
|
|
|
|
#include <logbuff.h>
|
2002-11-03 09:24:07 +09:00
|
|
|
|
2009-10-10 19:42:21 +09:00
|
|
|
#ifdef CONFIG_BITBANGMII
|
|
|
|
#include <miiphy.h>
|
|
|
|
#endif
|
|
|
|
|
2004-06-09 22:37:52 +09:00
|
|
|
#ifdef CONFIG_DRIVER_SMC91111
|
2007-11-22 05:19:24 +09:00
|
|
|
#include "../drivers/net/smc91111.h"
|
2004-06-09 22:37:52 +09:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_DRIVER_LAN91C96
|
2007-11-22 05:19:24 +09:00
|
|
|
#include "../drivers/net/lan91c96.h"
|
2004-06-09 22:37:52 +09:00
|
|
|
#endif
|
|
|
|
|
2006-02-10 19:25:41 +09:00
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2003-05-30 21:48:29 +09:00
|
|
|
ulong monitor_flash_len;
|
|
|
|
|
2003-06-17 08:50:08 +09:00
|
|
|
#ifdef CONFIG_HAS_DATAFLASH
|
|
|
|
extern int AT91F_DataflashInit(void);
|
|
|
|
extern void dataflash_print_info(void);
|
|
|
|
#endif
|
|
|
|
|
2007-12-19 09:00:54 +09:00
|
|
|
#if defined(CONFIG_HARD_I2C) || \
|
|
|
|
defined(CONFIG_SOFT_I2C)
|
|
|
|
#include <i2c.h>
|
|
|
|
#endif
|
|
|
|
|
2007-09-05 00:18:38 +09:00
|
|
|
/************************************************************************
|
|
|
|
* Coloured LED functionality
|
|
|
|
************************************************************************
|
|
|
|
* May be supplied by boards if desired
|
|
|
|
*/
|
2011-07-16 04:36:36 +09:00
|
|
|
inline void __coloured_LED_init(void) {}
|
|
|
|
void coloured_LED_init(void)
|
|
|
|
__attribute__((weak, alias("__coloured_LED_init")));
|
2011-09-05 03:40:16 +09:00
|
|
|
inline void __red_led_on(void) {}
|
|
|
|
void red_led_on(void) __attribute__((weak, alias("__red_led_on")));
|
|
|
|
inline void __red_led_off(void) {}
|
|
|
|
void red_led_off(void) __attribute__((weak, alias("__red_led_off")));
|
|
|
|
inline void __green_led_on(void) {}
|
|
|
|
void green_led_on(void) __attribute__((weak, alias("__green_led_on")));
|
|
|
|
inline void __green_led_off(void) {}
|
|
|
|
void green_led_off(void) __attribute__((weak, alias("__green_led_off")));
|
|
|
|
inline void __yellow_led_on(void) {}
|
|
|
|
void yellow_led_on(void) __attribute__((weak, alias("__yellow_led_on")));
|
|
|
|
inline void __yellow_led_off(void) {}
|
|
|
|
void yellow_led_off(void) __attribute__((weak, alias("__yellow_led_off")));
|
|
|
|
inline void __blue_led_on(void) {}
|
|
|
|
void blue_led_on(void) __attribute__((weak, alias("__blue_led_on")));
|
|
|
|
inline void __blue_led_off(void) {}
|
|
|
|
void blue_led_off(void) __attribute__((weak, alias("__blue_led_off")));
|
2007-09-05 00:18:38 +09:00
|
|
|
|
2011-07-16 04:36:36 +09:00
|
|
|
/*
|
|
|
|
************************************************************************
|
2002-11-03 09:24:07 +09:00
|
|
|
* Init Utilities *
|
|
|
|
************************************************************************
|
|
|
|
* Some of this code should be moved into the core functions,
|
|
|
|
* or dropped completely,
|
|
|
|
* but let's get it working (again) first...
|
|
|
|
*/
|
|
|
|
|
2009-02-22 23:49:28 +09:00
|
|
|
#if defined(CONFIG_ARM_DCC) && !defined(CONFIG_BAUDRATE)
|
|
|
|
#define CONFIG_BAUDRATE 115200
|
|
|
|
#endif
|
2011-10-13 23:43:06 +09:00
|
|
|
|
2011-07-16 04:36:36 +09:00
|
|
|
static int init_baudrate(void)
|
2002-11-03 09:24:07 +09:00
|
|
|
{
|
2011-10-13 23:43:06 +09:00
|
|
|
gd->baudrate = getenv_ulong("baudrate", 10, CONFIG_BAUDRATE);
|
|
|
|
return 0;
|
2002-11-03 09:24:07 +09:00
|
|
|
}
|
|
|
|
|
2011-07-16 04:36:36 +09:00
|
|
|
static int display_banner(void)
|
2002-11-03 09:24:07 +09:00
|
|
|
{
|
2011-07-16 04:36:36 +09:00
|
|
|
printf("\n\n%s\n\n", version_string);
|
|
|
|
debug("U-Boot code: %08lX -> %08lX BSS: -> %08lX\n",
|
2010-09-17 20:10:39 +09:00
|
|
|
_TEXT_BASE,
|
2011-07-16 04:36:36 +09:00
|
|
|
_bss_start_ofs + _TEXT_BASE, _bss_end_ofs + _TEXT_BASE);
|
2002-11-03 09:24:07 +09:00
|
|
|
#ifdef CONFIG_MODEM_SUPPORT
|
2011-07-16 04:36:36 +09:00
|
|
|
debug("Modem Support enabled\n");
|
2002-11-03 09:24:07 +09:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_USE_IRQ
|
2011-07-16 04:36:36 +09:00
|
|
|
debug("IRQ Stack: %08lx\n", IRQ_STACK_START);
|
|
|
|
debug("FIQ Stack: %08lx\n", FIQ_STACK_START);
|
2002-11-03 09:24:07 +09:00
|
|
|
#endif
|
2003-10-10 19:05:42 +09:00
|
|
|
|
2002-11-03 09:24:07 +09:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* WARNING: this code looks "cleaner" than the PowerPC version, but
|
|
|
|
* has the disadvantage that you either get nothing, or everything.
|
|
|
|
* On PowerPC, you might see "DRAM: " before the system hangs - which
|
|
|
|
* gives a simple yet clear indication which part of the
|
|
|
|
* initialization if failing.
|
|
|
|
*/
|
2011-07-16 04:36:36 +09:00
|
|
|
static int display_dram_config(void)
|
2002-11-03 09:24:07 +09:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2006-01-30 03:12:41 +09:00
|
|
|
#ifdef DEBUG
|
2011-07-16 04:36:36 +09:00
|
|
|
puts("RAM Configuration:\n");
|
2002-11-03 09:24:07 +09:00
|
|
|
|
2011-07-16 04:36:36 +09:00
|
|
|
for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
|
|
|
|
printf("Bank #%d: %08lx ", i, gd->bd->bi_dram[i].start);
|
|
|
|
print_size(gd->bd->bi_dram[i].size, "\n");
|
2002-11-03 09:24:07 +09:00
|
|
|
}
|
2006-01-30 03:12:41 +09:00
|
|
|
#else
|
|
|
|
ulong size = 0;
|
|
|
|
|
2011-07-16 04:36:36 +09:00
|
|
|
for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++)
|
2006-01-30 03:12:41 +09:00
|
|
|
size += gd->bd->bi_dram[i].size;
|
2011-07-16 04:36:36 +09:00
|
|
|
|
2006-01-30 03:12:41 +09:00
|
|
|
puts("DRAM: ");
|
|
|
|
print_size(size, "\n");
|
|
|
|
#endif
|
2002-11-03 09:24:07 +09:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2007-12-19 09:00:54 +09:00
|
|
|
#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
|
2011-07-16 04:36:36 +09:00
|
|
|
static int init_func_i2c(void)
|
2007-12-19 09:00:54 +09:00
|
|
|
{
|
2011-07-16 04:36:36 +09:00
|
|
|
puts("I2C: ");
|
|
|
|
i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
|
|
|
|
puts("ready\n");
|
2007-12-19 09:00:54 +09:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-01-31 17:04:58 +09:00
|
|
|
#if defined(CONFIG_CMD_PCI) || defined (CONFIG_PCI)
|
|
|
|
#include <pci.h>
|
|
|
|
static int arm_pci_init(void)
|
|
|
|
{
|
|
|
|
pci_init();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_CMD_PCI || CONFIG_PCI */
|
|
|
|
|
2002-11-03 09:24:07 +09:00
|
|
|
/*
|
2003-12-07 04:49:23 +09:00
|
|
|
* Breathe some life into the board...
|
2002-11-03 09:24:07 +09:00
|
|
|
*
|
2003-09-18 07:48:07 +09:00
|
|
|
* Initialize a serial port as console, and carry out some hardware
|
2002-11-03 09:24:07 +09:00
|
|
|
* tests.
|
|
|
|
*
|
|
|
|
* The first part of initialization is running from Flash memory;
|
|
|
|
* its main purpose is to initialize the RAM so that we
|
|
|
|
* can relocate the monitor code to RAM.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* All attempts to come up with a "common" initialization sequence
|
|
|
|
* that works for all boards and architectures failed: some of the
|
|
|
|
* requirements are just _too_ different. To get rid of the resulting
|
2004-02-09 04:38:38 +09:00
|
|
|
* mess of board dependent #ifdef'ed code we now make the whole
|
2002-11-03 09:24:07 +09:00
|
|
|
* initialization sequence configurable to the user.
|
|
|
|
*
|
|
|
|
* The requirements for any new initalization function is simple: it
|
|
|
|
* receives a pointer to the "global data" structure as it's only
|
|
|
|
* argument, and returns an integer return code, where 0 means
|
|
|
|
* "continue" and != 0 means "fatal error, hang the system".
|
|
|
|
*/
|
|
|
|
typedef int (init_fnc_t) (void);
|
|
|
|
|
2011-07-16 04:36:36 +09:00
|
|
|
int print_cpuinfo(void);
|
2006-01-30 03:12:41 +09:00
|
|
|
|
2010-09-17 20:10:39 +09:00
|
|
|
void __dram_init_banksize(void)
|
|
|
|
{
|
|
|
|
gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
|
|
|
|
gd->bd->bi_dram[0].size = gd->ram_size;
|
|
|
|
}
|
|
|
|
void dram_init_banksize(void)
|
|
|
|
__attribute__((weak, alias("__dram_init_banksize")));
|
|
|
|
|
|
|
|
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,
|
2011-10-25 04:15:33 +09:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_OF_CONTROL
|
|
|
|
fdtdec_check_fdt,
|
2010-09-17 20:10:39 +09:00
|
|
|
#endif
|
|
|
|
timer_init, /* initialize timer */
|
|
|
|
#ifdef CONFIG_FSL_ESDHC
|
|
|
|
get_clocks,
|
|
|
|
#endif
|
|
|
|
env_init, /* initialize environment */
|
|
|
|
init_baudrate, /* initialze baudrate settings */
|
|
|
|
serial_init, /* serial communications setup */
|
|
|
|
console_init_f, /* stage 1 init of console */
|
|
|
|
display_banner, /* say that we are here */
|
|
|
|
#if defined(CONFIG_DISPLAY_CPUINFO)
|
|
|
|
print_cpuinfo, /* display cpu info (and speed) */
|
|
|
|
#endif
|
|
|
|
#if defined(CONFIG_DISPLAY_BOARDINFO)
|
|
|
|
checkboard, /* display board info */
|
|
|
|
#endif
|
|
|
|
#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
|
|
|
|
init_func_i2c,
|
|
|
|
#endif
|
|
|
|
dram_init, /* configure available RAM banks */
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
2011-07-16 04:36:36 +09:00
|
|
|
void board_init_f(ulong bootflag)
|
2010-09-17 20:10:39 +09:00
|
|
|
{
|
|
|
|
bd_t *bd;
|
|
|
|
init_fnc_t **init_fnc_ptr;
|
|
|
|
gd_t *id;
|
|
|
|
ulong addr, addr_sp;
|
2011-10-13 23:43:06 +09:00
|
|
|
#ifdef CONFIG_PRAM
|
|
|
|
ulong reg;
|
|
|
|
#endif
|
2010-09-17 20:10:39 +09:00
|
|
|
|
2012-02-13 22:51:21 +09:00
|
|
|
bootstage_mark_name(BOOTSTAGE_ID_START_UBOOT_F, "board_init_f");
|
|
|
|
|
2010-09-17 20:10:39 +09:00
|
|
|
/* Pointer is writable since we allocated a register for it */
|
2010-11-12 15:53:55 +09:00
|
|
|
gd = (gd_t *) ((CONFIG_SYS_INIT_SP_ADDR) & ~0x07);
|
2010-09-17 20:10:39 +09:00
|
|
|
/* compiler optimization barrier needed for GCC >= 3.4 */
|
|
|
|
__asm__ __volatile__("": : :"memory");
|
|
|
|
|
2011-07-16 04:36:36 +09:00
|
|
|
memset((void *)gd, 0, sizeof(gd_t));
|
2010-09-17 20:10:39 +09:00
|
|
|
|
2010-10-11 20:13:28 +09:00
|
|
|
gd->mon_len = _bss_end_ofs;
|
2011-10-25 04:15:33 +09:00
|
|
|
#ifdef CONFIG_OF_EMBED
|
|
|
|
/* Get a pointer to the FDT */
|
|
|
|
gd->fdt_blob = _binary_dt_dtb_start;
|
|
|
|
#elif defined CONFIG_OF_SEPARATE
|
|
|
|
/* FDT is at end of image */
|
|
|
|
gd->fdt_blob = (void *)(_end_ofs + _TEXT_BASE);
|
|
|
|
#endif
|
2011-10-25 04:15:34 +09:00
|
|
|
/* Allow the early environment to override the fdt address */
|
|
|
|
gd->fdt_blob = (void *)getenv_ulong("fdtcontroladdr", 16,
|
|
|
|
(uintptr_t)gd->fdt_blob);
|
2010-09-17 20:10:39 +09:00
|
|
|
|
|
|
|
for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
|
|
|
|
if ((*init_fnc_ptr)() != 0) {
|
|
|
|
hang ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-28 19:08:25 +09:00
|
|
|
#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
|
|
|
|
|
2011-07-16 04:36:36 +09:00
|
|
|
debug("monitor len: %08lX\n", gd->mon_len);
|
2010-09-17 20:10:39 +09:00
|
|
|
/*
|
|
|
|
* Ram is setup, size stored in gd !!
|
|
|
|
*/
|
2011-07-16 04:36:36 +09:00
|
|
|
debug("ramsize: %08lX\n", gd->ram_size);
|
2010-09-17 20:10:39 +09:00
|
|
|
#if defined(CONFIG_SYS_MEM_TOP_HIDE)
|
|
|
|
/*
|
|
|
|
* Subtract specified amount of memory to hide so that it won't
|
|
|
|
* get "touched" at all by U-Boot. By fixing up gd->ram_size
|
|
|
|
* the Linux kernel should now get passed the now "corrected"
|
|
|
|
* memory size and won't touch it either. This should work
|
|
|
|
* for arch/ppc and arch/powerpc. Only Linux board ports in
|
|
|
|
* arch/powerpc with bootwrapper support, that recalculate the
|
|
|
|
* memory size from the SDRAM controller setup will have to
|
|
|
|
* get fixed.
|
|
|
|
*/
|
|
|
|
gd->ram_size -= CONFIG_SYS_MEM_TOP_HIDE;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
addr = CONFIG_SYS_SDRAM_BASE + gd->ram_size;
|
|
|
|
|
|
|
|
#ifdef CONFIG_LOGBUFFER
|
|
|
|
#ifndef CONFIG_ALT_LB_ADDR
|
|
|
|
/* reserve kernel log buffer */
|
|
|
|
addr -= (LOGBUFF_RESERVE);
|
2011-07-16 04:36:36 +09:00
|
|
|
debug("Reserving %dk for kernel logbuffer at %08lx\n", LOGBUFF_LEN,
|
|
|
|
addr);
|
2010-09-17 20:10:39 +09:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_PRAM
|
|
|
|
/*
|
|
|
|
* reserve protected RAM
|
|
|
|
*/
|
2011-10-13 23:43:06 +09:00
|
|
|
reg = getenv_ulong("pram", 10, CONFIG_PRAM);
|
2010-09-17 20:10:39 +09:00
|
|
|
addr -= (reg << 10); /* size is in kB */
|
2011-07-16 04:36:36 +09:00
|
|
|
debug("Reserving %ldk for protected RAM at %08lx\n", reg, addr);
|
2010-09-17 20:10:39 +09:00
|
|
|
#endif /* CONFIG_PRAM */
|
|
|
|
|
2011-06-17 08:30:48 +09:00
|
|
|
#if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF))
|
2010-09-17 20:10:39 +09:00
|
|
|
/* reserve TLB table */
|
|
|
|
addr -= (4096 * 4);
|
|
|
|
|
|
|
|
/* round down to next 64 kB limit */
|
|
|
|
addr &= ~(0x10000 - 1);
|
|
|
|
|
|
|
|
gd->tlb_addr = addr;
|
2011-07-16 04:36:36 +09:00
|
|
|
debug("TLB table at: %08lx\n", addr);
|
2010-09-17 20:10:39 +09:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* round down to next 4 kB limit */
|
|
|
|
addr &= ~(4096 - 1);
|
2011-07-16 04:36:36 +09:00
|
|
|
debug("Top of RAM usable for U-Boot at: %08lx\n", addr);
|
2010-09-17 20:10:39 +09:00
|
|
|
|
|
|
|
#ifdef CONFIG_LCD
|
2011-04-25 07:22:34 +09:00
|
|
|
#ifdef CONFIG_FB_ADDR
|
|
|
|
gd->fb_base = CONFIG_FB_ADDR;
|
|
|
|
#else
|
2010-09-17 20:10:39 +09:00
|
|
|
/* reserve memory for LCD display (always full pages) */
|
2011-07-16 04:36:36 +09:00
|
|
|
addr = lcd_setmem(addr);
|
2010-09-17 20:10:39 +09:00
|
|
|
gd->fb_base = addr;
|
2011-04-25 07:22:34 +09:00
|
|
|
#endif /* CONFIG_FB_ADDR */
|
2010-09-17 20:10:39 +09:00
|
|
|
#endif /* CONFIG_LCD */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* reserve memory for U-Boot code, data & bss
|
|
|
|
* round down to next 4 kB limit
|
|
|
|
*/
|
|
|
|
addr -= gd->mon_len;
|
|
|
|
addr &= ~(4096 - 1);
|
|
|
|
|
2011-07-16 04:36:36 +09:00
|
|
|
debug("Reserving %ldk for U-Boot at: %08lx\n", gd->mon_len >> 10, addr);
|
2010-09-17 20:10:39 +09:00
|
|
|
|
2011-07-13 14:11:07 +09:00
|
|
|
#ifndef CONFIG_SPL_BUILD
|
2010-09-17 20:10:39 +09:00
|
|
|
/*
|
|
|
|
* reserve memory for malloc() arena
|
|
|
|
*/
|
|
|
|
addr_sp = addr - TOTAL_MALLOC_LEN;
|
2011-07-16 04:36:36 +09:00
|
|
|
debug("Reserving %dk for malloc() at: %08lx\n",
|
2010-09-17 20:10:39 +09:00
|
|
|
TOTAL_MALLOC_LEN >> 10, addr_sp);
|
|
|
|
/*
|
|
|
|
* (permanently) allocate a Board Info struct
|
|
|
|
* and a permanent copy of the "global" data
|
|
|
|
*/
|
|
|
|
addr_sp -= sizeof (bd_t);
|
|
|
|
bd = (bd_t *) addr_sp;
|
|
|
|
gd->bd = bd;
|
2011-07-16 04:36:36 +09:00
|
|
|
debug("Reserving %zu Bytes for Board Info at: %08lx\n",
|
2010-09-17 20:10:39 +09:00
|
|
|
sizeof (bd_t), addr_sp);
|
2011-08-17 08:48:23 +09:00
|
|
|
|
|
|
|
#ifdef CONFIG_MACH_TYPE
|
|
|
|
gd->bd->bi_arch_number = CONFIG_MACH_TYPE; /* board id for Linux */
|
|
|
|
#endif
|
|
|
|
|
2010-09-17 20:10:39 +09:00
|
|
|
addr_sp -= sizeof (gd_t);
|
|
|
|
id = (gd_t *) addr_sp;
|
2011-07-16 04:36:36 +09:00
|
|
|
debug("Reserving %zu Bytes for Global Data at: %08lx\n",
|
2010-09-17 20:10:39 +09:00
|
|
|
sizeof (gd_t), addr_sp);
|
|
|
|
|
|
|
|
/* setup stackpointer for exeptions */
|
|
|
|
gd->irq_sp = addr_sp;
|
|
|
|
#ifdef CONFIG_USE_IRQ
|
|
|
|
addr_sp -= (CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ);
|
2011-07-16 04:36:36 +09:00
|
|
|
debug("Reserving %zu Bytes for IRQ stack at: %08lx\n",
|
2010-09-17 20:10:39 +09:00
|
|
|
CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ, addr_sp);
|
|
|
|
#endif
|
|
|
|
/* leave 3 words for abort-stack */
|
2011-04-14 21:32:37 +09:00
|
|
|
addr_sp -= 12;
|
2010-09-17 20:10:39 +09:00
|
|
|
|
|
|
|
/* 8-byte alignment for ABI compliance */
|
|
|
|
addr_sp &= ~0x07;
|
|
|
|
#else
|
|
|
|
addr_sp += 128; /* leave 32 words for abort-stack */
|
|
|
|
gd->irq_sp = addr_sp;
|
|
|
|
#endif
|
|
|
|
|
2011-07-16 04:36:36 +09:00
|
|
|
debug("New Stack Pointer is: %08lx\n", addr_sp);
|
2010-09-17 20:10:39 +09:00
|
|
|
|
|
|
|
#ifdef CONFIG_POST
|
|
|
|
post_bootmode_init();
|
2011-07-16 04:36:36 +09:00
|
|
|
post_run(NULL, POST_ROM | post_bootmode_get(0));
|
2010-09-17 20:10:39 +09:00
|
|
|
#endif
|
|
|
|
|
|
|
|
gd->bd->bi_baudrate = gd->baudrate;
|
|
|
|
/* Ram ist board specific, so move it to board code ... */
|
|
|
|
dram_init_banksize();
|
|
|
|
display_dram_config(); /* and display it */
|
|
|
|
|
|
|
|
gd->relocaddr = addr;
|
|
|
|
gd->start_addr_sp = addr_sp;
|
|
|
|
gd->reloc_off = addr - _TEXT_BASE;
|
2011-07-16 04:36:36 +09:00
|
|
|
debug("relocation Offset is: %08lx\n", gd->reloc_off);
|
|
|
|
memcpy(id, (void *)gd, sizeof(gd_t));
|
2010-09-17 20:10:39 +09:00
|
|
|
|
2011-07-16 04:36:36 +09:00
|
|
|
relocate_code(addr_sp, id, addr);
|
2010-09-17 20:10:39 +09:00
|
|
|
|
|
|
|
/* NOTREACHED - relocate_code() does not return */
|
|
|
|
}
|
|
|
|
|
|
|
|
#if !defined(CONFIG_SYS_NO_FLASH)
|
|
|
|
static char *failed = "*** failed ***\n";
|
|
|
|
#endif
|
|
|
|
|
2011-07-16 04:36:36 +09:00
|
|
|
/*
|
|
|
|
************************************************************************
|
2010-09-17 20:10:39 +09:00
|
|
|
*
|
|
|
|
* This is the next part if the initialization sequence: we are now
|
|
|
|
* running from RAM and have a "normal" C environment, i. e. global
|
|
|
|
* data can be written, BSS has been cleared, the stack size in not
|
|
|
|
* that critical any more, etc.
|
|
|
|
*
|
|
|
|
************************************************************************
|
|
|
|
*/
|
2010-10-11 20:13:28 +09:00
|
|
|
|
2011-07-16 04:36:36 +09:00
|
|
|
void board_init_r(gd_t *id, ulong dest_addr)
|
2010-09-17 20:10:39 +09:00
|
|
|
{
|
|
|
|
ulong malloc_start;
|
|
|
|
#if !defined(CONFIG_SYS_NO_FLASH)
|
|
|
|
ulong flash_size;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
gd = id;
|
|
|
|
|
|
|
|
gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */
|
2012-02-13 22:51:21 +09:00
|
|
|
bootstage_mark_name(BOOTSTAGE_ID_START_UBOOT_R, "board_init_r");
|
2010-09-17 20:10:39 +09:00
|
|
|
|
2011-03-02 08:02:04 +09:00
|
|
|
monitor_flash_len = _end_ofs;
|
2011-08-16 13:33:05 +09:00
|
|
|
|
|
|
|
/* Enable caches */
|
|
|
|
enable_caches();
|
2011-06-17 08:30:49 +09:00
|
|
|
|
2011-07-16 04:36:36 +09:00
|
|
|
debug("monitor flash len: %08lX\n", monitor_flash_len);
|
2010-09-17 20:10:39 +09:00
|
|
|
board_init(); /* Setup chipselects */
|
2012-02-06 09:30:44 +09:00
|
|
|
/*
|
|
|
|
* 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
|
2010-09-17 20:10:39 +09:00
|
|
|
#ifdef CONFIG_SERIAL_MULTI
|
|
|
|
serial_initialize();
|
|
|
|
#endif
|
|
|
|
|
2011-07-16 04:36:36 +09:00
|
|
|
debug("Now running in RAM - U-Boot at: %08lx\n", dest_addr);
|
2010-09-17 20:10:39 +09:00
|
|
|
|
|
|
|
#ifdef CONFIG_LOGBUFFER
|
2011-07-16 04:36:36 +09:00
|
|
|
logbuff_init_ptrs();
|
2010-09-17 20:10:39 +09:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_POST
|
2011-07-16 04:36:36 +09:00
|
|
|
post_output_backlog();
|
2010-09-17 20:10:39 +09:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* The Malloc area is immediately below the monitor copy in DRAM */
|
|
|
|
malloc_start = dest_addr - TOTAL_MALLOC_LEN;
|
|
|
|
mem_malloc_init (malloc_start, TOTAL_MALLOC_LEN);
|
|
|
|
|
2012-04-02 20:19:45 +09:00
|
|
|
#ifdef CONFIG_ARCH_EARLY_INIT_R
|
|
|
|
arch_early_init_r();
|
|
|
|
#endif
|
|
|
|
|
2010-09-17 20:10:39 +09:00
|
|
|
#if !defined(CONFIG_SYS_NO_FLASH)
|
2011-07-16 04:36:36 +09:00
|
|
|
puts("Flash: ");
|
2010-09-17 20:10:39 +09:00
|
|
|
|
2011-07-16 04:36:36 +09:00
|
|
|
flash_size = flash_init();
|
|
|
|
if (flash_size > 0) {
|
2010-09-17 20:10:39 +09:00
|
|
|
# ifdef CONFIG_SYS_FLASH_CHECKSUM
|
2011-10-24 02:44:35 +09:00
|
|
|
char *s = getenv("flashchecksum");
|
|
|
|
|
2011-07-16 04:36:36 +09:00
|
|
|
print_size(flash_size, "");
|
2010-09-17 20:10:39 +09:00
|
|
|
/*
|
|
|
|
* Compute and print flash CRC if flashchecksum is set to 'y'
|
|
|
|
*
|
|
|
|
* NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
|
|
|
|
*/
|
|
|
|
if (s && (*s == 'y')) {
|
2011-07-16 04:36:36 +09:00
|
|
|
printf(" CRC: %08X", crc32(0,
|
|
|
|
(const unsigned char *) CONFIG_SYS_FLASH_BASE,
|
|
|
|
flash_size));
|
2010-09-17 20:10:39 +09:00
|
|
|
}
|
2011-07-16 04:36:36 +09:00
|
|
|
putc('\n');
|
2010-09-17 20:10:39 +09:00
|
|
|
# else /* !CONFIG_SYS_FLASH_CHECKSUM */
|
2011-07-16 04:36:36 +09:00
|
|
|
print_size(flash_size, "\n");
|
2010-09-17 20:10:39 +09:00
|
|
|
# endif /* CONFIG_SYS_FLASH_CHECKSUM */
|
|
|
|
} else {
|
2011-07-16 04:36:36 +09:00
|
|
|
puts(failed);
|
|
|
|
hang();
|
2010-09-17 20:10:39 +09:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(CONFIG_CMD_NAND)
|
2011-07-16 04:36:36 +09:00
|
|
|
puts("NAND: ");
|
2010-09-17 20:10:39 +09:00
|
|
|
nand_init(); /* go init the NAND */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(CONFIG_CMD_ONENAND)
|
|
|
|
onenand_init();
|
|
|
|
#endif
|
|
|
|
|
2010-10-11 21:51:39 +09:00
|
|
|
#ifdef CONFIG_GENERIC_MMC
|
|
|
|
puts("MMC: ");
|
2011-10-06 05:44:43 +09:00
|
|
|
mmc_initialize(gd->bd);
|
2010-10-11 21:51:39 +09:00
|
|
|
#endif
|
|
|
|
|
2010-09-17 20:10:39 +09:00
|
|
|
#ifdef CONFIG_HAS_DATAFLASH
|
|
|
|
AT91F_DataflashInit();
|
|
|
|
dataflash_print_info();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* initialize environment */
|
2011-07-16 04:36:36 +09:00
|
|
|
env_relocate();
|
2010-09-17 20:10:39 +09:00
|
|
|
|
2011-05-23 07:00:13 +09:00
|
|
|
#if defined(CONFIG_CMD_PCI) || defined(CONFIG_PCI)
|
|
|
|
arm_pci_init();
|
|
|
|
#endif
|
2010-09-17 20:10:39 +09:00
|
|
|
|
2011-07-16 04:36:36 +09:00
|
|
|
stdio_init(); /* get the devices list going. */
|
2010-09-17 20:10:39 +09:00
|
|
|
|
2011-07-16 04:36:36 +09:00
|
|
|
jumptable_init();
|
2010-09-17 20:10:39 +09:00
|
|
|
|
|
|
|
#if defined(CONFIG_API)
|
|
|
|
/* Initialize API */
|
2011-07-16 04:36:36 +09:00
|
|
|
api_init();
|
2010-09-17 20:10:39 +09:00
|
|
|
#endif
|
|
|
|
|
2011-07-16 04:36:36 +09:00
|
|
|
console_init_r(); /* fully init console as a device */
|
2010-09-17 20:10:39 +09:00
|
|
|
|
|
|
|
#if defined(CONFIG_ARCH_MISC_INIT)
|
|
|
|
/* miscellaneous arch dependent initialisations */
|
2011-07-16 04:36:36 +09:00
|
|
|
arch_misc_init();
|
2010-09-17 20:10:39 +09:00
|
|
|
#endif
|
|
|
|
#if defined(CONFIG_MISC_INIT_R)
|
|
|
|
/* miscellaneous platform dependent initialisations */
|
2011-07-16 04:36:36 +09:00
|
|
|
misc_init_r();
|
2010-09-17 20:10:39 +09:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* set up exceptions */
|
2011-07-16 04:36:36 +09:00
|
|
|
interrupt_init();
|
2010-09-17 20:10:39 +09:00
|
|
|
/* enable exceptions */
|
2011-07-16 04:36:36 +09:00
|
|
|
enable_interrupts();
|
2010-09-17 20:10:39 +09:00
|
|
|
|
|
|
|
/* Perform network card initialisation if necessary */
|
|
|
|
#if defined(CONFIG_DRIVER_SMC91111) || defined (CONFIG_DRIVER_LAN91C96)
|
|
|
|
/* XXX: this needs to be moved to board init */
|
2011-07-16 04:36:36 +09:00
|
|
|
if (getenv("ethaddr")) {
|
2010-09-17 20:10:39 +09:00
|
|
|
uchar enetaddr[6];
|
|
|
|
eth_getenv_enetaddr("ethaddr", enetaddr);
|
|
|
|
smc_set_mac_addr(enetaddr);
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_DRIVER_SMC91111 || CONFIG_DRIVER_LAN91C96 */
|
|
|
|
|
|
|
|
/* Initialize from environment */
|
2011-10-13 23:43:06 +09:00
|
|
|
load_addr = getenv_ulong("loadaddr", 16, load_addr);
|
2010-09-17 20:10:39 +09:00
|
|
|
|
2011-10-20 13:19:47 +09:00
|
|
|
#ifdef CONFIG_BOARD_LATE_INIT
|
2011-07-16 04:36:36 +09:00
|
|
|
board_late_init();
|
2010-09-17 20:10:39 +09:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_BITBANGMII
|
|
|
|
bb_miiphy_init();
|
|
|
|
#endif
|
|
|
|
#if defined(CONFIG_CMD_NET)
|
2011-07-16 04:36:36 +09:00
|
|
|
puts("Net: ");
|
2010-09-17 20:10:39 +09:00
|
|
|
eth_initialize(gd->bd);
|
|
|
|
#if defined(CONFIG_RESET_PHY_R)
|
2011-07-16 04:36:36 +09:00
|
|
|
debug("Reset Ethernet PHY\n");
|
2010-09-17 20:10:39 +09:00
|
|
|
reset_phy();
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_POST
|
2011-07-16 04:36:36 +09:00
|
|
|
post_run(NULL, POST_RAM | post_bootmode_get(0));
|
2010-09-17 20:10:39 +09:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER)
|
|
|
|
/*
|
|
|
|
* Export available size of memory for Linux,
|
|
|
|
* taking into account the protected RAM at top of memory
|
|
|
|
*/
|
|
|
|
{
|
2011-10-13 23:43:06 +09:00
|
|
|
ulong pram = 0;
|
2010-09-17 20:10:39 +09:00
|
|
|
uchar memsz[32];
|
|
|
|
|
2011-10-13 23:43:06 +09:00
|
|
|
#ifdef CONFIG_PRAM
|
|
|
|
pram = getenv_ulong("pram", 10, CONFIG_PRAM);
|
2010-09-17 20:10:39 +09:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_LOGBUFFER
|
|
|
|
#ifndef CONFIG_ALT_LB_ADDR
|
|
|
|
/* Also take the logbuffer into account (pram is in kB) */
|
2011-07-16 04:36:36 +09:00
|
|
|
pram += (LOGBUFF_LEN + LOGBUFF_OVERHEAD) / 1024;
|
2010-09-17 20:10:39 +09:00
|
|
|
#endif
|
|
|
|
#endif
|
2011-06-03 07:11:37 +09:00
|
|
|
sprintf((char *)memsz, "%ldk", (gd->ram_size / 1024) - pram);
|
2011-07-16 04:36:36 +09:00
|
|
|
setenv("mem", (char *)memsz);
|
2010-09-17 20:10:39 +09:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* main_loop() can return to retry autoboot, if so just run it again. */
|
|
|
|
for (;;) {
|
2011-07-16 04:36:36 +09:00
|
|
|
main_loop();
|
2010-09-17 20:10:39 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
/* NOTREACHED - no way out of command loop except booting */
|
|
|
|
}
|
2010-10-11 20:13:28 +09:00
|
|
|
|
2011-07-16 04:36:36 +09:00
|
|
|
void hang(void)
|
2002-11-03 09:24:07 +09:00
|
|
|
{
|
2011-07-16 04:36:36 +09:00
|
|
|
puts("### ERROR ### Please RESET the board ###\n");
|
2002-11-03 09:24:07 +09:00
|
|
|
for (;;);
|
|
|
|
}
|