2 * Copyright (c) 2011 The Chromium OS Authors.
3 * (C) Copyright 2002-2006
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
7 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
8 * Marius Groeger <mgroeger@sysgo.de>
10 * SPDX-License-Identifier: GPL-2.0+
14 #include <linux/compiler.h>
17 #include <environment.h>
21 #if defined(CONFIG_CMD_IDE)
30 /* TODO: Can we move these into arch/ headers? */
40 #if defined(CONFIG_MP) && (defined(CONFIG_MPC86xx) || defined(CONFIG_E500))
47 #include <status_led.h>
51 #include <asm/errno.h>
53 #include <asm/sections.h>
54 #if defined(CONFIG_X86) || defined(CONFIG_ARC)
55 #include <asm/init_helpers.h>
56 #include <asm/relocate.h>
59 #include <asm/state.h>
62 #include <linux/compiler.h>
65 * Pointer to initial global data area
67 * Here we initialize it if needed.
69 #ifdef XTRN_DECLARE_GLOBAL_DATA_PTR
70 #undef XTRN_DECLARE_GLOBAL_DATA_PTR
71 #define XTRN_DECLARE_GLOBAL_DATA_PTR /* empty = allocate here */
72 DECLARE_GLOBAL_DATA_PTR = (gd_t *) (CONFIG_SYS_INIT_GD_ADDR);
74 DECLARE_GLOBAL_DATA_PTR;
78 * TODO(sjg@chromium.org): IMO this code should be
79 * refactored to a single function, something like:
81 * void led_set_state(enum led_colour_t colour, int on);
83 /************************************************************************
84 * Coloured LED functionality
85 ************************************************************************
86 * May be supplied by boards if desired
88 __weak void coloured_LED_init(void) {}
89 __weak void red_led_on(void) {}
90 __weak void red_led_off(void) {}
91 __weak void green_led_on(void) {}
92 __weak void green_led_off(void) {}
93 __weak void yellow_led_on(void) {}
94 __weak void yellow_led_off(void) {}
95 __weak void blue_led_on(void) {}
96 __weak void blue_led_off(void) {}
99 * Why is gd allocated a register? Prior to reloc it might be better to
100 * just pass it around to each function in this file?
102 * After reloc one could argue that it is hardly used and doesn't need
103 * to be in a register. Or if it is it should perhaps hold pointers to all
104 * global data for all modules, so that post-reloc we can avoid the massive
105 * literal pool we get on ARM. Or perhaps just encourage each module to use
110 * Could the CONFIG_SPL_BUILD infection become a flag in gd?
113 #if defined(CONFIG_WATCHDOG) || defined(CONFIG_HW_WATCHDOG)
114 static int init_func_watchdog_init(void)
116 # if defined(CONFIG_HW_WATCHDOG) && (defined(CONFIG_BLACKFIN) || \
117 defined(CONFIG_M68K) || defined(CONFIG_MICROBLAZE) || \
118 defined(CONFIG_SH) || defined(CONFIG_AT91SAM9_WATCHDOG) || \
119 defined(CONFIG_IMX_WATCHDOG))
122 puts(" Watchdog enabled\n");
128 int init_func_watchdog_reset(void)
134 #endif /* CONFIG_WATCHDOG */
136 __weak void board_add_ram_info(int use_default)
138 /* please define platform specific board_add_ram_info() */
141 static int init_baud_rate(void)
143 gd->baudrate = getenv_ulong("baudrate", 10, CONFIG_BAUDRATE);
147 static int display_text_info(void)
149 #if !defined(CONFIG_SANDBOX) && !defined(CONFIG_EFI_APP)
150 ulong bss_start, bss_end, text_base;
152 bss_start = (ulong)&__bss_start;
153 bss_end = (ulong)&__bss_end;
155 #ifdef CONFIG_SYS_TEXT_BASE
156 text_base = CONFIG_SYS_TEXT_BASE;
158 text_base = CONFIG_SYS_MONITOR_BASE;
161 debug("U-Boot code: %08lX -> %08lX BSS: -> %08lX\n",
162 text_base, bss_start, bss_end);
165 #ifdef CONFIG_MODEM_SUPPORT
166 debug("Modem Support enabled\n");
168 #ifdef CONFIG_USE_IRQ
169 debug("IRQ Stack: %08lx\n", IRQ_STACK_START);
170 debug("FIQ Stack: %08lx\n", FIQ_STACK_START);
176 static int announce_dram_init(void)
182 #if defined(CONFIG_MIPS) || defined(CONFIG_PPC) || defined(CONFIG_M68K)
183 static int init_func_ram(void)
185 #ifdef CONFIG_BOARD_TYPES
186 int board_type = gd->board_type;
188 int board_type = 0; /* use dummy arg */
191 gd->ram_size = initdram(board_type);
193 if (gd->ram_size > 0)
196 puts("*** failed ***\n");
201 static int show_dram_config(void)
203 unsigned long long size;
205 #ifdef CONFIG_NR_DRAM_BANKS
208 debug("\nRAM Configuration:\n");
209 for (i = size = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
210 size += gd->bd->bi_dram[i].size;
211 debug("Bank #%d: %llx ", i,
212 (unsigned long long)(gd->bd->bi_dram[i].start));
214 print_size(gd->bd->bi_dram[i].size, "\n");
222 print_size(size, "");
223 board_add_ram_info(0);
229 __weak void dram_init_banksize(void)
231 #if defined(CONFIG_NR_DRAM_BANKS) && defined(CONFIG_SYS_SDRAM_BASE)
232 gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
233 gd->bd->bi_dram[0].size = get_effective_memsize();
237 #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SYS_I2C)
238 static int init_func_i2c(void)
241 #ifdef CONFIG_SYS_I2C
244 i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
251 #if defined(CONFIG_HARD_SPI)
252 static int init_func_spi(void)
262 static int zero_global_data(void)
264 memset((void *)gd, '\0', sizeof(gd_t));
269 static int setup_mon_len(void)
271 #if defined(__ARM__) || defined(__MICROBLAZE__)
272 gd->mon_len = (ulong)&__bss_end - (ulong)_start;
273 #elif defined(CONFIG_SANDBOX) || defined(CONFIG_EFI_APP)
274 gd->mon_len = (ulong)&_end - (ulong)_init;
275 #elif defined(CONFIG_BLACKFIN) || defined(CONFIG_NIOS2)
276 gd->mon_len = CONFIG_SYS_MONITOR_LEN;
277 #elif defined(CONFIG_NDS32)
278 gd->mon_len = (ulong)(&__bss_end) - (ulong)(&_start);
280 /* TODO: use (ulong)&__bss_end - (ulong)&__text_start; ? */
281 gd->mon_len = (ulong)&__bss_end - CONFIG_SYS_MONITOR_BASE;
286 __weak int arch_cpu_init(void)
291 #ifdef CONFIG_SANDBOX
292 static int setup_ram_buf(void)
294 struct sandbox_state *state = state_get_current();
296 gd->arch.ram_buf = state->ram_buf;
297 gd->ram_size = state->ram_size;
303 /* Get the top of usable RAM */
304 __weak ulong board_get_usable_ram_top(ulong total_size)
306 #ifdef CONFIG_SYS_SDRAM_BASE
308 * Detect whether we have so much RAM that it goes past the end of our
309 * 32-bit address space. If so, clip the usable RAM so it doesn't.
311 if (gd->ram_top < CONFIG_SYS_SDRAM_BASE)
313 * Will wrap back to top of 32-bit space when reservations
321 __weak phys_size_t board_reserve_ram_top(phys_size_t ram_size)
323 #ifdef CONFIG_SYS_MEM_TOP_HIDE
324 return ram_size - CONFIG_SYS_MEM_TOP_HIDE;
330 static int setup_dest_addr(void)
332 debug("Monitor len: %08lX\n", gd->mon_len);
334 * Ram is setup, size stored in gd !!
336 debug("Ram size: %08lX\n", (ulong)gd->ram_size);
337 #ifdef CONFIG_SYS_MEM_RESERVE_SECURE
338 /* Reserve memory for secure MMU tables, and/or security monitor */
339 gd->ram_size -= CONFIG_SYS_MEM_RESERVE_SECURE;
341 * Record secure memory location. Need recalcuate if memory splits
342 * into banks, or the ram base is not zero.
344 gd->secure_ram = gd->ram_size;
347 * Subtract specified amount of memory to hide so that it won't
348 * get "touched" at all by U-Boot. By fixing up gd->ram_size
349 * the Linux kernel should now get passed the now "corrected"
350 * memory size and won't touch it either. This has been used
351 * by arch/powerpc exclusively. Now ARMv8 takes advantage of
352 * thie mechanism. If memory is split into banks, addresses
353 * need to be calculated.
355 gd->ram_size = board_reserve_ram_top(gd->ram_size);
357 #ifdef CONFIG_SYS_SDRAM_BASE
358 gd->ram_top = CONFIG_SYS_SDRAM_BASE;
360 gd->ram_top += get_effective_memsize();
361 gd->ram_top = board_get_usable_ram_top(gd->mon_len);
362 gd->relocaddr = gd->ram_top;
363 debug("Ram top: %08lX\n", (ulong)gd->ram_top);
364 #if defined(CONFIG_MP) && (defined(CONFIG_MPC86xx) || defined(CONFIG_E500))
366 * We need to make sure the location we intend to put secondary core
367 * boot code is reserved and not used by any part of u-boot
369 if (gd->relocaddr > determine_mp_bootpg(NULL)) {
370 gd->relocaddr = determine_mp_bootpg(NULL);
371 debug("Reserving MP boot page to %08lx\n", gd->relocaddr);
377 #if defined(CONFIG_SPARC)
378 static int reserve_prom(void)
380 /* defined in arch/sparc/cpu/leon?/prom.c */
381 extern void *__prom_start_reloc;
382 int size = 8192; /* page table = 2k, prom = 6k */
383 gd->relocaddr -= size;
384 __prom_start_reloc = map_sysmem(gd->relocaddr + 2048, size - 2048);
385 debug("Reserving %dk for PROM and page table at %08lx\n", size,
391 #if defined(CONFIG_LOGBUFFER) && !defined(CONFIG_ALT_LB_ADDR)
392 static int reserve_logbuffer(void)
394 /* reserve kernel log buffer */
395 gd->relocaddr -= LOGBUFF_RESERVE;
396 debug("Reserving %dk for kernel logbuffer at %08lx\n", LOGBUFF_LEN,
403 /* reserve protected RAM */
404 static int reserve_pram(void)
408 reg = getenv_ulong("pram", 10, CONFIG_PRAM);
409 gd->relocaddr -= (reg << 10); /* size is in kB */
410 debug("Reserving %ldk for protected RAM at %08lx\n", reg,
414 #endif /* CONFIG_PRAM */
416 /* Round memory pointer down to next 4 kB limit */
417 static int reserve_round_4k(void)
419 gd->relocaddr &= ~(4096 - 1);
423 #if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF)) && \
425 static int reserve_mmu(void)
427 /* reserve TLB table */
428 gd->arch.tlb_size = PGTABLE_SIZE;
429 gd->relocaddr -= gd->arch.tlb_size;
431 /* round down to next 64 kB limit */
432 gd->relocaddr &= ~(0x10000 - 1);
434 gd->arch.tlb_addr = gd->relocaddr;
435 debug("TLB table from %08lx to %08lx\n", gd->arch.tlb_addr,
436 gd->arch.tlb_addr + gd->arch.tlb_size);
441 #ifdef CONFIG_DM_VIDEO
442 static int reserve_video(void)
447 addr = gd->relocaddr;
448 ret = video_reserve(&addr);
451 gd->relocaddr = addr;
458 static int reserve_lcd(void)
460 # ifdef CONFIG_FB_ADDR
461 gd->fb_base = CONFIG_FB_ADDR;
463 /* reserve memory for LCD display (always full pages) */
464 gd->relocaddr = lcd_setmem(gd->relocaddr);
465 gd->fb_base = gd->relocaddr;
466 # endif /* CONFIG_FB_ADDR */
470 # endif /* CONFIG_LCD */
472 # if defined(CONFIG_VIDEO) && (!defined(CONFIG_PPC) || defined(CONFIG_8xx)) && \
473 !defined(CONFIG_ARM) && !defined(CONFIG_X86) && \
474 !defined(CONFIG_BLACKFIN) && !defined(CONFIG_M68K)
475 static int reserve_legacy_video(void)
477 /* reserve memory for video display (always full pages) */
478 gd->relocaddr = video_setmem(gd->relocaddr);
479 gd->fb_base = gd->relocaddr;
484 #endif /* !CONFIG_DM_VIDEO */
486 static int reserve_trace(void)
489 gd->relocaddr -= CONFIG_TRACE_BUFFER_SIZE;
490 gd->trace_buff = map_sysmem(gd->relocaddr, CONFIG_TRACE_BUFFER_SIZE);
491 debug("Reserving %dk for trace data at: %08lx\n",
492 CONFIG_TRACE_BUFFER_SIZE >> 10, gd->relocaddr);
498 static int reserve_uboot(void)
501 * reserve memory for U-Boot code, data & bss
502 * round down to next 4 kB limit
504 gd->relocaddr -= gd->mon_len;
505 gd->relocaddr &= ~(4096 - 1);
507 /* round down to next 64 kB limit so that IVPR stays aligned */
508 gd->relocaddr &= ~(65536 - 1);
511 debug("Reserving %ldk for U-Boot at: %08lx\n", gd->mon_len >> 10,
514 gd->start_addr_sp = gd->relocaddr;
519 #ifndef CONFIG_SPL_BUILD
520 /* reserve memory for malloc() area */
521 static int reserve_malloc(void)
523 gd->start_addr_sp = gd->start_addr_sp - TOTAL_MALLOC_LEN;
524 debug("Reserving %dk for malloc() at: %08lx\n",
525 TOTAL_MALLOC_LEN >> 10, gd->start_addr_sp);
529 /* (permanently) allocate a Board Info struct */
530 static int reserve_board(void)
533 gd->start_addr_sp -= sizeof(bd_t);
534 gd->bd = (bd_t *)map_sysmem(gd->start_addr_sp, sizeof(bd_t));
535 memset(gd->bd, '\0', sizeof(bd_t));
536 debug("Reserving %zu Bytes for Board Info at: %08lx\n",
537 sizeof(bd_t), gd->start_addr_sp);
543 static int setup_machine(void)
545 #ifdef CONFIG_MACH_TYPE
546 gd->bd->bi_arch_number = CONFIG_MACH_TYPE; /* board id for Linux */
551 static int reserve_global_data(void)
553 gd->start_addr_sp -= sizeof(gd_t);
554 gd->new_gd = (gd_t *)map_sysmem(gd->start_addr_sp, sizeof(gd_t));
555 debug("Reserving %zu Bytes for Global Data at: %08lx\n",
556 sizeof(gd_t), gd->start_addr_sp);
560 static int reserve_fdt(void)
562 #ifndef CONFIG_OF_EMBED
564 * If the device tree is sitting immediately above our image then we
565 * must relocate it. If it is embedded in the data section, then it
566 * will be relocated with other data.
569 gd->fdt_size = ALIGN(fdt_totalsize(gd->fdt_blob) + 0x1000, 32);
571 gd->start_addr_sp -= gd->fdt_size;
572 gd->new_fdt = map_sysmem(gd->start_addr_sp, gd->fdt_size);
573 debug("Reserving %lu Bytes for FDT at: %08lx\n",
574 gd->fdt_size, gd->start_addr_sp);
581 int arch_reserve_stacks(void)
586 static int reserve_stacks(void)
588 /* make stack pointer 16-byte aligned */
589 gd->start_addr_sp -= 16;
590 gd->start_addr_sp &= ~0xf;
593 * let the architecture-specific code tailor gd->start_addr_sp and
596 return arch_reserve_stacks();
599 static int display_new_sp(void)
601 debug("New Stack Pointer is: %08lx\n", gd->start_addr_sp);
606 #if defined(CONFIG_PPC) || defined(CONFIG_M68K) || defined(CONFIG_MIPS)
607 static int setup_board_part1(void)
612 * Save local variables to board info struct
614 bd->bi_memstart = CONFIG_SYS_SDRAM_BASE; /* start of memory */
615 bd->bi_memsize = gd->ram_size; /* size in bytes */
617 #ifdef CONFIG_SYS_SRAM_BASE
618 bd->bi_sramstart = CONFIG_SYS_SRAM_BASE; /* start of SRAM */
619 bd->bi_sramsize = CONFIG_SYS_SRAM_SIZE; /* size of SRAM */
622 #if defined(CONFIG_8xx) || defined(CONFIG_MPC8260) || defined(CONFIG_5xx) || \
623 defined(CONFIG_E500) || defined(CONFIG_MPC86xx)
624 bd->bi_immr_base = CONFIG_SYS_IMMR; /* base of IMMR register */
626 #if defined(CONFIG_MPC5xxx) || defined(CONFIG_M68K)
627 bd->bi_mbar_base = CONFIG_SYS_MBAR; /* base of internal registers */
629 #if defined(CONFIG_MPC83xx)
630 bd->bi_immrbar = CONFIG_SYS_IMMR;
637 #if defined(CONFIG_PPC) || defined(CONFIG_M68K)
638 static int setup_board_part2(void)
642 bd->bi_intfreq = gd->cpu_clk; /* Internal Freq, in Hz */
643 bd->bi_busfreq = gd->bus_clk; /* Bus Freq, in Hz */
644 #if defined(CONFIG_CPM2)
645 bd->bi_cpmfreq = gd->arch.cpm_clk;
646 bd->bi_brgfreq = gd->arch.brg_clk;
647 bd->bi_sccfreq = gd->arch.scc_clk;
648 bd->bi_vco = gd->arch.vco_out;
649 #endif /* CONFIG_CPM2 */
650 #if defined(CONFIG_MPC512X)
651 bd->bi_ipsfreq = gd->arch.ips_clk;
652 #endif /* CONFIG_MPC512X */
653 #if defined(CONFIG_MPC5xxx)
654 bd->bi_ipbfreq = gd->arch.ipb_clk;
655 bd->bi_pcifreq = gd->pci_clk;
656 #endif /* CONFIG_MPC5xxx */
657 #if defined(CONFIG_M68K) && defined(CONFIG_PCI)
658 bd->bi_pcifreq = gd->pci_clk;
660 #if defined(CONFIG_EXTRA_CLOCK)
661 bd->bi_inpfreq = gd->arch.inp_clk; /* input Freq in Hz */
662 bd->bi_vcofreq = gd->arch.vco_clk; /* vco Freq in Hz */
663 bd->bi_flbfreq = gd->arch.flb_clk; /* flexbus Freq in Hz */
670 #ifdef CONFIG_SYS_EXTBDINFO
671 static int setup_board_extra(void)
675 strncpy((char *) bd->bi_s_version, "1.2", sizeof(bd->bi_s_version));
676 strncpy((char *) bd->bi_r_version, U_BOOT_VERSION,
677 sizeof(bd->bi_r_version));
679 bd->bi_procfreq = gd->cpu_clk; /* Processor Speed, In Hz */
680 bd->bi_plb_busfreq = gd->bus_clk;
681 #if defined(CONFIG_405GP) || defined(CONFIG_405EP) || \
682 defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
683 defined(CONFIG_440EPX) || defined(CONFIG_440GRX)
684 bd->bi_pci_busfreq = get_PCI_freq();
685 bd->bi_opbfreq = get_OPB_freq();
686 #elif defined(CONFIG_XILINX_405)
687 bd->bi_pci_busfreq = get_PCI_freq();
695 static int init_post(void)
697 post_bootmode_init();
698 post_run(NULL, POST_ROM | post_bootmode_get(0));
704 static int setup_dram_config(void)
706 /* Ram is board specific, so move it to board code ... */
707 dram_init_banksize();
712 static int reloc_fdt(void)
714 #ifndef CONFIG_OF_EMBED
715 if (gd->flags & GD_FLG_SKIP_RELOC)
718 memcpy(gd->new_fdt, gd->fdt_blob, gd->fdt_size);
719 gd->fdt_blob = gd->new_fdt;
726 static int setup_reloc(void)
728 if (gd->flags & GD_FLG_SKIP_RELOC) {
729 debug("Skipping relocation due to flag\n");
733 #ifdef CONFIG_SYS_TEXT_BASE
734 gd->reloc_off = gd->relocaddr - CONFIG_SYS_TEXT_BASE;
737 * On all ColdFire arch cpu, monitor code starts always
738 * just after the default vector table location, so at 0x400
740 gd->reloc_off = gd->relocaddr - (CONFIG_SYS_TEXT_BASE + 0x400);
743 memcpy(gd->new_gd, (char *)gd, sizeof(gd_t));
745 debug("Relocation Offset is: %08lx\n", gd->reloc_off);
746 debug("Relocating to %08lx, new gd at %08lx, sp at %08lx\n",
747 gd->relocaddr, (ulong)map_to_sysmem(gd->new_gd),
753 /* ARM calls relocate_code from its crt0.S */
754 #if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX)
756 static int jump_to_copy(void)
758 if (gd->flags & GD_FLG_SKIP_RELOC)
761 * x86 is special, but in a nice way. It uses a trampoline which
762 * enables the dcache if possible.
764 * For now, other archs use relocate_code(), which is implemented
765 * similarly for all archs. When we do generic relocation, hopefully
766 * we can make all archs enable the dcache prior to relocation.
768 #if defined(CONFIG_X86) || defined(CONFIG_ARC)
770 * SDRAM and console are now initialised. The final stack can now
771 * be setup in SDRAM. Code execution will continue in Flash, but
772 * with the stack in SDRAM and Global Data in temporary memory
775 arch_setup_gd(gd->new_gd);
776 board_init_f_r_trampoline(gd->start_addr_sp);
778 relocate_code(gd->start_addr_sp, gd->new_gd, gd->relocaddr);
785 /* Record the board_init_f() bootstage (after arch_cpu_init()) */
786 static int mark_bootstage(void)
788 bootstage_mark_name(BOOTSTAGE_ID_START_UBOOT_F, "board_init_f");
793 static int initf_console_record(void)
795 #if defined(CONFIG_CONSOLE_RECORD) && defined(CONFIG_SYS_MALLOC_F_LEN)
796 return console_record_init();
802 static int initf_dm(void)
804 #if defined(CONFIG_DM) && defined(CONFIG_SYS_MALLOC_F_LEN)
807 ret = dm_init_and_scan(true);
815 /* Architecture-specific memory reservation */
816 __weak int reserve_arch(void)
821 __weak int arch_cpu_init_dm(void)
826 static init_fnc_t init_sequence_f[] = {
827 #ifdef CONFIG_SANDBOX
831 #ifdef CONFIG_OF_CONTROL
838 initf_console_record,
839 #if defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx)
840 /* TODO: can this go into arch_cpu_init()? */
843 #if defined(CONFIG_X86) && defined(CONFIG_HAVE_FSP)
846 arch_cpu_init, /* basic arch cpu dependent setup */
849 mark_bootstage, /* need timer, go after init dm */
850 #if defined(CONFIG_BOARD_EARLY_INIT_F)
853 /* TODO: can any of this go into arch_cpu_init()? */
854 #if defined(CONFIG_PPC) && !defined(CONFIG_8xx_CPUCLK_DEFAULT)
855 get_clocks, /* get CPU and bus clocks (etc.) */
856 #if defined(CONFIG_TQM8xxL) && !defined(CONFIG_TQM866M) \
857 && !defined(CONFIG_TQM885D)
858 adjust_sdram_tbs_8xx,
860 /* TODO: can we rename this to timer_init()? */
863 #if defined(CONFIG_ARM) || defined(CONFIG_MIPS) || \
864 defined(CONFIG_BLACKFIN) || defined(CONFIG_NDS32) || \
865 defined(CONFIG_SPARC)
866 timer_init, /* initialize timer */
868 #ifdef CONFIG_SYS_ALLOC_DPRAM
869 #if !defined(CONFIG_CPM2)
873 #if defined(CONFIG_BOARD_POSTCLK_INIT)
876 #if defined(CONFIG_SYS_FSL_CLK) || defined(CONFIG_M68K)
879 env_init, /* initialize environment */
880 #if defined(CONFIG_8xx_CPUCLK_DEFAULT)
881 /* get CPU and bus clocks according to the environment variable */
883 /* adjust sdram refresh rate according to the new clock */
887 init_baud_rate, /* initialze baudrate settings */
888 serial_init, /* serial communications setup */
889 console_init_f, /* stage 1 init of console */
890 #ifdef CONFIG_SANDBOX
891 sandbox_early_getopt_check,
893 #ifdef CONFIG_OF_CONTROL
896 display_options, /* say that we are here */
897 display_text_info, /* show debugging info if required */
898 #if defined(CONFIG_MPC8260)
901 #endif /* CONFIG_MPC8260 */
902 #if defined(CONFIG_MPC83xx)
905 #if defined(CONFIG_PPC) || defined(CONFIG_M68K)
908 print_cpuinfo, /* display cpu info (and speed) */
909 #if defined(CONFIG_MPC5xxx)
911 #endif /* CONFIG_MPC5xxx */
912 #if defined(CONFIG_DISPLAY_BOARDINFO)
915 INIT_FUNC_WATCHDOG_INIT
916 #if defined(CONFIG_MISC_INIT_F)
919 INIT_FUNC_WATCHDOG_RESET
920 #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SYS_I2C)
923 #if defined(CONFIG_HARD_SPI)
927 /* TODO: unify all these dram functions? */
928 #if defined(CONFIG_ARM) || defined(CONFIG_X86) || defined(CONFIG_NDS32) || \
929 defined(CONFIG_MICROBLAZE) || defined(CONFIG_AVR32)
930 dram_init, /* configure available RAM banks */
932 #if defined(CONFIG_MIPS) || defined(CONFIG_PPC) || defined(CONFIG_M68K)
938 INIT_FUNC_WATCHDOG_RESET
939 #if defined(CONFIG_SYS_DRAM_TEST)
941 #endif /* CONFIG_SYS_DRAM_TEST */
942 INIT_FUNC_WATCHDOG_RESET
947 INIT_FUNC_WATCHDOG_RESET
949 * Now that we have DRAM mapped and working, we can
950 * relocate the code and continue running from DRAM.
952 * Reserve memory at end of RAM for (top down in that order):
953 * - area that won't get touched by U-Boot and Linux (optional)
954 * - kernel log buffer
958 * - board info struct
961 #if defined(CONFIG_BLACKFIN)
962 /* Blackfin u-boot monitor should be on top of the ram */
965 #if defined(CONFIG_SPARC)
968 #if defined(CONFIG_LOGBUFFER) && !defined(CONFIG_ALT_LB_ADDR)
975 #if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF)) && \
979 #ifdef CONFIG_DM_VIDEO
985 /* TODO: Why the dependency on CONFIG_8xx? */
986 # if defined(CONFIG_VIDEO) && (!defined(CONFIG_PPC) || defined(CONFIG_8xx)) && \
987 !defined(CONFIG_ARM) && !defined(CONFIG_X86) && \
988 !defined(CONFIG_BLACKFIN) && !defined(CONFIG_M68K)
989 reserve_legacy_video,
991 #endif /* CONFIG_DM_VIDEO */
993 #if !defined(CONFIG_BLACKFIN)
996 #ifndef CONFIG_SPL_BUILD
1001 reserve_global_data,
1007 #if defined(CONFIG_PPC) || defined(CONFIG_M68K) || defined(CONFIG_MIPS)
1010 #if defined(CONFIG_PPC) || defined(CONFIG_M68K)
1011 INIT_FUNC_WATCHDOG_RESET
1015 #ifdef CONFIG_SYS_EXTBDINFO
1018 INIT_FUNC_WATCHDOG_RESET
1021 #if defined(CONFIG_X86) || defined(CONFIG_ARC)
1024 do_elf_reloc_fixups,
1026 #if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX)
1032 void board_init_f(ulong boot_flags)
1034 #ifdef CONFIG_SYS_GENERIC_GLOBAL_DATA
1036 * For some archtectures, global data is initialized and used before
1037 * calling this function. The data should be preserved. For others,
1038 * CONFIG_SYS_GENERIC_GLOBAL_DATA should be defined and use the stack
1039 * here to host global data until relocation.
1046 * Clear global data before it is accessed at debug print
1047 * in initcall_run_list. Otherwise the debug print probably
1048 * get the wrong vaule of gd->have_console.
1053 gd->flags = boot_flags;
1054 gd->have_console = 0;
1056 if (initcall_run_list(init_sequence_f))
1059 #if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX) && \
1060 !defined(CONFIG_EFI_APP)
1061 /* NOTREACHED - jump_to_copy() does not return */
1066 #if defined(CONFIG_X86) || defined(CONFIG_ARC)
1068 * For now this code is only used on x86.
1070 * init_sequence_f_r is the list of init functions which are run when
1071 * U-Boot is executing from Flash with a semi-limited 'C' environment.
1072 * The following limitations must be considered when implementing an
1074 * - 'static' variables are read-only
1075 * - Global Data (gd->xxx) is read/write
1077 * The '_f_r' sequence must, as a minimum, copy U-Boot to RAM (if
1078 * supported). It _should_, if possible, copy global data to RAM and
1079 * initialise the CPU caches (to speed up the relocation process)
1081 * NOTE: At present only x86 uses this route, but it is intended that
1082 * all archs will move to this when generic relocation is implemented.
1084 static init_fnc_t init_sequence_f_r[] = {
1090 void board_init_f_r(void)
1092 if (initcall_run_list(init_sequence_f_r))
1096 * U-Boot has been copied into SDRAM, the BSS has been cleared etc.
1097 * Transfer execution from Flash to RAM by calculating the address
1098 * of the in-RAM copy of board_init_r() and calling it
1100 (board_init_r + gd->reloc_off)((gd_t *)gd, gd->relocaddr);
1102 /* NOTREACHED - board_init_r() does not return */
1105 #endif /* CONFIG_X86 */