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