]>
git.ipfire.org Git - people/ms/u-boot.git/blob - lib_blackfin/board.c
2 * U-boot - board.c First C file to be called contains init routines
4 * Copyright (c) 2005 blackfin.uclinux.org
6 * (C) Copyright 2000-2004
7 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
9 * See file CREDITS for list of people who contributed to this
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License as
14 * published by the Free Software Foundation; either version 2 of
15 * the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
34 #include <environment.h>
35 #include "blackfin_board.h"
36 #include "../drivers/smc91111.h"
38 DECLARE_GLOBAL_DATA_PTR
;
40 extern flash_info_t flash_info
[];
43 static void mem_malloc_init(void)
45 mem_malloc_start
= CFG_MALLOC_BASE
;
46 mem_malloc_end
= (CFG_MALLOC_BASE
+ CFG_MALLOC_LEN
);
47 mem_malloc_brk
= mem_malloc_start
;
48 memset((void *) mem_malloc_start
, 0,
49 mem_malloc_end
- mem_malloc_start
);
52 void *sbrk(ptrdiff_t increment
)
54 ulong old
= mem_malloc_brk
;
55 ulong
new = old
+ increment
;
57 if ((new < mem_malloc_start
) || (new > mem_malloc_end
)) {
62 return ((void *) old
);
65 static int display_banner(void)
67 sprintf(version_string
, VERSION_STRING_FORMAT
, VERSION_STRING
);
68 printf("%s\n", version_string
);
72 static void display_flash_config(ulong size
)
75 print_size(size
, "\n");
79 static int init_baudrate(void)
82 int i
= getenv_r("baudrate", tmp
, sizeof(tmp
));
83 gd
->bd
->bi_baudrate
= gd
->baudrate
= (i
> 0)
84 ? (int) simple_strtoul(tmp
, NULL
, 10)
90 static void display_global_data(void)
94 printf("--flags:%x\n", gd
->flags
);
95 printf("--board_type:%x\n", gd
->board_type
);
96 printf("--baudrate:%x\n", gd
->baudrate
);
97 printf("--have_console:%x\n", gd
->have_console
);
98 printf("--ram_size:%x\n", gd
->ram_size
);
99 printf("--reloc_off:%x\n", gd
->reloc_off
);
100 printf("--env_addr:%x\n", gd
->env_addr
);
101 printf("--env_valid:%x\n", gd
->env_valid
);
102 printf("--bd:%x %x\n", gd
->bd
, bd
);
103 printf("---bi_baudrate:%x\n", bd
->bi_baudrate
);
104 printf("---bi_ip_addr:%x\n", bd
->bi_ip_addr
);
105 printf("---bi_enetaddr:%x %x %x %x %x %x\n",
112 printf("---bi_arch_number:%x\n", bd
->bi_arch_number
);
113 printf("---bi_boot_params:%x\n", bd
->bi_boot_params
);
114 printf("---bi_memstart:%x\n", bd
->bi_memstart
);
115 printf("---bi_memsize:%x\n", bd
->bi_memsize
);
116 printf("---bi_flashstart:%x\n", bd
->bi_flashstart
);
117 printf("---bi_flashsize:%x\n", bd
->bi_flashsize
);
118 printf("---bi_flashoffset:%x\n", bd
->bi_flashoffset
);
119 printf("--jt:%x *:%x\n", gd
->jt
, *(gd
->jt
));
124 * All attempts to come up with a "common" initialization sequence
125 * that works for all boards and architectures failed: some of the
126 * requirements are just _too_ different. To get rid of the resulting
127 * mess of board dependend #ifdef'ed code we now make the whole
128 * initialization sequence configurable to the user.
130 * The requirements for any new initalization function is simple: it
131 * receives a pointer to the "global data" structure as it's only
132 * argument, and returns an integer return code, where 0 means
133 * "continue" and != 0 means "fatal error, hang the system".
136 void board_init_f(ulong bootflag
)
141 gd
= (gd_t
*) (CFG_GBL_DATA_ADDR
);
142 memset((void *) gd
, 0, sizeof(gd_t
));
144 /* Board data initialization */
145 addr
= (CFG_GBL_DATA_ADDR
+ sizeof(gd_t
));
147 /* Align to 4 byte boundary */
151 memset((void *) bd
, 0, sizeof(bd_t
));
155 env_init(); /* initialize environment */
156 init_baudrate(); /* initialze baudrate settings */
157 serial_init(); /* serial communications setup */
159 display_banner(); /* say that we are here */
161 #if defined(CONFIG_RTC_BF533) && (CONFIG_COMMANDS & CFG_CMD_DATE)
165 printf("Clock: VCO: %lu MHz, Core: %lu MHz, System: %lu MHz\n", \
166 CONFIG_VCO_HZ
/1000000, CONFIG_CCLK_HZ
/1000000, CONFIG_SCLK_HZ
/1000000);
168 print_size(initdram(0), "\n");
169 board_init_r((gd_t
*) gd
, 0x20000010);
172 void board_init_r(gd_t
* id
, ulong dest_addr
)
175 extern void malloc_bin_reloc(void);
180 gd
->flags
|= GD_FLG_RELOC
; /* tell others: relocation done */
184 /* There are some other pointer constants we must deal with */
185 /* configure available FLASH banks */
187 display_flash_config(size
);
188 flash_protect(FLAG_PROTECT_SET
, CFG_FLASH_BASE
, CFG_FLASH_BASE
+ 0x1ffff, &flash_info
[0]);
189 bd
->bi_flashstart
= CFG_FLASH_BASE
;
190 bd
->bi_flashsize
= size
;
191 bd
->bi_flashoffset
= 0;
193 bd
->bi_flashstart
= 0;
194 bd
->bi_flashsize
= 0;
195 bd
->bi_flashoffset
= 0;
197 /* initialize malloc() area */
201 /* relocate environment function pointers etc. */
204 /* board MAC address */
205 s
= getenv("ethaddr");
206 for (i
= 0; i
< 6; ++i
) {
207 bd
->bi_enetaddr
[i
] = s
? simple_strtoul(s
, &e
, 16) : 0;
209 s
= (*e
) ? e
+ 1 : e
;
213 bd
->bi_ip_addr
= getenv_IPaddr("ipaddr");
215 /* Initialize devices */
219 /* Initialize the console (after the relocation and devices init) */
222 /* Initialize from environment */
223 if ((s
= getenv("loadaddr")) != NULL
) {
224 load_addr
= simple_strtoul(s
, NULL
, 16);
226 #if (CONFIG_COMMANDS & CFG_CMD_NET)
227 if ((s
= getenv("bootfile")) != NULL
) {
228 copy_filename(BootFile
, s
, sizeof(BootFile
));
231 #if defined(CONFIG_MISC_INIT_R)
232 /* miscellaneous platform dependent initialisations */
236 #ifdef CONFIG_DRIVER_SMC91111
237 #ifdef SHARED_RESOURCES
238 /* Switch to Ethernet */
241 if ( (SMC_inw(BANK_SELECT
) & UPPER_BYTE_MASK
) != SMC_IDENT
) {
242 printf("ERROR: Can't find SMC91111 at address %x\n", SMC_BASE_ADDRESS
);
244 printf("Net: SMC91111 at 0x%08X\n", SMC_BASE_ADDRESS
);
247 #ifdef SHARED_RESOURCES
251 #ifdef CONFIG_SOFT_I2C
256 display_global_data(void);
259 /* main_loop() can return to retry autoboot, if so just run it again. */
265 #ifdef CONFIG_SOFT_I2C
266 static int init_func_i2c (void)
269 i2c_init (CFG_I2C_SPEED
, CFG_I2C_SLAVE
);
277 puts("### ERROR ### Please RESET the board ###\n");