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