xref: /openbmc/u-boot/common/board_r.c (revision 00a457b2)
1 /*
2  * Copyright (c) 2011 The Chromium OS Authors.
3  * (C) Copyright 2002-2006
4  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5  *
6  * (C) Copyright 2002
7  * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
8  * Marius Groeger <mgroeger@sysgo.de>
9  *
10  * SPDX-License-Identifier:	GPL-2.0+
11  */
12 
13 #include <common.h>
14 /* TODO: can we just include all these headers whether needed or not? */
15 #if defined(CONFIG_CMD_BEDBUG)
16 #include <bedbug/type.h>
17 #endif
18 #include <command.h>
19 #include <console.h>
20 #ifdef CONFIG_HAS_DATAFLASH
21 #include <dataflash.h>
22 #endif
23 #include <dm.h>
24 #include <environment.h>
25 #include <fdtdec.h>
26 #if defined(CONFIG_CMD_IDE)
27 #include <ide.h>
28 #endif
29 #include <initcall.h>
30 #ifdef CONFIG_PS2KBD
31 #include <keyboard.h>
32 #endif
33 #if defined(CONFIG_CMD_KGDB)
34 #include <kgdb.h>
35 #endif
36 #include <logbuff.h>
37 #include <malloc.h>
38 #include <mapmem.h>
39 #ifdef CONFIG_BITBANGMII
40 #include <miiphy.h>
41 #endif
42 #include <mmc.h>
43 #include <nand.h>
44 #include <onenand_uboot.h>
45 #include <scsi.h>
46 #include <serial.h>
47 #include <spi.h>
48 #include <stdio_dev.h>
49 #include <trace.h>
50 #include <watchdog.h>
51 #ifdef CONFIG_CMD_AMBAPP
52 #include <ambapp.h>
53 #endif
54 #ifdef CONFIG_ADDR_MAP
55 #include <asm/mmu.h>
56 #endif
57 #include <asm/sections.h>
58 #ifdef CONFIG_X86
59 #include <asm/init_helpers.h>
60 #endif
61 #include <dm/root.h>
62 #include <linux/compiler.h>
63 #include <linux/err.h>
64 #ifdef CONFIG_AVR32
65 #include <asm/arch/mmu.h>
66 #endif
67 
68 DECLARE_GLOBAL_DATA_PTR;
69 
70 #if defined(CONFIG_SPARC)
71 extern int prom_init(void);
72 #endif
73 
74 ulong monitor_flash_len;
75 
76 __weak int board_flash_wp_on(void)
77 {
78 	/*
79 	 * Most flashes can't be detected when write protection is enabled,
80 	 * so provide a way to let U-Boot gracefully ignore write protected
81 	 * devices.
82 	 */
83 	return 0;
84 }
85 
86 __weak void cpu_secondary_init_r(void)
87 {
88 }
89 
90 static int initr_secondary_cpu(void)
91 {
92 	/*
93 	 * after non-volatile devices & environment is setup and cpu code have
94 	 * another round to deal with any initialization that might require
95 	 * full access to the environment or loading of some image (firmware)
96 	 * from a non-volatile device
97 	 */
98 	/* TODO: maybe define this for all archs? */
99 	cpu_secondary_init_r();
100 
101 	return 0;
102 }
103 
104 static int initr_trace(void)
105 {
106 #ifdef CONFIG_TRACE
107 	trace_init(gd->trace_buff, CONFIG_TRACE_BUFFER_SIZE);
108 #endif
109 
110 	return 0;
111 }
112 
113 static int initr_reloc(void)
114 {
115 	/* tell others: relocation done */
116 	gd->flags |= GD_FLG_RELOC | GD_FLG_FULL_MALLOC_INIT;
117 
118 	return 0;
119 }
120 
121 #ifdef CONFIG_ARM
122 /*
123  * Some of these functions are needed purely because the functions they
124  * call return void. If we change them to return 0, these stubs can go away.
125  */
126 static int initr_caches(void)
127 {
128 	/* Enable caches */
129 	enable_caches();
130 	return 0;
131 }
132 #endif
133 
134 __weak int fixup_cpu(void)
135 {
136 	return 0;
137 }
138 
139 static int initr_reloc_global_data(void)
140 {
141 #ifdef __ARM__
142 	monitor_flash_len = _end - __image_copy_start;
143 #elif defined(CONFIG_NDS32)
144 	monitor_flash_len = (ulong)&_end - (ulong)&_start;
145 #elif !defined(CONFIG_SANDBOX) && !defined(CONFIG_NIOS2)
146 	monitor_flash_len = (ulong)&__init_end - gd->relocaddr;
147 #endif
148 #if defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx)
149 	/*
150 	 * The gd->cpu pointer is set to an address in flash before relocation.
151 	 * We need to update it to point to the same CPU entry in RAM.
152 	 * TODO: why not just add gd->reloc_ofs?
153 	 */
154 	gd->arch.cpu += gd->relocaddr - CONFIG_SYS_MONITOR_BASE;
155 
156 	/*
157 	 * If we didn't know the cpu mask & # cores, we can save them of
158 	 * now rather than 'computing' them constantly
159 	 */
160 	fixup_cpu();
161 #endif
162 #ifdef CONFIG_SYS_EXTRA_ENV_RELOC
163 	/*
164 	 * Some systems need to relocate the env_addr pointer early because the
165 	 * location it points to will get invalidated before env_relocate is
166 	 * called.  One example is on systems that might use a L2 or L3 cache
167 	 * in SRAM mode and initialize that cache from SRAM mode back to being
168 	 * a cache in cpu_init_r.
169 	 */
170 	gd->env_addr += gd->relocaddr - CONFIG_SYS_MONITOR_BASE;
171 #endif
172 #ifdef CONFIG_OF_EMBED
173 	/*
174 	* The fdt_blob needs to be moved to new relocation address
175 	* incase of FDT blob is embedded with in image
176 	*/
177 	gd->fdt_blob += gd->reloc_off;
178 #endif
179 
180 	return 0;
181 }
182 
183 static int initr_serial(void)
184 {
185 	serial_initialize();
186 	return 0;
187 }
188 
189 #if defined(CONFIG_PPC) || defined(CONFIG_M68K)
190 static int initr_trap(void)
191 {
192 	/*
193 	 * Setup trap handlers
194 	 */
195 #if defined(CONFIG_PPC)
196 	trap_init(gd->relocaddr);
197 #else
198 	trap_init(CONFIG_SYS_SDRAM_BASE);
199 #endif
200 	return 0;
201 }
202 #endif
203 
204 #ifdef CONFIG_ADDR_MAP
205 static int initr_addr_map(void)
206 {
207 	init_addr_map();
208 
209 	return 0;
210 }
211 #endif
212 
213 #ifdef CONFIG_LOGBUFFER
214 unsigned long logbuffer_base(void)
215 {
216 	return gd->ram_top - LOGBUFF_LEN;
217 }
218 
219 static int initr_logbuffer(void)
220 {
221 	logbuff_init_ptrs();
222 	return 0;
223 }
224 #endif
225 
226 #ifdef CONFIG_POST
227 static int initr_post_backlog(void)
228 {
229 	post_output_backlog();
230 	return 0;
231 }
232 #endif
233 
234 #ifdef CONFIG_SYS_DELAYED_ICACHE
235 static int initr_icache_enable(void)
236 {
237 	return 0;
238 }
239 #endif
240 
241 #if defined(CONFIG_SYS_INIT_RAM_LOCK) && defined(CONFIG_E500)
242 static int initr_unlock_ram_in_cache(void)
243 {
244 	unlock_ram_in_cache();	/* it's time to unlock D-cache in e500 */
245 	return 0;
246 }
247 #endif
248 
249 #ifdef CONFIG_PCI
250 static int initr_pci(void)
251 {
252 #ifndef CONFIG_DM_PCI
253 	pci_init();
254 #endif
255 
256 	return 0;
257 }
258 #endif
259 
260 #ifdef CONFIG_WINBOND_83C553
261 static int initr_w83c553f(void)
262 {
263 	/*
264 	 * Initialise the ISA bridge
265 	 */
266 	initialise_w83c553f();
267 	return 0;
268 }
269 #endif
270 
271 static int initr_barrier(void)
272 {
273 #ifdef CONFIG_PPC
274 	/* TODO: Can we not use dmb() macros for this? */
275 	asm("sync ; isync");
276 #endif
277 	return 0;
278 }
279 
280 static int initr_malloc(void)
281 {
282 	ulong malloc_start;
283 
284 #ifdef CONFIG_SYS_MALLOC_F_LEN
285 	debug("Pre-reloc malloc() used %#lx bytes (%ld KB)\n", gd->malloc_ptr,
286 	      gd->malloc_ptr / 1024);
287 #endif
288 	/* The malloc area is immediately below the monitor copy in DRAM */
289 	malloc_start = gd->relocaddr - TOTAL_MALLOC_LEN;
290 	mem_malloc_init((ulong)map_sysmem(malloc_start, TOTAL_MALLOC_LEN),
291 			TOTAL_MALLOC_LEN);
292 	return 0;
293 }
294 
295 static int initr_console_record(void)
296 {
297 #if defined(CONFIG_CONSOLE_RECORD)
298 	return console_record_init();
299 #else
300 	return 0;
301 #endif
302 }
303 
304 #ifdef CONFIG_SYS_NONCACHED_MEMORY
305 static int initr_noncached(void)
306 {
307 	noncached_init();
308 	return 0;
309 }
310 #endif
311 
312 #ifdef CONFIG_DM
313 static int initr_dm(void)
314 {
315 	/* Save the pre-reloc driver model and start a new one */
316 	gd->dm_root_f = gd->dm_root;
317 	gd->dm_root = NULL;
318 #ifdef CONFIG_TIMER
319 	gd->timer = NULL;
320 #endif
321 	return dm_init_and_scan(false);
322 }
323 #endif
324 
325 static int initr_bootstage(void)
326 {
327 	/* We cannot do this before initr_dm() */
328 	bootstage_mark_name(BOOTSTAGE_ID_START_UBOOT_R, "board_init_r");
329 
330 	return 0;
331 }
332 
333 __weak int power_init_board(void)
334 {
335 	return 0;
336 }
337 
338 static int initr_announce(void)
339 {
340 	debug("Now running in RAM - U-Boot at: %08lx\n", gd->relocaddr);
341 	return 0;
342 }
343 
344 #ifdef CONFIG_NEEDS_MANUAL_RELOC
345 static int initr_manual_reloc_cmdtable(void)
346 {
347 	fixup_cmdtable(ll_entry_start(cmd_tbl_t, cmd),
348 		       ll_entry_count(cmd_tbl_t, cmd));
349 	return 0;
350 }
351 #endif
352 
353 #if !defined(CONFIG_SYS_NO_FLASH)
354 static int initr_flash(void)
355 {
356 	ulong flash_size = 0;
357 	bd_t *bd = gd->bd;
358 
359 	puts("Flash: ");
360 
361 	if (board_flash_wp_on())
362 		printf("Uninitialized - Write Protect On\n");
363 	else
364 		flash_size = flash_init();
365 
366 	print_size(flash_size, "");
367 #ifdef CONFIG_SYS_FLASH_CHECKSUM
368 	/*
369 	* Compute and print flash CRC if flashchecksum is set to 'y'
370 	*
371 	* NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
372 	*/
373 	if (getenv_yesno("flashchecksum") == 1) {
374 		printf("  CRC: %08X", crc32(0,
375 			(const unsigned char *) CONFIG_SYS_FLASH_BASE,
376 			flash_size));
377 	}
378 #endif /* CONFIG_SYS_FLASH_CHECKSUM */
379 	putc('\n');
380 
381 	/* update start of FLASH memory    */
382 #ifdef CONFIG_SYS_FLASH_BASE
383 	bd->bi_flashstart = CONFIG_SYS_FLASH_BASE;
384 #endif
385 	/* size of FLASH memory (final value) */
386 	bd->bi_flashsize = flash_size;
387 
388 #if defined(CONFIG_SYS_UPDATE_FLASH_SIZE)
389 	/* Make a update of the Memctrl. */
390 	update_flash_size(flash_size);
391 #endif
392 
393 
394 #if defined(CONFIG_OXC) || defined(CONFIG_RMU)
395 	/* flash mapped at end of memory map */
396 	bd->bi_flashoffset = CONFIG_SYS_TEXT_BASE + flash_size;
397 #elif CONFIG_SYS_MONITOR_BASE == CONFIG_SYS_FLASH_BASE
398 	bd->bi_flashoffset = monitor_flash_len;	/* reserved area for monitor */
399 #endif
400 	return 0;
401 }
402 #endif
403 
404 #if defined(CONFIG_PPC) && !defined(CONFIG_DM_SPI)
405 static int initr_spi(void)
406 {
407 	/* PPC does this here */
408 #ifdef CONFIG_SPI
409 #if !defined(CONFIG_ENV_IS_IN_EEPROM)
410 	spi_init_f();
411 #endif
412 	spi_init_r();
413 #endif
414 	return 0;
415 }
416 #endif
417 
418 #ifdef CONFIG_CMD_NAND
419 /* go init the NAND */
420 static int initr_nand(void)
421 {
422 	puts("NAND:  ");
423 	nand_init();
424 	return 0;
425 }
426 #endif
427 
428 #if defined(CONFIG_CMD_ONENAND)
429 /* go init the NAND */
430 static int initr_onenand(void)
431 {
432 	puts("NAND:  ");
433 	onenand_init();
434 	return 0;
435 }
436 #endif
437 
438 #ifdef CONFIG_GENERIC_MMC
439 static int initr_mmc(void)
440 {
441 	puts("MMC:   ");
442 	mmc_initialize(gd->bd);
443 	return 0;
444 }
445 #endif
446 
447 #ifdef CONFIG_HAS_DATAFLASH
448 static int initr_dataflash(void)
449 {
450 	AT91F_DataflashInit();
451 	dataflash_print_info();
452 	return 0;
453 }
454 #endif
455 
456 /*
457  * Tell if it's OK to load the environment early in boot.
458  *
459  * If CONFIG_OF_CONFIG is defined, we'll check with the FDT to see
460  * if this is OK (defaulting to saying it's OK).
461  *
462  * NOTE: Loading the environment early can be a bad idea if security is
463  *       important, since no verification is done on the environment.
464  *
465  * @return 0 if environment should not be loaded, !=0 if it is ok to load
466  */
467 static int should_load_env(void)
468 {
469 #ifdef CONFIG_OF_CONTROL
470 	return fdtdec_get_config_int(gd->fdt_blob, "load-environment", 1);
471 #elif defined CONFIG_DELAY_ENVIRONMENT
472 	return 0;
473 #else
474 	return 1;
475 #endif
476 }
477 
478 static int initr_env(void)
479 {
480 	/* initialize environment */
481 	if (should_load_env())
482 		env_relocate();
483 	else
484 		set_default_env(NULL);
485 #ifdef CONFIG_OF_CONTROL
486 	setenv_addr("fdtcontroladdr", gd->fdt_blob);
487 #endif
488 
489 	/* Initialize from environment */
490 	load_addr = getenv_ulong("loadaddr", 16, load_addr);
491 #if defined(CONFIG_SYS_EXTBDINFO)
492 #if defined(CONFIG_405GP) || defined(CONFIG_405EP)
493 #if defined(CONFIG_I2CFAST)
494 	/*
495 	 * set bi_iic_fast for linux taking environment variable
496 	 * "i2cfast" into account
497 	 */
498 	{
499 		char *s = getenv("i2cfast");
500 
501 		if (s && ((*s == 'y') || (*s == 'Y'))) {
502 			gd->bd->bi_iic_fast[0] = 1;
503 			gd->bd->bi_iic_fast[1] = 1;
504 		}
505 	}
506 #endif /* CONFIG_I2CFAST */
507 #endif /* CONFIG_405GP, CONFIG_405EP */
508 #endif /* CONFIG_SYS_EXTBDINFO */
509 	return 0;
510 }
511 
512 #ifdef CONFIG_SYS_BOOTPARAMS_LEN
513 static int initr_malloc_bootparams(void)
514 {
515 	gd->bd->bi_boot_params = (ulong)malloc(CONFIG_SYS_BOOTPARAMS_LEN);
516 	if (!gd->bd->bi_boot_params) {
517 		puts("WARNING: Cannot allocate space for boot parameters\n");
518 		return -ENOMEM;
519 	}
520 	return 0;
521 }
522 #endif
523 
524 static int initr_jumptable(void)
525 {
526 	jumptable_init();
527 	return 0;
528 }
529 
530 #if defined(CONFIG_API)
531 static int initr_api(void)
532 {
533 	/* Initialize API */
534 	api_init();
535 	return 0;
536 }
537 #endif
538 
539 /* enable exceptions */
540 #if defined(CONFIG_ARM) || defined(CONFIG_AVR32)
541 static int initr_enable_interrupts(void)
542 {
543 	enable_interrupts();
544 	return 0;
545 }
546 #endif
547 
548 #ifdef CONFIG_CMD_NET
549 static int initr_ethaddr(void)
550 {
551 	bd_t *bd = gd->bd;
552 
553 	/* kept around for legacy kernels only ... ignore the next section */
554 	eth_getenv_enetaddr("ethaddr", bd->bi_enetaddr);
555 #ifdef CONFIG_HAS_ETH1
556 	eth_getenv_enetaddr("eth1addr", bd->bi_enet1addr);
557 #endif
558 #ifdef CONFIG_HAS_ETH2
559 	eth_getenv_enetaddr("eth2addr", bd->bi_enet2addr);
560 #endif
561 #ifdef CONFIG_HAS_ETH3
562 	eth_getenv_enetaddr("eth3addr", bd->bi_enet3addr);
563 #endif
564 #ifdef CONFIG_HAS_ETH4
565 	eth_getenv_enetaddr("eth4addr", bd->bi_enet4addr);
566 #endif
567 #ifdef CONFIG_HAS_ETH5
568 	eth_getenv_enetaddr("eth5addr", bd->bi_enet5addr);
569 #endif
570 	return 0;
571 }
572 #endif /* CONFIG_CMD_NET */
573 
574 #ifdef CONFIG_CMD_KGDB
575 static int initr_kgdb(void)
576 {
577 	puts("KGDB:  ");
578 	kgdb_init();
579 	return 0;
580 }
581 #endif
582 
583 #if defined(CONFIG_STATUS_LED)
584 static int initr_status_led(void)
585 {
586 #if defined(STATUS_LED_BOOT)
587 	status_led_set(STATUS_LED_BOOT, STATUS_LED_BLINKING);
588 #else
589 	status_led_init();
590 #endif
591 	return 0;
592 }
593 #endif
594 
595 #if defined(CONFIG_CMD_AMBAPP) && defined(CONFIG_SYS_AMBAPP_PRINT_ON_STARTUP)
596 extern int do_ambapp_print(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
597 
598 static int initr_ambapp_print(void)
599 {
600 	puts("AMBA:\n");
601 	do_ambapp_print(NULL, 0, 0, NULL);
602 
603 	return 0;
604 }
605 #endif
606 
607 #if defined(CONFIG_CMD_SCSI)
608 static int initr_scsi(void)
609 {
610 	puts("SCSI:  ");
611 	scsi_init();
612 
613 	return 0;
614 }
615 #endif
616 
617 #if defined(CONFIG_CMD_DOC)
618 static int initr_doc(void)
619 {
620 	puts("DOC:   ");
621 	doc_init();
622 	return 0;
623 }
624 #endif
625 
626 #ifdef CONFIG_BITBANGMII
627 static int initr_bbmii(void)
628 {
629 	bb_miiphy_init();
630 	return 0;
631 }
632 #endif
633 
634 #ifdef CONFIG_CMD_NET
635 static int initr_net(void)
636 {
637 	puts("Net:   ");
638 	eth_initialize();
639 #if defined(CONFIG_RESET_PHY_R)
640 	debug("Reset Ethernet PHY\n");
641 	reset_phy();
642 #endif
643 	return 0;
644 }
645 #endif
646 
647 #ifdef CONFIG_POST
648 static int initr_post(void)
649 {
650 	post_run(NULL, POST_RAM | post_bootmode_get(0));
651 	return 0;
652 }
653 #endif
654 
655 #if defined(CONFIG_CMD_PCMCIA) && !defined(CONFIG_CMD_IDE)
656 static int initr_pcmcia(void)
657 {
658 	puts("PCMCIA:");
659 	pcmcia_init();
660 	return 0;
661 }
662 #endif
663 
664 #if defined(CONFIG_CMD_IDE)
665 static int initr_ide(void)
666 {
667 #ifdef	CONFIG_IDE_8xx_PCCARD
668 	puts("PCMCIA:");
669 #else
670 	puts("IDE:   ");
671 #endif
672 #if defined(CONFIG_START_IDE)
673 	if (board_start_ide())
674 		ide_init();
675 #else
676 	ide_init();
677 #endif
678 	return 0;
679 }
680 #endif
681 
682 #if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER)
683 /*
684  * Export available size of memory for Linux, taking into account the
685  * protected RAM at top of memory
686  */
687 int initr_mem(void)
688 {
689 	ulong pram = 0;
690 	char memsz[32];
691 
692 # ifdef CONFIG_PRAM
693 	pram = getenv_ulong("pram", 10, CONFIG_PRAM);
694 # endif
695 # if defined(CONFIG_LOGBUFFER) && !defined(CONFIG_ALT_LB_ADDR)
696 	/* Also take the logbuffer into account (pram is in kB) */
697 	pram += (LOGBUFF_LEN + LOGBUFF_OVERHEAD) / 1024;
698 # endif
699 	sprintf(memsz, "%ldk", (long int) ((gd->ram_size / 1024) - pram));
700 	setenv("mem", memsz);
701 
702 	return 0;
703 }
704 #endif
705 
706 #ifdef CONFIG_CMD_BEDBUG
707 static int initr_bedbug(void)
708 {
709 	bedbug_init();
710 
711 	return 0;
712 }
713 #endif
714 
715 #ifdef CONFIG_PS2KBD
716 static int initr_kbd(void)
717 {
718 	puts("PS/2:  ");
719 	kbd_init();
720 	return 0;
721 }
722 #endif
723 
724 static int run_main_loop(void)
725 {
726 #ifdef CONFIG_SANDBOX
727 	sandbox_main_loop_init();
728 #endif
729 	/* main_loop() can return to retry autoboot, if so just run it again */
730 	for (;;)
731 		main_loop();
732 	return 0;
733 }
734 
735 /*
736  * Over time we hope to remove these functions with code fragments and
737  * stub funtcions, and instead call the relevant function directly.
738  *
739  * We also hope to remove most of the driver-related init and do it if/when
740  * the driver is later used.
741  *
742  * TODO: perhaps reset the watchdog in the initcall function after each call?
743  */
744 init_fnc_t init_sequence_r[] = {
745 	initr_trace,
746 	initr_reloc,
747 	/* TODO: could x86/PPC have this also perhaps? */
748 #ifdef CONFIG_ARM
749 	initr_caches,
750 	/* Note: For Freescale LS2 SoCs, new MMU table is created in DDR.
751 	 *	 A temporary mapping of IFC high region is since removed,
752 	 *	 so environmental variables in NOR flash is not availble
753 	 *	 until board_init() is called below to remap IFC to high
754 	 *	 region.
755 	 */
756 #endif
757 	initr_reloc_global_data,
758 #if defined(CONFIG_SYS_INIT_RAM_LOCK) && defined(CONFIG_E500)
759 	initr_unlock_ram_in_cache,
760 #endif
761 	initr_barrier,
762 	initr_malloc,
763 	initr_console_record,
764 #ifdef CONFIG_SYS_NONCACHED_MEMORY
765 	initr_noncached,
766 #endif
767 	bootstage_relocate,
768 #ifdef CONFIG_DM
769 	initr_dm,
770 #endif
771 	initr_bootstage,
772 #if defined(CONFIG_ARM) || defined(CONFIG_NDS32)
773 	board_init,	/* Setup chipselects */
774 #endif
775 	/*
776 	 * TODO: printing of the clock inforamtion of the board is now
777 	 * implemented as part of bdinfo command. Currently only support for
778 	 * davinci SOC's is added. Remove this check once all the board
779 	 * implement this.
780 	 */
781 #ifdef CONFIG_CLOCKS
782 	set_cpu_clk_info, /* Setup clock information */
783 #endif
784 	stdio_init_tables,
785 	initr_serial,
786 	initr_announce,
787 	INIT_FUNC_WATCHDOG_RESET
788 #ifdef CONFIG_NEEDS_MANUAL_RELOC
789 	initr_manual_reloc_cmdtable,
790 #endif
791 #if defined(CONFIG_PPC) || defined(CONFIG_M68K)
792 	initr_trap,
793 #endif
794 #ifdef CONFIG_ADDR_MAP
795 	initr_addr_map,
796 #endif
797 #if defined(CONFIG_BOARD_EARLY_INIT_R)
798 	board_early_init_r,
799 #endif
800 	INIT_FUNC_WATCHDOG_RESET
801 #ifdef CONFIG_LOGBUFFER
802 	initr_logbuffer,
803 #endif
804 #ifdef CONFIG_POST
805 	initr_post_backlog,
806 #endif
807 	INIT_FUNC_WATCHDOG_RESET
808 #ifdef CONFIG_SYS_DELAYED_ICACHE
809 	initr_icache_enable,
810 #endif
811 #if defined(CONFIG_PCI) && defined(CONFIG_SYS_EARLY_PCI_INIT)
812 	/*
813 	 * Do early PCI configuration _before_ the flash gets initialised,
814 	 * because PCU ressources are crucial for flash access on some boards.
815 	 */
816 	initr_pci,
817 #endif
818 #ifdef CONFIG_WINBOND_83C553
819 	initr_w83c553f,
820 #endif
821 #ifdef CONFIG_ARCH_EARLY_INIT_R
822 	arch_early_init_r,
823 #endif
824 	power_init_board,
825 #ifndef CONFIG_SYS_NO_FLASH
826 	initr_flash,
827 #endif
828 	INIT_FUNC_WATCHDOG_RESET
829 #if defined(CONFIG_PPC) || defined(CONFIG_M68K) || defined(CONFIG_X86) || \
830 	defined(CONFIG_SPARC)
831 	/* initialize higher level parts of CPU like time base and timers */
832 	cpu_init_r,
833 #endif
834 #ifdef CONFIG_PPC
835 	initr_spi,
836 #endif
837 #ifdef CONFIG_CMD_NAND
838 	initr_nand,
839 #endif
840 #ifdef CONFIG_CMD_ONENAND
841 	initr_onenand,
842 #endif
843 #ifdef CONFIG_GENERIC_MMC
844 	initr_mmc,
845 #endif
846 #ifdef CONFIG_HAS_DATAFLASH
847 	initr_dataflash,
848 #endif
849 	initr_env,
850 #ifdef CONFIG_SYS_BOOTPARAMS_LEN
851 	initr_malloc_bootparams,
852 #endif
853 	INIT_FUNC_WATCHDOG_RESET
854 	initr_secondary_cpu,
855 #if defined(CONFIG_ID_EEPROM) || defined(CONFIG_SYS_I2C_MAC_OFFSET)
856 	mac_read_from_eeprom,
857 #endif
858 	INIT_FUNC_WATCHDOG_RESET
859 #if defined(CONFIG_PCI) && !defined(CONFIG_SYS_EARLY_PCI_INIT)
860 	/*
861 	 * Do pci configuration
862 	 */
863 	initr_pci,
864 #endif
865 	stdio_add_devices,
866 	initr_jumptable,
867 #ifdef CONFIG_API
868 	initr_api,
869 #endif
870 	console_init_r,		/* fully init console as a device */
871 #ifdef CONFIG_DISPLAY_BOARDINFO_LATE
872 	show_board_info,
873 #endif
874 #ifdef CONFIG_ARCH_MISC_INIT
875 	arch_misc_init,		/* miscellaneous arch-dependent init */
876 #endif
877 #ifdef CONFIG_MISC_INIT_R
878 	misc_init_r,		/* miscellaneous platform-dependent init */
879 #endif
880 	INIT_FUNC_WATCHDOG_RESET
881 #ifdef CONFIG_CMD_KGDB
882 	initr_kgdb,
883 #endif
884 	interrupt_init,
885 #if defined(CONFIG_ARM) || defined(CONFIG_AVR32)
886 	initr_enable_interrupts,
887 #endif
888 #if defined(CONFIG_MICROBLAZE) || defined(CONFIG_AVR32) || defined(CONFIG_M68K)
889 	timer_init,		/* initialize timer */
890 #endif
891 #if defined(CONFIG_STATUS_LED)
892 	initr_status_led,
893 #endif
894 	/* PPC has a udelay(20) here dating from 2002. Why? */
895 #ifdef CONFIG_CMD_NET
896 	initr_ethaddr,
897 #endif
898 #ifdef CONFIG_BOARD_LATE_INIT
899 	board_late_init,
900 #endif
901 #if defined(CONFIG_CMD_AMBAPP)
902 	ambapp_init_reloc,
903 #if defined(CONFIG_SYS_AMBAPP_PRINT_ON_STARTUP)
904 	initr_ambapp_print,
905 #endif
906 #endif
907 #ifdef CONFIG_CMD_SCSI
908 	INIT_FUNC_WATCHDOG_RESET
909 	initr_scsi,
910 #endif
911 #ifdef CONFIG_CMD_DOC
912 	INIT_FUNC_WATCHDOG_RESET
913 	initr_doc,
914 #endif
915 #ifdef CONFIG_BITBANGMII
916 	initr_bbmii,
917 #endif
918 #ifdef CONFIG_CMD_NET
919 	INIT_FUNC_WATCHDOG_RESET
920 	initr_net,
921 #endif
922 #ifdef CONFIG_POST
923 	initr_post,
924 #endif
925 #if defined(CONFIG_CMD_PCMCIA) && !defined(CONFIG_CMD_IDE)
926 	initr_pcmcia,
927 #endif
928 #if defined(CONFIG_CMD_IDE)
929 	initr_ide,
930 #endif
931 #ifdef CONFIG_LAST_STAGE_INIT
932 	INIT_FUNC_WATCHDOG_RESET
933 	/*
934 	 * Some parts can be only initialized if all others (like
935 	 * Interrupts) are up and running (i.e. the PC-style ISA
936 	 * keyboard).
937 	 */
938 	last_stage_init,
939 #endif
940 #ifdef CONFIG_CMD_BEDBUG
941 	INIT_FUNC_WATCHDOG_RESET
942 	initr_bedbug,
943 #endif
944 #if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER)
945 	initr_mem,
946 #endif
947 #ifdef CONFIG_PS2KBD
948 	initr_kbd,
949 #endif
950 #if defined(CONFIG_SPARC)
951 	prom_init,
952 #endif
953 	run_main_loop,
954 };
955 
956 void board_init_r(gd_t *new_gd, ulong dest_addr)
957 {
958 #ifdef CONFIG_NEEDS_MANUAL_RELOC
959 	int i;
960 #endif
961 
962 #ifdef CONFIG_AVR32
963 	mmu_init_r(dest_addr);
964 #endif
965 
966 #if !defined(CONFIG_X86) && !defined(CONFIG_ARM) && !defined(CONFIG_ARM64)
967 	gd = new_gd;
968 #endif
969 
970 #ifdef CONFIG_NEEDS_MANUAL_RELOC
971 	for (i = 0; i < ARRAY_SIZE(init_sequence_r); i++)
972 		init_sequence_r[i] += gd->reloc_off;
973 #endif
974 
975 	if (initcall_run_list(init_sequence_r))
976 		hang();
977 
978 	/* NOTREACHED - run_main_loop() does not return */
979 	hang();
980 }
981