blob: 75b6c463d87ba0348af947a5a1466a51c94aae4b [file] [log] [blame]
Wolfgang Denk97caf672006-03-12 02:12:27 +01001/*
2 * U-boot - board.c First C file to be called contains init routines
3 *
Mike Frysinger6a675322008-02-19 00:54:20 -05004 * Copyright (c) 2005-2008 Analog Devices Inc.
Wolfgang Denk97caf672006-03-12 02:12:27 +01005 *
6 * (C) Copyright 2000-2004
7 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
8 *
Mike Frysinger6a675322008-02-19 00:54:20 -05009 * Licensed under the GPL-2 or later.
Wolfgang Denk97caf672006-03-12 02:12:27 +010010 */
11
12#include <common.h>
13#include <command.h>
Jean-Christophe PLAGNIOL-VILLARD2a7a0312009-05-16 12:14:54 +020014#include <stdio_dev.h>
Mike Frysinger53ba3222011-04-29 23:23:28 -040015#include <serial.h>
Wolfgang Denk97caf672006-03-12 02:12:27 +010016#include <environment.h>
Mike Frysinger6a675322008-02-19 00:54:20 -050017#include <malloc.h>
Cliff Caie4638922009-11-20 08:24:43 +000018#include <mmc.h>
Mike Frysinger6a675322008-02-19 00:54:20 -050019#include <net.h>
Mike Frysingerc6b978b2008-10-06 03:52:24 -040020#include <status_led.h>
Mike Frysinger6a675322008-02-19 00:54:20 -050021#include <version.h>
22
Aubrey.Li9da597f2007-03-09 13:38:44 +080023#include <asm/cplb.h>
Mike Frysinger6a675322008-02-19 00:54:20 -050024#include <asm/mach-common/bits/mpu.h>
Robin Getz230d0012009-12-21 16:35:48 -050025#include <kgdb.h>
Mike Frysinger6a675322008-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 Denk97caf672006-03-12 02:12:27 +010030
Luigi 'Comio' Mantellini01db1552009-10-10 12:42:21 +020031#ifdef CONFIG_BITBANGMII
32#include <miiphy.h>
33#endif
34
Mike Frysinger94bae5c2008-03-30 15:46:13 -040035#if defined(CONFIG_POST)
Aubrey.Li9da597f2007-03-09 13:38:44 +080036#include <post.h>
37int post_flag;
38#endif
Wolfgang Denk6405a152006-03-31 18:32:53 +020039
Wolfgang Denkd112a2c2007-09-15 20:48:41 +020040DECLARE_GLOBAL_DATA_PTR;
41
Mike Frysinger6a675322008-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);
Aubrey.Li9da597f2007-03-09 13:38:44 +080048#endif
Mike Frysinger6a675322008-02-19 00:54:20 -050049}
Aubrey.Li9da597f2007-03-09 13:38:44 +080050
Wolfgang Denk97caf672006-03-12 02:12:27 +010051static int display_banner(void)
52{
Mike Frysinger5b74f0b2011-06-30 18:26:39 -040053 display_options();
Mike Frysinger36e63df2010-08-09 17:39:22 -040054 printf("CPU: ADSP %s "
Mike Frysinger7e1bbd82009-01-06 06:16:19 -050055 "(Detected Rev: 0.%d) "
56 "(%s boot)\n",
Mike Frysinger36e63df2010-08-09 17:39:22 -040057 gd->bd->bi_cpu,
Mike Frysinger7e1bbd82009-01-06 06:16:19 -050058 bfin_revid(),
59 get_bfin_boot_mode(CONFIG_BFIN_BOOT_MODE));
Mike Frysinger6a675322008-02-19 00:54:20 -050060 return 0;
Wolfgang Denk97caf672006-03-12 02:12:27 +010061}
62
Wolfgang Denk97caf672006-03-12 02:12:27 +010063static int init_baudrate(void)
64{
Simon Glass3d87f6b2011-10-13 14:43:08 +000065 gd->baudrate = getenv_ulong("baudrate", 10, CONFIG_BAUDRATE);
Mike Frysinger6a675322008-02-19 00:54:20 -050066 return 0;
Wolfgang Denk97caf672006-03-12 02:12:27 +010067}
68
Wolfgang Denk97caf672006-03-12 02:12:27 +010069static void display_global_data(void)
70{
Wolfgang Denk97caf672006-03-12 02:12:27 +010071 bd_t *bd;
Mike Frysinger188cd542010-01-19 15:39:07 -050072
73#ifndef CONFIG_DEBUG_EARLY_SERIAL
74 return;
75#endif
76
Wolfgang Denk97caf672006-03-12 02:12:27 +010077 bd = gd->bd;
Mike Frysinger34298372009-08-24 19:03:18 -040078 printf(" gd: %p\n", gd);
79 printf(" |-flags: %lx\n", gd->flags);
Simon Glassbbeac162013-03-05 14:39:59 +000080 printf(" |-board_type: %lx\n", gd->arch.board_type);
Simon Glass25c2bad2012-10-12 14:21:17 +000081 printf(" |-baudrate: %u\n", gd->baudrate);
Mike Frysinger34298372009-08-24 19:03:18 -040082 printf(" |-have_console: %lx\n", gd->have_console);
83 printf(" |-ram_size: %lx\n", gd->ram_size);
Mike Frysinger34298372009-08-24 19:03:18 -040084 printf(" |-env_addr: %lx\n", gd->env_addr);
85 printf(" |-env_valid: %lx\n", gd->env_valid);
86 printf(" |-jt(%p): %p\n", gd->jt, *(gd->jt));
87 printf(" \\-bd: %p\n", gd->bd);
Mike Frysinger6a675322008-02-19 00:54:20 -050088 printf(" |-bi_baudrate: %x\n", bd->bi_baudrate);
Mike Frysinger34298372009-08-24 19:03:18 -040089 printf(" |-bi_boot_params: %lx\n", bd->bi_boot_params);
90 printf(" |-bi_memstart: %lx\n", bd->bi_memstart);
91 printf(" |-bi_memsize: %lx\n", bd->bi_memsize);
92 printf(" |-bi_flashstart: %lx\n", bd->bi_flashstart);
93 printf(" |-bi_flashsize: %lx\n", bd->bi_flashsize);
94 printf(" \\-bi_flashoffset: %lx\n", bd->bi_flashoffset);
Mike Frysinger6a675322008-02-19 00:54:20 -050095}
Aubrey.Li9da597f2007-03-09 13:38:44 +080096
Mike Frysinger6a675322008-02-19 00:54:20 -050097#define CPLB_PAGE_SIZE (4 * 1024 * 1024)
98#define CPLB_PAGE_MASK (~(CPLB_PAGE_SIZE - 1))
Bob Liu49334b82011-10-25 18:07:58 +080099#if defined(__ADSPBF60x__)
100#define CPLB_EX_PAGE_SIZE (16 * 1024 * 1024)
101#define CPLB_EX_PAGE_MASK (~(CPLB_EX_PAGE_SIZE - 1))
102#else
103#define CPLB_EX_PAGE_SIZE CPLB_PAGE_SIZE
104#define CPLB_EX_PAGE_MASK CPLB_PAGE_MASK
105#endif
Aubrey.Li9da597f2007-03-09 13:38:44 +0800106void init_cplbtables(void)
107{
Mike Frysinger6a675322008-02-19 00:54:20 -0500108 volatile uint32_t *ICPLB_ADDR, *ICPLB_DATA;
109 volatile uint32_t *DCPLB_ADDR, *DCPLB_DATA;
110 uint32_t extern_memory;
111 size_t i;
Aubrey.Li9da597f2007-03-09 13:38:44 +0800112
Mike Frysinger6a675322008-02-19 00:54:20 -0500113 void icplb_add(uint32_t addr, uint32_t data)
114 {
115 *(ICPLB_ADDR + i) = addr;
116 *(ICPLB_DATA + i) = data;
Aubrey.Li9da597f2007-03-09 13:38:44 +0800117 }
Mike Frysinger6a675322008-02-19 00:54:20 -0500118 void dcplb_add(uint32_t addr, uint32_t data)
119 {
120 *(DCPLB_ADDR + i) = addr;
121 *(DCPLB_DATA + i) = data;
122 }
Aubrey.Li9da597f2007-03-09 13:38:44 +0800123
Mike Frysinger6a675322008-02-19 00:54:20 -0500124 /* populate a few common entries ... we'll let
125 * the memory map and cplb exception handler do
126 * the rest of the work.
127 */
128 i = 0;
129 ICPLB_ADDR = (uint32_t *)ICPLB_ADDR0;
130 ICPLB_DATA = (uint32_t *)ICPLB_DATA0;
131 DCPLB_ADDR = (uint32_t *)DCPLB_ADDR0;
132 DCPLB_DATA = (uint32_t *)DCPLB_DATA0;
133
134 icplb_add(0xFFA00000, L1_IMEMORY);
135 dcplb_add(0xFF800000, L1_DMEMORY);
136 ++i;
Bob Liu49334b82011-10-25 18:07:58 +0800137#if defined(__ADSPBF60x__)
138 icplb_add(0x0, 0x0);
139 dcplb_add(CONFIG_SYS_FLASH_BASE, SDRAM_EBIU);
140 ++i;
141#endif
Mike Frysinger6a675322008-02-19 00:54:20 -0500142
Mike Frysinger4368ea22009-11-09 19:38:23 -0500143 if (CONFIG_MEM_SIZE) {
144 uint32_t mbase = CONFIG_SYS_MONITOR_BASE;
145 uint32_t mend = mbase + CONFIG_SYS_MONITOR_LEN;
146 mbase &= CPLB_PAGE_MASK;
147 mend &= CPLB_PAGE_MASK;
Mike Frysinger6a675322008-02-19 00:54:20 -0500148
Mike Frysinger4368ea22009-11-09 19:38:23 -0500149 icplb_add(mbase, SDRAM_IKERNEL);
150 dcplb_add(mbase, SDRAM_DKERNEL);
Mike Frysinger6a675322008-02-19 00:54:20 -0500151 ++i;
Mike Frysinger4368ea22009-11-09 19:38:23 -0500152
153 /*
154 * If the monitor crosses a 4 meg boundary, we'll need
155 * to lock two entries for it. We assume it doesn't
156 * cross two 4 meg boundaries ...
157 */
158 if (mbase != mend) {
159 icplb_add(mend, SDRAM_IKERNEL);
160 dcplb_add(mend, SDRAM_DKERNEL);
161 ++i;
162 }
Aubrey.Li9da597f2007-03-09 13:38:44 +0800163 }
164
Bob Liu49334b82011-10-25 18:07:58 +0800165#ifndef __ADSPBF60x__
Mike Frysinger6a675322008-02-19 00:54:20 -0500166 icplb_add(0x20000000, SDRAM_INON_CHBL);
167 dcplb_add(0x20000000, SDRAM_EBIU);
168 ++i;
Bob Liu49334b82011-10-25 18:07:58 +0800169#endif
Mike Frysinger6a675322008-02-19 00:54:20 -0500170
171 /* Add entries for the rest of external RAM up to the bootrom */
172 extern_memory = 0;
173
174#ifdef CONFIG_DEBUG_NULL_PTR
175 icplb_add(extern_memory, (SDRAM_IKERNEL & ~PAGE_SIZE_MASK) | PAGE_SIZE_1KB);
176 dcplb_add(extern_memory, (SDRAM_DKERNEL & ~PAGE_SIZE_MASK) | PAGE_SIZE_1KB);
177 ++i;
178 icplb_add(extern_memory, SDRAM_IKERNEL);
179 dcplb_add(extern_memory, SDRAM_DKERNEL);
180 extern_memory += CPLB_PAGE_SIZE;
181 ++i;
182#endif
183
Bob Liu49334b82011-10-25 18:07:58 +0800184 while (i < 16 && extern_memory <
185 (CONFIG_SYS_MONITOR_BASE & CPLB_EX_PAGE_MASK)) {
Mike Frysinger6a675322008-02-19 00:54:20 -0500186 icplb_add(extern_memory, SDRAM_IGENERIC);
187 dcplb_add(extern_memory, SDRAM_DGENERIC);
Bob Liu49334b82011-10-25 18:07:58 +0800188 extern_memory += CPLB_EX_PAGE_SIZE;
Mike Frysinger6a675322008-02-19 00:54:20 -0500189 ++i;
190 }
191 while (i < 16) {
192 icplb_add(0, 0);
193 dcplb_add(0, 0);
194 ++i;
195 }
Aubrey.Li9da597f2007-03-09 13:38:44 +0800196}
197
Mike Frysingera067a5e2012-02-29 22:48:10 -0500198static int global_board_data_init(void)
199{
200#ifndef CONFIG_SYS_GBL_DATA_ADDR
201# define CONFIG_SYS_GBL_DATA_ADDR 0
202#endif
203#ifndef CONFIG_SYS_BD_INFO_ADDR
204# define CONFIG_SYS_BD_INFO_ADDR 0
205#endif
206
207 bd_t *bd;
208
209 if (CONFIG_SYS_GBL_DATA_ADDR) {
210 gd = (gd_t *) (CONFIG_SYS_GBL_DATA_ADDR);
211 memset((void *)gd, 0, GENERATED_GBL_DATA_SIZE);
212 } else {
213 static gd_t _bfin_gd;
214 gd = &_bfin_gd;
215 }
216
217 if (CONFIG_SYS_BD_INFO_ADDR) {
218 bd = (bd_t *) (CONFIG_SYS_BD_INFO_ADDR);
219 memset(bd, 0, GENERATED_BD_INFO_SIZE);
220 } else {
221 static bd_t _bfin_bd;
222 bd = &_bfin_bd;
223 }
224 gd->bd = bd;
225
226 bd->bi_r_version = version_string;
Marek Vasut0b3176c2012-09-23 17:41:24 +0200227 bd->bi_cpu = __stringify(CONFIG_BFIN_CPU);
Mike Frysingera067a5e2012-02-29 22:48:10 -0500228 bd->bi_board_name = BFIN_BOARD_NAME;
229 bd->bi_vco = get_vco();
230 bd->bi_cclk = get_cclk();
231 bd->bi_sclk = get_sclk();
232 bd->bi_memstart = CONFIG_SYS_SDRAM_BASE;
233 bd->bi_memsize = CONFIG_SYS_MAX_RAM_SIZE;
234
235 return 0;
236}
237
Wolfgang Denk97caf672006-03-12 02:12:27 +0100238/*
239 * All attempts to come up with a "common" initialization sequence
240 * that works for all boards and architectures failed: some of the
241 * requirements are just _too_ different. To get rid of the resulting
242 * mess of board dependend #ifdef'ed code we now make the whole
243 * initialization sequence configurable to the user.
244 *
245 * The requirements for any new initalization function is simple: it
246 * receives a pointer to the "global data" structure as it's only
247 * argument, and returns an integer return code, where 0 means
248 * "continue" and != 0 means "fatal error, hang the system".
249 */
250
Mike Frysinger851b8172010-02-11 20:19:10 -0500251extern int watchdog_init(void);
Mike Frysinger6a675322008-02-19 00:54:20 -0500252extern int exception_init(void);
253extern int irq_init(void);
Mike Frysinger6a675322008-02-19 00:54:20 -0500254extern int timer_init(void);
255
Wolfgang Denk97caf672006-03-12 02:12:27 +0100256void board_init_f(ulong bootflag)
257{
Mike Frysingera2672072008-10-20 16:15:04 -0400258 char buf[32];
Aubrey.Li9da597f2007-03-09 13:38:44 +0800259
Mike Frysinger6a675322008-02-19 00:54:20 -0500260#ifdef CONFIG_BOARD_EARLY_INIT_F
261 serial_early_puts("Board early init flash\n");
262 board_early_init_f();
263#endif
264
265 serial_early_puts("Init CPLB tables\n");
Aubrey.Li9da597f2007-03-09 13:38:44 +0800266 init_cplbtables();
Wolfgang Denk97caf672006-03-12 02:12:27 +0100267
Mike Frysinger6a675322008-02-19 00:54:20 -0500268 serial_early_puts("Exceptions setup\n");
269 exception_init();
270
271#ifndef CONFIG_ICACHE_OFF
272 serial_early_puts("Turn on ICACHE\n");
273 icache_enable();
274#endif
275#ifndef CONFIG_DCACHE_OFF
276 serial_early_puts("Turn on DCACHE\n");
277 dcache_enable();
278#endif
279
Mike Frysinger851b8172010-02-11 20:19:10 -0500280#ifdef CONFIG_WATCHDOG
281 serial_early_puts("Setting up external watchdog\n");
282 watchdog_init();
283#endif
284
Mike Frysingerf93f0302008-10-06 03:57:39 -0400285#ifdef DEBUG
Wolfgang Denk0191e472010-10-26 14:34:52 +0200286 if (GENERATED_GBL_DATA_SIZE < sizeof(*gd))
Mike Frysingerf93f0302008-10-06 03:57:39 -0400287 hang();
288#endif
Mike Frysinger6a675322008-02-19 00:54:20 -0500289 serial_early_puts("Init global data\n");
Wolfgang Denk97caf672006-03-12 02:12:27 +0100290
Mike Frysingera067a5e2012-02-29 22:48:10 -0500291 global_board_data_init();
Mike Frysinger6a675322008-02-19 00:54:20 -0500292
Wolfgang Denk97caf672006-03-12 02:12:27 +0100293 /* Initialize */
Mike Frysinger6a675322008-02-19 00:54:20 -0500294 serial_early_puts("IRQ init\n");
Mike Frysinger94bae5c2008-03-30 15:46:13 -0400295 irq_init();
Mike Frysinger6a675322008-02-19 00:54:20 -0500296 serial_early_puts("Environment init\n");
297 env_init();
298 serial_early_puts("Baudrate init\n");
299 init_baudrate();
300 serial_early_puts("Serial init\n");
301 serial_init();
Mike Frysinger53ba3222011-04-29 23:23:28 -0400302 serial_initialize();
Mike Frysinger6a675322008-02-19 00:54:20 -0500303 serial_early_puts("Console init flash\n");
Wolfgang Denk97caf672006-03-12 02:12:27 +0100304 console_init_f();
Mike Frysinger6a675322008-02-19 00:54:20 -0500305 serial_early_puts("End of early debugging\n");
306 display_banner();
Aubrey.Li9da597f2007-03-09 13:38:44 +0800307
Wolfgang Denk97caf672006-03-12 02:12:27 +0100308 checkboard();
Wolfgang Denk97caf672006-03-12 02:12:27 +0100309 timer_init();
Mike Frysinger6a675322008-02-19 00:54:20 -0500310
Mike Frysingera2672072008-10-20 16:15:04 -0400311 printf("Clock: VCO: %s MHz, ", strmhz(buf, get_vco()));
312 printf("Core: %s MHz, ", strmhz(buf, get_cclk()));
Sonic Zhanga99f03e2012-08-16 11:56:14 +0800313#if defined(__ADSPBF60x__)
314 printf("System0: %s MHz, ", strmhz(buf, get_sclk0()));
315 printf("System1: %s MHz, ", strmhz(buf, get_sclk1()));
316 printf("Dclk: %s MHz\n", strmhz(buf, get_dclk()));
317#else
Mike Frysingera2672072008-10-20 16:15:04 -0400318 printf("System: %s MHz\n", strmhz(buf, get_sclk()));
Sonic Zhanga99f03e2012-08-16 11:56:14 +0800319#endif
Mike Frysinger6a675322008-02-19 00:54:20 -0500320
Mike Frysinger20ea9972010-12-20 05:18:55 -0500321 if (CONFIG_MEM_SIZE) {
322 printf("RAM: ");
Mike Frysingera067a5e2012-02-29 22:48:10 -0500323 print_size(gd->bd->bi_memsize, "\n");
Mike Frysinger20ea9972010-12-20 05:18:55 -0500324 }
325
Mike Frysinger94bae5c2008-03-30 15:46:13 -0400326#if defined(CONFIG_POST)
Aubrey.Li9da597f2007-03-09 13:38:44 +0800327 post_init_f();
328 post_bootmode_init();
329 post_run(NULL, POST_ROM | post_bootmode_get(0));
330#endif
Mike Frysinger6a675322008-02-19 00:54:20 -0500331
Wolfgang Denk97caf672006-03-12 02:12:27 +0100332 board_init_r((gd_t *) gd, 0x20000010);
333}
Aubrey.Li9da597f2007-03-09 13:38:44 +0800334
Mike Frysingere434b9f2009-02-22 16:02:27 -0500335static void board_net_init_r(bd_t *bd)
336{
Luigi 'Comio' Mantellini01db1552009-10-10 12:42:21 +0200337#ifdef CONFIG_BITBANGMII
338 bb_miiphy_init();
339#endif
Mike Frysingere434b9f2009-02-22 16:02:27 -0500340#ifdef CONFIG_CMD_NET
Mike Frysingere434b9f2009-02-22 16:02:27 -0500341 printf("Net: ");
Mike Frysinger36fe7db2012-04-04 18:53:41 +0000342 eth_initialize(bd);
Mike Frysingere434b9f2009-02-22 16:02:27 -0500343#endif
344}
345
Wolfgang Denk97caf672006-03-12 02:12:27 +0100346void board_init_r(gd_t * id, ulong dest_addr)
347{
Wolfgang Denk97caf672006-03-12 02:12:27 +0100348 bd_t *bd;
Wolfgang Denk97caf672006-03-12 02:12:27 +0100349 gd = id;
350 gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */
351 bd = gd->bd;
352
Mike Frysinger94bae5c2008-03-30 15:46:13 -0400353#if defined(CONFIG_POST)
Aubrey.Li9da597f2007-03-09 13:38:44 +0800354 post_output_backlog();
Aubrey.Li9da597f2007-03-09 13:38:44 +0800355#endif
356
Stefan Roeseb81464e2009-05-11 15:50:12 +0200357 /* initialize malloc() area */
Peter Tysered527702009-08-21 23:05:20 -0500358 mem_malloc_init(CONFIG_SYS_MALLOC_BASE, CONFIG_SYS_MALLOC_LEN);
Stefan Roeseb81464e2009-05-11 15:50:12 +0200359
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200360#if !defined(CONFIG_SYS_NO_FLASH)
Mike Frysinger0dc765f2008-10-06 04:00:07 -0400361 /* Initialize the flash and protect u-boot by default */
Mike Frysinger6a675322008-02-19 00:54:20 -0500362 extern flash_info_t flash_info[];
Mike Frysinger6a675322008-02-19 00:54:20 -0500363 puts("Flash: ");
Mike Frysingerd1c68c12008-10-06 04:01:26 -0400364 ulong size = flash_init();
Mike Frysinger6a675322008-02-19 00:54:20 -0500365 print_size(size, "\n");
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200366 flash_protect(FLAG_PROTECT_SET, CONFIG_SYS_FLASH_BASE,
Mike Frysinger0dc765f2008-10-06 04:00:07 -0400367 CONFIG_SYS_FLASH_BASE + CONFIG_SYS_MONITOR_LEN - 1,
368 &flash_info[0]);
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200369 bd->bi_flashstart = CONFIG_SYS_FLASH_BASE;
Wolfgang Denk97caf672006-03-12 02:12:27 +0100370 bd->bi_flashsize = size;
371 bd->bi_flashoffset = 0;
372#else
373 bd->bi_flashstart = 0;
374 bd->bi_flashsize = 0;
375 bd->bi_flashoffset = 0;
376#endif
Wolfgang Denk97caf672006-03-12 02:12:27 +0100377
Mike Frysinger392bc552008-10-06 03:55:25 -0400378#ifdef CONFIG_CMD_NAND
379 puts("NAND: ");
380 nand_init(); /* go init the NAND */
381#endif
382
Cliff Caie4638922009-11-20 08:24:43 +0000383#ifdef CONFIG_GENERIC_MMC
Mike Frysingerd9548e32010-09-29 14:46:42 -0400384 puts("MMC: ");
Cliff Caie4638922009-11-20 08:24:43 +0000385 mmc_initialize(bd);
386#endif
387
Wolfgang Denk97caf672006-03-12 02:12:27 +0100388 /* relocate environment function pointers etc. */
389 env_relocate();
390
Jean-Christophe PLAGNIOL-VILLARD2a7a0312009-05-16 12:14:54 +0200391 /* Initialize stdio devices */
392 stdio_init();
Wolfgang Denk97caf672006-03-12 02:12:27 +0100393 jumptable_init();
394
395 /* Initialize the console (after the relocation and devices init) */
396 console_init_r();
397
Robin Getz230d0012009-12-21 16:35:48 -0500398#ifdef CONFIG_CMD_KGDB
399 puts("KGDB: ");
400 kgdb_init();
401#endif
402
Mike Frysingerc6b978b2008-10-06 03:52:24 -0400403#ifdef CONFIG_STATUS_LED
404 status_led_set(STATUS_LED_BOOT, STATUS_LED_BLINKING);
405 status_led_set(STATUS_LED_CRASH, STATUS_LED_OFF);
406#endif
407
Wolfgang Denk97caf672006-03-12 02:12:27 +0100408 /* Initialize from environment */
Simon Glass3d87f6b2011-10-13 14:43:08 +0000409 load_addr = getenv_ulong("loadaddr", 16, load_addr);
Aubrey.Li9da597f2007-03-09 13:38:44 +0800410
Wolfgang Denk97caf672006-03-12 02:12:27 +0100411#if defined(CONFIG_MISC_INIT_R)
412 /* miscellaneous platform dependent initialisations */
413 misc_init_r();
414#endif
415
Mike Frysingere434b9f2009-02-22 16:02:27 -0500416 board_net_init_r(bd);
Wolfgang Denk97caf672006-03-12 02:12:27 +0100417
Aubrey.Li9da597f2007-03-09 13:38:44 +0800418 display_global_data();
Aubrey.Li9da597f2007-03-09 13:38:44 +0800419
Mike Frysinger94bae5c2008-03-30 15:46:13 -0400420#if defined(CONFIG_POST)
Aubrey.Li9da597f2007-03-09 13:38:44 +0800421 if (post_flag)
422 post_run(NULL, POST_RAM | post_bootmode_get(0));
Wolfgang Denk97caf672006-03-12 02:12:27 +0100423#endif
424
Mike Frysinger7edbbfa2010-12-24 13:19:25 -0500425 if (CONFIG_MEM_SIZE && bfin_os_log_check()) {
Mike Frysinger08975892009-07-09 01:15:05 -0400426 puts("\nLog buffer from operating system:\n");
427 bfin_os_log_dump();
428 puts("\n");
429 }
430
Wolfgang Denk97caf672006-03-12 02:12:27 +0100431 /* main_loop() can return to retry autoboot, if so just run it again. */
Mike Frysinger6a675322008-02-19 00:54:20 -0500432 for (;;)
Wolfgang Denk97caf672006-03-12 02:12:27 +0100433 main_loop();
Wolfgang Denk97caf672006-03-12 02:12:27 +0100434}
Wolfgang Denk97caf672006-03-12 02:12:27 +0100435
436void hang(void)
437{
Mike Frysingerc6b978b2008-10-06 03:52:24 -0400438#ifdef CONFIG_STATUS_LED
439 status_led_set(STATUS_LED_BOOT, STATUS_LED_OFF);
440 status_led_set(STATUS_LED_CRASH, STATUS_LED_BLINKING);
441#endif
Wolfgang Denk97caf672006-03-12 02:12:27 +0100442 puts("### ERROR ### Please RESET the board ###\n");
Mike Frysinger6a675322008-02-19 00:54:20 -0500443 while (1)
444 /* If a JTAG emulator is hooked up, we'll automatically trigger
445 * a breakpoint in it. If one isn't, this is just a NOP.
446 */
447 asm("emuexcpt;");
Wolfgang Denk97caf672006-03-12 02:12:27 +0100448}