blob: facbc7a563f34eb8cb9ebccb5626d7c033a82665 [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>
Sonic Zhang31d5d4e2013-12-09 12:56:27 +080022#include <watchdog.h>
Mike Frysingerd5bffeb2008-02-19 00:54:20 -050023
Aubrey.Li3f0606a2007-03-09 13:38:44 +080024#include <asm/cplb.h>
Mike Frysingerd5bffeb2008-02-19 00:54:20 -050025#include <asm/mach-common/bits/mpu.h>
Robin Getzf19fd872009-12-21 16:35:48 -050026#include <kgdb.h>
Mike Frysingerd5bffeb2008-02-19 00:54:20 -050027
28#ifdef CONFIG_CMD_NAND
29#include <nand.h> /* cannot even include nand.h if it isnt configured */
30#endif
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010031
Luigi 'Comio' Mantellini310cecb2009-10-10 12:42:21 +020032#ifdef CONFIG_BITBANGMII
33#include <miiphy.h>
34#endif
35
Mike Frysinger9171fc82008-03-30 15:46:13 -040036#if defined(CONFIG_POST)
Aubrey.Li3f0606a2007-03-09 13:38:44 +080037#include <post.h>
38int post_flag;
39#endif
Wolfgang Denkd87080b2006-03-31 18:32:53 +020040
Heiko Schocher3f4978c2012-01-16 21:12:24 +000041#if defined(CONFIG_SYS_I2C)
42#include <i2c.h>
43#endif
44
Wolfgang Denk1218abf2007-09-15 20:48:41 +020045DECLARE_GLOBAL_DATA_PTR;
46
Mike Frysingerd5bffeb2008-02-19 00:54:20 -050047__attribute__((always_inline))
48static inline void serial_early_puts(const char *s)
49{
50#ifdef CONFIG_DEBUG_EARLY_SERIAL
51 serial_puts("Early: ");
52 serial_puts(s);
53#endif
54}
55
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010056static int display_banner(void)
57{
Mike Frysingerbb838752011-06-30 18:26:39 -040058 display_options();
Mike Frysinger5d891152010-08-09 17:39:22 -040059 printf("CPU: ADSP %s "
Mike Frysingerfc68f9f2009-01-06 06:16:19 -050060 "(Detected Rev: 0.%d) "
61 "(%s boot)\n",
Mike Frysinger5d891152010-08-09 17:39:22 -040062 gd->bd->bi_cpu,
Mike Frysingerfc68f9f2009-01-06 06:16:19 -050063 bfin_revid(),
64 get_bfin_boot_mode(CONFIG_BFIN_BOOT_MODE));
Mike Frysingerd5bffeb2008-02-19 00:54:20 -050065 return 0;
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010066}
67
68static int init_baudrate(void)
69{
Simon Glassc1f485a2011-10-13 14:43:08 +000070 gd->baudrate = getenv_ulong("baudrate", 10, CONFIG_BAUDRATE);
Axel Lin53086be2013-07-01 13:16:17 +080071 gd->bd->bi_baudrate = gd->baudrate;
Mike Frysingerd5bffeb2008-02-19 00:54:20 -050072 return 0;
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010073}
74
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010075static void display_global_data(void)
76{
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010077 bd_t *bd;
Mike Frysinger03f70532010-01-19 15:39:07 -050078
79#ifndef CONFIG_DEBUG_EARLY_SERIAL
80 return;
81#endif
82
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010083 bd = gd->bd;
Mike Frysingerf541e1d2009-08-24 19:03:18 -040084 printf(" gd: %p\n", gd);
85 printf(" |-flags: %lx\n", gd->flags);
Simon Glass4da25512013-03-05 14:39:59 +000086 printf(" |-board_type: %lx\n", gd->arch.board_type);
Simon Glass5e84e5a2012-10-12 14:21:17 +000087 printf(" |-baudrate: %u\n", gd->baudrate);
Mike Frysingerf541e1d2009-08-24 19:03:18 -040088 printf(" |-have_console: %lx\n", gd->have_console);
89 printf(" |-ram_size: %lx\n", gd->ram_size);
Mike Frysingerf541e1d2009-08-24 19:03:18 -040090 printf(" |-env_addr: %lx\n", gd->env_addr);
91 printf(" |-env_valid: %lx\n", gd->env_valid);
92 printf(" |-jt(%p): %p\n", gd->jt, *(gd->jt));
93 printf(" \\-bd: %p\n", gd->bd);
Mike Frysingerd5bffeb2008-02-19 00:54:20 -050094 printf(" |-bi_baudrate: %x\n", bd->bi_baudrate);
Mike Frysingerf541e1d2009-08-24 19:03:18 -040095 printf(" |-bi_boot_params: %lx\n", bd->bi_boot_params);
96 printf(" |-bi_memstart: %lx\n", bd->bi_memstart);
97 printf(" |-bi_memsize: %lx\n", bd->bi_memsize);
98 printf(" |-bi_flashstart: %lx\n", bd->bi_flashstart);
99 printf(" |-bi_flashsize: %lx\n", bd->bi_flashsize);
100 printf(" \\-bi_flashoffset: %lx\n", bd->bi_flashoffset);
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500101}
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100102
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500103#define CPLB_PAGE_SIZE (4 * 1024 * 1024)
104#define CPLB_PAGE_MASK (~(CPLB_PAGE_SIZE - 1))
Bob Liu7677d652011-10-25 18:07:58 +0800105#if defined(__ADSPBF60x__)
106#define CPLB_EX_PAGE_SIZE (16 * 1024 * 1024)
107#define CPLB_EX_PAGE_MASK (~(CPLB_EX_PAGE_SIZE - 1))
108#else
109#define CPLB_EX_PAGE_SIZE CPLB_PAGE_SIZE
110#define CPLB_EX_PAGE_MASK CPLB_PAGE_MASK
111#endif
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800112void init_cplbtables(void)
113{
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500114 volatile uint32_t *ICPLB_ADDR, *ICPLB_DATA;
115 volatile uint32_t *DCPLB_ADDR, *DCPLB_DATA;
116 uint32_t extern_memory;
117 size_t i;
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800118
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500119 void icplb_add(uint32_t addr, uint32_t data)
120 {
121 *(ICPLB_ADDR + i) = addr;
122 *(ICPLB_DATA + i) = data;
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800123 }
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500124 void dcplb_add(uint32_t addr, uint32_t data)
125 {
126 *(DCPLB_ADDR + i) = addr;
127 *(DCPLB_DATA + i) = data;
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800128 }
129
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500130 /* populate a few common entries ... we'll let
131 * the memory map and cplb exception handler do
132 * the rest of the work.
133 */
134 i = 0;
135 ICPLB_ADDR = (uint32_t *)ICPLB_ADDR0;
136 ICPLB_DATA = (uint32_t *)ICPLB_DATA0;
137 DCPLB_ADDR = (uint32_t *)DCPLB_ADDR0;
138 DCPLB_DATA = (uint32_t *)DCPLB_DATA0;
139
140 icplb_add(0xFFA00000, L1_IMEMORY);
141 dcplb_add(0xFF800000, L1_DMEMORY);
142 ++i;
Bob Liu7677d652011-10-25 18:07:58 +0800143#if defined(__ADSPBF60x__)
144 icplb_add(0x0, 0x0);
Sonic Zhang861aa632014-01-22 16:04:19 +0800145 dcplb_add(CONFIG_SYS_FLASH_BASE, PAGE_SIZE_16MB | CPLB_DIRTY |
146 CPLB_SUPV_WR | CPLB_USER_WR | CPLB_USER_RD | CPLB_VALID);
Bob Liu7677d652011-10-25 18:07:58 +0800147 ++i;
148#endif
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500149
Mike Frysinger7527fee2009-11-09 19:38:23 -0500150 if (CONFIG_MEM_SIZE) {
151 uint32_t mbase = CONFIG_SYS_MONITOR_BASE;
152 uint32_t mend = mbase + CONFIG_SYS_MONITOR_LEN;
153 mbase &= CPLB_PAGE_MASK;
154 mend &= CPLB_PAGE_MASK;
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500155
Mike Frysinger7527fee2009-11-09 19:38:23 -0500156 icplb_add(mbase, SDRAM_IKERNEL);
157 dcplb_add(mbase, SDRAM_DKERNEL);
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500158 ++i;
Mike Frysinger7527fee2009-11-09 19:38:23 -0500159
160 /*
161 * If the monitor crosses a 4 meg boundary, we'll need
162 * to lock two entries for it. We assume it doesn't
163 * cross two 4 meg boundaries ...
164 */
165 if (mbase != mend) {
166 icplb_add(mend, SDRAM_IKERNEL);
167 dcplb_add(mend, SDRAM_DKERNEL);
168 ++i;
169 }
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500170 }
171
Bob Liu7677d652011-10-25 18:07:58 +0800172#ifndef __ADSPBF60x__
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500173 icplb_add(0x20000000, SDRAM_INON_CHBL);
174 dcplb_add(0x20000000, SDRAM_EBIU);
175 ++i;
Bob Liu7677d652011-10-25 18:07:58 +0800176#endif
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500177
178 /* Add entries for the rest of external RAM up to the bootrom */
179 extern_memory = 0;
180
181#ifdef CONFIG_DEBUG_NULL_PTR
182 icplb_add(extern_memory, (SDRAM_IKERNEL & ~PAGE_SIZE_MASK) | PAGE_SIZE_1KB);
183 dcplb_add(extern_memory, (SDRAM_DKERNEL & ~PAGE_SIZE_MASK) | PAGE_SIZE_1KB);
184 ++i;
185 icplb_add(extern_memory, SDRAM_IKERNEL);
186 dcplb_add(extern_memory, SDRAM_DKERNEL);
187 extern_memory += CPLB_PAGE_SIZE;
188 ++i;
189#endif
190
Bob Liu7677d652011-10-25 18:07:58 +0800191 while (i < 16 && extern_memory <
192 (CONFIG_SYS_MONITOR_BASE & CPLB_EX_PAGE_MASK)) {
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500193 icplb_add(extern_memory, SDRAM_IGENERIC);
194 dcplb_add(extern_memory, SDRAM_DGENERIC);
Bob Liu7677d652011-10-25 18:07:58 +0800195 extern_memory += CPLB_EX_PAGE_SIZE;
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500196 ++i;
197 }
198 while (i < 16) {
199 icplb_add(0, 0);
200 dcplb_add(0, 0);
201 ++i;
202 }
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800203}
204
Mike Frysingera4932d72012-02-29 22:48:10 -0500205static int global_board_data_init(void)
206{
207#ifndef CONFIG_SYS_GBL_DATA_ADDR
208# define CONFIG_SYS_GBL_DATA_ADDR 0
209#endif
210#ifndef CONFIG_SYS_BD_INFO_ADDR
211# define CONFIG_SYS_BD_INFO_ADDR 0
212#endif
213
214 bd_t *bd;
215
216 if (CONFIG_SYS_GBL_DATA_ADDR) {
217 gd = (gd_t *) (CONFIG_SYS_GBL_DATA_ADDR);
218 memset((void *)gd, 0, GENERATED_GBL_DATA_SIZE);
219 } else {
220 static gd_t _bfin_gd;
221 gd = &_bfin_gd;
222 }
223
224 if (CONFIG_SYS_BD_INFO_ADDR) {
225 bd = (bd_t *) (CONFIG_SYS_BD_INFO_ADDR);
226 memset(bd, 0, GENERATED_BD_INFO_SIZE);
227 } else {
228 static bd_t _bfin_bd;
229 bd = &_bfin_bd;
230 }
231 gd->bd = bd;
232
233 bd->bi_r_version = version_string;
Marek Vasut5368c552012-09-23 17:41:24 +0200234 bd->bi_cpu = __stringify(CONFIG_BFIN_CPU);
Mike Frysingera4932d72012-02-29 22:48:10 -0500235 bd->bi_board_name = BFIN_BOARD_NAME;
236 bd->bi_vco = get_vco();
237 bd->bi_cclk = get_cclk();
238 bd->bi_sclk = get_sclk();
239 bd->bi_memstart = CONFIG_SYS_SDRAM_BASE;
240 bd->bi_memsize = CONFIG_SYS_MAX_RAM_SIZE;
241
242 return 0;
243}
244
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100245/*
246 * All attempts to come up with a "common" initialization sequence
247 * that works for all boards and architectures failed: some of the
248 * requirements are just _too_ different. To get rid of the resulting
249 * mess of board dependend #ifdef'ed code we now make the whole
250 * initialization sequence configurable to the user.
251 *
252 * The requirements for any new initalization function is simple: it
253 * receives a pointer to the "global data" structure as it's only
254 * argument, and returns an integer return code, where 0 means
255 * "continue" and != 0 means "fatal error, hang the system".
256 */
257
Mike Frysinger0c080aa2010-02-11 20:19:10 -0500258extern int watchdog_init(void);
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500259extern int exception_init(void);
260extern int irq_init(void);
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500261extern int timer_init(void);
262
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100263void board_init_f(ulong bootflag)
264{
Mike Frysinger6dadc912008-10-20 16:15:04 -0400265 char buf[32];
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800266
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500267#ifdef CONFIG_BOARD_EARLY_INIT_F
268 serial_early_puts("Board early init flash\n");
269 board_early_init_f();
270#endif
271
272 serial_early_puts("Init CPLB tables\n");
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800273 init_cplbtables();
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100274
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500275 serial_early_puts("Exceptions setup\n");
276 exception_init();
277
278#ifndef CONFIG_ICACHE_OFF
279 serial_early_puts("Turn on ICACHE\n");
280 icache_enable();
281#endif
282#ifndef CONFIG_DCACHE_OFF
283 serial_early_puts("Turn on DCACHE\n");
284 dcache_enable();
285#endif
286
Sonic Zhange9a389a2013-04-07 18:02:37 +0800287#ifdef CONFIG_HW_WATCHDOG
Mike Frysinger0c080aa2010-02-11 20:19:10 -0500288 serial_early_puts("Setting up external watchdog\n");
Sonic Zhange9a389a2013-04-07 18:02:37 +0800289 hw_watchdog_init();
Mike Frysinger0c080aa2010-02-11 20:19:10 -0500290#endif
291
Mike Frysinger78a0ba72008-10-06 03:57:39 -0400292#ifdef DEBUG
Wolfgang Denk25ddd1f2010-10-26 14:34:52 +0200293 if (GENERATED_GBL_DATA_SIZE < sizeof(*gd))
Mike Frysinger78a0ba72008-10-06 03:57:39 -0400294 hang();
295#endif
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500296 serial_early_puts("Init global data\n");
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100297
Mike Frysingera4932d72012-02-29 22:48:10 -0500298 global_board_data_init();
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800299
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500300 /* Initialize */
301 serial_early_puts("IRQ init\n");
302 irq_init();
303 serial_early_puts("Environment init\n");
304 env_init();
305 serial_early_puts("Baudrate init\n");
306 init_baudrate();
307 serial_early_puts("Serial init\n");
308 serial_init();
Mike Frysinger635f3302011-04-29 23:23:28 -0400309 serial_initialize();
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500310 serial_early_puts("Console init flash\n");
311 console_init_f();
312 serial_early_puts("End of early debugging\n");
313 display_banner();
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800314
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100315 checkboard();
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100316 timer_init();
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500317
Mike Frysinger6dadc912008-10-20 16:15:04 -0400318 printf("Clock: VCO: %s MHz, ", strmhz(buf, get_vco()));
319 printf("Core: %s MHz, ", strmhz(buf, get_cclk()));
Sonic Zhanga2979dc2012-08-16 11:56:14 +0800320#if defined(__ADSPBF60x__)
321 printf("System0: %s MHz, ", strmhz(buf, get_sclk0()));
322 printf("System1: %s MHz, ", strmhz(buf, get_sclk1()));
323 printf("Dclk: %s MHz\n", strmhz(buf, get_dclk()));
324#else
Mike Frysinger6dadc912008-10-20 16:15:04 -0400325 printf("System: %s MHz\n", strmhz(buf, get_sclk()));
Sonic Zhanga2979dc2012-08-16 11:56:14 +0800326#endif
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500327
Mike Frysinger7d69dfd2010-12-20 05:18:55 -0500328 if (CONFIG_MEM_SIZE) {
329 printf("RAM: ");
Mike Frysingera4932d72012-02-29 22:48:10 -0500330 print_size(gd->bd->bi_memsize, "\n");
Mike Frysinger7d69dfd2010-12-20 05:18:55 -0500331 }
332
Mike Frysinger9171fc82008-03-30 15:46:13 -0400333#if defined(CONFIG_POST)
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800334 post_init_f();
335 post_bootmode_init();
336 post_run(NULL, POST_ROM | post_bootmode_get(0));
337#endif
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500338
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100339 board_init_r((gd_t *) gd, 0x20000010);
340}
341
Mike Frysinger8996d162009-02-22 16:02:27 -0500342static void board_net_init_r(bd_t *bd)
343{
Luigi 'Comio' Mantellini310cecb2009-10-10 12:42:21 +0200344#ifdef CONFIG_BITBANGMII
345 bb_miiphy_init();
346#endif
Mike Frysinger8996d162009-02-22 16:02:27 -0500347#ifdef CONFIG_CMD_NET
Mike Frysinger8996d162009-02-22 16:02:27 -0500348 printf("Net: ");
Mike Frysingerde301222012-04-04 18:53:41 +0000349 eth_initialize(bd);
Mike Frysinger8996d162009-02-22 16:02:27 -0500350#endif
351}
352
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100353void board_init_r(gd_t * id, ulong dest_addr)
354{
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100355 bd_t *bd;
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100356 gd = id;
357 gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */
358 bd = gd->bd;
359
Mike Frysinger9171fc82008-03-30 15:46:13 -0400360#if defined(CONFIG_POST)
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800361 post_output_backlog();
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800362#endif
363
Stefan Roesec790b042009-05-11 15:50:12 +0200364 /* initialize malloc() area */
Peter Tysera483a162009-08-21 23:05:20 -0500365 mem_malloc_init(CONFIG_SYS_MALLOC_BASE, CONFIG_SYS_MALLOC_LEN);
Stefan Roesec790b042009-05-11 15:50:12 +0200366
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200367#if !defined(CONFIG_SYS_NO_FLASH)
Mike Frysingerb6edc712008-10-06 04:00:07 -0400368 /* Initialize the flash and protect u-boot by default */
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500369 extern flash_info_t flash_info[];
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500370 puts("Flash: ");
Mike Frysinger45c48952008-10-06 04:01:26 -0400371 ulong size = flash_init();
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500372 print_size(size, "\n");
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200373 flash_protect(FLAG_PROTECT_SET, CONFIG_SYS_FLASH_BASE,
Mike Frysingerb6edc712008-10-06 04:00:07 -0400374 CONFIG_SYS_FLASH_BASE + CONFIG_SYS_MONITOR_LEN - 1,
375 &flash_info[0]);
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200376 bd->bi_flashstart = CONFIG_SYS_FLASH_BASE;
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100377 bd->bi_flashsize = size;
378 bd->bi_flashoffset = 0;
379#else
380 bd->bi_flashstart = 0;
381 bd->bi_flashsize = 0;
382 bd->bi_flashoffset = 0;
383#endif
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100384
Mike Frysinger39782722008-10-06 03:55:25 -0400385#ifdef CONFIG_CMD_NAND
386 puts("NAND: ");
387 nand_init(); /* go init the NAND */
388#endif
389
Cliff Caie54c8202009-11-20 08:24:43 +0000390#ifdef CONFIG_GENERIC_MMC
Mike Frysingerd3c07a52010-09-29 14:46:42 -0400391 puts("MMC: ");
Cliff Caie54c8202009-11-20 08:24:43 +0000392 mmc_initialize(bd);
393#endif
394
Heiko Schocher3f4978c2012-01-16 21:12:24 +0000395#if defined(CONFIG_SYS_I2C)
396 i2c_reloc_fixup();
397#endif
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100398 /* relocate environment function pointers etc. */
399 env_relocate();
400
Jean-Christophe PLAGNIOL-VILLARD52cb4d42009-05-16 12:14:54 +0200401 /* Initialize stdio devices */
402 stdio_init();
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100403 jumptable_init();
404
405 /* Initialize the console (after the relocation and devices init) */
406 console_init_r();
407
Robin Getzf19fd872009-12-21 16:35:48 -0500408#ifdef CONFIG_CMD_KGDB
409 puts("KGDB: ");
410 kgdb_init();
411#endif
412
Mike Frysinger01815c22008-10-06 03:52:24 -0400413#ifdef CONFIG_STATUS_LED
414 status_led_set(STATUS_LED_BOOT, STATUS_LED_BLINKING);
415 status_led_set(STATUS_LED_CRASH, STATUS_LED_OFF);
416#endif
417
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100418 /* Initialize from environment */
Simon Glassc1f485a2011-10-13 14:43:08 +0000419 load_addr = getenv_ulong("loadaddr", 16, load_addr);
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800420
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100421#if defined(CONFIG_MISC_INIT_R)
422 /* miscellaneous platform dependent initialisations */
423 misc_init_r();
424#endif
425
Mike Frysinger8996d162009-02-22 16:02:27 -0500426 board_net_init_r(bd);
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800427
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800428 display_global_data();
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800429
Mike Frysinger9171fc82008-03-30 15:46:13 -0400430#if defined(CONFIG_POST)
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800431 if (post_flag)
432 post_run(NULL, POST_RAM | post_bootmode_get(0));
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100433#endif
434
Mike Frysinger05e78252010-12-24 13:19:25 -0500435 if (CONFIG_MEM_SIZE && bfin_os_log_check()) {
Mike Frysinger909878f2009-07-09 01:15:05 -0400436 puts("\nLog buffer from operating system:\n");
437 bfin_os_log_dump();
438 puts("\n");
439 }
440
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100441 /* main_loop() can return to retry autoboot, if so just run it again. */
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500442 for (;;)
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100443 main_loop();
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100444}