2 * Copyright (C) 2007,2008
3 * Nobuhiro Iwamatsu <iwamatsu@nigauri.org>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of
8 * the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
27 #include <environment.h>
29 extern void malloc_bin_reloc (void);
30 extern int cpu_init(void);
31 extern int board_init(void);
32 extern int dram_init(void);
33 extern int watchdog_init(void);
34 extern int timer_init(void);
36 const char version_string[] = U_BOOT_VERSION" (" __DATE__ " - " __TIME__ ")";
38 unsigned long monitor_flash_len = CFG_MONITOR_LEN;
40 static unsigned long mem_malloc_start;
41 static unsigned long mem_malloc_end;
42 static unsigned long mem_malloc_brk;
44 static void mem_malloc_init (void)
47 mem_malloc_start = (TEXT_BASE - CFG_GBL_DATA_SIZE - CFG_MALLOC_LEN);
48 mem_malloc_end = (mem_malloc_start + CFG_MALLOC_LEN - 16);
49 mem_malloc_brk = mem_malloc_start;
50 memset ((void *) mem_malloc_start, 0,
51 (mem_malloc_end - mem_malloc_start));
54 void *sbrk (ptrdiff_t increment)
56 unsigned long old = mem_malloc_brk;
57 unsigned long new = old + increment;
59 if ((new < mem_malloc_start) ||
60 (new > mem_malloc_end)) {
68 static int sh_flash_init(void)
70 DECLARE_GLOBAL_DATA_PTR;
72 gd->bd->bi_flashsize = flash_init();
73 printf("FLASH: %dMB\n", gd->bd->bi_flashsize / (1024*1024));
78 #if defined(CONFIG_CMD_NAND)
80 static int sh_nand_init(void)
83 nand_init(); /* go init the NAND */
86 #endif /* CONFIG_CMD_NAND */
88 #if defined(CONFIG_CMD_IDE)
90 static int sh_marubun_init(void)
96 #endif /* (CONFIG_CMD_IDE) */
98 #if defined(CONFIG_PCI)
99 static int sh_pci_init(void)
104 #endif /* CONFIG_PCI */
106 static int sh_mem_env_init(void)
115 static int sh_net_init(void)
117 DECLARE_GLOBAL_DATA_PTR;
121 gd->bd->bi_ip_addr = getenv_IPaddr("ipaddr");
122 s = getenv("ethaddr");
123 for (i = 0; i < 6; ++i) {
124 gd->bd->bi_enetaddr[i] = s ? simple_strtoul(s, &e, 16) : 0;
125 if (s) s = (*e) ? e + 1 : e;
131 typedef int (init_fnc_t) (void);
133 init_fnc_t *init_sequence[] =
135 cpu_init, /* basic cpu dependent setup */
136 board_init, /* basic board dependent setup */
137 interrupt_init, /* set up exceptions */
138 env_init, /* event init */
139 serial_init, /* SCIF init */
140 watchdog_init, /* watchdog init */
144 checkboard, /* Check support board */
145 dram_init, /* SDRAM init */
146 timer_init, /* SuperH Timer (TCNT0 only) init */
147 sh_flash_init, /* Flash memory(NOR) init*/
149 #if defined(CONFIG_CMD_NAND)
150 sh_nand_init, /* Flash memory (NAND) init */
152 #if defined(CONFIG_PCI)
153 sh_pci_init, /* PCI Init */
158 #ifdef BOARD_LATE_INIT
161 #if defined(CONFIG_CMD_NET)
162 sh_net_init, /* SH specific eth init */
164 NULL /* Terminate this list */
167 void sh_generic_init (void)
169 DECLARE_GLOBAL_DATA_PTR;
172 init_fnc_t **init_fnc_ptr;
176 memset (gd, 0, CFG_GBL_DATA_SIZE);
178 gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */
180 gd->bd = (bd_t *) (gd + 1); /* At end of global data */
181 gd->baudrate = CONFIG_BAUDRATE;
183 gd->cpu_clk = CONFIG_SYS_CLK_FREQ;
186 bd->bi_memstart = CFG_SDRAM_BASE;
187 bd->bi_memsize = CFG_SDRAM_SIZE;
188 bd->bi_flashstart = CFG_FLASH_BASE;
189 #if defined(CFG_SRAM_BASE) && defined(CFG_SRAM_SIZE)
190 bd->bi_sramstart= CFG_SRAM_BASE;
191 bd->bi_sramsize = CFG_SRAM_SIZE;
193 bd->bi_baudrate = CONFIG_BAUDRATE;
195 for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr , i++) {
196 if ((*init_fnc_ptr) () != 0) {
201 #if defined(CONFIG_CMD_NET)
203 eth_initialize(gd->bd);
205 if ((s = getenv ("bootfile")) != NULL) {
206 copy_filename (BootFile, s, sizeof (BootFile));
208 #endif /* CONFIG_CMD_NET */
215 /***********************************************************************/
219 puts ("Board ERROR\n");