2002-11-03 00:24:07 +00:00
|
|
|
/*
|
2006-01-29 18:12:41 +00:00
|
|
|
* (C) Copyright 2002-2006
|
2002-11-03 00:24:07 +00: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-29 18:12:41 +00: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 00:24:07 +00:00
|
|
|
#include <common.h>
|
|
|
|
#include <command.h>
|
2003-06-22 17:18:28 +00:00
|
|
|
#include <malloc.h>
|
2009-05-16 10:14:54 +00:00
|
|
|
#include <stdio_dev.h>
|
2002-11-03 00:24:07 +00:00
|
|
|
#include <version.h>
|
|
|
|
#include <net.h>
|
2008-05-01 07:05:26 +00:00
|
|
|
#include <serial.h>
|
2008-05-22 15:49:46 +00:00
|
|
|
#include <nand.h>
|
|
|
|
#include <onenand_uboot.h>
|
2009-06-08 00:12:50 +00:00
|
|
|
#include <mmc.h>
|
2002-11-03 00:24:07 +00:00
|
|
|
|
2009-10-10 10:42:21 +00:00
|
|
|
#ifdef CONFIG_BITBANGMII
|
|
|
|
#include <miiphy.h>
|
|
|
|
#endif
|
|
|
|
|
2004-06-09 13:37:52 +00:00
|
|
|
#ifdef CONFIG_DRIVER_SMC91111
|
2007-11-21 20:19:24 +00:00
|
|
|
#include "../drivers/net/smc91111.h"
|
2004-06-09 13:37:52 +00:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_DRIVER_LAN91C96
|
2007-11-21 20:19:24 +00:00
|
|
|
#include "../drivers/net/lan91c96.h"
|
2004-06-09 13:37:52 +00:00
|
|
|
#endif
|
|
|
|
|
2006-02-10 10:25:41 +00:00
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2003-05-30 12:48:29 +00:00
|
|
|
ulong monitor_flash_len;
|
|
|
|
|
2003-06-16 23:50:08 +00:00
|
|
|
#ifdef CONFIG_HAS_DATAFLASH
|
|
|
|
extern int AT91F_DataflashInit(void);
|
|
|
|
extern void dataflash_print_info(void);
|
|
|
|
#endif
|
|
|
|
|
2004-06-06 22:11:41 +00:00
|
|
|
#ifdef CONFIG_DRIVER_RTL8019
|
2003-12-07 00:46:27 +00:00
|
|
|
extern void rtl8019_get_enetaddr (uchar * addr);
|
|
|
|
#endif
|
|
|
|
|
2007-12-19 00:00:54 +00:00
|
|
|
#if defined(CONFIG_HARD_I2C) || \
|
|
|
|
defined(CONFIG_SOFT_I2C)
|
|
|
|
#include <i2c.h>
|
|
|
|
#endif
|
|
|
|
|
2008-05-09 19:57:18 +00:00
|
|
|
|
2007-09-04 15:18:38 +00:00
|
|
|
/************************************************************************
|
|
|
|
* Coloured LED functionality
|
|
|
|
************************************************************************
|
|
|
|
* May be supplied by boards if desired
|
|
|
|
*/
|
2011-07-15 19:36:36 +00:00
|
|
|
inline void __coloured_LED_init(void) {}
|
|
|
|
void coloured_LED_init(void)
|
|
|
|
__attribute__((weak, alias("__coloured_LED_init")));
|
|
|
|
inline void __red_LED_on(void) {}
|
|
|
|
void red_LED_on(void) __attribute__((weak, alias("__red_LED_on")));
|
|
|
|
inline void __red_LED_off(void) {}
|
2009-08-05 18:14:01 +00:00
|
|
|
void red_LED_off(void) __attribute__((weak, alias("__red_LED_off")));
|
2011-07-15 19:36:36 +00:00
|
|
|
inline void __green_LED_on(void) {}
|
2009-08-05 18:14:01 +00:00
|
|
|
void green_LED_on(void) __attribute__((weak, alias("__green_LED_on")));
|
2011-07-15 19:36:36 +00:00
|
|
|
inline void __green_LED_off(void) {}
|
2009-08-05 18:14:01 +00:00
|
|
|
void green_LED_off(void) __attribute__((weak, alias("__green_LED_off")));
|
2011-07-15 19:36:36 +00:00
|
|
|
inline void __yellow_LED_on(void) {}
|
2009-08-05 18:14:01 +00:00
|
|
|
void yellow_LED_on(void) __attribute__((weak, alias("__yellow_LED_on")));
|
2011-07-15 19:36:36 +00:00
|
|
|
inline void __yellow_LED_off(void) {}
|
2009-08-05 18:14:01 +00:00
|
|
|
void yellow_LED_off(void) __attribute__((weak, alias("__yellow_LED_off")));
|
2011-07-15 19:36:36 +00:00
|
|
|
inline void __blue_LED_on(void) {}
|
2009-08-05 18:14:01 +00:00
|
|
|
void blue_LED_on(void) __attribute__((weak, alias("__blue_LED_on")));
|
2011-07-15 19:36:36 +00:00
|
|
|
inline void __blue_LED_off(void) {}
|
2009-08-05 18:14:01 +00:00
|
|
|
void blue_LED_off(void) __attribute__((weak, alias("__blue_LED_off")));
|
2007-09-04 15:18:38 +00:00
|
|
|
|
2011-07-15 19:36:36 +00:00
|
|
|
/*
|
|
|
|
************************************************************************
|
2002-11-03 00:24:07 +00: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 14:49:28 +00:00
|
|
|
#if defined(CONFIG_ARM_DCC) && !defined(CONFIG_BAUDRATE)
|
|
|
|
#define CONFIG_BAUDRATE 115200
|
|
|
|
#endif
|
2011-07-15 19:36:36 +00:00
|
|
|
static int init_baudrate(void)
|
2002-11-03 00:24:07 +00:00
|
|
|
{
|
2006-03-11 21:53:33 +00:00
|
|
|
char tmp[64]; /* long enough for environment variables */
|
2011-07-15 19:36:36 +00:00
|
|
|
int i = getenv_f("baudrate", tmp, sizeof(tmp));
|
2010-09-17 11:10:39 +00:00
|
|
|
|
|
|
|
gd->baudrate = (i > 0)
|
2011-07-15 19:36:36 +00:00
|
|
|
? (int) simple_strtoul(tmp, NULL, 10)
|
2002-11-03 00:24:07 +00:00
|
|
|
: CONFIG_BAUDRATE;
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2011-07-15 19:36:36 +00:00
|
|
|
static int display_banner(void)
|
2002-11-03 00:24:07 +00:00
|
|
|
{
|
2011-07-15 19:36:36 +00:00
|
|
|
printf("\n\n%s\n\n", version_string);
|
|
|
|
debug("U-Boot code: %08lX -> %08lX BSS: -> %08lX\n",
|
2010-09-17 11:10:39 +00:00
|
|
|
_TEXT_BASE,
|
2011-07-15 19:36:36 +00:00
|
|
|
_bss_start_ofs + _TEXT_BASE, _bss_end_ofs + _TEXT_BASE);
|
2002-11-03 00:24:07 +00:00
|
|
|
#ifdef CONFIG_MODEM_SUPPORT
|
2011-07-15 19:36:36 +00:00
|
|
|
debug("Modem Support enabled\n");
|
2002-11-03 00:24:07 +00:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_USE_IRQ
|
2011-07-15 19:36:36 +00:00
|
|
|
debug("IRQ Stack: %08lx\n", IRQ_STACK_START);
|
|
|
|
debug("FIQ Stack: %08lx\n", FIQ_STACK_START);
|
2002-11-03 00:24:07 +00:00
|
|
|
#endif
|
2003-10-10 10:05:42 +00:00
|
|
|
|
2002-11-03 00:24:07 +00: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-15 19:36:36 +00:00
|
|
|
static int display_dram_config(void)
|
2002-11-03 00:24:07 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2006-01-29 18:12:41 +00:00
|
|
|
#ifdef DEBUG
|
2011-07-15 19:36:36 +00:00
|
|
|
puts("RAM Configuration:\n");
|
2002-11-03 00:24:07 +00:00
|
|
|
|
2011-07-15 19:36:36 +00: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 00:24:07 +00:00
|
|
|
}
|
2006-01-29 18:12:41 +00:00
|
|
|
#else
|
|
|
|
ulong size = 0;
|
|
|
|
|
2011-07-15 19:36:36 +00:00
|
|
|
for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++)
|
2006-01-29 18:12:41 +00:00
|
|
|
size += gd->bd->bi_dram[i].size;
|
2011-07-15 19:36:36 +00:00
|
|
|
|
2006-01-29 18:12:41 +00:00
|
|
|
puts("DRAM: ");
|
|
|
|
print_size(size, "\n");
|
|
|
|
#endif
|
2002-11-03 00:24:07 +00:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2007-12-19 00:00:54 +00:00
|
|
|
#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
|
2011-07-15 19:36:36 +00:00
|
|
|
static int init_func_i2c(void)
|
2007-12-19 00:00:54 +00:00
|
|
|
{
|
2011-07-15 19:36:36 +00:00
|
|
|
puts("I2C: ");
|
|
|
|
i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
|
|
|
|
puts("ready\n");
|
2007-12-19 00:00:54 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-01-31 08:04:58 +00: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 00:24:07 +00:00
|
|
|
/*
|
2003-12-06 19:49:23 +00:00
|
|
|
* Breathe some life into the board...
|
2002-11-03 00:24:07 +00:00
|
|
|
*
|
2003-09-17 22:48:07 +00:00
|
|
|
* Initialize a serial port as console, and carry out some hardware
|
2002-11-03 00:24:07 +00: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-08 19:38:38 +00:00
|
|
|
* mess of board dependent #ifdef'ed code we now make the whole
|
2002-11-03 00:24:07 +00: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-15 19:36:36 +00:00
|
|
|
int print_cpuinfo(void);
|
2006-01-29 18:12:41 +00:00
|
|
|
|
2010-09-17 11:10:39 +00: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,
|
|
|
|
#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-15 19:36:36 +00:00
|
|
|
void board_init_f(ulong bootflag)
|
2010-09-17 11:10:39 +00:00
|
|
|
{
|
|
|
|
bd_t *bd;
|
|
|
|
init_fnc_t **init_fnc_ptr;
|
|
|
|
gd_t *id;
|
|
|
|
ulong addr, addr_sp;
|
|
|
|
|
|
|
|
/* Pointer is writable since we allocated a register for it */
|
2010-11-12 06:53:55 +00:00
|
|
|
gd = (gd_t *) ((CONFIG_SYS_INIT_SP_ADDR) & ~0x07);
|
2010-09-17 11:10:39 +00:00
|
|
|
/* compiler optimization barrier needed for GCC >= 3.4 */
|
|
|
|
__asm__ __volatile__("": : :"memory");
|
|
|
|
|
2011-07-15 19:36:36 +00:00
|
|
|
memset((void *)gd, 0, sizeof(gd_t));
|
2010-09-17 11:10:39 +00:00
|
|
|
|
2010-10-11 11:13:28 +00:00
|
|
|
gd->mon_len = _bss_end_ofs;
|
2010-09-17 11:10:39 +00:00
|
|
|
|
|
|
|
for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
|
|
|
|
if ((*init_fnc_ptr)() != 0) {
|
|
|
|
hang ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-15 19:36:36 +00:00
|
|
|
debug("monitor len: %08lX\n", gd->mon_len);
|
2010-09-17 11:10:39 +00:00
|
|
|
/*
|
|
|
|
* Ram is setup, size stored in gd !!
|
|
|
|
*/
|
2011-07-15 19:36:36 +00:00
|
|
|
debug("ramsize: %08lX\n", gd->ram_size);
|
2010-09-17 11:10:39 +00: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-15 19:36:36 +00:00
|
|
|
debug("Reserving %dk for kernel logbuffer at %08lx\n", LOGBUFF_LEN,
|
|
|
|
addr);
|
2010-09-17 11:10:39 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_PRAM
|
|
|
|
/*
|
|
|
|
* reserve protected RAM
|
|
|
|
*/
|
2011-07-15 19:36:36 +00:00
|
|
|
i = getenv_r("pram", (char *)tmp, sizeof(tmp));
|
|
|
|
reg = (i > 0) ? simple_strtoul((const char *)tmp, NULL, 10) :
|
|
|
|
CONFIG_PRAM;
|
2010-09-17 11:10:39 +00:00
|
|
|
addr -= (reg << 10); /* size is in kB */
|
2011-07-15 19:36:36 +00:00
|
|
|
debug("Reserving %ldk for protected RAM at %08lx\n", reg, addr);
|
2010-09-17 11:10:39 +00:00
|
|
|
#endif /* CONFIG_PRAM */
|
|
|
|
|
2011-06-16 23:30:48 +00:00
|
|
|
#if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF))
|
2010-09-17 11:10:39 +00:00
|
|
|
/* reserve TLB table */
|
|
|
|
addr -= (4096 * 4);
|
|
|
|
|
|
|
|
/* round down to next 64 kB limit */
|
|
|
|
addr &= ~(0x10000 - 1);
|
|
|
|
|
|
|
|
gd->tlb_addr = addr;
|
2011-07-15 19:36:36 +00:00
|
|
|
debug("TLB table at: %08lx\n", addr);
|
2010-09-17 11:10:39 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* round down to next 4 kB limit */
|
|
|
|
addr &= ~(4096 - 1);
|
2011-07-15 19:36:36 +00:00
|
|
|
debug("Top of RAM usable for U-Boot at: %08lx\n", addr);
|
2010-09-17 11:10:39 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_LCD
|
2011-04-24 22:22:34 +00:00
|
|
|
#ifdef CONFIG_FB_ADDR
|
|
|
|
gd->fb_base = CONFIG_FB_ADDR;
|
|
|
|
#else
|
2010-09-17 11:10:39 +00:00
|
|
|
/* reserve memory for LCD display (always full pages) */
|
2011-07-15 19:36:36 +00:00
|
|
|
addr = lcd_setmem(addr);
|
2010-09-17 11:10:39 +00:00
|
|
|
gd->fb_base = addr;
|
2011-04-24 22:22:34 +00:00
|
|
|
#endif /* CONFIG_FB_ADDR */
|
2010-09-17 11:10:39 +00: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-15 19:36:36 +00:00
|
|
|
debug("Reserving %ldk for U-Boot at: %08lx\n", gd->mon_len >> 10, addr);
|
2010-09-17 11:10:39 +00:00
|
|
|
|
2011-07-13 05:11:07 +00:00
|
|
|
#ifndef CONFIG_SPL_BUILD
|
2010-09-17 11:10:39 +00:00
|
|
|
/*
|
|
|
|
* reserve memory for malloc() arena
|
|
|
|
*/
|
|
|
|
addr_sp = addr - TOTAL_MALLOC_LEN;
|
2011-07-15 19:36:36 +00:00
|
|
|
debug("Reserving %dk for malloc() at: %08lx\n",
|
2010-09-17 11:10:39 +00: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-15 19:36:36 +00:00
|
|
|
debug("Reserving %zu Bytes for Board Info at: %08lx\n",
|
2010-09-17 11:10:39 +00:00
|
|
|
sizeof (bd_t), addr_sp);
|
2011-08-16 23:48:23 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_MACH_TYPE
|
|
|
|
gd->bd->bi_arch_number = CONFIG_MACH_TYPE; /* board id for Linux */
|
|
|
|
#endif
|
|
|
|
|
2010-09-17 11:10:39 +00:00
|
|
|
addr_sp -= sizeof (gd_t);
|
|
|
|
id = (gd_t *) addr_sp;
|
2011-07-15 19:36:36 +00:00
|
|
|
debug("Reserving %zu Bytes for Global Data at: %08lx\n",
|
2010-09-17 11:10:39 +00: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-15 19:36:36 +00:00
|
|
|
debug("Reserving %zu Bytes for IRQ stack at: %08lx\n",
|
2010-09-17 11:10:39 +00:00
|
|
|
CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ, addr_sp);
|
|
|
|
#endif
|
|
|
|
/* leave 3 words for abort-stack */
|
2011-04-14 12:32:37 +00:00
|
|
|
addr_sp -= 12;
|
2010-09-17 11:10:39 +00: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-15 19:36:36 +00:00
|
|
|
debug("New Stack Pointer is: %08lx\n", addr_sp);
|
2010-09-17 11:10:39 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_POST
|
|
|
|
post_bootmode_init();
|
2011-07-15 19:36:36 +00:00
|
|
|
post_run(NULL, POST_ROM | post_bootmode_get(0));
|
2010-09-17 11:10:39 +00: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-15 19:36:36 +00:00
|
|
|
debug("relocation Offset is: %08lx\n", gd->reloc_off);
|
|
|
|
memcpy(id, (void *)gd, sizeof(gd_t));
|
2010-09-17 11:10:39 +00:00
|
|
|
|
2011-07-15 19:36:36 +00:00
|
|
|
relocate_code(addr_sp, id, addr);
|
2010-09-17 11:10:39 +00:00
|
|
|
|
|
|
|
/* NOTREACHED - relocate_code() does not return */
|
|
|
|
}
|
|
|
|
|
|
|
|
#if !defined(CONFIG_SYS_NO_FLASH)
|
|
|
|
static char *failed = "*** failed ***\n";
|
|
|
|
#endif
|
|
|
|
|
2011-07-15 19:36:36 +00:00
|
|
|
/*
|
|
|
|
************************************************************************
|
2010-09-17 11:10:39 +00: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 11:13:28 +00:00
|
|
|
|
2011-07-15 19:36:36 +00:00
|
|
|
void board_init_r(gd_t *id, ulong dest_addr)
|
2010-09-17 11:10:39 +00:00
|
|
|
{
|
|
|
|
char *s;
|
|
|
|
bd_t *bd;
|
|
|
|
ulong malloc_start;
|
|
|
|
#if !defined(CONFIG_SYS_NO_FLASH)
|
|
|
|
ulong flash_size;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
gd = id;
|
|
|
|
bd = gd->bd;
|
|
|
|
|
|
|
|
gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */
|
|
|
|
|
2011-03-01 23:02:04 +00:00
|
|
|
monitor_flash_len = _end_ofs;
|
2011-08-16 04:33:05 +00:00
|
|
|
|
|
|
|
/* Enable caches */
|
|
|
|
enable_caches();
|
2011-06-16 23:30:49 +00:00
|
|
|
|
2011-07-15 19:36:36 +00:00
|
|
|
debug("monitor flash len: %08lX\n", monitor_flash_len);
|
2010-09-17 11:10:39 +00:00
|
|
|
board_init(); /* Setup chipselects */
|
|
|
|
|
|
|
|
#ifdef CONFIG_SERIAL_MULTI
|
|
|
|
serial_initialize();
|
|
|
|
#endif
|
|
|
|
|
2011-07-15 19:36:36 +00:00
|
|
|
debug("Now running in RAM - U-Boot at: %08lx\n", dest_addr);
|
2010-09-17 11:10:39 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_LOGBUFFER
|
2011-07-15 19:36:36 +00:00
|
|
|
logbuff_init_ptrs();
|
2010-09-17 11:10:39 +00:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_POST
|
2011-07-15 19:36:36 +00:00
|
|
|
post_output_backlog();
|
2010-09-17 11:10:39 +00: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);
|
|
|
|
|
|
|
|
#if !defined(CONFIG_SYS_NO_FLASH)
|
2011-07-15 19:36:36 +00:00
|
|
|
puts("Flash: ");
|
2010-09-17 11:10:39 +00:00
|
|
|
|
2011-07-15 19:36:36 +00:00
|
|
|
flash_size = flash_init();
|
|
|
|
if (flash_size > 0) {
|
2010-09-17 11:10:39 +00:00
|
|
|
# ifdef CONFIG_SYS_FLASH_CHECKSUM
|
2011-07-15 19:36:36 +00:00
|
|
|
print_size(flash_size, "");
|
2010-09-17 11:10:39 +00:00
|
|
|
/*
|
|
|
|
* Compute and print flash CRC if flashchecksum is set to 'y'
|
|
|
|
*
|
|
|
|
* NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
|
|
|
|
*/
|
2011-07-15 19:36:36 +00:00
|
|
|
s = getenv("flashchecksum");
|
2010-09-17 11:10:39 +00:00
|
|
|
if (s && (*s == 'y')) {
|
2011-07-15 19:36:36 +00:00
|
|
|
printf(" CRC: %08X", crc32(0,
|
|
|
|
(const unsigned char *) CONFIG_SYS_FLASH_BASE,
|
|
|
|
flash_size));
|
2010-09-17 11:10:39 +00:00
|
|
|
}
|
2011-07-15 19:36:36 +00:00
|
|
|
putc('\n');
|
2010-09-17 11:10:39 +00:00
|
|
|
# else /* !CONFIG_SYS_FLASH_CHECKSUM */
|
2011-07-15 19:36:36 +00:00
|
|
|
print_size(flash_size, "\n");
|
2010-09-17 11:10:39 +00:00
|
|
|
# endif /* CONFIG_SYS_FLASH_CHECKSUM */
|
|
|
|
} else {
|
2011-07-15 19:36:36 +00:00
|
|
|
puts(failed);
|
|
|
|
hang();
|
2010-09-17 11:10:39 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(CONFIG_CMD_NAND)
|
2011-07-15 19:36:36 +00:00
|
|
|
puts("NAND: ");
|
2010-09-17 11:10:39 +00:00
|
|
|
nand_init(); /* go init the NAND */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(CONFIG_CMD_ONENAND)
|
|
|
|
onenand_init();
|
|
|
|
#endif
|
|
|
|
|
2010-10-11 12:51:39 +00:00
|
|
|
#ifdef CONFIG_GENERIC_MMC
|
|
|
|
puts("MMC: ");
|
|
|
|
mmc_initialize(bd);
|
|
|
|
#endif
|
|
|
|
|
2010-09-17 11:10:39 +00:00
|
|
|
#ifdef CONFIG_HAS_DATAFLASH
|
|
|
|
AT91F_DataflashInit();
|
|
|
|
dataflash_print_info();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* initialize environment */
|
2011-07-15 19:36:36 +00:00
|
|
|
env_relocate();
|
2010-09-17 11:10:39 +00:00
|
|
|
|
2011-05-22 22:00:13 +00:00
|
|
|
#if defined(CONFIG_CMD_PCI) || defined(CONFIG_PCI)
|
|
|
|
arm_pci_init();
|
|
|
|
#endif
|
2010-09-17 11:10:39 +00:00
|
|
|
|
|
|
|
/* IP Address */
|
2011-07-15 19:36:36 +00:00
|
|
|
gd->bd->bi_ip_addr = getenv_IPaddr("ipaddr");
|
2010-09-17 11:10:39 +00:00
|
|
|
|
2011-07-15 19:36:36 +00:00
|
|
|
stdio_init(); /* get the devices list going. */
|
2010-09-17 11:10:39 +00:00
|
|
|
|
2011-07-15 19:36:36 +00:00
|
|
|
jumptable_init();
|
2010-09-17 11:10:39 +00:00
|
|
|
|
|
|
|
#if defined(CONFIG_API)
|
|
|
|
/* Initialize API */
|
2011-07-15 19:36:36 +00:00
|
|
|
api_init();
|
2010-09-17 11:10:39 +00:00
|
|
|
#endif
|
|
|
|
|
2011-07-15 19:36:36 +00:00
|
|
|
console_init_r(); /* fully init console as a device */
|
2010-09-17 11:10:39 +00:00
|
|
|
|
|
|
|
#if defined(CONFIG_ARCH_MISC_INIT)
|
|
|
|
/* miscellaneous arch dependent initialisations */
|
2011-07-15 19:36:36 +00:00
|
|
|
arch_misc_init();
|
2010-09-17 11:10:39 +00:00
|
|
|
#endif
|
|
|
|
#if defined(CONFIG_MISC_INIT_R)
|
|
|
|
/* miscellaneous platform dependent initialisations */
|
2011-07-15 19:36:36 +00:00
|
|
|
misc_init_r();
|
2010-09-17 11:10:39 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* set up exceptions */
|
2011-07-15 19:36:36 +00:00
|
|
|
interrupt_init();
|
2010-09-17 11:10:39 +00:00
|
|
|
/* enable exceptions */
|
2011-07-15 19:36:36 +00:00
|
|
|
enable_interrupts();
|
2010-09-17 11:10:39 +00: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-15 19:36:36 +00:00
|
|
|
if (getenv("ethaddr")) {
|
2010-09-17 11:10:39 +00: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-07-15 19:36:36 +00:00
|
|
|
s = getenv("loadaddr");
|
|
|
|
if (s != NULL)
|
|
|
|
load_addr = simple_strtoul(s, NULL, 16);
|
2010-09-17 11:10:39 +00:00
|
|
|
#if defined(CONFIG_CMD_NET)
|
2011-07-15 19:36:36 +00:00
|
|
|
s = getenv("bootfile");
|
|
|
|
if (s != NULL)
|
|
|
|
copy_filename(BootFile, s, sizeof(BootFile));
|
2010-09-17 11:10:39 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef BOARD_LATE_INIT
|
2011-07-15 19:36:36 +00:00
|
|
|
board_late_init();
|
2010-09-17 11:10:39 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_BITBANGMII
|
|
|
|
bb_miiphy_init();
|
|
|
|
#endif
|
|
|
|
#if defined(CONFIG_CMD_NET)
|
|
|
|
#if defined(CONFIG_NET_MULTI)
|
2011-07-15 19:36:36 +00:00
|
|
|
puts("Net: ");
|
2010-09-17 11:10:39 +00:00
|
|
|
#endif
|
|
|
|
eth_initialize(gd->bd);
|
|
|
|
#if defined(CONFIG_RESET_PHY_R)
|
2011-07-15 19:36:36 +00:00
|
|
|
debug("Reset Ethernet PHY\n");
|
2010-09-17 11:10:39 +00:00
|
|
|
reset_phy();
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_POST
|
2011-07-15 19:36:36 +00:00
|
|
|
post_run(NULL, POST_RAM | post_bootmode_get(0));
|
2010-09-17 11:10:39 +00: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
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
ulong pram;
|
|
|
|
uchar memsz[32];
|
|
|
|
#ifdef CONFIG_PRAM
|
|
|
|
char *s;
|
|
|
|
|
2011-07-15 19:36:36 +00:00
|
|
|
s = getenv("pram");
|
|
|
|
if (s != NULL)
|
|
|
|
pram = simple_strtoul(s, NULL, 10);
|
|
|
|
else
|
2010-09-17 11:10:39 +00:00
|
|
|
pram = CONFIG_PRAM;
|
|
|
|
#else
|
2011-07-15 19:36:36 +00:00
|
|
|
pram = 0;
|
2010-09-17 11:10:39 +00:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_LOGBUFFER
|
|
|
|
#ifndef CONFIG_ALT_LB_ADDR
|
|
|
|
/* Also take the logbuffer into account (pram is in kB) */
|
2011-07-15 19:36:36 +00:00
|
|
|
pram += (LOGBUFF_LEN + LOGBUFF_OVERHEAD) / 1024;
|
2010-09-17 11:10:39 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
2011-06-02 22:11:37 +00:00
|
|
|
sprintf((char *)memsz, "%ldk", (gd->ram_size / 1024) - pram);
|
2011-07-15 19:36:36 +00:00
|
|
|
setenv("mem", (char *)memsz);
|
2010-09-17 11:10:39 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* main_loop() can return to retry autoboot, if so just run it again. */
|
|
|
|
for (;;) {
|
2011-07-15 19:36:36 +00:00
|
|
|
main_loop();
|
2010-09-17 11:10:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* NOTREACHED - no way out of command loop except booting */
|
|
|
|
}
|
2010-10-11 11:13:28 +00:00
|
|
|
|
2011-07-15 19:36:36 +00:00
|
|
|
void hang(void)
|
2002-11-03 00:24:07 +00:00
|
|
|
{
|
2011-07-15 19:36:36 +00:00
|
|
|
puts("### ERROR ### Please RESET the board ###\n");
|
2002-11-03 00:24:07 +00:00
|
|
|
for (;;);
|
|
|
|
}
|