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>
16 #include <environment.h>
20 #if defined(CONFIG_CMD_IDE)
27 /* TODO: Can we move these into arch/ headers? */
37 #if defined(CONFIG_MP) && (defined(CONFIG_MPC86xx) || defined(CONFIG_E500))
44 #include <status_led.h>
47 #include <asm/errno.h>
49 #include <asm/sections.h>
51 #include <asm/init_helpers.h>
52 #include <asm/relocate.h>
55 #include <asm/state.h>
58 #include <linux/compiler.h>
61 * Pointer to initial global data area
63 * Here we initialize it if needed.
65 #ifdef XTRN_DECLARE_GLOBAL_DATA_PTR
66 #undef XTRN_DECLARE_GLOBAL_DATA_PTR
67 #define XTRN_DECLARE_GLOBAL_DATA_PTR /* empty = allocate here */
68 DECLARE_GLOBAL_DATA_PTR = (gd_t *) (CONFIG_SYS_INIT_GD_ADDR);
70 DECLARE_GLOBAL_DATA_PTR;
74 * sjg: IMO this code should be
75 * refactored to a single function, something like:
77 * void led_set_state(enum led_colour_t colour, int on);
79 /************************************************************************
80 * Coloured LED functionality
81 ************************************************************************
82 * May be supplied by boards if desired
84 __weak void coloured_LED_init(void) {}
85 __weak void red_led_on(void) {}
86 __weak void red_led_off(void) {}
87 __weak void green_led_on(void) {}
88 __weak void green_led_off(void) {}
89 __weak void yellow_led_on(void) {}
90 __weak void yellow_led_off(void) {}
91 __weak void blue_led_on(void) {}
92 __weak void blue_led_off(void) {}
95 * Why is gd allocated a register? Prior to reloc it might be better to
96 * just pass it around to each function in this file?
98 * After reloc one could argue that it is hardly used and doesn't need
99 * to be in a register. Or if it is it should perhaps hold pointers to all
100 * global data for all modules, so that post-reloc we can avoid the massive
101 * literal pool we get on ARM. Or perhaps just encourage each module to use
106 * Could the CONFIG_SPL_BUILD infection become a flag in gd?
109 #if defined(CONFIG_WATCHDOG) || defined(CONFIG_HW_WATCHDOG)
110 static int init_func_watchdog_init(void)
112 # if defined(CONFIG_HW_WATCHDOG) && (defined(CONFIG_BLACKFIN) || \
113 defined(CONFIG_M68K) || defined(CONFIG_MICROBLAZE) || \
117 puts(" Watchdog enabled\n");
123 int init_func_watchdog_reset(void)
129 #endif /* CONFIG_WATCHDOG */
131 __weak void board_add_ram_info(int use_default)
133 /* please define platform specific board_add_ram_info() */
136 static int init_baud_rate(void)
138 gd->baudrate = getenv_ulong("baudrate", 10, CONFIG_BAUDRATE);
142 static int display_text_info(void)
144 #ifndef CONFIG_SANDBOX
145 ulong bss_start, bss_end, text_base;
147 bss_start = (ulong)&__bss_start;
148 bss_end = (ulong)&__bss_end;
150 #ifdef CONFIG_SYS_TEXT_BASE
151 text_base = CONFIG_SYS_TEXT_BASE;
153 text_base = CONFIG_SYS_MONITOR_BASE;
156 debug("U-Boot code: %08lX -> %08lX BSS: -> %08lX\n",
157 text_base, bss_start, bss_end);
160 #ifdef CONFIG_MODEM_SUPPORT
161 debug("Modem Support enabled\n");
163 #ifdef CONFIG_USE_IRQ
164 debug("IRQ Stack: %08lx\n", IRQ_STACK_START);
165 debug("FIQ Stack: %08lx\n", FIQ_STACK_START);
171 static int announce_dram_init(void)
177 #if defined(CONFIG_MIPS) || defined(CONFIG_PPC)
178 static int init_func_ram(void)
180 #ifdef CONFIG_BOARD_TYPES
181 int board_type = gd->board_type;
183 int board_type = 0; /* use dummy arg */
186 gd->ram_size = initdram(board_type);
188 if (gd->ram_size > 0)
191 puts("*** failed ***\n");
196 static int show_dram_config(void)
198 unsigned long long size;
200 #ifdef CONFIG_NR_DRAM_BANKS
203 debug("\nRAM Configuration:\n");
204 for (i = size = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
205 size += gd->bd->bi_dram[i].size;
206 debug("Bank #%d: %08lx ", i, gd->bd->bi_dram[i].start);
208 print_size(gd->bd->bi_dram[i].size, "\n");
216 print_size(size, "");
217 board_add_ram_info(0);
223 __weak void dram_init_banksize(void)
225 #if defined(CONFIG_NR_DRAM_BANKS) && defined(CONFIG_SYS_SDRAM_BASE)
226 gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
227 gd->bd->bi_dram[0].size = get_effective_memsize();
231 #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SYS_I2C)
232 static int init_func_i2c(void)
235 #ifdef CONFIG_SYS_I2C
238 i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
245 #if defined(CONFIG_HARD_SPI)
246 static int init_func_spi(void)
256 static int zero_global_data(void)
258 memset((void *)gd, '\0', sizeof(gd_t));
263 static int setup_mon_len(void)
266 gd->mon_len = (ulong)&__bss_end - (ulong)_start;
267 #elif defined(CONFIG_SANDBOX)
268 gd->mon_len = (ulong)&_end - (ulong)_init;
269 #elif defined(CONFIG_BLACKFIN) || defined(CONFIG_NIOS2)
270 gd->mon_len = CONFIG_SYS_MONITOR_LEN;
272 /* TODO: use (ulong)&__bss_end - (ulong)&__text_start; ? */
273 gd->mon_len = (ulong)&__bss_end - CONFIG_SYS_MONITOR_BASE;
278 __weak int arch_cpu_init(void)
283 __weak unsigned long get_timer_masked(void)
288 #ifdef CONFIG_OF_HOSTFILE
290 static int read_fdt_from_file(void)
292 struct sandbox_state *state = state_get_current();
293 const char *fname = state->fdt_fname;
299 blob = map_sysmem(CONFIG_SYS_FDT_LOAD_ADDR, 0);
300 if (!state->fdt_fname) {
301 err = fdt_create_empty_tree(blob, 256);
304 printf("Unable to create empty FDT: %s\n", fdt_strerror(err));
308 err = os_get_filesize(fname, &size);
310 printf("Failed to file FDT file '%s'\n", fname);
313 fd = os_open(fname, OS_O_RDONLY);
315 printf("Failed to open FDT file '%s'\n", fname);
318 if (os_read(fd, blob, size) != size) {
331 #ifdef CONFIG_SANDBOX
332 static int setup_ram_buf(void)
334 struct sandbox_state *state = state_get_current();
336 gd->arch.ram_buf = state->ram_buf;
337 gd->ram_size = state->ram_size;
343 static int setup_fdt(void)
345 #ifdef CONFIG_OF_CONTROL
346 # ifdef CONFIG_OF_EMBED
347 /* Get a pointer to the FDT */
348 gd->fdt_blob = __dtb_dt_begin;
349 # elif defined CONFIG_OF_SEPARATE
350 /* FDT is at end of image */
351 gd->fdt_blob = (ulong *)&_end;
352 # elif defined(CONFIG_OF_HOSTFILE)
353 if (read_fdt_from_file()) {
354 puts("Failed to read control FDT\n");
358 /* Allow the early environment to override the fdt address */
359 gd->fdt_blob = (void *)getenv_ulong("fdtcontroladdr", 16,
360 (uintptr_t)gd->fdt_blob);
365 /* Get the top of usable RAM */
366 __weak ulong board_get_usable_ram_top(ulong total_size)
371 static int setup_dest_addr(void)
373 debug("Monitor len: %08lX\n", gd->mon_len);
375 * Ram is setup, size stored in gd !!
377 debug("Ram size: %08lX\n", (ulong)gd->ram_size);
378 #if defined(CONFIG_SYS_MEM_TOP_HIDE)
380 * Subtract specified amount of memory to hide so that it won't
381 * get "touched" at all by U-Boot. By fixing up gd->ram_size
382 * the Linux kernel should now get passed the now "corrected"
383 * memory size and won't touch it either. This should work
384 * for arch/ppc and arch/powerpc. Only Linux board ports in
385 * arch/powerpc with bootwrapper support, that recalculate the
386 * memory size from the SDRAM controller setup will have to
389 gd->ram_size -= CONFIG_SYS_MEM_TOP_HIDE;
391 #ifdef CONFIG_SYS_SDRAM_BASE
392 gd->ram_top = CONFIG_SYS_SDRAM_BASE;
394 gd->ram_top += get_effective_memsize();
395 gd->ram_top = board_get_usable_ram_top(gd->mon_len);
396 gd->relocaddr = gd->ram_top;
397 debug("Ram top: %08lX\n", (ulong)gd->ram_top);
398 #if defined(CONFIG_MP) && (defined(CONFIG_MPC86xx) || defined(CONFIG_E500))
400 * We need to make sure the location we intend to put secondary core
401 * boot code is reserved and not used by any part of u-boot
403 if (gd->relocaddr > determine_mp_bootpg(NULL)) {
404 gd->relocaddr = determine_mp_bootpg(NULL);
405 debug("Reserving MP boot page to %08lx\n", gd->relocaddr);
411 #if defined(CONFIG_LOGBUFFER) && !defined(CONFIG_ALT_LB_ADDR)
412 static int reserve_logbuffer(void)
414 /* reserve kernel log buffer */
415 gd->relocaddr -= LOGBUFF_RESERVE;
416 debug("Reserving %dk for kernel logbuffer at %08lx\n", LOGBUFF_LEN,
423 /* reserve protected RAM */
424 static int reserve_pram(void)
428 reg = getenv_ulong("pram", 10, CONFIG_PRAM);
429 gd->relocaddr -= (reg << 10); /* size is in kB */
430 debug("Reserving %ldk for protected RAM at %08lx\n", reg,
434 #endif /* CONFIG_PRAM */
436 /* Round memory pointer down to next 4 kB limit */
437 static int reserve_round_4k(void)
439 gd->relocaddr &= ~(4096 - 1);
443 #if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF)) && \
445 static int reserve_mmu(void)
447 /* reserve TLB table */
448 gd->arch.tlb_size = PGTABLE_SIZE;
449 gd->relocaddr -= gd->arch.tlb_size;
451 /* round down to next 64 kB limit */
452 gd->relocaddr &= ~(0x10000 - 1);
454 gd->arch.tlb_addr = gd->relocaddr;
455 debug("TLB table from %08lx to %08lx\n", gd->arch.tlb_addr,
456 gd->arch.tlb_addr + gd->arch.tlb_size);
462 static int reserve_lcd(void)
464 #ifdef CONFIG_FB_ADDR
465 gd->fb_base = CONFIG_FB_ADDR;
467 /* reserve memory for LCD display (always full pages) */
468 gd->relocaddr = lcd_setmem(gd->relocaddr);
469 gd->fb_base = gd->relocaddr;
470 #endif /* CONFIG_FB_ADDR */
473 #endif /* CONFIG_LCD */
475 static int reserve_trace(void)
478 gd->relocaddr -= CONFIG_TRACE_BUFFER_SIZE;
479 gd->trace_buff = map_sysmem(gd->relocaddr, CONFIG_TRACE_BUFFER_SIZE);
480 debug("Reserving %dk for trace data at: %08lx\n",
481 CONFIG_TRACE_BUFFER_SIZE >> 10, gd->relocaddr);
487 #if defined(CONFIG_VIDEO) && (!defined(CONFIG_PPC) || defined(CONFIG_8xx)) && \
488 !defined(CONFIG_ARM) && !defined(CONFIG_X86) && \
489 !defined(CONFIG_BLACKFIN)
490 static int reserve_video(void)
492 /* reserve memory for video display (always full pages) */
493 gd->relocaddr = video_setmem(gd->relocaddr);
494 gd->fb_base = gd->relocaddr;
500 static int reserve_uboot(void)
503 * reserve memory for U-Boot code, data & bss
504 * round down to next 4 kB limit
506 gd->relocaddr -= gd->mon_len;
507 gd->relocaddr &= ~(4096 - 1);
509 /* round down to next 64 kB limit so that IVPR stays aligned */
510 gd->relocaddr &= ~(65536 - 1);
513 debug("Reserving %ldk for U-Boot at: %08lx\n", gd->mon_len >> 10,
516 gd->start_addr_sp = gd->relocaddr;
521 #ifndef CONFIG_SPL_BUILD
522 /* reserve memory for malloc() area */
523 static int reserve_malloc(void)
525 gd->start_addr_sp = gd->start_addr_sp - TOTAL_MALLOC_LEN;
526 debug("Reserving %dk for malloc() at: %08lx\n",
527 TOTAL_MALLOC_LEN >> 10, gd->start_addr_sp);
531 /* (permanently) allocate a Board Info struct */
532 static int reserve_board(void)
535 gd->start_addr_sp -= sizeof(bd_t);
536 gd->bd = (bd_t *)map_sysmem(gd->start_addr_sp, sizeof(bd_t));
537 memset(gd->bd, '\0', sizeof(bd_t));
538 debug("Reserving %zu Bytes for Board Info at: %08lx\n",
539 sizeof(bd_t), gd->start_addr_sp);
545 static int setup_machine(void)
547 #ifdef CONFIG_MACH_TYPE
548 gd->bd->bi_arch_number = CONFIG_MACH_TYPE; /* board id for Linux */
553 static int reserve_global_data(void)
555 gd->start_addr_sp -= sizeof(gd_t);
556 gd->new_gd = (gd_t *)map_sysmem(gd->start_addr_sp, sizeof(gd_t));
557 debug("Reserving %zu Bytes for Global Data at: %08lx\n",
558 sizeof(gd_t), gd->start_addr_sp);
562 static int reserve_fdt(void)
565 * If the device tree is sitting immediate above our image then we
566 * must relocate it. If it is embedded in the data section, then it
567 * will be relocated with other data.
570 gd->fdt_size = ALIGN(fdt_totalsize(gd->fdt_blob) + 0x1000, 32);
572 gd->start_addr_sp -= gd->fdt_size;
573 gd->new_fdt = map_sysmem(gd->start_addr_sp, gd->fdt_size);
574 debug("Reserving %lu Bytes for FDT at: %08lx\n",
575 gd->fdt_size, gd->start_addr_sp);
581 static int reserve_stacks(void)
583 #ifdef CONFIG_SPL_BUILD
585 gd->start_addr_sp -= 128; /* leave 32 words for abort-stack */
586 gd->irq_sp = gd->start_addr_sp;
593 /* setup stack pointer for exceptions */
594 gd->start_addr_sp -= 16;
595 gd->start_addr_sp &= ~0xf;
596 gd->irq_sp = gd->start_addr_sp;
599 * Handle architecture-specific things here
600 * TODO(sjg@chromium.org): Perhaps create arch_reserve_stack()
601 * to handle this and put in arch/xxx/lib/stack.c
603 # if defined(CONFIG_ARM) && !defined(CONFIG_ARM64)
604 # ifdef CONFIG_USE_IRQ
605 gd->start_addr_sp -= (CONFIG_STACKSIZE_IRQ + CONFIG_STACKSIZE_FIQ);
606 debug("Reserving %zu Bytes for IRQ stack at: %08lx\n",
607 CONFIG_STACKSIZE_IRQ + CONFIG_STACKSIZE_FIQ, gd->start_addr_sp);
609 /* 8-byte alignment for ARM ABI compliance */
610 gd->start_addr_sp &= ~0x07;
612 /* leave 3 words for abort-stack, plus 1 for alignment */
613 gd->start_addr_sp -= 16;
614 # elif defined(CONFIG_PPC)
615 /* Clear initial stack frame */
616 s = (ulong *) gd->start_addr_sp;
617 *s = 0; /* Terminate back chain */
618 *++s = 0; /* NULL return address */
619 # endif /* Architecture specific code */
625 static int display_new_sp(void)
627 debug("New Stack Pointer is: %08lx\n", gd->start_addr_sp);
633 static int setup_board_part1(void)
638 * Save local variables to board info struct
641 bd->bi_memstart = CONFIG_SYS_SDRAM_BASE; /* start of memory */
642 bd->bi_memsize = gd->ram_size; /* size in bytes */
644 #ifdef CONFIG_SYS_SRAM_BASE
645 bd->bi_sramstart = CONFIG_SYS_SRAM_BASE; /* start of SRAM */
646 bd->bi_sramsize = CONFIG_SYS_SRAM_SIZE; /* size of SRAM */
649 #if defined(CONFIG_8xx) || defined(CONFIG_MPC8260) || defined(CONFIG_5xx) || \
650 defined(CONFIG_E500) || defined(CONFIG_MPC86xx)
651 bd->bi_immr_base = CONFIG_SYS_IMMR; /* base of IMMR register */
653 #if defined(CONFIG_MPC5xxx)
654 bd->bi_mbar_base = CONFIG_SYS_MBAR; /* base of internal registers */
656 #if defined(CONFIG_MPC83xx)
657 bd->bi_immrbar = CONFIG_SYS_IMMR;
663 static int setup_board_part2(void)
667 bd->bi_intfreq = gd->cpu_clk; /* Internal Freq, in Hz */
668 bd->bi_busfreq = gd->bus_clk; /* Bus Freq, in Hz */
669 #if defined(CONFIG_CPM2)
670 bd->bi_cpmfreq = gd->arch.cpm_clk;
671 bd->bi_brgfreq = gd->arch.brg_clk;
672 bd->bi_sccfreq = gd->arch.scc_clk;
673 bd->bi_vco = gd->arch.vco_out;
674 #endif /* CONFIG_CPM2 */
675 #if defined(CONFIG_MPC512X)
676 bd->bi_ipsfreq = gd->arch.ips_clk;
677 #endif /* CONFIG_MPC512X */
678 #if defined(CONFIG_MPC5xxx)
679 bd->bi_ipbfreq = gd->arch.ipb_clk;
680 bd->bi_pcifreq = gd->pci_clk;
681 #endif /* CONFIG_MPC5xxx */
687 #ifdef CONFIG_SYS_EXTBDINFO
688 static int setup_board_extra(void)
692 strncpy((char *) bd->bi_s_version, "1.2", sizeof(bd->bi_s_version));
693 strncpy((char *) bd->bi_r_version, U_BOOT_VERSION,
694 sizeof(bd->bi_r_version));
696 bd->bi_procfreq = gd->cpu_clk; /* Processor Speed, In Hz */
697 bd->bi_plb_busfreq = gd->bus_clk;
698 #if defined(CONFIG_405GP) || defined(CONFIG_405EP) || \
699 defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
700 defined(CONFIG_440EPX) || defined(CONFIG_440GRX)
701 bd->bi_pci_busfreq = get_PCI_freq();
702 bd->bi_opbfreq = get_OPB_freq();
703 #elif defined(CONFIG_XILINX_405)
704 bd->bi_pci_busfreq = get_PCI_freq();
712 static int init_post(void)
714 post_bootmode_init();
715 post_run(NULL, POST_ROM | post_bootmode_get(0));
721 static int setup_dram_config(void)
723 /* Ram is board specific, so move it to board code ... */
724 dram_init_banksize();
729 static int reloc_fdt(void)
732 memcpy(gd->new_fdt, gd->fdt_blob, gd->fdt_size);
733 gd->fdt_blob = gd->new_fdt;
739 static int setup_reloc(void)
741 #ifdef CONFIG_SYS_TEXT_BASE
743 gd->reloc_off = gd->relocaddr - CONFIG_SYS_TEXT_BASE;
745 gd->reloc_off = gd->relocaddr - (unsigned long)__image_copy_start;
748 memcpy(gd->new_gd, (char *)gd, sizeof(gd_t));
750 debug("Relocation Offset is: %08lx\n", gd->reloc_off);
751 debug("Relocating to %08lx, new gd at %08lx, sp at %08lx\n",
752 gd->relocaddr, (ulong)map_to_sysmem(gd->new_gd),
758 /* ARM calls relocate_code from its crt0.S */
759 #if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX)
761 static int jump_to_copy(void)
764 * x86 is special, but in a nice way. It uses a trampoline which
765 * enables the dcache if possible.
767 * For now, other archs use relocate_code(), which is implemented
768 * similarly for all archs. When we do generic relocation, hopefully
769 * we can make all archs enable the dcache prior to relocation.
773 * SDRAM and console are now initialised. The final stack can now
774 * be setup in SDRAM. Code execution will continue in Flash, but
775 * with the stack in SDRAM and Global Data in temporary memory
778 board_init_f_r_trampoline(gd->start_addr_sp);
780 relocate_code(gd->start_addr_sp, gd->new_gd, gd->relocaddr);
787 /* Record the board_init_f() bootstage (after arch_cpu_init()) */
788 static int mark_bootstage(void)
790 bootstage_mark_name(BOOTSTAGE_ID_START_UBOOT_F, "board_init_f");
795 static int initf_malloc(void)
797 #ifdef CONFIG_SYS_MALLOC_F_LEN
798 assert(gd->malloc_base); /* Set up by crt0.S */
799 gd->malloc_limit = gd->malloc_base + CONFIG_SYS_MALLOC_F_LEN;
806 static int initf_dm(void)
808 #if defined(CONFIG_DM) && defined(CONFIG_SYS_MALLOC_F_LEN)
811 ret = dm_init_and_scan(true);
819 /* Architecture-specific memory reservation */
820 __weak int reserve_arch(void)
825 static init_fnc_t init_sequence_f[] = {
826 #ifdef CONFIG_SANDBOX
835 #if defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx)
836 /* TODO: can this go into arch_cpu_init()? */
839 arch_cpu_init, /* basic arch cpu dependent setup */
841 #ifdef CONFIG_OF_CONTROL
845 #if defined(CONFIG_BOARD_EARLY_INIT_F)
848 /* TODO: can any of this go into arch_cpu_init()? */
849 #if defined(CONFIG_PPC) && !defined(CONFIG_8xx_CPUCLK_DEFAULT)
850 get_clocks, /* get CPU and bus clocks (etc.) */
851 #if defined(CONFIG_TQM8xxL) && !defined(CONFIG_TQM866M) \
852 && !defined(CONFIG_TQM885D)
853 adjust_sdram_tbs_8xx,
855 /* TODO: can we rename this to timer_init()? */
858 #if defined(CONFIG_ARM) || defined(CONFIG_MIPS) || defined(CONFIG_BLACKFIN)
859 timer_init, /* initialize timer */
861 #ifdef CONFIG_SYS_ALLOC_DPRAM
862 #if !defined(CONFIG_CPM2)
866 #if defined(CONFIG_BOARD_POSTCLK_INIT)
869 #ifdef CONFIG_FSL_ESDHC
872 env_init, /* initialize environment */
873 #if defined(CONFIG_8xx_CPUCLK_DEFAULT)
874 /* get CPU and bus clocks according to the environment variable */
876 /* adjust sdram refresh rate according to the new clock */
880 init_baud_rate, /* initialze baudrate settings */
881 serial_init, /* serial communications setup */
882 console_init_f, /* stage 1 init of console */
883 #ifdef CONFIG_SANDBOX
884 sandbox_early_getopt_check,
886 #ifdef CONFIG_OF_CONTROL
889 display_options, /* say that we are here */
890 display_text_info, /* show debugging info if required */
891 #if defined(CONFIG_MPC8260)
894 #endif /* CONFIG_MPC8260 */
895 #if defined(CONFIG_MPC83xx)
901 print_cpuinfo, /* display cpu info (and speed) */
902 #if defined(CONFIG_MPC5xxx)
904 #endif /* CONFIG_MPC5xxx */
905 #if defined(CONFIG_DISPLAY_BOARDINFO)
908 INIT_FUNC_WATCHDOG_INIT
909 #if defined(CONFIG_MISC_INIT_F)
912 INIT_FUNC_WATCHDOG_RESET
913 #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SYS_I2C)
916 #if defined(CONFIG_HARD_SPI)
920 /* TODO: unify all these dram functions? */
921 #if defined(CONFIG_ARM) || defined(CONFIG_X86)
922 dram_init, /* configure available RAM banks */
924 #if defined(CONFIG_MIPS) || defined(CONFIG_PPC)
930 INIT_FUNC_WATCHDOG_RESET
931 #if defined(CONFIG_SYS_DRAM_TEST)
933 #endif /* CONFIG_SYS_DRAM_TEST */
934 INIT_FUNC_WATCHDOG_RESET
939 INIT_FUNC_WATCHDOG_RESET
941 * Now that we have DRAM mapped and working, we can
942 * relocate the code and continue running from DRAM.
944 * Reserve memory at end of RAM for (top down in that order):
945 * - area that won't get touched by U-Boot and Linux (optional)
946 * - kernel log buffer
950 * - board info struct
953 #if defined(CONFIG_BLACKFIN) || defined(CONFIG_NIOS2)
954 /* Blackfin u-boot monitor should be on top of the ram */
957 #if defined(CONFIG_LOGBUFFER) && !defined(CONFIG_ALT_LB_ADDR)
964 #if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF)) && \
972 /* TODO: Why the dependency on CONFIG_8xx? */
973 #if defined(CONFIG_VIDEO) && (!defined(CONFIG_PPC) || defined(CONFIG_8xx)) && \
974 !defined(CONFIG_ARM) && !defined(CONFIG_X86) && \
975 !defined(CONFIG_BLACKFIN)
978 #if !defined(CONFIG_BLACKFIN) && !defined(CONFIG_NIOS2)
981 #ifndef CONFIG_SPL_BUILD
994 INIT_FUNC_WATCHDOG_RESET
998 #ifdef CONFIG_SYS_EXTBDINFO
1001 INIT_FUNC_WATCHDOG_RESET
1007 do_elf_reloc_fixups,
1009 #if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX)
1015 void board_init_f(ulong boot_flags)
1017 #ifdef CONFIG_SYS_GENERIC_GLOBAL_DATA
1019 * For some archtectures, global data is initialized and used before
1020 * calling this function. The data should be preserved. For others,
1021 * CONFIG_SYS_GENERIC_GLOBAL_DATA should be defined and use the stack
1022 * here to host global data until relocation.
1029 * Clear global data before it is accessed at debug print
1030 * in initcall_run_list. Otherwise the debug print probably
1031 * get the wrong vaule of gd->have_console.
1036 gd->flags = boot_flags;
1037 gd->have_console = 0;
1039 if (initcall_run_list(init_sequence_f))
1042 #if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX)
1043 /* NOTREACHED - jump_to_copy() does not return */
1050 * For now this code is only used on x86.
1052 * init_sequence_f_r is the list of init functions which are run when
1053 * U-Boot is executing from Flash with a semi-limited 'C' environment.
1054 * The following limitations must be considered when implementing an
1056 * - 'static' variables are read-only
1057 * - Global Data (gd->xxx) is read/write
1059 * The '_f_r' sequence must, as a minimum, copy U-Boot to RAM (if
1060 * supported). It _should_, if possible, copy global data to RAM and
1061 * initialise the CPU caches (to speed up the relocation process)
1063 * NOTE: At present only x86 uses this route, but it is intended that
1064 * all archs will move to this when generic relocation is implemented.
1066 static init_fnc_t init_sequence_f_r[] = {
1072 void board_init_f_r(void)
1074 if (initcall_run_list(init_sequence_f_r))
1078 * U-Boot has been copied into SDRAM, the BSS has been cleared etc.
1079 * Transfer execution from Flash to RAM by calculating the address
1080 * of the in-RAM copy of board_init_r() and calling it
1082 (board_init_r + gd->reloc_off)(gd, gd->relocaddr);
1084 /* NOTREACHED - board_init_r() does not return */
1087 #endif /* CONFIG_X86 */