blob: 10223bdb791dfe7bd1ca55244f28577a16e6beeb [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
Heiko Schocher3f4978c2012-01-16 21:12:24 +000040#if defined(CONFIG_SYS_I2C)
41#include <i2c.h>
42#endif
43
Wolfgang Denk1218abf2007-09-15 20:48:41 +020044DECLARE_GLOBAL_DATA_PTR;
45
Mike Frysingerd5bffeb2008-02-19 00:54:20 -050046__attribute__((always_inline))
47static inline void serial_early_puts(const char *s)
48{
49#ifdef CONFIG_DEBUG_EARLY_SERIAL
50 serial_puts("Early: ");
51 serial_puts(s);
52#endif
53}
54
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010055static int display_banner(void)
56{
Mike Frysingerbb838752011-06-30 18:26:39 -040057 display_options();
Mike Frysinger5d891152010-08-09 17:39:22 -040058 printf("CPU: ADSP %s "
Mike Frysingerfc68f9f2009-01-06 06:16:19 -050059 "(Detected Rev: 0.%d) "
60 "(%s boot)\n",
Mike Frysinger5d891152010-08-09 17:39:22 -040061 gd->bd->bi_cpu,
Mike Frysingerfc68f9f2009-01-06 06:16:19 -050062 bfin_revid(),
63 get_bfin_boot_mode(CONFIG_BFIN_BOOT_MODE));
Mike Frysingerd5bffeb2008-02-19 00:54:20 -050064 return 0;
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010065}
66
67static int init_baudrate(void)
68{
Simon Glassc1f485a2011-10-13 14:43:08 +000069 gd->baudrate = getenv_ulong("baudrate", 10, 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);
Simon Glass4da25512013-03-05 14:39:59 +000084 printf(" |-board_type: %lx\n", gd->arch.board_type);
Simon Glass5e84e5a2012-10-12 14:21:17 +000085 printf(" |-baudrate: %u\n", gd->baudrate);
Mike Frysingerf541e1d2009-08-24 19:03:18 -040086 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_boot_params: %lx\n", bd->bi_boot_params);
94 printf(" |-bi_memstart: %lx\n", bd->bi_memstart);
95 printf(" |-bi_memsize: %lx\n", bd->bi_memsize);
96 printf(" |-bi_flashstart: %lx\n", bd->bi_flashstart);
97 printf(" |-bi_flashsize: %lx\n", bd->bi_flashsize);
98 printf(" \\-bi_flashoffset: %lx\n", bd->bi_flashoffset);
Mike Frysingerd5bffeb2008-02-19 00:54:20 -050099}
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100100
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500101#define CPLB_PAGE_SIZE (4 * 1024 * 1024)
102#define CPLB_PAGE_MASK (~(CPLB_PAGE_SIZE - 1))
Bob Liu7677d652011-10-25 18:07:58 +0800103#if defined(__ADSPBF60x__)
104#define CPLB_EX_PAGE_SIZE (16 * 1024 * 1024)
105#define CPLB_EX_PAGE_MASK (~(CPLB_EX_PAGE_SIZE - 1))
106#else
107#define CPLB_EX_PAGE_SIZE CPLB_PAGE_SIZE
108#define CPLB_EX_PAGE_MASK CPLB_PAGE_MASK
109#endif
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800110void init_cplbtables(void)
111{
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500112 volatile uint32_t *ICPLB_ADDR, *ICPLB_DATA;
113 volatile uint32_t *DCPLB_ADDR, *DCPLB_DATA;
114 uint32_t extern_memory;
115 size_t i;
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800116
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500117 void icplb_add(uint32_t addr, uint32_t data)
118 {
119 *(ICPLB_ADDR + i) = addr;
120 *(ICPLB_DATA + i) = data;
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800121 }
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500122 void dcplb_add(uint32_t addr, uint32_t data)
123 {
124 *(DCPLB_ADDR + i) = addr;
125 *(DCPLB_DATA + i) = data;
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800126 }
127
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500128 /* populate a few common entries ... we'll let
129 * the memory map and cplb exception handler do
130 * the rest of the work.
131 */
132 i = 0;
133 ICPLB_ADDR = (uint32_t *)ICPLB_ADDR0;
134 ICPLB_DATA = (uint32_t *)ICPLB_DATA0;
135 DCPLB_ADDR = (uint32_t *)DCPLB_ADDR0;
136 DCPLB_DATA = (uint32_t *)DCPLB_DATA0;
137
138 icplb_add(0xFFA00000, L1_IMEMORY);
139 dcplb_add(0xFF800000, L1_DMEMORY);
140 ++i;
Bob Liu7677d652011-10-25 18:07:58 +0800141#if defined(__ADSPBF60x__)
142 icplb_add(0x0, 0x0);
143 dcplb_add(CONFIG_SYS_FLASH_BASE, SDRAM_EBIU);
144 ++i;
145#endif
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500146
Mike Frysinger7527fee2009-11-09 19:38:23 -0500147 if (CONFIG_MEM_SIZE) {
148 uint32_t mbase = CONFIG_SYS_MONITOR_BASE;
149 uint32_t mend = mbase + CONFIG_SYS_MONITOR_LEN;
150 mbase &= CPLB_PAGE_MASK;
151 mend &= CPLB_PAGE_MASK;
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500152
Mike Frysinger7527fee2009-11-09 19:38:23 -0500153 icplb_add(mbase, SDRAM_IKERNEL);
154 dcplb_add(mbase, SDRAM_DKERNEL);
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500155 ++i;
Mike Frysinger7527fee2009-11-09 19:38:23 -0500156
157 /*
158 * If the monitor crosses a 4 meg boundary, we'll need
159 * to lock two entries for it. We assume it doesn't
160 * cross two 4 meg boundaries ...
161 */
162 if (mbase != mend) {
163 icplb_add(mend, SDRAM_IKERNEL);
164 dcplb_add(mend, SDRAM_DKERNEL);
165 ++i;
166 }
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500167 }
168
Bob Liu7677d652011-10-25 18:07:58 +0800169#ifndef __ADSPBF60x__
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500170 icplb_add(0x20000000, SDRAM_INON_CHBL);
171 dcplb_add(0x20000000, SDRAM_EBIU);
172 ++i;
Bob Liu7677d652011-10-25 18:07:58 +0800173#endif
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500174
175 /* Add entries for the rest of external RAM up to the bootrom */
176 extern_memory = 0;
177
178#ifdef CONFIG_DEBUG_NULL_PTR
179 icplb_add(extern_memory, (SDRAM_IKERNEL & ~PAGE_SIZE_MASK) | PAGE_SIZE_1KB);
180 dcplb_add(extern_memory, (SDRAM_DKERNEL & ~PAGE_SIZE_MASK) | PAGE_SIZE_1KB);
181 ++i;
182 icplb_add(extern_memory, SDRAM_IKERNEL);
183 dcplb_add(extern_memory, SDRAM_DKERNEL);
184 extern_memory += CPLB_PAGE_SIZE;
185 ++i;
186#endif
187
Bob Liu7677d652011-10-25 18:07:58 +0800188 while (i < 16 && extern_memory <
189 (CONFIG_SYS_MONITOR_BASE & CPLB_EX_PAGE_MASK)) {
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500190 icplb_add(extern_memory, SDRAM_IGENERIC);
191 dcplb_add(extern_memory, SDRAM_DGENERIC);
Bob Liu7677d652011-10-25 18:07:58 +0800192 extern_memory += CPLB_EX_PAGE_SIZE;
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500193 ++i;
194 }
195 while (i < 16) {
196 icplb_add(0, 0);
197 dcplb_add(0, 0);
198 ++i;
199 }
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800200}
201
Mike Frysingera4932d72012-02-29 22:48:10 -0500202static int global_board_data_init(void)
203{
204#ifndef CONFIG_SYS_GBL_DATA_ADDR
205# define CONFIG_SYS_GBL_DATA_ADDR 0
206#endif
207#ifndef CONFIG_SYS_BD_INFO_ADDR
208# define CONFIG_SYS_BD_INFO_ADDR 0
209#endif
210
211 bd_t *bd;
212
213 if (CONFIG_SYS_GBL_DATA_ADDR) {
214 gd = (gd_t *) (CONFIG_SYS_GBL_DATA_ADDR);
215 memset((void *)gd, 0, GENERATED_GBL_DATA_SIZE);
216 } else {
217 static gd_t _bfin_gd;
218 gd = &_bfin_gd;
219 }
220
221 if (CONFIG_SYS_BD_INFO_ADDR) {
222 bd = (bd_t *) (CONFIG_SYS_BD_INFO_ADDR);
223 memset(bd, 0, GENERATED_BD_INFO_SIZE);
224 } else {
225 static bd_t _bfin_bd;
226 bd = &_bfin_bd;
227 }
228 gd->bd = bd;
229
230 bd->bi_r_version = version_string;
Marek Vasut5368c552012-09-23 17:41:24 +0200231 bd->bi_cpu = __stringify(CONFIG_BFIN_CPU);
Mike Frysingera4932d72012-02-29 22:48:10 -0500232 bd->bi_board_name = BFIN_BOARD_NAME;
233 bd->bi_vco = get_vco();
234 bd->bi_cclk = get_cclk();
235 bd->bi_sclk = get_sclk();
236 bd->bi_memstart = CONFIG_SYS_SDRAM_BASE;
237 bd->bi_memsize = CONFIG_SYS_MAX_RAM_SIZE;
Bob Liuddb5c5b2012-08-13 14:22:08 +0800238 bd->bi_baudrate = (gd->baudrate > 0)
239 ? simple_strtoul(gd->baudrate, NULL, 10) : CONFIG_BAUDRATE;
Mike Frysingera4932d72012-02-29 22:48:10 -0500240
241 return 0;
242}
243
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100244/*
245 * All attempts to come up with a "common" initialization sequence
246 * that works for all boards and architectures failed: some of the
247 * requirements are just _too_ different. To get rid of the resulting
248 * mess of board dependend #ifdef'ed code we now make the whole
249 * initialization sequence configurable to the user.
250 *
251 * The requirements for any new initalization function is simple: it
252 * receives a pointer to the "global data" structure as it's only
253 * argument, and returns an integer return code, where 0 means
254 * "continue" and != 0 means "fatal error, hang the system".
255 */
256
Mike Frysinger0c080aa2010-02-11 20:19:10 -0500257extern int watchdog_init(void);
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500258extern int exception_init(void);
259extern int irq_init(void);
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500260extern int timer_init(void);
261
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100262void board_init_f(ulong bootflag)
263{
Mike Frysinger6dadc912008-10-20 16:15:04 -0400264 char buf[32];
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800265
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500266#ifdef CONFIG_BOARD_EARLY_INIT_F
267 serial_early_puts("Board early init flash\n");
268 board_early_init_f();
269#endif
270
271 serial_early_puts("Init CPLB tables\n");
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800272 init_cplbtables();
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100273
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500274 serial_early_puts("Exceptions setup\n");
275 exception_init();
276
277#ifndef CONFIG_ICACHE_OFF
278 serial_early_puts("Turn on ICACHE\n");
279 icache_enable();
280#endif
281#ifndef CONFIG_DCACHE_OFF
282 serial_early_puts("Turn on DCACHE\n");
283 dcache_enable();
284#endif
285
Sonic Zhange9a389a2013-04-07 18:02:37 +0800286#ifdef CONFIG_HW_WATCHDOG
Mike Frysinger0c080aa2010-02-11 20:19:10 -0500287 serial_early_puts("Setting up external watchdog\n");
Sonic Zhange9a389a2013-04-07 18:02:37 +0800288 hw_watchdog_init();
Mike Frysinger0c080aa2010-02-11 20:19:10 -0500289#endif
290
Mike Frysinger78a0ba72008-10-06 03:57:39 -0400291#ifdef DEBUG
Wolfgang Denk25ddd1f2010-10-26 14:34:52 +0200292 if (GENERATED_GBL_DATA_SIZE < sizeof(*gd))
Mike Frysinger78a0ba72008-10-06 03:57:39 -0400293 hang();
294#endif
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500295 serial_early_puts("Init global data\n");
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100296
Mike Frysingera4932d72012-02-29 22:48:10 -0500297 global_board_data_init();
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800298
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500299 /* Initialize */
300 serial_early_puts("IRQ init\n");
301 irq_init();
302 serial_early_puts("Environment init\n");
303 env_init();
304 serial_early_puts("Baudrate init\n");
305 init_baudrate();
306 serial_early_puts("Serial init\n");
307 serial_init();
Mike Frysinger635f3302011-04-29 23:23:28 -0400308 serial_initialize();
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500309 serial_early_puts("Console init flash\n");
310 console_init_f();
311 serial_early_puts("End of early debugging\n");
312 display_banner();
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800313
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100314 checkboard();
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100315 timer_init();
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500316
Mike Frysinger6dadc912008-10-20 16:15:04 -0400317 printf("Clock: VCO: %s MHz, ", strmhz(buf, get_vco()));
318 printf("Core: %s MHz, ", strmhz(buf, get_cclk()));
Sonic Zhanga2979dc2012-08-16 11:56:14 +0800319#if defined(__ADSPBF60x__)
320 printf("System0: %s MHz, ", strmhz(buf, get_sclk0()));
321 printf("System1: %s MHz, ", strmhz(buf, get_sclk1()));
322 printf("Dclk: %s MHz\n", strmhz(buf, get_dclk()));
323#else
Mike Frysinger6dadc912008-10-20 16:15:04 -0400324 printf("System: %s MHz\n", strmhz(buf, get_sclk()));
Sonic Zhanga2979dc2012-08-16 11:56:14 +0800325#endif
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500326
Mike Frysinger7d69dfd2010-12-20 05:18:55 -0500327 if (CONFIG_MEM_SIZE) {
328 printf("RAM: ");
Mike Frysingera4932d72012-02-29 22:48:10 -0500329 print_size(gd->bd->bi_memsize, "\n");
Mike Frysinger7d69dfd2010-12-20 05:18:55 -0500330 }
331
Mike Frysinger9171fc82008-03-30 15:46:13 -0400332#if defined(CONFIG_POST)
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800333 post_init_f();
334 post_bootmode_init();
335 post_run(NULL, POST_ROM | post_bootmode_get(0));
336#endif
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500337
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100338 board_init_r((gd_t *) gd, 0x20000010);
339}
340
Mike Frysinger8996d162009-02-22 16:02:27 -0500341static void board_net_init_r(bd_t *bd)
342{
Luigi 'Comio' Mantellini310cecb2009-10-10 12:42:21 +0200343#ifdef CONFIG_BITBANGMII
344 bb_miiphy_init();
345#endif
Mike Frysinger8996d162009-02-22 16:02:27 -0500346#ifdef CONFIG_CMD_NET
Mike Frysinger8996d162009-02-22 16:02:27 -0500347 printf("Net: ");
Mike Frysingerde301222012-04-04 18:53:41 +0000348 eth_initialize(bd);
Mike Frysinger8996d162009-02-22 16:02:27 -0500349#endif
350}
351
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100352void board_init_r(gd_t * id, ulong dest_addr)
353{
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100354 bd_t *bd;
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100355 gd = id;
356 gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */
357 bd = gd->bd;
358
Mike Frysinger9171fc82008-03-30 15:46:13 -0400359#if defined(CONFIG_POST)
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800360 post_output_backlog();
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800361#endif
362
Stefan Roesec790b042009-05-11 15:50:12 +0200363 /* initialize malloc() area */
Peter Tysera483a162009-08-21 23:05:20 -0500364 mem_malloc_init(CONFIG_SYS_MALLOC_BASE, CONFIG_SYS_MALLOC_LEN);
Stefan Roesec790b042009-05-11 15:50:12 +0200365
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200366#if !defined(CONFIG_SYS_NO_FLASH)
Mike Frysingerb6edc712008-10-06 04:00:07 -0400367 /* Initialize the flash and protect u-boot by default */
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500368 extern flash_info_t flash_info[];
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500369 puts("Flash: ");
Mike Frysinger45c48952008-10-06 04:01:26 -0400370 ulong size = flash_init();
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500371 print_size(size, "\n");
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200372 flash_protect(FLAG_PROTECT_SET, CONFIG_SYS_FLASH_BASE,
Mike Frysingerb6edc712008-10-06 04:00:07 -0400373 CONFIG_SYS_FLASH_BASE + CONFIG_SYS_MONITOR_LEN - 1,
374 &flash_info[0]);
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200375 bd->bi_flashstart = CONFIG_SYS_FLASH_BASE;
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100376 bd->bi_flashsize = size;
377 bd->bi_flashoffset = 0;
378#else
379 bd->bi_flashstart = 0;
380 bd->bi_flashsize = 0;
381 bd->bi_flashoffset = 0;
382#endif
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100383
Mike Frysinger39782722008-10-06 03:55:25 -0400384#ifdef CONFIG_CMD_NAND
385 puts("NAND: ");
386 nand_init(); /* go init the NAND */
387#endif
388
Cliff Caie54c8202009-11-20 08:24:43 +0000389#ifdef CONFIG_GENERIC_MMC
Mike Frysingerd3c07a52010-09-29 14:46:42 -0400390 puts("MMC: ");
Cliff Caie54c8202009-11-20 08:24:43 +0000391 mmc_initialize(bd);
392#endif
393
Heiko Schocher3f4978c2012-01-16 21:12:24 +0000394#if defined(CONFIG_SYS_I2C)
395 i2c_reloc_fixup();
396#endif
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100397 /* relocate environment function pointers etc. */
398 env_relocate();
399
Jean-Christophe PLAGNIOL-VILLARD52cb4d42009-05-16 12:14:54 +0200400 /* Initialize stdio devices */
401 stdio_init();
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100402 jumptable_init();
403
404 /* Initialize the console (after the relocation and devices init) */
405 console_init_r();
406
Robin Getzf19fd872009-12-21 16:35:48 -0500407#ifdef CONFIG_CMD_KGDB
408 puts("KGDB: ");
409 kgdb_init();
410#endif
411
Mike Frysinger01815c22008-10-06 03:52:24 -0400412#ifdef CONFIG_STATUS_LED
413 status_led_set(STATUS_LED_BOOT, STATUS_LED_BLINKING);
414 status_led_set(STATUS_LED_CRASH, STATUS_LED_OFF);
415#endif
416
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100417 /* Initialize from environment */
Simon Glassc1f485a2011-10-13 14:43:08 +0000418 load_addr = getenv_ulong("loadaddr", 16, load_addr);
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800419
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100420#if defined(CONFIG_MISC_INIT_R)
421 /* miscellaneous platform dependent initialisations */
422 misc_init_r();
423#endif
424
Mike Frysinger8996d162009-02-22 16:02:27 -0500425 board_net_init_r(bd);
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800426
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800427 display_global_data();
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800428
Mike Frysinger9171fc82008-03-30 15:46:13 -0400429#if defined(CONFIG_POST)
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800430 if (post_flag)
431 post_run(NULL, POST_RAM | post_bootmode_get(0));
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100432#endif
433
Mike Frysinger05e78252010-12-24 13:19:25 -0500434 if (CONFIG_MEM_SIZE && bfin_os_log_check()) {
Mike Frysinger909878f2009-07-09 01:15:05 -0400435 puts("\nLog buffer from operating system:\n");
436 bfin_os_log_dump();
437 puts("\n");
438 }
439
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100440 /* main_loop() can return to retry autoboot, if so just run it again. */
Mike Frysingerd5bffeb2008-02-19 00:54:20 -0500441 for (;;)
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100442 main_loop();
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100443}