3 * Graeme Russ, <graeme.russ@gmail.com>
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
26 #include <stdio_dev.h>
33 #include <status_led.h>
34 #include <asm/processor.h>
35 #include <asm/u-boot-x86.h>
36 #include <linux/compiler.h>
38 #include <asm/init_helpers.h>
40 DECLARE_GLOBAL_DATA_PTR;
42 /************************************************************************
44 ************************************************************************
45 * Some of this code should be moved into the core functions,
46 * or dropped completely,
47 * but let's get it working (again) first...
50 int display_banner(void)
52 printf("\n\n%s\n\n", version_string);
57 int display_dram_config(void)
61 puts("DRAM Configuration:\n");
63 for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
64 printf("Bank #%d: %08lx ", i, gd->bd->bi_dram[i].start);
65 print_size(gd->bd->bi_dram[i].size, "\n");
71 int init_baudrate_f(void)
73 gd->baudrate = getenv_ulong("baudrate", 10, CONFIG_BAUDRATE);
77 /* Get the top of usable RAM */
78 __weak ulong board_get_usable_ram_top(ulong total_size)
83 int calculate_relocation_address(void)
85 const ulong uboot_size = (uintptr_t)&__bss_end -
86 (uintptr_t)&__text_start;
91 #if defined(CONFIG_OF_SEPARATE) && defined(CONFIG_OF_CONTROL)
93 fdt_size = ALIGN(fdt_totalsize(gd->fdt_blob) + 0x1000, 32);
95 total_size = ALIGN(uboot_size, 1 << 12) + CONFIG_SYS_MALLOC_LEN +
96 CONFIG_SYS_STACK_SIZE + fdt_size;
98 dest_addr = board_get_usable_ram_top(total_size);
100 * NOTE: All destination address are rounded down to 16-byte
101 * boundary to satisfy various worst-case alignment
106 #if defined(CONFIG_OF_SEPARATE) && defined(CONFIG_OF_CONTROL)
108 * If the device tree is sitting immediate above our image then we
109 * must relocate it. If it is embedded in the data section, then it
110 * will be relocated with other data.
113 dest_addr -= fdt_size;
114 gd->arch.new_fdt = (void *)dest_addr;
118 /* U-Boot is below the FDT */
119 dest_addr -= uboot_size;
120 dest_addr &= ~((1 << 12) - 1);
121 gd->relocaddr = dest_addr;
122 gd->reloc_off = dest_addr - (uintptr_t)&__text_start;
124 /* Stack is at the bottom, so it can grow down */
125 gd->start_addr_sp = dest_addr - CONFIG_SYS_MALLOC_LEN;
130 int init_cache_f_r(void)
132 /* Initialise the CPU cache(s) */
136 int set_reloc_flag_r(void)
138 gd->flags = GD_FLG_RELOC;
143 int mem_malloc_init_r(void)
145 mem_malloc_init(((gd->relocaddr - CONFIG_SYS_MALLOC_LEN)+3)&~3,
146 CONFIG_SYS_MALLOC_LEN);
153 int init_bd_struct_r(void)
156 memset(gd->bd, 0, sizeof(bd_t));
161 #ifndef CONFIG_SYS_NO_FLASH
162 int flash_init_r(void)
168 /* configure available FLASH banks */
171 print_size(size, "\n");
177 #ifdef CONFIG_STATUS_LED
178 int status_led_set_r(void)
180 status_led_set(STATUS_LED_BOOT, STATUS_LED_BLINKING);
186 int set_load_addr_r(void)
188 /* Initialize from environment */
189 load_addr = getenv_ulong("loadaddr", 16, load_addr);
194 int init_func_spi(void)
202 #ifdef CONFIG_OF_CONTROL
205 #ifdef CONFIG_OF_EMBED
206 /* Get a pointer to the FDT */
207 gd->fdt_blob = _binary_dt_dtb_start;
208 #elif defined CONFIG_OF_SEPARATE
209 /* FDT is at end of image */
210 gd->fdt_blob = (ulong *)&_end;
212 /* Allow the early environment to override the fdt address */
213 gd->fdt_blob = (void *)getenv_ulong("fdtcontroladdr", 16,
214 (uintptr_t)gd->fdt_blob);
219 int prepare_fdt(void)
221 /* For now, put this check after the console is ready */
222 if (fdtdec_prepare_fdt()) {
223 panic("** CONFIG_OF_CONTROL defined but no FDT - please see "
224 "doc/README.fdt-control");