blob: 28de372b78f3305509b0fb7de9242bc6fb5b7790 [file] [log] [blame]
Wolfgang Denk6cb142f2006-03-12 02:12:27 +01001/*
2 * U-boot - board.c First C file to be called contains init routines
3 *
Mike Frysingerd5bffeb2008-02-19 00:54:20 -05004 * Copyright (c) 2005-2008 Analog Devices Inc.
Wolfgang Denk6cb142f2006-03-12 02:12:27 +01005 *
6 * (C) Copyright 2000-2004
7 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
8 *
Mike Frysingerd5bffeb2008-02-19 00:54:20 -05009 * Licensed under the GPL-2 or later.
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010010 */
11
12#include <common.h>
13#include <command.h>
Jean-Christophe PLAGNIOL-VILLARD52cb4d42009-05-16 12:14:54 +020014#include <stdio_dev.h>
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010015#include <environment.h>
Mike Frysingerd5bffeb2008-02-19 00:54:20 -050016#include <malloc.h>
17#include <net.h>
Peter Tyser561858e2008-11-03 09:30:59 -060018#include <timestamp.h>
Mike Frysinger01815c22008-10-06 03:52:24 -040019#include <status_led.h>
Mike Frysingerd5bffeb2008-02-19 00:54:20 -050020#include <version.h>
21
Aubrey.Li3f0606a2007-03-09 13:38:44 +080022#include <asm/cplb.h>
Mike Frysingerd5bffeb2008-02-19 00:54:20 -050023#include <asm/mach-common/bits/mpu.h>
24
25#ifdef CONFIG_CMD_NAND
26#include <nand.h> /* cannot even include nand.h if it isnt configured */
27#endif
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010028
Mike Frysinger9171fc82008-03-30 15:46:13 -040029#if defined(CONFIG_POST)
Aubrey.Li3f0606a2007-03-09 13:38:44 +080030#include <post.h>
31int post_flag;
32#endif
Wolfgang Denkd87080b2006-03-31 18:32:53 +020033
Wolfgang Denk1218abf2007-09-15 20:48:41 +020034DECLARE_GLOBAL_DATA_PTR;
35
Peter Tyser561858e2008-11-03 09:30:59 -060036const char version_string[] = U_BOOT_VERSION " ("U_BOOT_DATE" - "U_BOOT_TIME")";
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010037
Mike Frysingerd5bffeb2008-02-19 00:54:20 -050038__attribute__((always_inline))
39static inline void serial_early_puts(const char *s)
40{
41#ifdef CONFIG_DEBUG_EARLY_SERIAL
42 serial_puts("Early: ");
43 serial_puts(s);
44#endif
45}
46
Mike Frysingerd5bffeb2008-02-19 00:54:20 -050047static void *mem_malloc_start, *mem_malloc_end, *mem_malloc_brk;
48
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010049static void mem_malloc_init(void)
50{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020051 mem_malloc_start = (void *)CONFIG_SYS_MALLOC_BASE;
52 mem_malloc_end = (void *)(CONFIG_SYS_MALLOC_BASE + CONFIG_SYS_MALLOC_LEN);
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010053 mem_malloc_brk = mem_malloc_start;
Mike Frysingerd5bffeb2008-02-19 00:54:20 -050054 memset(mem_malloc_start, 0, mem_malloc_end - mem_malloc_start);
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010055}
56
57void *sbrk(ptrdiff_t increment)
58{
Mike Frysingerd5bffeb2008-02-19 00:54:20 -050059 void *old = mem_malloc_brk;
60 void *new = old + increment;
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010061
Mike Frysingerd5bffeb2008-02-19 00:54:20 -050062 if (new < mem_malloc_start || new > mem_malloc_end)
63 return NULL;
64
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010065 mem_malloc_brk = new;
66
Mike Frysingerd5bffeb2008-02-19 00:54:20 -050067 return old;
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010068}
69
70static int display_banner(void)
71{
Mike Frysingerd5bffeb2008-02-19 00:54:20 -050072 printf("\n\n%s\n\n", version_string);
Mike Frysingerfc68f9f2009-01-06 06:16:19 -050073 printf("CPU: ADSP " MK_STR(CONFIG_BFIN_CPU) " "
74 "(Detected Rev: 0.%d) "
75 "(%s boot)\n",
76 bfin_revid(),
77 get_bfin_boot_mode(CONFIG_BFIN_BOOT_MODE));
Mike Frysingerd5bffeb2008-02-19 00:54:20 -050078 return 0;
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010079}
80
81static int init_baudrate(void)
82{
Mike Frysingerd5bffeb2008-02-19 00:54:20 -050083 char baudrate[15];
84 int i = getenv_r("baudrate", baudrate, sizeof(baudrate));
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010085 gd->bd->bi_baudrate = gd->baudrate = (i > 0)
Mike Frysingerd5bffeb2008-02-19 00:54:20 -050086 ? simple_strtoul(baudrate, NULL, 10)
Aubrey.Li3f0606a2007-03-09 13:38:44 +080087 : CONFIG_BAUDRATE;
Mike Frysingerd5bffeb2008-02-19 00:54:20 -050088 return 0;
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010089}
90
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010091static void display_global_data(void)
92{
Mike Frysingerd5bffeb2008-02-19 00:54:20 -050093#ifdef CONFIG_DEBUG_EARLY_SERIAL
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010094 bd_t *bd;
95 bd = gd->bd;
Mike Frysingerd5bffeb2008-02-19 00:54:20 -050096 printf(" gd: %x\n", gd);
97 printf(" |-flags: %x\n", gd->flags);
98 printf(" |-board_type: %x\n", gd->board_type);
99 printf(" |-baudrate: %i\n", gd->baudrate);
100 printf(" |-have_console: %x\n", gd->have_console);
101 printf(" |-ram_size: %x\n", gd->ram_size);
102 printf(" |-reloc_off: %x\n", gd->reloc_off);
103 printf(" |-env_addr: %x\n", gd->env_addr);
104 printf(" |-env_valid: %x\n", gd->env_valid);
105 printf(" |-jt(%x): %x\n", gd->jt, *(gd->jt));
106 printf(" \\-bd: %x\n", gd->bd);
107 printf(" |-bi_baudrate: %x\n", bd->bi_baudrate);
108 printf(" |-bi_ip_addr: %x\n", bd->bi_ip_addr);
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500109 printf(" |-bi_boot_params: %x\n", bd->bi_boot_params);
110 printf(" |-bi_memstart: %x\n", bd->bi_memstart);
111 printf(" |-bi_memsize: %x\n", bd->bi_memsize);
112 printf(" |-bi_flashstart: %x\n", bd->bi_flashstart);
113 printf(" |-bi_flashsize: %x\n", bd->bi_flashsize);
114 printf(" \\-bi_flashoffset: %x\n", bd->bi_flashoffset);
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100115#endif
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500116}
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100117
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500118#define CPLB_PAGE_SIZE (4 * 1024 * 1024)
119#define CPLB_PAGE_MASK (~(CPLB_PAGE_SIZE - 1))
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800120void init_cplbtables(void)
121{
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500122 volatile uint32_t *ICPLB_ADDR, *ICPLB_DATA;
123 volatile uint32_t *DCPLB_ADDR, *DCPLB_DATA;
124 uint32_t extern_memory;
125 size_t i;
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800126
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500127 void icplb_add(uint32_t addr, uint32_t data)
128 {
129 *(ICPLB_ADDR + i) = addr;
130 *(ICPLB_DATA + i) = data;
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800131 }
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500132 void dcplb_add(uint32_t addr, uint32_t data)
133 {
134 *(DCPLB_ADDR + i) = addr;
135 *(DCPLB_DATA + i) = data;
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800136 }
137
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500138 /* populate a few common entries ... we'll let
139 * the memory map and cplb exception handler do
140 * the rest of the work.
141 */
142 i = 0;
143 ICPLB_ADDR = (uint32_t *)ICPLB_ADDR0;
144 ICPLB_DATA = (uint32_t *)ICPLB_DATA0;
145 DCPLB_ADDR = (uint32_t *)DCPLB_ADDR0;
146 DCPLB_DATA = (uint32_t *)DCPLB_DATA0;
147
148 icplb_add(0xFFA00000, L1_IMEMORY);
149 dcplb_add(0xFF800000, L1_DMEMORY);
150 ++i;
151
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200152 icplb_add(CONFIG_SYS_MONITOR_BASE & CPLB_PAGE_MASK, SDRAM_IKERNEL);
153 dcplb_add(CONFIG_SYS_MONITOR_BASE & CPLB_PAGE_MASK, SDRAM_DKERNEL);
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500154 ++i;
155
156 /* If the monitor crosses a 4 meg boundary, we'll need
157 * to lock two entries for it.
158 */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200159 if ((CONFIG_SYS_MONITOR_BASE & CPLB_PAGE_MASK) != ((CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN) & CPLB_PAGE_MASK)) {
160 icplb_add((CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN) & CPLB_PAGE_MASK, SDRAM_IKERNEL);
161 dcplb_add((CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN) & CPLB_PAGE_MASK, SDRAM_DKERNEL);
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500162 ++i;
163 }
164
165 icplb_add(0x20000000, SDRAM_INON_CHBL);
166 dcplb_add(0x20000000, SDRAM_EBIU);
167 ++i;
168
169 /* Add entries for the rest of external RAM up to the bootrom */
170 extern_memory = 0;
171
172#ifdef CONFIG_DEBUG_NULL_PTR
173 icplb_add(extern_memory, (SDRAM_IKERNEL & ~PAGE_SIZE_MASK) | PAGE_SIZE_1KB);
174 dcplb_add(extern_memory, (SDRAM_DKERNEL & ~PAGE_SIZE_MASK) | PAGE_SIZE_1KB);
175 ++i;
176 icplb_add(extern_memory, SDRAM_IKERNEL);
177 dcplb_add(extern_memory, SDRAM_DKERNEL);
178 extern_memory += CPLB_PAGE_SIZE;
179 ++i;
180#endif
181
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200182 while (i < 16 && extern_memory < (CONFIG_SYS_MONITOR_BASE & CPLB_PAGE_MASK)) {
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500183 icplb_add(extern_memory, SDRAM_IGENERIC);
184 dcplb_add(extern_memory, SDRAM_DGENERIC);
185 extern_memory += CPLB_PAGE_SIZE;
186 ++i;
187 }
188 while (i < 16) {
189 icplb_add(0, 0);
190 dcplb_add(0, 0);
191 ++i;
192 }
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800193}
194
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100195/*
196 * All attempts to come up with a "common" initialization sequence
197 * that works for all boards and architectures failed: some of the
198 * requirements are just _too_ different. To get rid of the resulting
199 * mess of board dependend #ifdef'ed code we now make the whole
200 * initialization sequence configurable to the user.
201 *
202 * The requirements for any new initalization function is simple: it
203 * receives a pointer to the "global data" structure as it's only
204 * argument, and returns an integer return code, where 0 means
205 * "continue" and != 0 means "fatal error, hang the system".
206 */
207
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500208extern int exception_init(void);
209extern int irq_init(void);
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500210extern int timer_init(void);
211
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100212void board_init_f(ulong bootflag)
213{
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100214 ulong addr;
215 bd_t *bd;
Mike Frysinger6dadc912008-10-20 16:15:04 -0400216 char buf[32];
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800217
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500218#ifdef CONFIG_BOARD_EARLY_INIT_F
219 serial_early_puts("Board early init flash\n");
220 board_early_init_f();
221#endif
222
223 serial_early_puts("Init CPLB tables\n");
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800224 init_cplbtables();
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100225
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500226 serial_early_puts("Exceptions setup\n");
227 exception_init();
228
229#ifndef CONFIG_ICACHE_OFF
230 serial_early_puts("Turn on ICACHE\n");
231 icache_enable();
232#endif
233#ifndef CONFIG_DCACHE_OFF
234 serial_early_puts("Turn on DCACHE\n");
235 dcache_enable();
236#endif
237
Mike Frysinger78a0ba72008-10-06 03:57:39 -0400238#ifdef DEBUG
239 if (CONFIG_SYS_GBL_DATA_SIZE < sizeof(*gd))
240 hang();
241#endif
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500242 serial_early_puts("Init global data\n");
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200243 gd = (gd_t *) (CONFIG_SYS_GBL_DATA_ADDR);
Mike Frysinger78a0ba72008-10-06 03:57:39 -0400244 memset((void *)gd, 0, CONFIG_SYS_GBL_DATA_SIZE);
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100245
246 /* Board data initialization */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200247 addr = (CONFIG_SYS_GBL_DATA_ADDR + sizeof(gd_t));
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100248
249 /* Align to 4 byte boundary */
Wolfgang Denk8e7b7032006-03-12 02:55:22 +0100250 addr &= ~(4 - 1);
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800251 bd = (bd_t *) addr;
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100252 gd->bd = bd;
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800253 memset((void *)bd, 0, sizeof(bd_t));
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100254
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500255 bd->bi_r_version = version_string;
256 bd->bi_cpu = MK_STR(CONFIG_BFIN_CPU);
257 bd->bi_board_name = BFIN_BOARD_NAME;
258 bd->bi_vco = get_vco();
259 bd->bi_cclk = get_cclk();
260 bd->bi_sclk = get_sclk();
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800261
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500262 /* Initialize */
263 serial_early_puts("IRQ init\n");
264 irq_init();
265 serial_early_puts("Environment init\n");
266 env_init();
267 serial_early_puts("Baudrate init\n");
268 init_baudrate();
269 serial_early_puts("Serial init\n");
270 serial_init();
271 serial_early_puts("Console init flash\n");
272 console_init_f();
273 serial_early_puts("End of early debugging\n");
274 display_banner();
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800275
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100276 checkboard();
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100277 timer_init();
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500278
Mike Frysinger6dadc912008-10-20 16:15:04 -0400279 printf("Clock: VCO: %s MHz, ", strmhz(buf, get_vco()));
280 printf("Core: %s MHz, ", strmhz(buf, get_cclk()));
281 printf("System: %s MHz\n", strmhz(buf, get_sclk()));
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500282
283 printf("RAM: ");
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100284 print_size(initdram(0), "\n");
Mike Frysinger9171fc82008-03-30 15:46:13 -0400285#if defined(CONFIG_POST)
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800286 post_init_f();
287 post_bootmode_init();
288 post_run(NULL, POST_ROM | post_bootmode_get(0));
289#endif
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500290
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100291 board_init_r((gd_t *) gd, 0x20000010);
292}
293
Mike Frysinger8996d162009-02-22 16:02:27 -0500294static void board_net_init_r(bd_t *bd)
295{
296#ifdef CONFIG_CMD_NET
297 uchar enetaddr[6];
298 char *s;
299
300 if ((s = getenv("bootfile")) != NULL)
301 copy_filename(BootFile, s, sizeof(BootFile));
302
303 bd->bi_ip_addr = getenv_IPaddr("ipaddr");
304
305 printf("Net: ");
306 eth_initialize(gd->bd);
307
308 eth_getenv_enetaddr("ethaddr", enetaddr);
309 printf("MAC: %pM\n", enetaddr);
310#endif
311}
312
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100313void board_init_r(gd_t * id, ulong dest_addr)
314{
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100315 extern void malloc_bin_reloc(void);
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500316 char *s;
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100317 bd_t *bd;
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100318 gd = id;
319 gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */
320 bd = gd->bd;
321
Mike Frysinger9171fc82008-03-30 15:46:13 -0400322#if defined(CONFIG_POST)
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800323 post_output_backlog();
324 post_reloc();
325#endif
326
Stefan Roesec790b042009-05-11 15:50:12 +0200327 /* initialize malloc() area */
328 mem_malloc_init();
329 malloc_bin_reloc();
330
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200331#if !defined(CONFIG_SYS_NO_FLASH)
Mike Frysingerb6edc712008-10-06 04:00:07 -0400332 /* Initialize the flash and protect u-boot by default */
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500333 extern flash_info_t flash_info[];
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500334 puts("Flash: ");
Mike Frysinger45c48952008-10-06 04:01:26 -0400335 ulong size = flash_init();
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500336 print_size(size, "\n");
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200337 flash_protect(FLAG_PROTECT_SET, CONFIG_SYS_FLASH_BASE,
Mike Frysingerb6edc712008-10-06 04:00:07 -0400338 CONFIG_SYS_FLASH_BASE + CONFIG_SYS_MONITOR_LEN - 1,
339 &flash_info[0]);
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200340 bd->bi_flashstart = CONFIG_SYS_FLASH_BASE;
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100341 bd->bi_flashsize = size;
342 bd->bi_flashoffset = 0;
343#else
344 bd->bi_flashstart = 0;
345 bd->bi_flashsize = 0;
346 bd->bi_flashoffset = 0;
347#endif
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100348
Mike Frysinger39782722008-10-06 03:55:25 -0400349#ifdef CONFIG_CMD_NAND
350 puts("NAND: ");
351 nand_init(); /* go init the NAND */
352#endif
353
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100354 /* relocate environment function pointers etc. */
355 env_relocate();
356
Jean-Christophe PLAGNIOL-VILLARD52cb4d42009-05-16 12:14:54 +0200357 /* Initialize stdio devices */
358 stdio_init();
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100359 jumptable_init();
360
361 /* Initialize the console (after the relocation and devices init) */
362 console_init_r();
363
Mike Frysinger01815c22008-10-06 03:52:24 -0400364#ifdef CONFIG_STATUS_LED
365 status_led_set(STATUS_LED_BOOT, STATUS_LED_BLINKING);
366 status_led_set(STATUS_LED_CRASH, STATUS_LED_OFF);
367#endif
368
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100369 /* Initialize from environment */
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500370 if ((s = getenv("loadaddr")) != NULL)
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100371 load_addr = simple_strtoul(s, NULL, 16);
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800372
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100373#if defined(CONFIG_MISC_INIT_R)
374 /* miscellaneous platform dependent initialisations */
375 misc_init_r();
376#endif
377
Mike Frysinger8996d162009-02-22 16:02:27 -0500378 board_net_init_r(bd);
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800379
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800380 display_global_data();
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800381
Mike Frysinger9171fc82008-03-30 15:46:13 -0400382#if defined(CONFIG_POST)
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800383 if (post_flag)
384 post_run(NULL, POST_RAM | post_bootmode_get(0));
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100385#endif
386
387 /* main_loop() can return to retry autoboot, if so just run it again. */
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500388 for (;;)
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100389 main_loop();
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100390}
391
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100392void hang(void)
393{
Mike Frysinger01815c22008-10-06 03:52:24 -0400394#ifdef CONFIG_STATUS_LED
395 status_led_set(STATUS_LED_BOOT, STATUS_LED_OFF);
396 status_led_set(STATUS_LED_CRASH, STATUS_LED_BLINKING);
397#endif
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100398 puts("### ERROR ### Please RESET the board ###\n");
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500399 while (1)
400 /* If a JTAG emulator is hooked up, we'll automatically trigger
401 * a breakpoint in it. If one isn't, this is just a NOP.
402 */
403 asm("emuexcpt;");
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100404}