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