blob: 87c7263fcb5094824e141cf737a5deac507744d5 [file] [log] [blame]
Graeme Russa875dda2011-12-23 16:51:29 +11001/*
2 * (C) Copyright 2011
3 * Graeme Russ, <graeme.russ@gmail.com>
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
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.
12 *
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.
17 *
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,
21 * MA 02111-1307 USA
22 */
23#include <common.h>
24#include <command.h>
25#include <stdio_dev.h>
26#include <version.h>
27#include <malloc.h>
28#include <net.h>
29#include <ide.h>
30#include <serial.h>
31#include <status_led.h>
Graeme Russ3fb4f9e2011-12-23 21:14:22 +110032#include <asm/processor.h>
Graeme Russa875dda2011-12-23 16:51:29 +110033#include <asm/u-boot-x86.h>
34
35#include <asm/init_helpers.h>
36
37DECLARE_GLOBAL_DATA_PTR;
38
39/************************************************************************
40 * Init Utilities *
41 ************************************************************************
42 * Some of this code should be moved into the core functions,
43 * or dropped completely,
44 * but let's get it working (again) first...
45 */
46
47int display_banner(void)
48{
49 printf("\n\n%s\n\n", version_string);
50
51 return 0;
52}
53
54int display_dram_config(void)
55{
56 int i;
57
58 puts("DRAM Configuration:\n");
59
60 for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
61 printf("Bank #%d: %08lx ", i, gd->bd->bi_dram[i].start);
62 print_size(gd->bd->bi_dram[i].size, "\n");
63 }
64
65 return 0;
66}
67
68int init_baudrate_f(void)
69{
70 gd->baudrate = getenv_ulong("baudrate", 10, CONFIG_BAUDRATE);
71 return 0;
72}
73
Graeme Russ3fb4f9e2011-12-23 21:14:22 +110074int calculate_relocation_address(void)
75{
76 ulong text_start = (ulong)&__text_start;
77 ulong bss_end = (ulong)&__bss_end;
78 ulong dest_addr;
79
80 /*
81 * NOTE: All destination address are rounded down to 16-byte
82 * boundary to satisfy various worst-case alignment
83 * requirements
84 */
85
Graeme Russ007818a2012-11-27 15:38:36 +000086 /* Stack is at top of available memory */
Graeme Russ3fb4f9e2011-12-23 21:14:22 +110087 dest_addr = gd->ram_size;
Graeme Russ3fb4f9e2011-12-23 21:14:22 +110088 gd->start_addr_sp = dest_addr;
89
90 /* U-Boot is below the stack */
91 dest_addr -= CONFIG_SYS_STACK_SIZE;
92 dest_addr -= (bss_end - text_start);
93 dest_addr &= ~15;
94 gd->relocaddr = dest_addr;
95 gd->reloc_off = (dest_addr - text_start);
96
97 return 0;
98}
99
Graeme Russ3fb4f9e2011-12-23 21:14:22 +1100100int init_cache_f_r(void)
101{
102 /* Initialise the CPU cache(s) */
103 return init_cache();
104}
105
106int set_reloc_flag_r(void)
107{
108 gd->flags = GD_FLG_RELOC;
109
110 return 0;
111}
112
Graeme Russa875dda2011-12-23 16:51:29 +1100113int mem_malloc_init_r(void)
114{
115 mem_malloc_init(((gd->relocaddr - CONFIG_SYS_MALLOC_LEN)+3)&~3,
116 CONFIG_SYS_MALLOC_LEN);
117
118 return 0;
119}
120
121bd_t bd_data;
122
123int init_bd_struct_r(void)
124{
125 gd->bd = &bd_data;
126 memset(gd->bd, 0, sizeof(bd_t));
127
128 return 0;
129}
130
131#ifndef CONFIG_SYS_NO_FLASH
132int flash_init_r(void)
133{
134 ulong size;
135
136 puts("Flash: ");
137
138 /* configure available FLASH banks */
139 size = flash_init();
140
141 print_size(size, "\n");
142
143 return 0;
144}
145#endif
146
Graeme Russa875dda2011-12-23 16:51:29 +1100147#ifdef CONFIG_STATUS_LED
148int status_led_set_r(void)
149{
150 status_led_set(STATUS_LED_BOOT, STATUS_LED_BLINKING);
151
152 return 0;
153}
154#endif
155
Graeme Russa875dda2011-12-23 16:51:29 +1100156int set_load_addr_r(void)
157{
158 /* Initialize from environment */
159 load_addr = getenv_ulong("loadaddr", 16, load_addr);
160
161 return 0;
162}