blob: bfdb586b343804554cf2f016bedfc2f5ca475ee3 [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>
Mike Frysinger635f3302011-04-29 23:23:28 -040015#include <serial.h>
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010016#include <environment.h>
Mike Frysingerd5bffeb2008-02-19 00:54:20 -050017#include <malloc.h>
Cliff Caie54c8202009-11-20 08:24:43 +000018#include <mmc.h>
Mike Frysingerd5bffeb2008-02-19 00:54:20 -050019#include <net.h>
Mike Frysinger01815c22008-10-06 03:52:24 -040020#include <status_led.h>
Mike Frysingerd5bffeb2008-02-19 00:54:20 -050021#include <version.h>
22
Aubrey.Li3f0606a2007-03-09 13:38:44 +080023#include <asm/cplb.h>
Mike Frysingerd5bffeb2008-02-19 00:54:20 -050024#include <asm/mach-common/bits/mpu.h>
Robin Getzf19fd872009-12-21 16:35:48 -050025#include <kgdb.h>
Mike Frysingerd5bffeb2008-02-19 00:54:20 -050026
27#ifdef CONFIG_CMD_NAND
28#include <nand.h> /* cannot even include nand.h if it isnt configured */
29#endif
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010030
Luigi 'Comio' Mantellini310cecb2009-10-10 12:42:21 +020031#ifdef CONFIG_BITBANGMII
32#include <miiphy.h>
33#endif
34
Mike Frysinger9171fc82008-03-30 15:46:13 -040035#if defined(CONFIG_POST)
Aubrey.Li3f0606a2007-03-09 13:38:44 +080036#include <post.h>
37int post_flag;
38#endif
Wolfgang Denkd87080b2006-03-31 18:32:53 +020039
Wolfgang Denk1218abf2007-09-15 20:48:41 +020040DECLARE_GLOBAL_DATA_PTR;
41
Mike Frysingerd5bffeb2008-02-19 00:54:20 -050042__attribute__((always_inline))
43static inline void serial_early_puts(const char *s)
44{
45#ifdef CONFIG_DEBUG_EARLY_SERIAL
46 serial_puts("Early: ");
47 serial_puts(s);
48#endif
49}
50
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010051static int display_banner(void)
52{
Mike Frysingerbb838752011-06-30 18:26:39 -040053 display_options();
Mike Frysinger5d891152010-08-09 17:39:22 -040054 printf("CPU: ADSP %s "
Mike Frysingerfc68f9f2009-01-06 06:16:19 -050055 "(Detected Rev: 0.%d) "
56 "(%s boot)\n",
Mike Frysinger5d891152010-08-09 17:39:22 -040057 gd->bd->bi_cpu,
Mike Frysingerfc68f9f2009-01-06 06:16:19 -050058 bfin_revid(),
59 get_bfin_boot_mode(CONFIG_BFIN_BOOT_MODE));
Mike Frysingerd5bffeb2008-02-19 00:54:20 -050060 return 0;
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010061}
62
63static int init_baudrate(void)
64{
Mike Frysingerd5bffeb2008-02-19 00:54:20 -050065 char baudrate[15];
Wolfgang Denkcdb74972010-07-24 21:55:43 +020066 int i = getenv_f("baudrate", baudrate, sizeof(baudrate));
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010067 gd->bd->bi_baudrate = gd->baudrate = (i > 0)
Mike Frysingerd5bffeb2008-02-19 00:54:20 -050068 ? simple_strtoul(baudrate, NULL, 10)
Aubrey.Li3f0606a2007-03-09 13:38:44 +080069 : CONFIG_BAUDRATE;
Mike Frysingerd5bffeb2008-02-19 00:54:20 -050070 return 0;
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010071}
72
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010073static void display_global_data(void)
74{
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010075 bd_t *bd;
Mike Frysinger03f70532010-01-19 15:39:07 -050076
77#ifndef CONFIG_DEBUG_EARLY_SERIAL
78 return;
79#endif
80
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010081 bd = gd->bd;
Mike Frysingerf541e1d2009-08-24 19:03:18 -040082 printf(" gd: %p\n", gd);
83 printf(" |-flags: %lx\n", gd->flags);
84 printf(" |-board_type: %lx\n", gd->board_type);
85 printf(" |-baudrate: %lu\n", gd->baudrate);
86 printf(" |-have_console: %lx\n", gd->have_console);
87 printf(" |-ram_size: %lx\n", gd->ram_size);
Mike Frysingerf541e1d2009-08-24 19:03:18 -040088 printf(" |-env_addr: %lx\n", gd->env_addr);
89 printf(" |-env_valid: %lx\n", gd->env_valid);
90 printf(" |-jt(%p): %p\n", gd->jt, *(gd->jt));
91 printf(" \\-bd: %p\n", gd->bd);
Mike Frysingerd5bffeb2008-02-19 00:54:20 -050092 printf(" |-bi_baudrate: %x\n", bd->bi_baudrate);
Mike Frysingerf541e1d2009-08-24 19:03:18 -040093 printf(" |-bi_ip_addr: %lx\n", bd->bi_ip_addr);
94 printf(" |-bi_boot_params: %lx\n", bd->bi_boot_params);
95 printf(" |-bi_memstart: %lx\n", bd->bi_memstart);
96 printf(" |-bi_memsize: %lx\n", bd->bi_memsize);
97 printf(" |-bi_flashstart: %lx\n", bd->bi_flashstart);
98 printf(" |-bi_flashsize: %lx\n", bd->bi_flashsize);
99 printf(" \\-bi_flashoffset: %lx\n", bd->bi_flashoffset);
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500100}
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100101
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500102#define CPLB_PAGE_SIZE (4 * 1024 * 1024)
103#define CPLB_PAGE_MASK (~(CPLB_PAGE_SIZE - 1))
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800104void init_cplbtables(void)
105{
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500106 volatile uint32_t *ICPLB_ADDR, *ICPLB_DATA;
107 volatile uint32_t *DCPLB_ADDR, *DCPLB_DATA;
108 uint32_t extern_memory;
109 size_t i;
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800110
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500111 void icplb_add(uint32_t addr, uint32_t data)
112 {
113 *(ICPLB_ADDR + i) = addr;
114 *(ICPLB_DATA + i) = data;
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800115 }
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500116 void dcplb_add(uint32_t addr, uint32_t data)
117 {
118 *(DCPLB_ADDR + i) = addr;
119 *(DCPLB_DATA + i) = data;
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800120 }
121
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500122 /* populate a few common entries ... we'll let
123 * the memory map and cplb exception handler do
124 * the rest of the work.
125 */
126 i = 0;
127 ICPLB_ADDR = (uint32_t *)ICPLB_ADDR0;
128 ICPLB_DATA = (uint32_t *)ICPLB_DATA0;
129 DCPLB_ADDR = (uint32_t *)DCPLB_ADDR0;
130 DCPLB_DATA = (uint32_t *)DCPLB_DATA0;
131
132 icplb_add(0xFFA00000, L1_IMEMORY);
133 dcplb_add(0xFF800000, L1_DMEMORY);
134 ++i;
135
Mike Frysinger7527fee2009-11-09 19:38:23 -0500136 if (CONFIG_MEM_SIZE) {
137 uint32_t mbase = CONFIG_SYS_MONITOR_BASE;
138 uint32_t mend = mbase + CONFIG_SYS_MONITOR_LEN;
139 mbase &= CPLB_PAGE_MASK;
140 mend &= CPLB_PAGE_MASK;
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500141
Mike Frysinger7527fee2009-11-09 19:38:23 -0500142 icplb_add(mbase, SDRAM_IKERNEL);
143 dcplb_add(mbase, SDRAM_DKERNEL);
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500144 ++i;
Mike Frysinger7527fee2009-11-09 19:38:23 -0500145
146 /*
147 * If the monitor crosses a 4 meg boundary, we'll need
148 * to lock two entries for it. We assume it doesn't
149 * cross two 4 meg boundaries ...
150 */
151 if (mbase != mend) {
152 icplb_add(mend, SDRAM_IKERNEL);
153 dcplb_add(mend, SDRAM_DKERNEL);
154 ++i;
155 }
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500156 }
157
158 icplb_add(0x20000000, SDRAM_INON_CHBL);
159 dcplb_add(0x20000000, SDRAM_EBIU);
160 ++i;
161
162 /* Add entries for the rest of external RAM up to the bootrom */
163 extern_memory = 0;
164
165#ifdef CONFIG_DEBUG_NULL_PTR
166 icplb_add(extern_memory, (SDRAM_IKERNEL & ~PAGE_SIZE_MASK) | PAGE_SIZE_1KB);
167 dcplb_add(extern_memory, (SDRAM_DKERNEL & ~PAGE_SIZE_MASK) | PAGE_SIZE_1KB);
168 ++i;
169 icplb_add(extern_memory, SDRAM_IKERNEL);
170 dcplb_add(extern_memory, SDRAM_DKERNEL);
171 extern_memory += CPLB_PAGE_SIZE;
172 ++i;
173#endif
174
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200175 while (i < 16 && extern_memory < (CONFIG_SYS_MONITOR_BASE & CPLB_PAGE_MASK)) {
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500176 icplb_add(extern_memory, SDRAM_IGENERIC);
177 dcplb_add(extern_memory, SDRAM_DGENERIC);
178 extern_memory += CPLB_PAGE_SIZE;
179 ++i;
180 }
181 while (i < 16) {
182 icplb_add(0, 0);
183 dcplb_add(0, 0);
184 ++i;
185 }
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800186}
187
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100188/*
189 * All attempts to come up with a "common" initialization sequence
190 * that works for all boards and architectures failed: some of the
191 * requirements are just _too_ different. To get rid of the resulting
192 * mess of board dependend #ifdef'ed code we now make the whole
193 * initialization sequence configurable to the user.
194 *
195 * The requirements for any new initalization function is simple: it
196 * receives a pointer to the "global data" structure as it's only
197 * argument, and returns an integer return code, where 0 means
198 * "continue" and != 0 means "fatal error, hang the system".
199 */
200
Mike Frysinger0c080aa2010-02-11 20:19:10 -0500201extern int watchdog_init(void);
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500202extern int exception_init(void);
203extern int irq_init(void);
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500204extern int timer_init(void);
205
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100206void board_init_f(ulong bootflag)
207{
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100208 bd_t *bd;
Mike Frysinger6dadc912008-10-20 16:15:04 -0400209 char buf[32];
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800210
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500211#ifdef CONFIG_BOARD_EARLY_INIT_F
212 serial_early_puts("Board early init flash\n");
213 board_early_init_f();
214#endif
215
216 serial_early_puts("Init CPLB tables\n");
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800217 init_cplbtables();
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100218
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500219 serial_early_puts("Exceptions setup\n");
220 exception_init();
221
222#ifndef CONFIG_ICACHE_OFF
223 serial_early_puts("Turn on ICACHE\n");
224 icache_enable();
225#endif
226#ifndef CONFIG_DCACHE_OFF
227 serial_early_puts("Turn on DCACHE\n");
228 dcache_enable();
229#endif
230
Mike Frysinger0c080aa2010-02-11 20:19:10 -0500231#ifdef CONFIG_WATCHDOG
232 serial_early_puts("Setting up external watchdog\n");
233 watchdog_init();
234#endif
235
Mike Frysinger78a0ba72008-10-06 03:57:39 -0400236#ifdef DEBUG
Wolfgang Denk25ddd1f2010-10-26 14:34:52 +0200237 if (GENERATED_GBL_DATA_SIZE < sizeof(*gd))
Mike Frysinger78a0ba72008-10-06 03:57:39 -0400238 hang();
239#endif
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500240 serial_early_puts("Init global data\n");
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200241 gd = (gd_t *) (CONFIG_SYS_GBL_DATA_ADDR);
Wolfgang Denk25ddd1f2010-10-26 14:34:52 +0200242 memset((void *)gd, 0, GENERATED_GBL_DATA_SIZE);
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100243
Mike Frysinger5a9a2c52010-12-24 12:48:16 -0500244 bd = (bd_t *) (CONFIG_SYS_BD_INFO_ADDR);
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100245 gd->bd = bd;
Mike Frysinger5a9a2c52010-12-24 12:48:16 -0500246 memset((void *)bd, 0, GENERATED_BD_INFO_SIZE);
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100247
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500248 bd->bi_r_version = version_string;
Mike Frysingerfbcf8e82010-12-23 14:58:37 -0500249 bd->bi_cpu = MK_STR(CONFIG_BFIN_CPU);
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500250 bd->bi_board_name = BFIN_BOARD_NAME;
251 bd->bi_vco = get_vco();
252 bd->bi_cclk = get_cclk();
253 bd->bi_sclk = get_sclk();
Mike Frysingerfa45bd42009-11-03 06:28:22 -0500254 bd->bi_memstart = CONFIG_SYS_SDRAM_BASE;
255 bd->bi_memsize = CONFIG_SYS_MAX_RAM_SIZE;
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800256
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500257 /* Initialize */
258 serial_early_puts("IRQ init\n");
259 irq_init();
260 serial_early_puts("Environment init\n");
261 env_init();
262 serial_early_puts("Baudrate init\n");
263 init_baudrate();
264 serial_early_puts("Serial init\n");
265 serial_init();
Mike Frysinger635f3302011-04-29 23:23:28 -0400266#ifdef CONFIG_SERIAL_MULTI
267 serial_initialize();
268#endif
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500269 serial_early_puts("Console init flash\n");
270 console_init_f();
271 serial_early_puts("End of early debugging\n");
272 display_banner();
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800273
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100274 checkboard();
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100275 timer_init();
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500276
Mike Frysinger6dadc912008-10-20 16:15:04 -0400277 printf("Clock: VCO: %s MHz, ", strmhz(buf, get_vco()));
278 printf("Core: %s MHz, ", strmhz(buf, get_cclk()));
279 printf("System: %s MHz\n", strmhz(buf, get_sclk()));
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500280
Mike Frysinger7d69dfd2010-12-20 05:18:55 -0500281 if (CONFIG_MEM_SIZE) {
282 printf("RAM: ");
283 print_size(bd->bi_memsize, "\n");
284 }
285
Mike Frysinger9171fc82008-03-30 15:46:13 -0400286#if defined(CONFIG_POST)
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800287 post_init_f();
288 post_bootmode_init();
289 post_run(NULL, POST_ROM | post_bootmode_get(0));
290#endif
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500291
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100292 board_init_r((gd_t *) gd, 0x20000010);
293}
294
Mike Frysinger8996d162009-02-22 16:02:27 -0500295static void board_net_init_r(bd_t *bd)
296{
Luigi 'Comio' Mantellini310cecb2009-10-10 12:42:21 +0200297#ifdef CONFIG_BITBANGMII
298 bb_miiphy_init();
299#endif
Mike Frysinger8996d162009-02-22 16:02:27 -0500300#ifdef CONFIG_CMD_NET
Mike Frysinger8996d162009-02-22 16:02:27 -0500301 char *s;
302
303 if ((s = getenv("bootfile")) != NULL)
304 copy_filename(BootFile, s, sizeof(BootFile));
305
306 bd->bi_ip_addr = getenv_IPaddr("ipaddr");
307
308 printf("Net: ");
309 eth_initialize(gd->bd);
Mike Frysinger8996d162009-02-22 16:02:27 -0500310#endif
311}
312
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100313void board_init_r(gd_t * id, ulong dest_addr)
314{
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500315 char *s;
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100316 bd_t *bd;
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100317 gd = id;
318 gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */
319 bd = gd->bd;
320
Mike Frysinger9171fc82008-03-30 15:46:13 -0400321#if defined(CONFIG_POST)
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800322 post_output_backlog();
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800323#endif
324
Stefan Roesec790b042009-05-11 15:50:12 +0200325 /* initialize malloc() area */
Peter Tysera483a162009-08-21 23:05:20 -0500326 mem_malloc_init(CONFIG_SYS_MALLOC_BASE, CONFIG_SYS_MALLOC_LEN);
Stefan Roesec790b042009-05-11 15:50:12 +0200327
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200328#if !defined(CONFIG_SYS_NO_FLASH)
Mike Frysingerb6edc712008-10-06 04:00:07 -0400329 /* Initialize the flash and protect u-boot by default */
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500330 extern flash_info_t flash_info[];
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500331 puts("Flash: ");
Mike Frysinger45c48952008-10-06 04:01:26 -0400332 ulong size = flash_init();
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500333 print_size(size, "\n");
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200334 flash_protect(FLAG_PROTECT_SET, CONFIG_SYS_FLASH_BASE,
Mike Frysingerb6edc712008-10-06 04:00:07 -0400335 CONFIG_SYS_FLASH_BASE + CONFIG_SYS_MONITOR_LEN - 1,
336 &flash_info[0]);
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200337 bd->bi_flashstart = CONFIG_SYS_FLASH_BASE;
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100338 bd->bi_flashsize = size;
339 bd->bi_flashoffset = 0;
340#else
341 bd->bi_flashstart = 0;
342 bd->bi_flashsize = 0;
343 bd->bi_flashoffset = 0;
344#endif
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100345
Mike Frysinger39782722008-10-06 03:55:25 -0400346#ifdef CONFIG_CMD_NAND
347 puts("NAND: ");
348 nand_init(); /* go init the NAND */
349#endif
350
Cliff Caie54c8202009-11-20 08:24:43 +0000351#ifdef CONFIG_GENERIC_MMC
Mike Frysingerd3c07a52010-09-29 14:46:42 -0400352 puts("MMC: ");
Cliff Caie54c8202009-11-20 08:24:43 +0000353 mmc_initialize(bd);
354#endif
355
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100356 /* relocate environment function pointers etc. */
357 env_relocate();
358
Jean-Christophe PLAGNIOL-VILLARD52cb4d42009-05-16 12:14:54 +0200359 /* Initialize stdio devices */
360 stdio_init();
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100361 jumptable_init();
362
363 /* Initialize the console (after the relocation and devices init) */
364 console_init_r();
365
Robin Getzf19fd872009-12-21 16:35:48 -0500366#ifdef CONFIG_CMD_KGDB
367 puts("KGDB: ");
368 kgdb_init();
369#endif
370
Mike Frysinger01815c22008-10-06 03:52:24 -0400371#ifdef CONFIG_STATUS_LED
372 status_led_set(STATUS_LED_BOOT, STATUS_LED_BLINKING);
373 status_led_set(STATUS_LED_CRASH, STATUS_LED_OFF);
374#endif
375
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100376 /* Initialize from environment */
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500377 if ((s = getenv("loadaddr")) != NULL)
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100378 load_addr = simple_strtoul(s, NULL, 16);
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800379
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100380#if defined(CONFIG_MISC_INIT_R)
381 /* miscellaneous platform dependent initialisations */
382 misc_init_r();
383#endif
384
Mike Frysinger8996d162009-02-22 16:02:27 -0500385 board_net_init_r(bd);
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800386
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800387 display_global_data();
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800388
Mike Frysinger9171fc82008-03-30 15:46:13 -0400389#if defined(CONFIG_POST)
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800390 if (post_flag)
391 post_run(NULL, POST_RAM | post_bootmode_get(0));
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100392#endif
393
Mike Frysinger05e78252010-12-24 13:19:25 -0500394 if (CONFIG_MEM_SIZE && bfin_os_log_check()) {
Mike Frysinger909878f2009-07-09 01:15:05 -0400395 puts("\nLog buffer from operating system:\n");
396 bfin_os_log_dump();
397 puts("\n");
398 }
399
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100400 /* main_loop() can return to retry autoboot, if so just run it again. */
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500401 for (;;)
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100402 main_loop();
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100403}
404
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100405void hang(void)
406{
Mike Frysinger01815c22008-10-06 03:52:24 -0400407#ifdef CONFIG_STATUS_LED
408 status_led_set(STATUS_LED_BOOT, STATUS_LED_OFF);
409 status_led_set(STATUS_LED_CRASH, STATUS_LED_BLINKING);
410#endif
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100411 puts("### ERROR ### Please RESET the board ###\n");
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500412 while (1)
413 /* If a JTAG emulator is hooked up, we'll automatically trigger
414 * a breakpoint in it. If one isn't, this is just a NOP.
415 */
416 asm("emuexcpt;");
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100417}