2006-03-12 01:12:27 +00:00
|
|
|
/*
|
|
|
|
* U-boot - board.c First C file to be called contains init routines
|
|
|
|
*
|
2008-02-19 05:54:20 +00:00
|
|
|
* Copyright (c) 2005-2008 Analog Devices Inc.
|
2006-03-12 01:12:27 +00:00
|
|
|
*
|
|
|
|
* (C) Copyright 2000-2004
|
|
|
|
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
|
|
|
*
|
2008-02-19 05:54:20 +00:00
|
|
|
* Licensed under the GPL-2 or later.
|
2006-03-12 01:12:27 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <command.h>
|
|
|
|
#include <devices.h>
|
|
|
|
#include <environment.h>
|
2007-03-09 05:38:44 +00:00
|
|
|
#include <i2c.h>
|
2008-02-19 05:54:20 +00:00
|
|
|
#include <malloc.h>
|
|
|
|
#include <net.h>
|
|
|
|
#include <version.h>
|
|
|
|
|
2007-03-09 05:38:44 +00:00
|
|
|
#include <asm/cplb.h>
|
2008-02-19 05:54:20 +00:00
|
|
|
#include <asm/mach-common/bits/mpu.h>
|
|
|
|
|
|
|
|
#ifdef CONFIG_CMD_NAND
|
|
|
|
#include <nand.h> /* cannot even include nand.h if it isnt configured */
|
|
|
|
#endif
|
2006-03-12 01:12:27 +00:00
|
|
|
|
2008-03-30 19:46:13 +00:00
|
|
|
#if defined(CONFIG_POST)
|
2007-03-09 05:38:44 +00:00
|
|
|
#include <post.h>
|
|
|
|
int post_flag;
|
|
|
|
#endif
|
2006-03-31 16:32:53 +00:00
|
|
|
|
2007-09-15 18:48:41 +00:00
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2008-02-19 05:54:20 +00:00
|
|
|
const char version_string[] = U_BOOT_VERSION " (" __DATE__ " - " __TIME__ ")";
|
|
|
|
|
|
|
|
__attribute__((always_inline))
|
|
|
|
static inline void serial_early_puts(const char *s)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_DEBUG_EARLY_SERIAL
|
|
|
|
serial_puts("Early: ");
|
|
|
|
serial_puts(s);
|
2007-03-09 05:38:44 +00:00
|
|
|
#endif
|
2008-02-19 05:54:20 +00:00
|
|
|
}
|
2006-03-12 01:12:27 +00:00
|
|
|
|
2008-02-19 05:54:20 +00:00
|
|
|
/* Get the input voltage */
|
|
|
|
static u_long get_vco(void)
|
2007-03-09 05:38:44 +00:00
|
|
|
{
|
|
|
|
u_long msel;
|
|
|
|
u_long vco;
|
|
|
|
|
|
|
|
msel = (*pPLL_CTL >> 9) & 0x3F;
|
|
|
|
if (0 == msel)
|
|
|
|
msel = 64;
|
|
|
|
|
|
|
|
vco = CONFIG_CLKIN_HZ;
|
|
|
|
vco >>= (1 & *pPLL_CTL); /* DF bit */
|
|
|
|
vco = msel * vco;
|
|
|
|
return vco;
|
|
|
|
}
|
|
|
|
|
2008-02-19 05:54:20 +00:00
|
|
|
/* Get the Core clock */
|
2007-03-09 05:38:44 +00:00
|
|
|
u_long get_cclk(void)
|
|
|
|
{
|
|
|
|
u_long csel, ssel;
|
|
|
|
if (*pPLL_STAT & 0x1)
|
|
|
|
return CONFIG_CLKIN_HZ;
|
|
|
|
|
|
|
|
ssel = *pPLL_DIV;
|
|
|
|
csel = ((ssel >> 4) & 0x03);
|
|
|
|
ssel &= 0xf;
|
|
|
|
if (ssel && ssel < (1 << csel)) /* SCLK > CCLK */
|
|
|
|
return get_vco() / ssel;
|
|
|
|
return get_vco() >> csel;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the System clock */
|
|
|
|
u_long get_sclk(void)
|
|
|
|
{
|
|
|
|
u_long ssel;
|
|
|
|
|
|
|
|
if (*pPLL_STAT & 0x1)
|
|
|
|
return CONFIG_CLKIN_HZ;
|
|
|
|
|
|
|
|
ssel = (*pPLL_DIV & 0xf);
|
|
|
|
|
|
|
|
return get_vco() / ssel;
|
|
|
|
}
|
2006-03-12 01:12:27 +00:00
|
|
|
|
2008-02-19 05:54:20 +00:00
|
|
|
static void *mem_malloc_start, *mem_malloc_end, *mem_malloc_brk;
|
|
|
|
|
2006-03-12 01:12:27 +00:00
|
|
|
static void mem_malloc_init(void)
|
|
|
|
{
|
2008-02-19 05:54:20 +00:00
|
|
|
mem_malloc_start = (void *)CFG_MALLOC_BASE;
|
|
|
|
mem_malloc_end = (void *)(CFG_MALLOC_BASE + CFG_MALLOC_LEN);
|
2006-03-12 01:12:27 +00:00
|
|
|
mem_malloc_brk = mem_malloc_start;
|
2008-02-19 05:54:20 +00:00
|
|
|
memset(mem_malloc_start, 0, mem_malloc_end - mem_malloc_start);
|
2006-03-12 01:12:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void *sbrk(ptrdiff_t increment)
|
|
|
|
{
|
2008-02-19 05:54:20 +00:00
|
|
|
void *old = mem_malloc_brk;
|
|
|
|
void *new = old + increment;
|
|
|
|
|
|
|
|
if (new < mem_malloc_start || new > mem_malloc_end)
|
|
|
|
return NULL;
|
2006-03-12 01:12:27 +00:00
|
|
|
|
|
|
|
mem_malloc_brk = new;
|
|
|
|
|
2008-02-19 05:54:20 +00:00
|
|
|
return old;
|
2006-03-12 01:12:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int display_banner(void)
|
|
|
|
{
|
2008-02-19 05:54:20 +00:00
|
|
|
printf("\n\n%s\n\n", version_string);
|
2008-02-18 10:26:48 +00:00
|
|
|
printf("CPU: ADSP " MK_STR(CONFIG_BFIN_CPU) " (Detected Rev: 0.%d)\n", bfin_revid());
|
2008-02-19 05:54:20 +00:00
|
|
|
return 0;
|
2006-03-12 01:12:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int init_baudrate(void)
|
|
|
|
{
|
2008-02-19 05:54:20 +00:00
|
|
|
char baudrate[15];
|
|
|
|
int i = getenv_r("baudrate", baudrate, sizeof(baudrate));
|
2006-03-12 01:12:27 +00:00
|
|
|
gd->bd->bi_baudrate = gd->baudrate = (i > 0)
|
2008-02-19 05:54:20 +00:00
|
|
|
? simple_strtoul(baudrate, NULL, 10)
|
2007-03-09 05:38:44 +00:00
|
|
|
: CONFIG_BAUDRATE;
|
2008-02-19 05:54:20 +00:00
|
|
|
return 0;
|
2006-03-12 01:12:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void display_global_data(void)
|
|
|
|
{
|
2008-02-19 05:54:20 +00:00
|
|
|
#ifdef CONFIG_DEBUG_EARLY_SERIAL
|
2006-03-12 01:12:27 +00:00
|
|
|
bd_t *bd;
|
|
|
|
bd = gd->bd;
|
2008-02-19 05:54:20 +00:00
|
|
|
printf(" gd: %x\n", gd);
|
|
|
|
printf(" |-flags: %x\n", gd->flags);
|
|
|
|
printf(" |-board_type: %x\n", gd->board_type);
|
|
|
|
printf(" |-baudrate: %i\n", gd->baudrate);
|
|
|
|
printf(" |-have_console: %x\n", gd->have_console);
|
|
|
|
printf(" |-ram_size: %x\n", gd->ram_size);
|
|
|
|
printf(" |-reloc_off: %x\n", gd->reloc_off);
|
|
|
|
printf(" |-env_addr: %x\n", gd->env_addr);
|
|
|
|
printf(" |-env_valid: %x\n", gd->env_valid);
|
|
|
|
printf(" |-jt(%x): %x\n", gd->jt, *(gd->jt));
|
|
|
|
printf(" \\-bd: %x\n", gd->bd);
|
|
|
|
printf(" |-bi_baudrate: %x\n", bd->bi_baudrate);
|
|
|
|
printf(" |-bi_ip_addr: %x\n", bd->bi_ip_addr);
|
|
|
|
printf(" |-bi_enetaddr: %x %x %x %x %x %x\n",
|
|
|
|
bd->bi_enetaddr[0], bd->bi_enetaddr[1],
|
|
|
|
bd->bi_enetaddr[2], bd->bi_enetaddr[3],
|
|
|
|
bd->bi_enetaddr[4], bd->bi_enetaddr[5]);
|
|
|
|
printf(" |-bi_boot_params: %x\n", bd->bi_boot_params);
|
|
|
|
printf(" |-bi_memstart: %x\n", bd->bi_memstart);
|
|
|
|
printf(" |-bi_memsize: %x\n", bd->bi_memsize);
|
|
|
|
printf(" |-bi_flashstart: %x\n", bd->bi_flashstart);
|
|
|
|
printf(" |-bi_flashsize: %x\n", bd->bi_flashsize);
|
|
|
|
printf(" \\-bi_flashoffset: %x\n", bd->bi_flashoffset);
|
2006-03-12 01:12:27 +00:00
|
|
|
#endif
|
2008-02-19 05:54:20 +00:00
|
|
|
}
|
2006-03-12 01:12:27 +00:00
|
|
|
|
2008-02-19 05:54:20 +00:00
|
|
|
#define CPLB_PAGE_SIZE (4 * 1024 * 1024)
|
|
|
|
#define CPLB_PAGE_MASK (~(CPLB_PAGE_SIZE - 1))
|
2007-03-09 05:38:44 +00:00
|
|
|
void init_cplbtables(void)
|
|
|
|
{
|
2008-02-19 05:54:20 +00:00
|
|
|
volatile uint32_t *ICPLB_ADDR, *ICPLB_DATA;
|
|
|
|
volatile uint32_t *DCPLB_ADDR, *DCPLB_DATA;
|
|
|
|
uint32_t extern_memory;
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
void icplb_add(uint32_t addr, uint32_t data)
|
|
|
|
{
|
|
|
|
*(ICPLB_ADDR + i) = addr;
|
|
|
|
*(ICPLB_DATA + i) = data;
|
2007-03-09 05:38:44 +00:00
|
|
|
}
|
2008-02-19 05:54:20 +00:00
|
|
|
void dcplb_add(uint32_t addr, uint32_t data)
|
|
|
|
{
|
|
|
|
*(DCPLB_ADDR + i) = addr;
|
|
|
|
*(DCPLB_DATA + i) = data;
|
2007-03-09 05:38:44 +00:00
|
|
|
}
|
|
|
|
|
2008-02-19 05:54:20 +00:00
|
|
|
/* populate a few common entries ... we'll let
|
|
|
|
* the memory map and cplb exception handler do
|
|
|
|
* the rest of the work.
|
|
|
|
*/
|
|
|
|
i = 0;
|
|
|
|
ICPLB_ADDR = (uint32_t *)ICPLB_ADDR0;
|
|
|
|
ICPLB_DATA = (uint32_t *)ICPLB_DATA0;
|
|
|
|
DCPLB_ADDR = (uint32_t *)DCPLB_ADDR0;
|
|
|
|
DCPLB_DATA = (uint32_t *)DCPLB_DATA0;
|
|
|
|
|
|
|
|
icplb_add(0xFFA00000, L1_IMEMORY);
|
|
|
|
dcplb_add(0xFF800000, L1_DMEMORY);
|
|
|
|
++i;
|
|
|
|
|
|
|
|
icplb_add(CFG_MONITOR_BASE & CPLB_PAGE_MASK, SDRAM_IKERNEL);
|
|
|
|
dcplb_add(CFG_MONITOR_BASE & CPLB_PAGE_MASK, SDRAM_DKERNEL);
|
|
|
|
++i;
|
|
|
|
|
|
|
|
/* If the monitor crosses a 4 meg boundary, we'll need
|
|
|
|
* to lock two entries for it.
|
|
|
|
*/
|
|
|
|
if ((CFG_MONITOR_BASE & CPLB_PAGE_MASK) != ((CFG_MONITOR_BASE + CFG_MONITOR_LEN) & CPLB_PAGE_MASK)) {
|
|
|
|
icplb_add((CFG_MONITOR_BASE + CFG_MONITOR_LEN) & CPLB_PAGE_MASK, SDRAM_IKERNEL);
|
|
|
|
dcplb_add((CFG_MONITOR_BASE + CFG_MONITOR_LEN) & CPLB_PAGE_MASK, SDRAM_DKERNEL);
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
icplb_add(0x20000000, SDRAM_INON_CHBL);
|
|
|
|
dcplb_add(0x20000000, SDRAM_EBIU);
|
|
|
|
++i;
|
|
|
|
|
|
|
|
/* Add entries for the rest of external RAM up to the bootrom */
|
|
|
|
extern_memory = 0;
|
|
|
|
|
|
|
|
#ifdef CONFIG_DEBUG_NULL_PTR
|
|
|
|
icplb_add(extern_memory, (SDRAM_IKERNEL & ~PAGE_SIZE_MASK) | PAGE_SIZE_1KB);
|
|
|
|
dcplb_add(extern_memory, (SDRAM_DKERNEL & ~PAGE_SIZE_MASK) | PAGE_SIZE_1KB);
|
|
|
|
++i;
|
|
|
|
icplb_add(extern_memory, SDRAM_IKERNEL);
|
|
|
|
dcplb_add(extern_memory, SDRAM_DKERNEL);
|
|
|
|
extern_memory += CPLB_PAGE_SIZE;
|
|
|
|
++i;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
while (i < 16 && extern_memory < (CFG_MONITOR_BASE & CPLB_PAGE_MASK)) {
|
|
|
|
icplb_add(extern_memory, SDRAM_IGENERIC);
|
|
|
|
dcplb_add(extern_memory, SDRAM_DGENERIC);
|
|
|
|
extern_memory += CPLB_PAGE_SIZE;
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
while (i < 16) {
|
|
|
|
icplb_add(0, 0);
|
|
|
|
dcplb_add(0, 0);
|
|
|
|
++i;
|
|
|
|
}
|
2007-03-09 05:38:44 +00:00
|
|
|
}
|
|
|
|
|
2006-03-12 01:12:27 +00:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
* mess of board dependend #ifdef'ed code we now make the whole
|
|
|
|
* 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".
|
|
|
|
*/
|
|
|
|
|
2008-02-19 05:54:20 +00:00
|
|
|
extern int exception_init(void);
|
|
|
|
extern int irq_init(void);
|
|
|
|
extern int rtc_init(void);
|
|
|
|
extern int timer_init(void);
|
|
|
|
|
2006-03-12 01:12:27 +00:00
|
|
|
void board_init_f(ulong bootflag)
|
|
|
|
{
|
|
|
|
ulong addr;
|
|
|
|
bd_t *bd;
|
2007-03-09 05:38:44 +00:00
|
|
|
|
2008-02-19 05:54:20 +00:00
|
|
|
#ifdef CONFIG_BOARD_EARLY_INIT_F
|
|
|
|
serial_early_puts("Board early init flash\n");
|
|
|
|
board_early_init_f();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
serial_early_puts("Init CPLB tables\n");
|
2007-03-09 05:38:44 +00:00
|
|
|
init_cplbtables();
|
2006-03-12 01:12:27 +00:00
|
|
|
|
2008-02-19 05:54:20 +00:00
|
|
|
serial_early_puts("Exceptions setup\n");
|
|
|
|
exception_init();
|
|
|
|
|
|
|
|
#ifndef CONFIG_ICACHE_OFF
|
|
|
|
serial_early_puts("Turn on ICACHE\n");
|
|
|
|
icache_enable();
|
|
|
|
#endif
|
|
|
|
#ifndef CONFIG_DCACHE_OFF
|
|
|
|
serial_early_puts("Turn on DCACHE\n");
|
|
|
|
dcache_enable();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
serial_early_puts("Init global data\n");
|
2006-03-12 01:12:27 +00:00
|
|
|
gd = (gd_t *) (CFG_GBL_DATA_ADDR);
|
2007-03-09 05:38:44 +00:00
|
|
|
memset((void *)gd, 0, sizeof(gd_t));
|
2006-03-12 01:12:27 +00:00
|
|
|
|
|
|
|
/* Board data initialization */
|
|
|
|
addr = (CFG_GBL_DATA_ADDR + sizeof(gd_t));
|
|
|
|
|
|
|
|
/* Align to 4 byte boundary */
|
2006-03-12 01:55:22 +00:00
|
|
|
addr &= ~(4 - 1);
|
2007-03-09 05:38:44 +00:00
|
|
|
bd = (bd_t *) addr;
|
2006-03-12 01:12:27 +00:00
|
|
|
gd->bd = bd;
|
2007-03-09 05:38:44 +00:00
|
|
|
memset((void *)bd, 0, sizeof(bd_t));
|
2006-03-12 01:12:27 +00:00
|
|
|
|
2008-02-19 05:54:20 +00:00
|
|
|
bd->bi_r_version = version_string;
|
|
|
|
bd->bi_cpu = MK_STR(CONFIG_BFIN_CPU);
|
|
|
|
bd->bi_board_name = BFIN_BOARD_NAME;
|
|
|
|
bd->bi_vco = get_vco();
|
|
|
|
bd->bi_cclk = get_cclk();
|
|
|
|
bd->bi_sclk = get_sclk();
|
|
|
|
|
2006-03-12 01:12:27 +00:00
|
|
|
/* Initialize */
|
2008-02-19 05:54:20 +00:00
|
|
|
serial_early_puts("IRQ init\n");
|
2008-03-30 19:46:13 +00:00
|
|
|
irq_init();
|
2008-02-19 05:54:20 +00:00
|
|
|
serial_early_puts("Environment init\n");
|
|
|
|
env_init();
|
|
|
|
serial_early_puts("Baudrate init\n");
|
|
|
|
init_baudrate();
|
|
|
|
serial_early_puts("Serial init\n");
|
|
|
|
serial_init();
|
|
|
|
serial_early_puts("Console init flash\n");
|
2006-03-12 01:12:27 +00:00
|
|
|
console_init_f();
|
2008-02-19 05:54:20 +00:00
|
|
|
serial_early_puts("End of early debugging\n");
|
|
|
|
display_banner();
|
2007-03-09 05:38:44 +00:00
|
|
|
|
2006-03-12 01:12:27 +00:00
|
|
|
checkboard();
|
2008-02-19 05:54:20 +00:00
|
|
|
#if defined(CONFIG_RTC_BFIN) && defined(CONFIG_CMD_DATE)
|
2006-03-12 01:12:27 +00:00
|
|
|
rtc_init();
|
|
|
|
#endif
|
|
|
|
timer_init();
|
2008-02-19 05:54:20 +00:00
|
|
|
|
2007-03-09 05:38:44 +00:00
|
|
|
printf("Clock: VCO: %lu MHz, Core: %lu MHz, System: %lu MHz\n",
|
|
|
|
get_vco() / 1000000, get_cclk() / 1000000, get_sclk() / 1000000);
|
2008-02-19 05:54:20 +00:00
|
|
|
|
|
|
|
printf("RAM: ");
|
2006-03-12 01:12:27 +00:00
|
|
|
print_size(initdram(0), "\n");
|
2008-03-30 19:46:13 +00:00
|
|
|
#if defined(CONFIG_POST)
|
2007-03-09 05:38:44 +00:00
|
|
|
post_init_f();
|
|
|
|
post_bootmode_init();
|
|
|
|
post_run(NULL, POST_ROM | post_bootmode_get(0));
|
|
|
|
#endif
|
2008-02-19 05:54:20 +00:00
|
|
|
|
2006-03-12 01:12:27 +00:00
|
|
|
board_init_r((gd_t *) gd, 0x20000010);
|
|
|
|
}
|
|
|
|
|
2007-03-09 05:38:44 +00:00
|
|
|
#if defined(CONFIG_SOFT_I2C) || defined(CONFIG_HARD_I2C)
|
|
|
|
static int init_func_i2c(void)
|
|
|
|
{
|
|
|
|
puts("I2C: ");
|
|
|
|
i2c_init(CFG_I2C_SPEED, CFG_I2C_SLAVE);
|
|
|
|
puts("ready\n");
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-03-12 01:12:27 +00:00
|
|
|
void board_init_r(gd_t * id, ulong dest_addr)
|
|
|
|
{
|
|
|
|
extern void malloc_bin_reloc(void);
|
2008-02-19 05:54:20 +00:00
|
|
|
char *s;
|
2006-03-12 01:12:27 +00:00
|
|
|
bd_t *bd;
|
|
|
|
gd = id;
|
|
|
|
gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */
|
|
|
|
bd = gd->bd;
|
|
|
|
|
2008-03-30 19:46:13 +00:00
|
|
|
#if defined(CONFIG_POST)
|
2007-03-09 05:38:44 +00:00
|
|
|
post_output_backlog();
|
|
|
|
post_reloc();
|
|
|
|
#endif
|
|
|
|
|
2008-03-30 19:46:13 +00:00
|
|
|
#if !defined(CFG_NO_FLASH)
|
2006-03-12 01:12:27 +00:00
|
|
|
/* There are some other pointer constants we must deal with */
|
|
|
|
/* configure available FLASH banks */
|
2008-02-19 05:54:20 +00:00
|
|
|
extern flash_info_t flash_info[];
|
|
|
|
ulong size = flash_init();
|
|
|
|
puts("Flash: ");
|
|
|
|
print_size(size, "\n");
|
2007-03-09 05:38:44 +00:00
|
|
|
flash_protect(FLAG_PROTECT_SET, CFG_FLASH_BASE,
|
|
|
|
CFG_FLASH_BASE + 0x1ffff, &flash_info[0]);
|
2006-03-12 01:12:27 +00:00
|
|
|
bd->bi_flashstart = CFG_FLASH_BASE;
|
|
|
|
bd->bi_flashsize = size;
|
|
|
|
bd->bi_flashoffset = 0;
|
|
|
|
#else
|
|
|
|
bd->bi_flashstart = 0;
|
|
|
|
bd->bi_flashsize = 0;
|
|
|
|
bd->bi_flashoffset = 0;
|
|
|
|
#endif
|
|
|
|
/* initialize malloc() area */
|
|
|
|
mem_malloc_init();
|
|
|
|
malloc_bin_reloc();
|
|
|
|
|
2007-03-09 05:38:44 +00:00
|
|
|
#ifdef CONFIG_SPI
|
|
|
|
# if ! defined(CFG_ENV_IS_IN_EEPROM)
|
|
|
|
spi_init_f();
|
|
|
|
# endif
|
|
|
|
spi_init_r();
|
|
|
|
#endif
|
|
|
|
|
2006-03-12 01:12:27 +00:00
|
|
|
/* relocate environment function pointers etc. */
|
|
|
|
env_relocate();
|
|
|
|
|
2008-02-19 05:54:20 +00:00
|
|
|
#ifdef CONFIG_CMD_NET
|
2006-03-12 01:12:27 +00:00
|
|
|
/* board MAC address */
|
|
|
|
s = getenv("ethaddr");
|
2008-02-19 05:54:20 +00:00
|
|
|
if (s == NULL) {
|
|
|
|
# ifndef CONFIG_ETHADDR
|
|
|
|
# if 0
|
|
|
|
if (!board_get_enetaddr(bd->bi_enetaddr)) {
|
|
|
|
char nid[20];
|
|
|
|
sprintf(nid, "%02X:%02X:%02X:%02X:%02X:%02X",
|
|
|
|
bd->bi_enetaddr[0], bd->bi_enetaddr[1],
|
|
|
|
bd->bi_enetaddr[2], bd->bi_enetaddr[3],
|
|
|
|
bd->bi_enetaddr[4], bd->bi_enetaddr[5]);
|
|
|
|
setenv("ethaddr", nid);
|
|
|
|
}
|
|
|
|
# endif
|
|
|
|
# endif
|
|
|
|
} else {
|
|
|
|
int i;
|
|
|
|
char *e;
|
|
|
|
for (i = 0; i < 6; ++i) {
|
|
|
|
bd->bi_enetaddr[i] = simple_strtoul(s, &e, 16);
|
2006-03-12 01:12:27 +00:00
|
|
|
s = (*e) ? e + 1 : e;
|
2008-02-19 05:54:20 +00:00
|
|
|
}
|
2006-03-12 01:12:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* IP Address */
|
|
|
|
bd->bi_ip_addr = getenv_IPaddr("ipaddr");
|
2008-02-19 05:54:20 +00:00
|
|
|
#endif
|
2006-03-12 01:12:27 +00:00
|
|
|
|
|
|
|
/* Initialize devices */
|
|
|
|
devices_init();
|
|
|
|
jumptable_init();
|
|
|
|
|
|
|
|
/* Initialize the console (after the relocation and devices init) */
|
|
|
|
console_init_r();
|
|
|
|
|
|
|
|
/* Initialize from environment */
|
2008-02-19 05:54:20 +00:00
|
|
|
if ((s = getenv("loadaddr")) != NULL)
|
2006-03-12 01:12:27 +00:00
|
|
|
load_addr = simple_strtoul(s, NULL, 16);
|
2008-02-19 05:54:20 +00:00
|
|
|
#ifdef CONFIG_CMD_NET
|
|
|
|
if ((s = getenv("bootfile")) != NULL)
|
2006-03-12 01:12:27 +00:00
|
|
|
copy_filename(BootFile, s, sizeof(BootFile));
|
|
|
|
#endif
|
2007-03-09 05:38:44 +00:00
|
|
|
|
2008-02-19 05:54:20 +00:00
|
|
|
#ifdef CONFIG_CMD_NAND
|
2007-03-09 05:38:44 +00:00
|
|
|
puts("NAND: ");
|
|
|
|
nand_init(); /* go init the NAND */
|
|
|
|
#endif
|
|
|
|
|
2006-03-12 01:12:27 +00:00
|
|
|
#if defined(CONFIG_MISC_INIT_R)
|
|
|
|
/* miscellaneous platform dependent initialisations */
|
|
|
|
misc_init_r();
|
|
|
|
#endif
|
|
|
|
|
2008-02-18 10:26:48 +00:00
|
|
|
#ifdef CONFIG_CMD_NET
|
2008-02-19 05:54:20 +00:00
|
|
|
printf("Net: ");
|
|
|
|
eth_initialize(gd->bd);
|
|
|
|
if (getenv("ethaddr"))
|
|
|
|
printf("MAC: %02X:%02X:%02X:%02X:%02X:%02X\n",
|
|
|
|
bd->bi_enetaddr[0], bd->bi_enetaddr[1], bd->bi_enetaddr[2],
|
|
|
|
bd->bi_enetaddr[3], bd->bi_enetaddr[4], bd->bi_enetaddr[5]);
|
2006-03-12 01:12:27 +00:00
|
|
|
#endif
|
|
|
|
|
2007-03-09 05:38:44 +00:00
|
|
|
#if defined(CONFIG_SOFT_I2C) || defined(CONFIG_HARD_I2C)
|
2006-03-12 01:12:27 +00:00
|
|
|
init_func_i2c();
|
|
|
|
#endif
|
|
|
|
|
2007-03-09 05:38:44 +00:00
|
|
|
display_global_data();
|
|
|
|
|
2008-03-30 19:46:13 +00:00
|
|
|
#if defined(CONFIG_POST)
|
2007-03-09 05:38:44 +00:00
|
|
|
if (post_flag)
|
|
|
|
post_run(NULL, POST_RAM | post_bootmode_get(0));
|
2006-03-12 01:12:27 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* main_loop() can return to retry autoboot, if so just run it again. */
|
2008-02-19 05:54:20 +00:00
|
|
|
for (;;)
|
2006-03-12 01:12:27 +00:00
|
|
|
main_loop();
|
|
|
|
}
|
|
|
|
|
|
|
|
void hang(void)
|
|
|
|
{
|
|
|
|
puts("### ERROR ### Please RESET the board ###\n");
|
2008-02-19 05:54:20 +00:00
|
|
|
while (1)
|
|
|
|
/* If a JTAG emulator is hooked up, we'll automatically trigger
|
|
|
|
* a breakpoint in it. If one isn't, this is just a NOP.
|
|
|
|
*/
|
|
|
|
asm("emuexcpt;");
|
2006-03-12 01:12:27 +00:00
|
|
|
}
|