blob: 416aa9e5f6e8faccf5c743638e1a982433a7cd7b [file] [log] [blame]
wdenk2262cfe2002-11-18 00:14:45 +00001/*
Graeme Russdbf71152011-04-13 19:43:26 +10002 * (C) Copyright 2008-2011
3 * Graeme Russ, <graeme.russ@gmail.com>
wdenk8bde7f72003-06-27 21:31:46 +00004 *
wdenk2262cfe2002-11-18 00:14:45 +00005 * (C) Copyright 2002
Albert ARIBAUDfa82f872011-08-04 18:45:45 +02006 * Daniel Engström, Omicron Ceti AB, <daniel@omicron.se>
Graeme Russdbf71152011-04-13 19:43:26 +10007 *
8 * (C) Copyright 2002
9 * Wolfgang Denk, DENX Software Engineering, <wd@denx.de>
wdenk8bde7f72003-06-27 21:31:46 +000010 *
wdenk2262cfe2002-11-18 00:14:45 +000011 * (C) Copyright 2002
12 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
13 * Marius Groeger <mgroeger@sysgo.de>
14 *
15 * See file CREDITS for list of people who contributed to this
16 * project.
17 *
18 * This program is free software; you can redistribute it and/or
19 * modify it under the terms of the GNU General Public License as
20 * published by the Free Software Foundation; either version 2 of
21 * the License, or (at your option) any later version.
22 *
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
27 *
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
31 * MA 02111-1307 USA
32 */
33
34#include <common.h>
35#include <watchdog.h>
36#include <command.h>
Jean-Christophe PLAGNIOL-VILLARD52cb4d42009-05-16 12:14:54 +020037#include <stdio_dev.h>
wdenk2262cfe2002-11-18 00:14:45 +000038#include <version.h>
39#include <malloc.h>
wdenk2262cfe2002-11-18 00:14:45 +000040#include <net.h>
41#include <ide.h>
Graeme Russbf165002010-04-24 00:05:47 +100042#include <serial.h>
Graeme Russfea25722011-04-13 19:43:28 +100043#include <asm/u-boot-x86.h>
Graeme Russ1c409bc2009-11-24 20:04:21 +110044#include <elf.h>
Graeme Russ9e6c5722011-12-31 22:58:15 +110045#include <asm/processor.h>
wdenk2262cfe2002-11-18 00:14:45 +000046
Luigi 'Comio' Mantellini310cecb2009-10-10 12:42:21 +020047#ifdef CONFIG_BITBANGMII
48#include <miiphy.h>
49#endif
50
wdenk2262cfe2002-11-18 00:14:45 +000051/************************************************************************
52 * Init Utilities *
53 ************************************************************************
54 * Some of this code should be moved into the core functions,
55 * or dropped completely,
56 * but let's get it working (again) first...
57 */
Graeme Russ83088af2011-11-08 02:33:15 +000058static int init_baudrate(void)
wdenk2262cfe2002-11-18 00:14:45 +000059{
Simon Glassf5ca20c2011-10-13 14:43:14 +000060 gd->baudrate = getenv_ulong("baudrate", 10, CONFIG_BAUDRATE);
61 return 0;
wdenk2262cfe2002-11-18 00:14:45 +000062}
63
Graeme Russ83088af2011-11-08 02:33:15 +000064static int display_banner(void)
wdenk2262cfe2002-11-18 00:14:45 +000065{
66
Graeme Russ83088af2011-11-08 02:33:15 +000067 printf("\n\n%s\n\n", version_string);
wdenk8bde7f72003-06-27 21:31:46 +000068
Graeme Russ83088af2011-11-08 02:33:15 +000069 return 0;
wdenk2262cfe2002-11-18 00:14:45 +000070}
71
Graeme Russ83088af2011-11-08 02:33:15 +000072static int display_dram_config(void)
wdenk2262cfe2002-11-18 00:14:45 +000073{
wdenk2262cfe2002-11-18 00:14:45 +000074 int i;
75
Graeme Russ83088af2011-11-08 02:33:15 +000076 puts("DRAM Configuration:\n");
wdenk2262cfe2002-11-18 00:14:45 +000077
Graeme Russ83088af2011-11-08 02:33:15 +000078 for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
79 printf("Bank #%d: %08lx ", i, gd->bd->bi_dram[i].start);
80 print_size(gd->bd->bi_dram[i].size, "\n");
wdenk2262cfe2002-11-18 00:14:45 +000081 }
wdenk8bde7f72003-06-27 21:31:46 +000082
Graeme Russ83088af2011-11-08 02:33:15 +000083 return 0;
wdenk2262cfe2002-11-18 00:14:45 +000084}
85
Graeme Russa76fc702011-11-08 02:33:20 +000086#ifndef CONFIG_SYS_NO_FLASH
Graeme Russ83088af2011-11-08 02:33:15 +000087static void display_flash_config(ulong size)
wdenk2262cfe2002-11-18 00:14:45 +000088{
Graeme Russ83088af2011-11-08 02:33:15 +000089 puts("Flash: ");
90 print_size(size, "\n");
wdenk2262cfe2002-11-18 00:14:45 +000091}
Graeme Russa76fc702011-11-08 02:33:20 +000092#endif
wdenk2262cfe2002-11-18 00:14:45 +000093
wdenk2262cfe2002-11-18 00:14:45 +000094/*
95 * Breath some life into the board...
96 *
97 * Initialize an SMC for serial comms, and carry out some hardware
98 * tests.
99 *
100 * The first part of initialization is running from Flash memory;
101 * its main purpose is to initialize the RAM so that we
102 * can relocate the monitor code to RAM.
103 */
104
105/*
106 * All attempts to come up with a "common" initialization sequence
107 * that works for all boards and architectures failed: some of the
108 * requirements are just _too_ different. To get rid of the resulting
109 * mess of board dependend #ifdef'ed code we now make the whole
110 * initialization sequence configurable to the user.
111 *
112 * The requirements for any new initalization function is simple: it
113 * receives a pointer to the "global data" structure as it's only
114 * argument, and returns an integer return code, where 0 means
115 * "continue" and != 0 means "fatal error, hang the system".
116 */
117typedef int (init_fnc_t) (void);
118
Graeme Russe4f78d72011-02-12 15:12:10 +1100119static int calculate_relocation_address(void);
120static int copy_uboot_to_ram(void);
121static int clear_bss(void);
122static int do_elf_reloc_fixups(void);
Graeme Russ9e6c5722011-12-31 22:58:15 +1100123static int copy_gd_to_ram(void);
Graeme Russe4f78d72011-02-12 15:12:10 +1100124
125init_fnc_t *init_sequence_f[] = {
126 cpu_init_f,
127 board_early_init_f,
128 env_init,
129 init_baudrate,
130 serial_init,
131 console_init_f,
132 dram_init_f,
133 calculate_relocation_address,
Graeme Russe4f78d72011-02-12 15:12:10 +1100134
135 NULL,
136};
137
138init_fnc_t *init_sequence_r[] = {
Graeme Russ1c409bc2009-11-24 20:04:21 +1100139 cpu_init_r, /* basic cpu dependent setup */
140 board_early_init_r, /* basic board dependent setup */
wdenk2262cfe2002-11-18 00:14:45 +0000141 dram_init, /* configure available RAM banks */
wdenk2262cfe2002-11-18 00:14:45 +0000142 interrupt_init, /* set up exceptions */
wdenk8bde7f72003-06-27 21:31:46 +0000143 timer_init,
wdenk2262cfe2002-11-18 00:14:45 +0000144 display_banner,
145 display_dram_config,
146
147 NULL,
148};
149
Graeme Russ71a54042011-02-12 15:12:06 +1100150static int calculate_relocation_address(void)
151{
Graeme Russ303418c2011-11-08 02:33:21 +0000152 ulong text_start = (ulong)&__text_start;
153 ulong bss_end = (ulong)&__bss_end;
154 ulong dest_addr;
Graeme Russ303418c2011-11-08 02:33:21 +0000155
156 /*
Graeme Russ240ab5a2012-01-01 15:57:02 +1100157 * NOTE: All destination address are rounded down to 16-byte
158 * boundary to satisfy various worst-case alignment
159 * requirements
Graeme Russ303418c2011-11-08 02:33:21 +0000160 */
Graeme Russ240ab5a2012-01-01 15:57:02 +1100161
Graeme Russ9e6c5722011-12-31 22:58:15 +1100162 /* Global Data is at top of available memory */
Graeme Russ240ab5a2012-01-01 15:57:02 +1100163 dest_addr = gd->ram_size;
Graeme Russ9e6c5722011-12-31 22:58:15 +1100164 dest_addr -= GENERATED_GBL_DATA_SIZE;
165 dest_addr &= ~15;
166 gd->new_gd_addr = dest_addr;
167
168 /* GDT is below Global Data */
169 dest_addr -= X86_GDT_SIZE;
170 dest_addr &= ~15;
171 gd->gdt_addr = dest_addr;
172
173 /* Stack is below GDT */
Graeme Russ240ab5a2012-01-01 15:57:02 +1100174 gd->start_addr_sp = dest_addr;
175
176 /* U-Boot is below the stack */
177 dest_addr -= CONFIG_SYS_STACK_SIZE;
178 dest_addr -= (bss_end - text_start);
Graeme Russ303418c2011-11-08 02:33:21 +0000179 dest_addr &= ~15;
Graeme Russ303418c2011-11-08 02:33:21 +0000180 gd->relocaddr = dest_addr;
Graeme Russ240ab5a2012-01-01 15:57:02 +1100181 gd->reloc_off = (dest_addr - text_start);
Graeme Russ71a54042011-02-12 15:12:06 +1100182
183 return 0;
184}
185
186static int copy_uboot_to_ram(void)
187{
Graeme Russ1176a702011-12-27 22:46:41 +1100188 size_t len = (size_t)&__data_end - (size_t)&__text_start;
Graeme Russ71a54042011-02-12 15:12:06 +1100189
Graeme Russ1176a702011-12-27 22:46:41 +1100190 memcpy((void *)gd->relocaddr, (void *)&__text_start, len);
Graeme Russ71a54042011-02-12 15:12:06 +1100191
192 return 0;
193}
194
195static int clear_bss(void)
196{
Graeme Russ1176a702011-12-27 22:46:41 +1100197 ulong dst_addr = (ulong)&__bss_start + gd->reloc_off;
198 size_t len = (size_t)&__bss_end - (size_t)&__bss_start;
Graeme Russ71a54042011-02-12 15:12:06 +1100199
Graeme Russ1176a702011-12-27 22:46:41 +1100200 memset((void *)dst_addr, 0x00, len);
Graeme Russ71a54042011-02-12 15:12:06 +1100201
202 return 0;
203}
204
205static int do_elf_reloc_fixups(void)
206{
207 Elf32_Rel *re_src = (Elf32_Rel *)(&__rel_dyn_start);
208 Elf32_Rel *re_end = (Elf32_Rel *)(&__rel_dyn_end);
209
Graeme Russ83088af2011-11-08 02:33:15 +0000210 Elf32_Addr *offset_ptr_rom;
211 Elf32_Addr *offset_ptr_ram;
212
Gabe Black60a9b6b2011-11-16 23:32:50 +0000213 /* The size of the region of u-boot that runs out of RAM. */
214 uintptr_t size = (uintptr_t)&__bss_end - (uintptr_t)&__text_start;
215
Graeme Russ71a54042011-02-12 15:12:06 +1100216 do {
Graeme Russ83088af2011-11-08 02:33:15 +0000217 /* Get the location from the relocation entry */
218 offset_ptr_rom = (Elf32_Addr *)re_src->r_offset;
219
220 /* Check that the location of the relocation is in .text */
221 if (offset_ptr_rom >= (Elf32_Addr *)CONFIG_SYS_TEXT_BASE) {
222
223 /* Switch to the in-RAM version */
Gabe Black60a9b6b2011-11-16 23:32:50 +0000224 offset_ptr_ram = (Elf32_Addr *)((ulong)offset_ptr_rom +
225 gd->reloc_off);
Graeme Russ83088af2011-11-08 02:33:15 +0000226
227 /* Check that the target points into .text */
Gabe Black769db032011-11-12 16:34:48 +0000228 if (*offset_ptr_ram >= CONFIG_SYS_TEXT_BASE &&
229 *offset_ptr_ram <
230 (CONFIG_SYS_TEXT_BASE + size)) {
Graeme Russ83088af2011-11-08 02:33:15 +0000231 *offset_ptr_ram += gd->reloc_off;
Gabe Black769db032011-11-12 16:34:48 +0000232 }
Graeme Russ83088af2011-11-08 02:33:15 +0000233 }
Graeme Russ71a54042011-02-12 15:12:06 +1100234 } while (re_src++ < re_end);
235
236 return 0;
237}
238
Graeme Russdbf71152011-04-13 19:43:26 +1000239/* Load U-Boot into RAM, initialize BSS, perform relocation adjustments */
Graeme Russ96cd6642011-02-12 15:11:54 +1100240void board_init_f(ulong boot_flags)
Graeme Russ1c409bc2009-11-24 20:04:21 +1100241{
Graeme Russe4f78d72011-02-12 15:12:10 +1100242 init_fnc_t **init_fnc_ptr;
Graeme Russa3824142011-02-12 15:12:08 +1100243
Graeme Russdbf71152011-04-13 19:43:26 +1000244 gd->flags = boot_flags;
245
Graeme Russe4f78d72011-02-12 15:12:10 +1100246 for (init_fnc_ptr = init_sequence_f; *init_fnc_ptr; ++init_fnc_ptr) {
247 if ((*init_fnc_ptr)() != 0)
248 hang();
249 }
Graeme Russf2ff75c2010-10-07 20:03:33 +1100250
Graeme Russf48dd6f2012-01-01 15:06:39 +1100251 /*
252 * SDRAM is now initialised, U-Boot has been copied into SDRAM,
253 * the BSS has been cleared etc. The final stack can now be setup
254 * in SDRAM. Code execution will continue (momentarily) in Flash,
255 * but with the stack in SDRAM and Global Data in temporary memory
256 * (CPU cache)
257 */
258 board_init_f_r_trampoline(gd->start_addr_sp);
Graeme Russ161b3582010-10-07 20:03:29 +1100259
Graeme Russf48dd6f2012-01-01 15:06:39 +1100260 /* NOTREACHED - board_init_f_r_trampoline() does not return */
261 while (1)
262 ;
263}
264
265void board_init_f_r(void)
266{
Graeme Russ98f1fa92011-12-27 22:46:42 +1100267 if (copy_gd_to_ram() != 0)
268 hang();
269
270 if (init_cache() != 0)
271 hang();
272
273 copy_uboot_to_ram();
274 clear_bss();
275 do_elf_reloc_fixups();
276
Graeme Russf48dd6f2012-01-01 15:06:39 +1100277 /*
278 * Transfer execution from Flash to RAM by calculating the address
279 * of the in-RAM copy of board_init_r() and calling it
280 */
281 (board_init_r + gd->reloc_off)(gd, gd->relocaddr);
282
283 /* NOTREACHED - board_init_r() does not return */
Graeme Russ83088af2011-11-08 02:33:15 +0000284 while (1)
285 ;
Graeme Russ1c409bc2009-11-24 20:04:21 +1100286}
287
Graeme Russ9e6c5722011-12-31 22:58:15 +1100288static int copy_gd_to_ram(void)
289{
290 gd_t *ram_gd;
291
292 /*
293 * Global data is still in temporary memory (the CPU cache).
294 * calculate_relocation_address() has set gd->new_gd_addr to
295 * where the global data lives in RAM but getting it there
296 * safely is a bit tricky due to the 'F-Segment Hack' that
297 * we need to use for x86
298 */
299 ram_gd = (gd_t *)gd->new_gd_addr;
300 memcpy((void *)ram_gd, gd, sizeof(gd_t));
301
302 /*
303 * Reload the Global Descriptor Table so FS points to the
304 * in-RAM copy of Global Data (calculate_relocation_address()
305 * has already calculated the in-RAM location of the GDT)
306 */
307 ram_gd->gd_addr = (ulong)ram_gd;
308 init_gd(ram_gd, (u64 *)gd->gdt_addr);
309
310 return 0;
311}
312
Graeme Russ2fb1bc42010-04-24 00:05:44 +1000313void board_init_r(gd_t *id, ulong dest_addr)
wdenk2262cfe2002-11-18 00:14:45 +0000314{
Graeme Russa76fc702011-11-08 02:33:20 +0000315#if defined(CONFIG_CMD_NET)
wdenk2262cfe2002-11-18 00:14:45 +0000316 char *s;
Graeme Russa76fc702011-11-08 02:33:20 +0000317#endif
318#ifndef CONFIG_SYS_NO_FLASH
wdenk2262cfe2002-11-18 00:14:45 +0000319 ulong size;
Graeme Russa76fc702011-11-08 02:33:20 +0000320#endif
wdenk2262cfe2002-11-18 00:14:45 +0000321 static bd_t bd_data;
322 init_fnc_t **init_fnc_ptr;
wdenk8bde7f72003-06-27 21:31:46 +0000323
wdenk2262cfe2002-11-18 00:14:45 +0000324 show_boot_progress(0x21);
325
wdenk93f6a672004-07-01 20:28:03 +0000326 /* compiler optimization barrier needed for GCC >= 3.4 */
Graeme Russ83088af2011-11-08 02:33:15 +0000327 __asm__ __volatile__("" : : : "memory");
wdenk8bde7f72003-06-27 21:31:46 +0000328
Graeme Russ3766bb32012-01-01 15:49:43 +1100329 gd->flags |= GD_FLG_RELOC;
330
wdenk2262cfe2002-11-18 00:14:45 +0000331 gd->bd = &bd_data;
Graeme Russ83088af2011-11-08 02:33:15 +0000332 memset(gd->bd, 0, sizeof(bd_t));
wdenk2262cfe2002-11-18 00:14:45 +0000333 show_boot_progress(0x22);
334
wdenk7a8e9bed2003-05-31 18:35:21 +0000335 gd->baudrate = CONFIG_BAUDRATE;
wdenk8bde7f72003-06-27 21:31:46 +0000336
Graeme Russ2fb1bc42010-04-24 00:05:44 +1000337 mem_malloc_init((((ulong)dest_addr - CONFIG_SYS_MALLOC_LEN)+3)&~3,
Graeme Russ1c409bc2009-11-24 20:04:21 +1100338 CONFIG_SYS_MALLOC_LEN);
339
Graeme Russe4f78d72011-02-12 15:12:10 +1100340 for (init_fnc_ptr = init_sequence_r; *init_fnc_ptr; ++init_fnc_ptr) {
341 if ((*init_fnc_ptr)() != 0)
Graeme Russ83088af2011-11-08 02:33:15 +0000342 hang();
wdenk2262cfe2002-11-18 00:14:45 +0000343 }
344 show_boot_progress(0x23);
345
Graeme Russbf165002010-04-24 00:05:47 +1000346#ifdef CONFIG_SERIAL_MULTI
347 serial_initialize();
348#endif
Graeme Russa76fc702011-11-08 02:33:20 +0000349
350#ifndef CONFIG_SYS_NO_FLASH
wdenk2262cfe2002-11-18 00:14:45 +0000351 /* configure available FLASH banks */
352 size = flash_init();
353 display_flash_config(size);
354 show_boot_progress(0x24);
Graeme Russa76fc702011-11-08 02:33:20 +0000355#endif
wdenk2262cfe2002-11-18 00:14:45 +0000356
357 show_boot_progress(0x25);
358
359 /* initialize environment */
Graeme Russ83088af2011-11-08 02:33:15 +0000360 env_relocate();
wdenk2262cfe2002-11-18 00:14:45 +0000361 show_boot_progress(0x26);
362
363
Graeme Russ535ad2d2010-04-24 00:05:36 +1000364#ifdef CONFIG_CMD_NET
wdenk2262cfe2002-11-18 00:14:45 +0000365 /* IP Address */
Graeme Russ83088af2011-11-08 02:33:15 +0000366 bd_data.bi_ip_addr = getenv_IPaddr("ipaddr");
Graeme Russ535ad2d2010-04-24 00:05:36 +1000367#endif
wdenk2262cfe2002-11-18 00:14:45 +0000368
wdenk2262cfe2002-11-18 00:14:45 +0000369#if defined(CONFIG_PCI)
370 /*
371 * Do pci configuration
372 */
373 pci_init();
374#endif
375
376 show_boot_progress(0x27);
377
378
Graeme Russ83088af2011-11-08 02:33:15 +0000379 stdio_init();
wdenk2262cfe2002-11-18 00:14:45 +0000380
Graeme Russ83088af2011-11-08 02:33:15 +0000381 jumptable_init();
wdenk8bde7f72003-06-27 21:31:46 +0000382
wdenk2262cfe2002-11-18 00:14:45 +0000383 /* Initialize the console (after the relocation and devices init) */
384 console_init_r();
wdenk2262cfe2002-11-18 00:14:45 +0000385
386#ifdef CONFIG_MISC_INIT_R
387 /* miscellaneous platform dependent initialisations */
388 misc_init_r();
389#endif
390
Jon Loeliger67350562007-07-09 18:05:38 -0500391#if defined(CONFIG_CMD_PCMCIA) && !defined(CONFIG_CMD_IDE)
wdenk2262cfe2002-11-18 00:14:45 +0000392 WATCHDOG_RESET();
Graeme Russ83088af2011-11-08 02:33:15 +0000393 puts("PCMCIA:");
wdenk2262cfe2002-11-18 00:14:45 +0000394 pcmcia_init();
395#endif
396
Jon Loeliger67350562007-07-09 18:05:38 -0500397#if defined(CONFIG_CMD_KGDB)
wdenk2262cfe2002-11-18 00:14:45 +0000398 WATCHDOG_RESET();
399 puts("KGDB: ");
400 kgdb_init();
401#endif
402
403 /* enable exceptions */
wdenk7a8e9bed2003-05-31 18:35:21 +0000404 enable_interrupts();
wdenk2262cfe2002-11-18 00:14:45 +0000405 show_boot_progress(0x28);
406
wdenk2262cfe2002-11-18 00:14:45 +0000407#ifdef CONFIG_STATUS_LED
Graeme Russ83088af2011-11-08 02:33:15 +0000408 status_led_set(STATUS_LED_BOOT, STATUS_LED_BLINKING);
wdenk2262cfe2002-11-18 00:14:45 +0000409#endif
410
wdenk7a8e9bed2003-05-31 18:35:21 +0000411 udelay(20);
wdenk2262cfe2002-11-18 00:14:45 +0000412
wdenk2262cfe2002-11-18 00:14:45 +0000413 /* Initialize from environment */
Simon Glassf5ca20c2011-10-13 14:43:14 +0000414 load_addr = getenv_ulong("loadaddr", 16, load_addr);
Jon Loeliger67350562007-07-09 18:05:38 -0500415#if defined(CONFIG_CMD_NET)
Graeme Russ83088af2011-11-08 02:33:15 +0000416 s = getenv("bootfile");
417
418 if (s != NULL)
419 copy_filename(BootFile, s, sizeof(BootFile));
Jon Loeligerb3aff0c2007-07-10 11:19:50 -0500420#endif
wdenk2262cfe2002-11-18 00:14:45 +0000421
422 WATCHDOG_RESET();
423
Jon Loeliger67350562007-07-09 18:05:38 -0500424#if defined(CONFIG_CMD_IDE)
wdenk2262cfe2002-11-18 00:14:45 +0000425 WATCHDOG_RESET();
426 puts("IDE: ");
427 ide_init();
Jon Loeligerb3aff0c2007-07-10 11:19:50 -0500428#endif
wdenk2262cfe2002-11-18 00:14:45 +0000429
Jon Loeliger67350562007-07-09 18:05:38 -0500430#if defined(CONFIG_CMD_SCSI)
wdenk2262cfe2002-11-18 00:14:45 +0000431 WATCHDOG_RESET();
432 puts("SCSI: ");
433 scsi_init();
434#endif
435
Jon Loeliger67350562007-07-09 18:05:38 -0500436#if defined(CONFIG_CMD_DOC)
wdenk2262cfe2002-11-18 00:14:45 +0000437 WATCHDOG_RESET();
wdenk7a8e9bed2003-05-31 18:35:21 +0000438 puts("DOC: ");
wdenk2262cfe2002-11-18 00:14:45 +0000439 doc_init();
440#endif
441
Luigi 'Comio' Mantellini310cecb2009-10-10 12:42:21 +0200442#ifdef CONFIG_BITBANGMII
443 bb_miiphy_init();
444#endif
Jon Loeliger67350562007-07-09 18:05:38 -0500445#if defined(CONFIG_CMD_NET)
wdenk2262cfe2002-11-18 00:14:45 +0000446 WATCHDOG_RESET();
447 puts("Net: ");
448 eth_initialize(gd->bd);
449#endif
450
Graeme Russ83088af2011-11-08 02:33:15 +0000451#if (defined(CONFIG_CMD_NET)) && (0)
Marian Balakowicz63ff0042005-10-28 22:30:33 +0200452 WATCHDOG_RESET();
453# ifdef DEBUG
Graeme Russ83088af2011-11-08 02:33:15 +0000454 puts("Reset Ethernet PHY\n");
Marian Balakowicz63ff0042005-10-28 22:30:33 +0200455# endif
456 reset_phy();
457#endif
458
wdenk2262cfe2002-11-18 00:14:45 +0000459#ifdef CONFIG_LAST_STAGE_INIT
460 WATCHDOG_RESET();
461 /*
462 * Some parts can be only initialized if all others (like
463 * Interrupts) are up and running (i.e. the PC-style ISA
464 * keyboard).
465 */
466 last_stage_init();
467#endif
468
469
wdenk2262cfe2002-11-18 00:14:45 +0000470#ifdef CONFIG_POST
Graeme Russ83088af2011-11-08 02:33:15 +0000471 post_run(NULL, POST_RAM | post_bootmode_get(0));
wdenk2262cfe2002-11-18 00:14:45 +0000472#endif
wdenk8bde7f72003-06-27 21:31:46 +0000473
wdenk2262cfe2002-11-18 00:14:45 +0000474 show_boot_progress(0x29);
wdenk8bde7f72003-06-27 21:31:46 +0000475
wdenk2262cfe2002-11-18 00:14:45 +0000476 /* main_loop() can return to retry autoboot, if so just run it again. */
Graeme Russ83088af2011-11-08 02:33:15 +0000477 for (;;)
wdenk7a8e9bed2003-05-31 18:35:21 +0000478 main_loop();
wdenk2262cfe2002-11-18 00:14:45 +0000479
480 /* NOTREACHED - no way out of command loop except booting */
481}
482
Graeme Russ83088af2011-11-08 02:33:15 +0000483void hang(void)
wdenk2262cfe2002-11-18 00:14:45 +0000484{
Graeme Russ83088af2011-11-08 02:33:15 +0000485 puts("### ERROR ### Please RESET the board ###\n");
486 for (;;)
487 ;
wdenk2262cfe2002-11-18 00:14:45 +0000488}