wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 1 | /* |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 2 | * (C) Copyright 2003 |
| 3 | * Josef Baumgartner <josef.baumgartner@telex.de> |
| 4 | * |
| 5 | * (C) Copyright 2000-2002 |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 6 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 7 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 8 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | #include <common.h> |
| 12 | #include <watchdog.h> |
| 13 | #include <command.h> |
| 14 | #include <malloc.h> |
Jean-Christophe PLAGNIOL-VILLARD | 2a7a031 | 2009-05-16 12:14:54 +0200 | [diff] [blame] | 15 | #include <stdio_dev.h> |
Marek Vasut | 136c04a | 2012-10-03 13:28:46 +0000 | [diff] [blame] | 16 | #include <linux/compiler.h> |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 17 | |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 18 | #include <asm/immap.h> |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 19 | |
Jon Loeliger | 6b23305 | 2007-07-09 18:02:11 -0500 | [diff] [blame] | 20 | #if defined(CONFIG_CMD_IDE) |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 21 | #include <ide.h> |
| 22 | #endif |
Jon Loeliger | 6b23305 | 2007-07-09 18:02:11 -0500 | [diff] [blame] | 23 | #if defined(CONFIG_CMD_SCSI) |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 24 | #include <scsi.h> |
| 25 | #endif |
Jon Loeliger | 6b23305 | 2007-07-09 18:02:11 -0500 | [diff] [blame] | 26 | #if defined(CONFIG_CMD_KGDB) |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 27 | #include <kgdb.h> |
| 28 | #endif |
| 29 | #ifdef CONFIG_STATUS_LED |
| 30 | #include <status_led.h> |
| 31 | #endif |
| 32 | #include <net.h> |
Marcel Ziswiler | b5a7541 | 2008-05-01 09:05:26 +0200 | [diff] [blame] | 33 | #include <serial.h> |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 34 | #ifdef CONFIG_SYS_ALLOC_DPRAM |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 35 | #include <commproc.h> |
| 36 | #endif |
| 37 | #include <version.h> |
| 38 | |
stroese | cd2128e | 2004-12-16 17:55:22 +0000 | [diff] [blame] | 39 | #if defined(CONFIG_HARD_I2C) || \ |
Heiko Schocher | 479a4cf | 2013-01-29 08:53:15 +0100 | [diff] [blame] | 40 | defined(CONFIG_SYS_I2C) |
stroese | cd2128e | 2004-12-16 17:55:22 +0000 | [diff] [blame] | 41 | #include <i2c.h> |
| 42 | #endif |
| 43 | |
TsiChung Liew | 663c952 | 2008-07-23 17:53:36 -0500 | [diff] [blame] | 44 | #ifdef CONFIG_CMD_SPI |
| 45 | #include <spi.h> |
| 46 | #endif |
| 47 | |
Luigi 'Comio' Mantellini | 01db155 | 2009-10-10 12:42:21 +0200 | [diff] [blame] | 48 | #ifdef CONFIG_BITBANGMII |
| 49 | #include <miiphy.h> |
| 50 | #endif |
| 51 | |
TsiChung Liew | 2a90e89 | 2008-08-13 12:07:03 +0000 | [diff] [blame] | 52 | #include <nand.h> |
| 53 | |
Wolfgang Denk | 6405a15 | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 54 | DECLARE_GLOBAL_DATA_PTR; |
| 55 | |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 56 | static char *failed = "*** failed ***\n"; |
| 57 | |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 58 | #include <environment.h> |
| 59 | |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 60 | extern ulong __init_end; |
Simon Glass | ed70c8f | 2013-03-14 06:54:53 +0000 | [diff] [blame] | 61 | extern ulong __bss_end; |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 62 | |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 63 | #if defined(CONFIG_WATCHDOG) |
Simon Glass | 6f98490 | 2013-03-05 14:39:42 +0000 | [diff] [blame] | 64 | # undef INIT_FUNC_WATCHDOG_INIT |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 65 | # define INIT_FUNC_WATCHDOG_INIT watchdog_init, |
| 66 | # define WATCHDOG_DISABLE watchdog_disable |
| 67 | |
| 68 | extern int watchdog_init(void); |
| 69 | extern int watchdog_disable(void); |
| 70 | #else |
| 71 | # define INIT_FUNC_WATCHDOG_INIT /* undef */ |
| 72 | # define WATCHDOG_DISABLE /* undef */ |
| 73 | #endif /* CONFIG_WATCHDOG */ |
| 74 | |
| 75 | ulong monitor_flash_len; |
| 76 | |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 77 | /************************************************************************ |
| 78 | * Utilities * |
| 79 | ************************************************************************ |
| 80 | */ |
| 81 | |
| 82 | /* |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 83 | * All attempts to come up with a "common" initialization sequence |
| 84 | * that works for all boards and architectures failed: some of the |
| 85 | * requirements are just _too_ different. To get rid of the resulting |
| 86 | * mess of board dependend #ifdef'ed code we now make the whole |
| 87 | * initialization sequence configurable to the user. |
| 88 | * |
| 89 | * The requirements for any new initalization function is simple: it |
| 90 | * receives a pointer to the "global data" structure as it's only |
| 91 | * argument, and returns an integer return code, where 0 means |
| 92 | * "continue" and != 0 means "fatal error, hang the system". |
| 93 | */ |
| 94 | typedef int (init_fnc_t) (void); |
| 95 | |
| 96 | /************************************************************************ |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 97 | * Init Utilities |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 98 | ************************************************************************ |
| 99 | * Some of this code should be moved into the core functions, |
| 100 | * but let's get it working (again) first... |
| 101 | */ |
| 102 | |
| 103 | static int init_baudrate (void) |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 104 | { |
Simon Glass | 9e5689f | 2011-10-13 14:43:09 +0000 | [diff] [blame] | 105 | gd->baudrate = getenv_ulong("baudrate", 10, CONFIG_BAUDRATE); |
| 106 | return 0; |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 107 | } |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 108 | |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 109 | /***********************************************************************/ |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 110 | |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 111 | static int init_func_ram (void) |
| 112 | { |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 113 | int board_type = 0; /* use dummy arg */ |
| 114 | puts ("DRAM: "); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 115 | |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 116 | if ((gd->ram_size = initdram (board_type)) > 0) { |
| 117 | print_size (gd->ram_size, "\n"); |
| 118 | return (0); |
| 119 | } |
| 120 | puts (failed); |
| 121 | return (1); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 122 | } |
stroese | cd2128e | 2004-12-16 17:55:22 +0000 | [diff] [blame] | 123 | |
| 124 | /***********************************************************************/ |
| 125 | |
Heiko Schocher | 479a4cf | 2013-01-29 08:53:15 +0100 | [diff] [blame] | 126 | #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SYS_I2C) |
stroese | cd2128e | 2004-12-16 17:55:22 +0000 | [diff] [blame] | 127 | static int init_func_i2c (void) |
| 128 | { |
| 129 | puts ("I2C: "); |
Heiko Schocher | e0e55bc | 2012-01-16 21:12:24 +0000 | [diff] [blame] | 130 | #ifdef CONFIG_SYS_I2C |
| 131 | i2c_init_all(); |
| 132 | #else |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 133 | i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE); |
Heiko Schocher | e0e55bc | 2012-01-16 21:12:24 +0000 | [diff] [blame] | 134 | #endif |
stroese | cd2128e | 2004-12-16 17:55:22 +0000 | [diff] [blame] | 135 | puts ("ready\n"); |
| 136 | return (0); |
| 137 | } |
| 138 | #endif |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 139 | |
TsiChung Liew | 663c952 | 2008-07-23 17:53:36 -0500 | [diff] [blame] | 140 | #if defined(CONFIG_HARD_SPI) |
| 141 | static int init_func_spi (void) |
| 142 | { |
| 143 | puts ("SPI: "); |
| 144 | spi_init (); |
| 145 | puts ("ready\n"); |
| 146 | return (0); |
| 147 | } |
| 148 | #endif |
| 149 | |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 150 | /***********************************************************************/ |
| 151 | |
| 152 | /************************************************************************ |
| 153 | * Initialization sequence * |
| 154 | ************************************************************************ |
| 155 | */ |
| 156 | |
| 157 | init_fnc_t *init_sequence[] = { |
Stefan Roese | a06fd37 | 2007-08-15 14:51:27 +0200 | [diff] [blame] | 158 | get_clocks, |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 159 | env_init, |
| 160 | init_baudrate, |
| 161 | serial_init, |
| 162 | console_init_f, |
| 163 | display_options, |
| 164 | checkcpu, |
| 165 | checkboard, |
Heiko Schocher | 479a4cf | 2013-01-29 08:53:15 +0100 | [diff] [blame] | 166 | #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SYS_I2C) |
stroese | cd2128e | 2004-12-16 17:55:22 +0000 | [diff] [blame] | 167 | init_func_i2c, |
| 168 | #endif |
TsiChung Liew | 663c952 | 2008-07-23 17:53:36 -0500 | [diff] [blame] | 169 | #if defined(CONFIG_HARD_SPI) |
| 170 | init_func_spi, |
| 171 | #endif |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 172 | init_func_ram, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 173 | #if defined(CONFIG_SYS_DRAM_TEST) |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 174 | testdram, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 175 | #endif /* CONFIG_SYS_DRAM_TEST */ |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 176 | INIT_FUNC_WATCHDOG_INIT |
| 177 | NULL, /* Terminate this list */ |
| 178 | }; |
| 179 | |
| 180 | |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 181 | /************************************************************************ |
| 182 | * |
| 183 | * This is the first part of the initialization sequence that is |
| 184 | * implemented in C, but still running from ROM. |
| 185 | * |
| 186 | * The main purpose is to provide a (serial) console interface as |
| 187 | * soon as possible (so we can see any error messages), and to |
| 188 | * initialize the RAM so that we can relocate the monitor code to |
| 189 | * RAM. |
| 190 | * |
| 191 | * Be aware of the restrictions: global data is read-only, BSS is not |
| 192 | * initialized, and stack space is limited to a few kB. |
| 193 | * |
| 194 | ************************************************************************ |
| 195 | */ |
| 196 | |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 197 | void |
| 198 | board_init_f (ulong bootflag) |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 199 | { |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 200 | bd_t *bd; |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 201 | ulong len, addr, addr_sp; |
Marian Balakowicz | 3e8b1dc | 2006-05-09 11:28:36 +0200 | [diff] [blame] | 202 | ulong *paddr; |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 203 | gd_t *id; |
| 204 | init_fnc_t **init_fnc_ptr; |
| 205 | #ifdef CONFIG_PRAM |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 206 | ulong reg; |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 207 | #endif |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 208 | |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 209 | /* Pointer is writable since we allocated a register for it */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 210 | gd = (gd_t *) (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET); |
wdenk | 3337af4 | 2004-07-01 20:28:03 +0000 | [diff] [blame] | 211 | /* compiler optimization barrier needed for GCC >= 3.4 */ |
| 212 | __asm__ __volatile__("": : :"memory"); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 213 | |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 214 | /* Clear initial global data */ |
| 215 | memset ((void *) gd, 0, sizeof (gd_t)); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 216 | |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 217 | for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) { |
| 218 | if ((*init_fnc_ptr)() != 0) { |
| 219 | hang (); |
| 220 | } |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 221 | } |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 222 | |
| 223 | /* |
| 224 | * Now that we have DRAM mapped and working, we can |
| 225 | * relocate the code and continue running from DRAM. |
| 226 | * |
| 227 | * Reserve memory at end of RAM for (top down in that order): |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 228 | * - protected RAM |
| 229 | * - LCD framebuffer |
| 230 | * - monitor code |
| 231 | * - board info struct |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 232 | */ |
Simon Glass | ed70c8f | 2013-03-14 06:54:53 +0000 | [diff] [blame] | 233 | len = (ulong)&__bss_end - CONFIG_SYS_MONITOR_BASE; |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 234 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 235 | addr = CONFIG_SYS_SDRAM_BASE + gd->ram_size; |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 236 | |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 237 | #ifdef CONFIG_LOGBUFFER |
| 238 | /* reserve kernel log buffer */ |
| 239 | addr -= (LOGBUFF_RESERVE); |
| 240 | debug ("Reserving %dk for kernel logbuffer at %08lx\n", LOGBUFF_LEN, addr); |
| 241 | #endif |
| 242 | |
| 243 | #ifdef CONFIG_PRAM |
| 244 | /* |
| 245 | * reserve protected RAM |
| 246 | */ |
Simon Glass | 9e5689f | 2011-10-13 14:43:09 +0000 | [diff] [blame] | 247 | reg = getenv_ulong("pram", 10, CONFIG_PRAM); |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 248 | addr -= (reg << 10); /* size is in kB */ |
| 249 | debug ("Reserving %ldk for protected RAM at %08lx\n", reg, addr); |
| 250 | #endif /* CONFIG_PRAM */ |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 251 | |
TsiChungLiew | 99b037a | 2008-01-14 17:43:33 -0600 | [diff] [blame] | 252 | /* round down to next 4 kB limit */ |
| 253 | addr &= ~(4096 - 1); |
| 254 | debug ("Top of RAM usable for U-Boot at: %08lx\n", addr); |
| 255 | |
| 256 | #ifdef CONFIG_LCD |
Minkyu Kang | 50777c4 | 2011-04-24 22:22:34 +0000 | [diff] [blame] | 257 | #ifdef CONFIG_FB_ADDR |
| 258 | gd->fb_base = CONFIG_FB_ADDR; |
| 259 | #else |
TsiChungLiew | 99b037a | 2008-01-14 17:43:33 -0600 | [diff] [blame] | 260 | /* reserve memory for LCD display (always full pages) */ |
| 261 | addr = lcd_setmem (addr); |
| 262 | gd->fb_base = addr; |
Minkyu Kang | 50777c4 | 2011-04-24 22:22:34 +0000 | [diff] [blame] | 263 | #endif /* CONFIG_FB_ADDR */ |
TsiChungLiew | 99b037a | 2008-01-14 17:43:33 -0600 | [diff] [blame] | 264 | #endif /* CONFIG_LCD */ |
| 265 | |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 266 | /* |
| 267 | * reserve memory for U-Boot code, data & bss |
| 268 | * round down to next 4 kB limit |
| 269 | */ |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 270 | addr -= len; |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 271 | addr &= ~(4096 - 1); |
| 272 | |
| 273 | debug ("Reserving %ldk for U-Boot at: %08lx\n", len >> 10, addr); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 274 | |
| 275 | /* |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 276 | * reserve memory for malloc() arena |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 277 | */ |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 278 | addr_sp = addr - TOTAL_MALLOC_LEN; |
| 279 | debug ("Reserving %dk for malloc() at: %08lx\n", |
| 280 | TOTAL_MALLOC_LEN >> 10, addr_sp); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 281 | |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 282 | /* |
| 283 | * (permanently) allocate a Board Info struct |
| 284 | * and a permanent copy of the "global" data |
| 285 | */ |
| 286 | addr_sp -= sizeof (bd_t); |
| 287 | bd = (bd_t *) addr_sp; |
| 288 | gd->bd = bd; |
Wolfgang Denk | 509cd07 | 2008-07-14 15:06:35 +0200 | [diff] [blame] | 289 | debug ("Reserving %zu Bytes for Board Info at: %08lx\n", |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 290 | sizeof (bd_t), addr_sp); |
| 291 | addr_sp -= sizeof (gd_t); |
| 292 | id = (gd_t *) addr_sp; |
Wolfgang Denk | 509cd07 | 2008-07-14 15:06:35 +0200 | [diff] [blame] | 293 | debug ("Reserving %zu Bytes for Global Data at: %08lx\n", |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 294 | sizeof (gd_t), addr_sp); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 295 | |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 296 | /* Reserve memory for boot params. */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 297 | addr_sp -= CONFIG_SYS_BOOTPARAMS_LEN; |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 298 | bd->bi_boot_params = addr_sp; |
| 299 | debug ("Reserving %dk for boot parameters at: %08lx\n", |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 300 | CONFIG_SYS_BOOTPARAMS_LEN >> 10, addr_sp); |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 301 | |
| 302 | /* |
| 303 | * Finally, we set up a new (bigger) stack. |
| 304 | * |
| 305 | * Leave some safety gap for SP, force alignment on 16 byte boundary |
| 306 | * Clear initial stack frame |
| 307 | */ |
| 308 | addr_sp -= 16; |
| 309 | addr_sp &= ~0xF; |
Marian Balakowicz | 3e8b1dc | 2006-05-09 11:28:36 +0200 | [diff] [blame] | 310 | |
| 311 | paddr = (ulong *)addr_sp; |
| 312 | *paddr-- = 0; |
| 313 | *paddr-- = 0; |
| 314 | addr_sp = (ulong)paddr; |
Wolfgang Denk | c2c4944 | 2006-05-10 17:43:20 +0200 | [diff] [blame] | 315 | |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 316 | debug ("Stack Pointer at: %08lx\n", addr_sp); |
| 317 | |
| 318 | /* |
| 319 | * Save local variables to board info struct |
| 320 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 321 | bd->bi_memstart = CONFIG_SYS_SDRAM_BASE; /* start of DRAM memory */ |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 322 | bd->bi_memsize = gd->ram_size; /* size of DRAM memory in bytes */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 323 | #ifdef CONFIG_SYS_INIT_RAM_ADDR |
| 324 | bd->bi_sramstart = CONFIG_SYS_INIT_RAM_ADDR; /* start of SRAM memory */ |
Wolfgang Denk | 1c2e98e | 2010-10-26 13:32:32 +0200 | [diff] [blame] | 325 | bd->bi_sramsize = CONFIG_SYS_INIT_RAM_SIZE; /* size of SRAM memory */ |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 326 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 327 | bd->bi_mbar_base = CONFIG_SYS_MBAR; /* base of internal registers */ |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 328 | |
| 329 | bd->bi_bootflags = bootflag; /* boot / reboot flag (for LynxOS) */ |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 330 | |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 331 | WATCHDOG_RESET (); |
| 332 | bd->bi_intfreq = gd->cpu_clk; /* Internal Freq, in Hz */ |
| 333 | bd->bi_busfreq = gd->bus_clk; /* Bus Freq, in Hz */ |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 334 | #ifdef CONFIG_PCI |
| 335 | bd->bi_pcifreq = gd->pci_clk; /* PCI Freq in Hz */ |
| 336 | #endif |
| 337 | #ifdef CONFIG_EXTRA_CLOCK |
Simon Glass | 568a7b6 | 2012-12-13 20:49:07 +0000 | [diff] [blame] | 338 | bd->bi_inpfreq = gd->arch.inp_clk; /* input Freq in Hz */ |
| 339 | bd->bi_vcofreq = gd->arch.vco_clk; /* vco Freq in Hz */ |
| 340 | bd->bi_flbfreq = gd->arch.flb_clk; /* flexbus Freq in Hz */ |
TsiChungLiew | fc3ca3b6 | 2007-08-16 15:05:11 -0500 | [diff] [blame] | 341 | #endif |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 342 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 343 | #ifdef CONFIG_SYS_EXTBDINFO |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 344 | strncpy (bd->bi_s_version, "1.2", sizeof (bd->bi_s_version)); |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 345 | strncpy (bd->bi_r_version, U_BOOT_VERSION, sizeof (bd->bi_r_version)); |
| 346 | #endif |
| 347 | |
| 348 | WATCHDOG_RESET (); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 349 | |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 350 | #ifdef CONFIG_POST |
| 351 | post_bootmode_init(); |
| 352 | post_run (NULL, POST_ROM | post_bootmode_get(0)); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 353 | #endif |
| 354 | |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 355 | WATCHDOG_RESET(); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 356 | |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 357 | memcpy (id, (void *)gd, sizeof (gd_t)); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 358 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 359 | debug ("Start relocate of code from %08x to %08lx\n", CONFIG_SYS_MONITOR_BASE, addr); |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 360 | relocate_code (addr_sp, id, addr); |
| 361 | |
| 362 | /* NOTREACHED - jump_to_ram() does not return */ |
| 363 | } |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 364 | |
| 365 | /************************************************************************ |
| 366 | * |
| 367 | * This is the next part if the initialization sequence: we are now |
| 368 | * running from RAM and have a "normal" C environment, i. e. global |
| 369 | * data can be written, BSS has been cleared, the stack size in not |
| 370 | * that critical any more, etc. |
| 371 | * |
| 372 | ************************************************************************ |
| 373 | */ |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 374 | void board_init_r (gd_t *id, ulong dest_addr) |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 375 | { |
Marek Vasut | 136c04a | 2012-10-03 13:28:46 +0000 | [diff] [blame] | 376 | char *s __maybe_unused; |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 377 | bd_t *bd; |
| 378 | |
Jean-Christophe PLAGNIOL-VILLARD | 68a8756 | 2008-09-10 22:48:00 +0200 | [diff] [blame] | 379 | #ifndef CONFIG_ENV_IS_NOWHERE |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 380 | extern char * env_name_spec; |
| 381 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 382 | #ifndef CONFIG_SYS_NO_FLASH |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 383 | ulong flash_size; |
| 384 | #endif |
| 385 | gd = id; /* initialize RAM version of global data */ |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 386 | bd = gd->bd; |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 387 | |
| 388 | gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */ |
| 389 | |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 390 | WATCHDOG_RESET (); |
| 391 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 392 | gd->reloc_off = dest_addr - CONFIG_SYS_MONITOR_BASE; |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 393 | |
angelo | 46c1ca1 | 2012-11-23 12:23:39 +0000 | [diff] [blame] | 394 | serial_initialize(); |
| 395 | |
Jens Scharsig (BuS Elektronik) | 537f186 | 2013-01-16 08:24:10 +0100 | [diff] [blame] | 396 | debug("Now running in RAM - U-Boot at: %08lx\n", dest_addr); |
| 397 | |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 398 | monitor_flash_len = (ulong)&__init_end - dest_addr; |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 399 | |
Wolfgang Denk | d0813e5 | 2010-10-28 20:00:11 +0200 | [diff] [blame] | 400 | #if defined(CONFIG_NEEDS_MANUAL_RELOC) |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 401 | /* |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 402 | * We have to relocate the command table manually |
| 403 | */ |
Marek Vasut | 69c5e34 | 2012-10-12 10:27:04 +0000 | [diff] [blame] | 404 | fixup_cmdtable(ll_entry_start(cmd_tbl_t, cmd), |
| 405 | ll_entry_count(cmd_tbl_t, cmd)); |
Wolfgang Denk | d0813e5 | 2010-10-28 20:00:11 +0200 | [diff] [blame] | 406 | #endif /* defined(CONFIG_NEEDS_MANUAL_RELOC) */ |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 407 | |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 408 | /* there are some other pointer constants we must deal with */ |
Jean-Christophe PLAGNIOL-VILLARD | 68a8756 | 2008-09-10 22:48:00 +0200 | [diff] [blame] | 409 | #ifndef CONFIG_ENV_IS_NOWHERE |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 410 | env_name_spec += gd->reloc_off; |
| 411 | #endif |
| 412 | |
| 413 | WATCHDOG_RESET (); |
| 414 | |
| 415 | #ifdef CONFIG_LOGBUFFER |
| 416 | logbuff_init_ptrs (); |
| 417 | #endif |
| 418 | #ifdef CONFIG_POST |
| 419 | post_output_backlog (); |
| 420 | post_reloc (); |
| 421 | #endif |
| 422 | WATCHDOG_RESET(); |
| 423 | |
| 424 | #if 0 |
| 425 | /* instruction cache enabled in cpu_init_f() for faster relocation */ |
| 426 | icache_enable (); /* it's time to enable the instruction cache */ |
| 427 | #endif |
| 428 | |
| 429 | /* |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 430 | * Setup trap handlers |
| 431 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 432 | trap_init (CONFIG_SYS_SDRAM_BASE); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 433 | |
Peter Tyser | 781c9b8 | 2009-08-21 23:05:21 -0500 | [diff] [blame] | 434 | /* The Malloc area is immediately below the monitor copy in DRAM */ |
Peter Tyser | ed52770 | 2009-08-21 23:05:20 -0500 | [diff] [blame] | 435 | mem_malloc_init (CONFIG_SYS_MONITOR_BASE + gd->reloc_off - |
| 436 | TOTAL_MALLOC_LEN, TOTAL_MALLOC_LEN); |
Stefan Roese | b81464e | 2009-05-11 15:50:12 +0200 | [diff] [blame] | 437 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 438 | #if !defined(CONFIG_SYS_NO_FLASH) |
Peter Tyser | 0b5a263 | 2010-12-28 18:12:05 -0600 | [diff] [blame] | 439 | puts ("Flash: "); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 440 | |
| 441 | if ((flash_size = flash_init ()) > 0) { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 442 | # ifdef CONFIG_SYS_FLASH_CHECKSUM |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 443 | print_size (flash_size, ""); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 444 | /* |
| 445 | * Compute and print flash CRC if flashchecksum is set to 'y' |
| 446 | * |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 447 | * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 448 | */ |
Joe Hershberger | 864ec56 | 2012-12-11 22:16:22 -0600 | [diff] [blame] | 449 | if (getenv_yesno("flashchecksum") == 1) { |
TsiChung Liew | 063097d | 2009-06-12 13:03:34 +0000 | [diff] [blame] | 450 | printf (" CRC: %08X", |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 451 | crc32 (0, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 452 | (const unsigned char *) CONFIG_SYS_FLASH_BASE, |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 453 | flash_size) |
| 454 | ); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 455 | } |
| 456 | putc ('\n'); |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 457 | # else /* !CONFIG_SYS_FLASH_CHECKSUM */ |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 458 | print_size (flash_size, "\n"); |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 459 | # endif /* CONFIG_SYS_FLASH_CHECKSUM */ |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 460 | } else { |
| 461 | puts (failed); |
| 462 | hang (); |
| 463 | } |
| 464 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 465 | bd->bi_flashstart = CONFIG_SYS_FLASH_BASE; /* update start of FLASH memory */ |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 466 | bd->bi_flashsize = flash_size; /* size of FLASH memory (final value) */ |
| 467 | bd->bi_flashoffset = 0; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 468 | #else /* CONFIG_SYS_NO_FLASH */ |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 469 | bd->bi_flashsize = 0; |
| 470 | bd->bi_flashstart = 0; |
| 471 | bd->bi_flashoffset = 0; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 472 | #endif /* !CONFIG_SYS_NO_FLASH */ |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 473 | |
| 474 | WATCHDOG_RESET (); |
| 475 | |
| 476 | /* initialize higher level parts of CPU like time base and timers */ |
| 477 | cpu_init_r (); |
| 478 | |
| 479 | WATCHDOG_RESET (); |
| 480 | |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 481 | #ifdef CONFIG_SPI |
Jean-Christophe PLAGNIOL-VILLARD | e46af64 | 2008-09-05 09:19:30 +0200 | [diff] [blame] | 482 | # if !defined(CONFIG_ENV_IS_IN_EEPROM) |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 483 | spi_init_f (); |
| 484 | # endif |
| 485 | spi_init_r (); |
| 486 | #endif |
| 487 | |
Heiko Schocher | e0e55bc | 2012-01-16 21:12:24 +0000 | [diff] [blame] | 488 | #if defined(CONFIG_SYS_I2C) |
| 489 | /* Adjust I2C subsystem pointers after relocation */ |
| 490 | i2c_reloc_fixup(); |
| 491 | #endif |
| 492 | |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 493 | /* relocate environment function pointers etc. */ |
| 494 | env_relocate (); |
| 495 | |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 496 | WATCHDOG_RESET (); |
| 497 | |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 498 | #if defined(CONFIG_PCI) |
| 499 | /* |
| 500 | * Do pci configuration |
| 501 | */ |
| 502 | pci_init (); |
| 503 | #endif |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 504 | |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 505 | /** leave this here (after malloc(), environment and PCI are working) **/ |
Jean-Christophe PLAGNIOL-VILLARD | 2a7a031 | 2009-05-16 12:14:54 +0200 | [diff] [blame] | 506 | /* Initialize stdio devices */ |
| 507 | stdio_init (); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 508 | |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 509 | /* Initialize the jump table for applications */ |
| 510 | jumptable_init (); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 511 | |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 512 | /* Initialize the console (after the relocation and devices init) */ |
| 513 | console_init_r (); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 514 | |
stroese | cd2128e | 2004-12-16 17:55:22 +0000 | [diff] [blame] | 515 | #if defined(CONFIG_MISC_INIT_R) |
| 516 | /* miscellaneous platform dependent initialisations */ |
| 517 | misc_init_r (); |
| 518 | #endif |
| 519 | |
Jon Loeliger | 6b23305 | 2007-07-09 18:02:11 -0500 | [diff] [blame] | 520 | #if defined(CONFIG_CMD_KGDB) |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 521 | WATCHDOG_RESET (); |
| 522 | puts ("KGDB: "); |
| 523 | kgdb_init (); |
| 524 | #endif |
| 525 | |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 526 | debug ("U-Boot relocated to %08lx\n", dest_addr); |
| 527 | |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 528 | /* |
| 529 | * Enable Interrupts |
| 530 | */ |
| 531 | interrupt_init (); |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 532 | |
| 533 | /* Must happen after interrupts are initialized since |
| 534 | * an irq handler gets installed |
| 535 | */ |
| 536 | timer_init(); |
| 537 | |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 538 | #ifdef CONFIG_STATUS_LED |
| 539 | status_led_set (STATUS_LED_BOOT, STATUS_LED_BLINKING); |
| 540 | #endif |
| 541 | |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 542 | udelay (20); |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 543 | |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 544 | /* Insert function pointers now that we have relocated the code */ |
| 545 | |
| 546 | /* Initialize from environment */ |
Simon Glass | 9e5689f | 2011-10-13 14:43:09 +0000 | [diff] [blame] | 547 | load_addr = getenv_ulong("loadaddr", 16, load_addr); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 548 | |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 549 | WATCHDOG_RESET (); |
| 550 | |
Jon Loeliger | 6b23305 | 2007-07-09 18:02:11 -0500 | [diff] [blame] | 551 | #if defined(CONFIG_CMD_DOC) |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 552 | WATCHDOG_RESET (); |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 553 | puts ("DOC: "); |
| 554 | doc_init (); |
| 555 | #endif |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 556 | |
Jon Loeliger | 6b23305 | 2007-07-09 18:02:11 -0500 | [diff] [blame] | 557 | #if defined(CONFIG_CMD_NAND) |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 558 | WATCHDOG_RESET (); |
Markus Klotzbuecher | b643732 | 2006-04-25 17:00:33 +0200 | [diff] [blame] | 559 | puts ("NAND: "); |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 560 | nand_init(); /* go init the NAND */ |
| 561 | #endif |
| 562 | |
Luigi 'Comio' Mantellini | 01db155 | 2009-10-10 12:42:21 +0200 | [diff] [blame] | 563 | #ifdef CONFIG_BITBANGMII |
| 564 | bb_miiphy_init(); |
| 565 | #endif |
Stefan Roese | a06fd37 | 2007-08-15 14:51:27 +0200 | [diff] [blame] | 566 | #if defined(CONFIG_CMD_NET) |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 567 | WATCHDOG_RESET(); |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 568 | #if defined(FEC_ENET) |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 569 | eth_init(bd); |
| 570 | #endif |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 571 | puts ("Net: "); |
TsiChungLiew | aedd3d7 | 2007-08-15 15:39:17 -0500 | [diff] [blame] | 572 | eth_initialize (bd); |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 573 | #endif |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 574 | |
| 575 | #ifdef CONFIG_POST |
| 576 | post_run (NULL, POST_RAM | post_bootmode_get(0)); |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 577 | #endif |
| 578 | |
Stefan Roese | a06fd37 | 2007-08-15 14:51:27 +0200 | [diff] [blame] | 579 | #if defined(CONFIG_CMD_PCMCIA) \ |
| 580 | && !defined(CONFIG_CMD_IDE) |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 581 | WATCHDOG_RESET (); |
| 582 | puts ("PCMCIA:"); |
| 583 | pcmcia_init (); |
| 584 | #endif |
| 585 | |
Stefan Roese | a06fd37 | 2007-08-15 14:51:27 +0200 | [diff] [blame] | 586 | #if defined(CONFIG_CMD_IDE) |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 587 | WATCHDOG_RESET (); |
| 588 | puts ("IDE: "); |
| 589 | ide_init (); |
Stefan Roese | a06fd37 | 2007-08-15 14:51:27 +0200 | [diff] [blame] | 590 | #endif |
TsiChung Liew | f6afe72 | 2007-06-18 13:50:13 -0500 | [diff] [blame] | 591 | |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 592 | #ifdef CONFIG_LAST_STAGE_INIT |
| 593 | WATCHDOG_RESET (); |
| 594 | /* |
| 595 | * Some parts can be only initialized if all others (like |
| 596 | * Interrupts) are up and running (i.e. the PC-style ISA |
| 597 | * keyboard). |
| 598 | */ |
| 599 | last_stage_init (); |
| 600 | #endif |
| 601 | |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 602 | #if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER) |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 603 | /* |
| 604 | * Export available size of memory for Linux, |
| 605 | * taking into account the protected RAM at top of memory |
| 606 | */ |
| 607 | { |
Simon Glass | 9e5689f | 2011-10-13 14:43:09 +0000 | [diff] [blame] | 608 | ulong pram = 0; |
Simon Glass | 0fb0622 | 2012-01-05 17:54:56 +0000 | [diff] [blame] | 609 | char memsz[32]; |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 610 | |
Simon Glass | 9e5689f | 2011-10-13 14:43:09 +0000 | [diff] [blame] | 611 | #ifdef CONFIG_PRAM |
| 612 | pram = getenv_ulong("pram", 10, CONFIG_PRAM); |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 613 | #endif |
| 614 | #ifdef CONFIG_LOGBUFFER |
| 615 | /* Also take the logbuffer into account (pram is in kB) */ |
| 616 | pram += (LOGBUFF_LEN+LOGBUFF_OVERHEAD)/1024; |
| 617 | #endif |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 618 | sprintf (memsz, "%ldk", (bd->bi_memsize / 1024) - pram); |
| 619 | setenv ("mem", memsz); |
| 620 | } |
| 621 | #endif |
| 622 | |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 623 | #ifdef CONFIG_WATCHDOG |
| 624 | /* disable watchdog if environment is set */ |
| 625 | if ((s = getenv ("watchdog")) != NULL) { |
| 626 | if (strncmp (s, "off", 3) == 0) { |
| 627 | WATCHDOG_DISABLE (); |
| 628 | } |
| 629 | } |
| 630 | #endif /* CONFIG_WATCHDOG*/ |
| 631 | |
| 632 | |
wdenk | abf7a7c | 2003-12-08 01:34:36 +0000 | [diff] [blame] | 633 | /* Initialization complete - start the monitor */ |
| 634 | |
| 635 | /* main_loop() can return to retry autoboot, if so just run it again. */ |
| 636 | for (;;) { |
| 637 | WATCHDOG_RESET (); |
| 638 | main_loop (); |
| 639 | } |
| 640 | |
| 641 | /* NOTREACHED - no way out of command loop except booting */ |
| 642 | } |