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