wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2003 |
| 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
| 9 | #include <command.h> |
| 10 | #include <malloc.h> |
Joe Hershberger | 7fe0ac8 | 2012-12-11 17:52:50 +0000 | [diff] [blame] | 11 | #include <serial.h> |
Jean-Christophe PLAGNIOL-VILLARD | 2a7a031 | 2009-05-16 12:14:54 +0200 | [diff] [blame] | 12 | #include <stdio_dev.h> |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 13 | #include <version.h> |
| 14 | #include <net.h> |
| 15 | #include <environment.h> |
Jason McMullan | 7d32b00 | 2008-05-30 00:53:37 +0900 | [diff] [blame] | 16 | #include <nand.h> |
Stefan Roese | 1af2a0d | 2008-11-12 13:18:19 +0100 | [diff] [blame] | 17 | #include <onenand_uboot.h> |
Jason McMullan | 733ad78 | 2008-05-30 00:53:37 +0900 | [diff] [blame] | 18 | #include <spi.h> |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 19 | |
Luigi 'Comio' Mantellini | 01db155 | 2009-10-10 12:42:21 +0200 | [diff] [blame] | 20 | #ifdef CONFIG_BITBANGMII |
| 21 | #include <miiphy.h> |
| 22 | #endif |
| 23 | |
Wolfgang Denk | 117b0b1 | 2005-12-01 02:15:07 +0100 | [diff] [blame] | 24 | DECLARE_GLOBAL_DATA_PTR; |
| 25 | |
wdenk | b9a83a9 | 2003-05-30 12:48:29 +0000 | [diff] [blame] | 26 | ulong monitor_flash_len; |
| 27 | |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 28 | static char *failed = "*** failed ***\n"; |
| 29 | |
| 30 | /* |
Jean-Christophe PLAGNIOL-VILLARD | 089dbb7 | 2007-11-13 09:11:05 +0100 | [diff] [blame] | 31 | * mips_io_port_base is the begin of the address space to which x86 style |
| 32 | * I/O ports are mapped. |
| 33 | */ |
Daniel Schwierzeck | 689eecd | 2012-12-12 13:13:48 +0100 | [diff] [blame] | 34 | const unsigned long mips_io_port_base = -1; |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 35 | |
Stefan Roese | 2b1c815 | 2008-11-12 13:18:02 +0100 | [diff] [blame] | 36 | int __board_early_init_f(void) |
| 37 | { |
| 38 | /* |
| 39 | * Nothing to do in this dummy implementation |
| 40 | */ |
| 41 | return 0; |
| 42 | } |
Wolfgang Denk | 11f9884 | 2011-12-08 02:01:49 +0000 | [diff] [blame] | 43 | int board_early_init_f(void) |
| 44 | __attribute__((weak, alias("__board_early_init_f"))); |
Stefan Roese | 2b1c815 | 2008-11-12 13:18:02 +0100 | [diff] [blame] | 45 | |
Wolfgang Denk | 11f9884 | 2011-12-08 02:01:49 +0000 | [diff] [blame] | 46 | static int init_func_ram(void) |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 47 | { |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 48 | #ifdef CONFIG_BOARD_TYPES |
| 49 | int board_type = gd->board_type; |
| 50 | #else |
| 51 | int board_type = 0; /* use dummy arg */ |
| 52 | #endif |
Wolfgang Denk | 11f9884 | 2011-12-08 02:01:49 +0000 | [diff] [blame] | 53 | puts("DRAM: "); |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 54 | |
Wolfgang Denk | 11f9884 | 2011-12-08 02:01:49 +0000 | [diff] [blame] | 55 | gd->ram_size = initdram(board_type); |
| 56 | if (gd->ram_size > 0) { |
| 57 | print_size(gd->ram_size, "\n"); |
| 58 | return 0; |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 59 | } |
Wolfgang Denk | 11f9884 | 2011-12-08 02:01:49 +0000 | [diff] [blame] | 60 | puts(failed); |
| 61 | return 1; |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | static int display_banner(void) |
| 65 | { |
| 66 | |
Wolfgang Denk | 11f9884 | 2011-12-08 02:01:49 +0000 | [diff] [blame] | 67 | printf("\n\n%s\n\n", version_string); |
| 68 | return 0; |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 69 | } |
| 70 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 71 | #ifndef CONFIG_SYS_NO_FLASH |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 72 | static void display_flash_config(ulong size) |
| 73 | { |
Wolfgang Denk | 11f9884 | 2011-12-08 02:01:49 +0000 | [diff] [blame] | 74 | puts("Flash: "); |
| 75 | print_size(size, "\n"); |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 76 | } |
Jean-Christophe PLAGNIOL-VILLARD | 3bd04ce | 2008-02-17 16:58:04 +0100 | [diff] [blame] | 77 | #endif |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 78 | |
Wolfgang Denk | 11f9884 | 2011-12-08 02:01:49 +0000 | [diff] [blame] | 79 | static int init_baudrate(void) |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 80 | { |
Simon Glass | 8ccbef9 | 2011-10-13 14:43:11 +0000 | [diff] [blame] | 81 | gd->baudrate = getenv_ulong("baudrate", 10, CONFIG_BAUDRATE); |
| 82 | return 0; |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | |
| 86 | /* |
| 87 | * Breath some life into the board... |
| 88 | * |
| 89 | * The first part of initialization is running from Flash memory; |
| 90 | * its main purpose is to initialize the RAM so that we |
| 91 | * can relocate the monitor code to RAM. |
| 92 | */ |
| 93 | |
| 94 | /* |
| 95 | * All attempts to come up with a "common" initialization sequence |
| 96 | * that works for all boards and architectures failed: some of the |
| 97 | * requirements are just _too_ different. To get rid of the resulting |
| 98 | * mess of board dependend #ifdef'ed code we now make the whole |
| 99 | * initialization sequence configurable to the user. |
| 100 | * |
| 101 | * The requirements for any new initalization function is simple: it |
| 102 | * receives a pointer to the "global data" structure as it's only |
| 103 | * argument, and returns an integer return code, where 0 means |
| 104 | * "continue" and != 0 means "fatal error, hang the system". |
| 105 | */ |
Wolfgang Denk | 11f9884 | 2011-12-08 02:01:49 +0000 | [diff] [blame] | 106 | typedef int (init_fnc_t)(void); |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 107 | |
| 108 | init_fnc_t *init_sequence[] = { |
Stefan Roese | 2b1c815 | 2008-11-12 13:18:02 +0100 | [diff] [blame] | 109 | board_early_init_f, |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 110 | timer_init, |
| 111 | env_init, /* initialize environment */ |
wdenk | 67f1336 | 2003-12-27 19:24:54 +0000 | [diff] [blame] | 112 | #ifdef CONFIG_INCA_IP |
Wolfgang Denk | 11f9884 | 2011-12-08 02:01:49 +0000 | [diff] [blame] | 113 | incaip_set_cpuclk, /* set cpu clock according to env. variable */ |
wdenk | 67f1336 | 2003-12-27 19:24:54 +0000 | [diff] [blame] | 114 | #endif |
Wolfgang Denk | 11f9884 | 2011-12-08 02:01:49 +0000 | [diff] [blame] | 115 | init_baudrate, /* initialize baudrate settings */ |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 116 | serial_init, /* serial communications setup */ |
| 117 | console_init_f, |
| 118 | display_banner, /* say that we are here */ |
wdenk | 8dba050 | 2003-03-31 16:34:49 +0000 | [diff] [blame] | 119 | checkboard, |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 120 | init_func_ram, |
| 121 | NULL, |
| 122 | }; |
| 123 | |
| 124 | |
| 125 | void board_init_f(ulong bootflag) |
| 126 | { |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 127 | gd_t gd_data, *id; |
| 128 | bd_t *bd; |
| 129 | init_fnc_t **init_fnc_ptr; |
Daniel Schwierzeck | bd4277d | 2013-02-12 22:22:12 +0100 | [diff] [blame] | 130 | ulong addr, addr_sp, len; |
Wolfgang Denk | 117b0b1 | 2005-12-01 02:15:07 +0100 | [diff] [blame] | 131 | ulong *s; |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 132 | |
wdenk | cd91445 | 2004-05-29 16:53:29 +0000 | [diff] [blame] | 133 | /* Pointer is writable since we allocated a register for it. |
| 134 | */ |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 135 | gd = &gd_data; |
wdenk | 3337af4 | 2004-07-01 20:28:03 +0000 | [diff] [blame] | 136 | /* compiler optimization barrier needed for GCC >= 3.4 */ |
Wolfgang Denk | 11f9884 | 2011-12-08 02:01:49 +0000 | [diff] [blame] | 137 | __asm__ __volatile__("" : : : "memory"); |
wdenk | 3337af4 | 2004-07-01 20:28:03 +0000 | [diff] [blame] | 138 | |
Wolfgang Denk | 11f9884 | 2011-12-08 02:01:49 +0000 | [diff] [blame] | 139 | memset((void *)gd, 0, sizeof(gd_t)); |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 140 | |
| 141 | for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) { |
Wolfgang Denk | 11f9884 | 2011-12-08 02:01:49 +0000 | [diff] [blame] | 142 | if ((*init_fnc_ptr)() != 0) |
| 143 | hang(); |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 144 | } |
| 145 | |
| 146 | /* |
| 147 | * Now that we have DRAM mapped and working, we can |
| 148 | * relocate the code and continue running from DRAM. |
| 149 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 150 | addr = CONFIG_SYS_SDRAM_BASE + gd->ram_size; |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 151 | |
wdenk | cd91445 | 2004-05-29 16:53:29 +0000 | [diff] [blame] | 152 | /* We can reserve some RAM "on top" here. |
| 153 | */ |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 154 | |
wdenk | cd91445 | 2004-05-29 16:53:29 +0000 | [diff] [blame] | 155 | /* round down to next 4 kB limit. |
| 156 | */ |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 157 | addr &= ~(4096 - 1); |
Wolfgang Denk | 11f9884 | 2011-12-08 02:01:49 +0000 | [diff] [blame] | 158 | debug("Top of RAM usable for U-Boot at: %08lx\n", addr); |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 159 | |
wdenk | cd91445 | 2004-05-29 16:53:29 +0000 | [diff] [blame] | 160 | /* Reserve memory for U-Boot code, data & bss |
| 161 | * round down to next 16 kB limit |
| 162 | */ |
Daniel Schwierzeck | bd4277d | 2013-02-12 22:22:12 +0100 | [diff] [blame] | 163 | len = bss_end() - CONFIG_SYS_MONITOR_BASE; |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 164 | addr -= len; |
wdenk | b9a83a9 | 2003-05-30 12:48:29 +0000 | [diff] [blame] | 165 | addr &= ~(16 * 1024 - 1); |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 166 | |
Wolfgang Denk | 11f9884 | 2011-12-08 02:01:49 +0000 | [diff] [blame] | 167 | debug("Reserving %ldk for U-Boot at: %08lx\n", len >> 10, addr); |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 168 | |
wdenk | cd91445 | 2004-05-29 16:53:29 +0000 | [diff] [blame] | 169 | /* Reserve memory for malloc() arena. |
| 170 | */ |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 171 | addr_sp = addr - TOTAL_MALLOC_LEN; |
Wolfgang Denk | 11f9884 | 2011-12-08 02:01:49 +0000 | [diff] [blame] | 172 | debug("Reserving %dk for malloc() at: %08lx\n", |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 173 | TOTAL_MALLOC_LEN >> 10, addr_sp); |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 174 | |
| 175 | /* |
| 176 | * (permanently) allocate a Board Info struct |
| 177 | * and a permanent copy of the "global" data |
| 178 | */ |
| 179 | addr_sp -= sizeof(bd_t); |
| 180 | bd = (bd_t *)addr_sp; |
| 181 | gd->bd = bd; |
Wolfgang Denk | 11f9884 | 2011-12-08 02:01:49 +0000 | [diff] [blame] | 182 | debug("Reserving %zu Bytes for Board Info at: %08lx\n", |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 183 | sizeof(bd_t), addr_sp); |
wdenk | cd91445 | 2004-05-29 16:53:29 +0000 | [diff] [blame] | 184 | |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 185 | addr_sp -= sizeof(gd_t); |
| 186 | id = (gd_t *)addr_sp; |
Wolfgang Denk | 11f9884 | 2011-12-08 02:01:49 +0000 | [diff] [blame] | 187 | debug("Reserving %zu Bytes for Global Data at: %08lx\n", |
| 188 | sizeof(gd_t), addr_sp); |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 189 | |
Jean-Christophe PLAGNIOL-VILLARD | 3bd04ce | 2008-02-17 16:58:04 +0100 | [diff] [blame] | 190 | /* Reserve memory for boot params. |
wdenk | cd91445 | 2004-05-29 16:53:29 +0000 | [diff] [blame] | 191 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 192 | addr_sp -= CONFIG_SYS_BOOTPARAMS_LEN; |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 193 | bd->bi_boot_params = addr_sp; |
Wolfgang Denk | 11f9884 | 2011-12-08 02:01:49 +0000 | [diff] [blame] | 194 | debug("Reserving %dk for boot params() at: %08lx\n", |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 195 | CONFIG_SYS_BOOTPARAMS_LEN >> 10, addr_sp); |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 196 | |
| 197 | /* |
| 198 | * Finally, we set up a new (bigger) stack. |
| 199 | * |
| 200 | * Leave some safety gap for SP, force alignment on 16 byte boundary |
| 201 | * Clear initial stack frame |
| 202 | */ |
| 203 | addr_sp -= 16; |
| 204 | addr_sp &= ~0xF; |
Wolfgang Denk | 117b0b1 | 2005-12-01 02:15:07 +0100 | [diff] [blame] | 205 | s = (ulong *)addr_sp; |
| 206 | *s-- = 0; |
| 207 | *s-- = 0; |
| 208 | addr_sp = (ulong)s; |
Wolfgang Denk | 11f9884 | 2011-12-08 02:01:49 +0000 | [diff] [blame] | 209 | debug("Stack Pointer at: %08lx\n", addr_sp); |
wdenk | cd91445 | 2004-05-29 16:53:29 +0000 | [diff] [blame] | 210 | |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 211 | /* |
| 212 | * Save local variables to board info struct |
| 213 | */ |
Wolfgang Denk | 11f9884 | 2011-12-08 02:01:49 +0000 | [diff] [blame] | 214 | bd->bi_memstart = CONFIG_SYS_SDRAM_BASE; /* start of DRAM */ |
| 215 | bd->bi_memsize = gd->ram_size; /* size of DRAM in bytes */ |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 216 | bd->bi_baudrate = gd->baudrate; /* Console Baudrate */ |
| 217 | |
Wolfgang Denk | 11f9884 | 2011-12-08 02:01:49 +0000 | [diff] [blame] | 218 | memcpy(id, (void *)gd, sizeof(gd_t)); |
wdenk | b02744a | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 219 | |
Wolfgang Denk | 11f9884 | 2011-12-08 02:01:49 +0000 | [diff] [blame] | 220 | relocate_code(addr_sp, id, addr); |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 221 | |
| 222 | /* NOTREACHED - relocate_code() does not return */ |
| 223 | } |
Wolfgang Denk | 11f9884 | 2011-12-08 02:01:49 +0000 | [diff] [blame] | 224 | |
| 225 | /* |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 226 | * This is the next part if the initialization sequence: we are now |
| 227 | * running from RAM and have a "normal" C environment, i. e. global |
| 228 | * data can be written, BSS has been cleared, the stack size in not |
| 229 | * that critical any more, etc. |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 230 | */ |
| 231 | |
Wolfgang Denk | 11f9884 | 2011-12-08 02:01:49 +0000 | [diff] [blame] | 232 | void board_init_r(gd_t *id, ulong dest_addr) |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 233 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 234 | #ifndef CONFIG_SYS_NO_FLASH |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 235 | ulong size; |
Jean-Christophe PLAGNIOL-VILLARD | 3bd04ce | 2008-02-17 16:58:04 +0100 | [diff] [blame] | 236 | #endif |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 237 | bd_t *bd; |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 238 | |
| 239 | gd = id; |
| 240 | gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */ |
| 241 | |
Wolfgang Denk | 11f9884 | 2011-12-08 02:01:49 +0000 | [diff] [blame] | 242 | debug("Now running in RAM - U-Boot at: %08lx\n", dest_addr); |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 243 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 244 | gd->reloc_off = dest_addr - CONFIG_SYS_MONITOR_BASE; |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 245 | |
Daniel Schwierzeck | bd4277d | 2013-02-12 22:22:12 +0100 | [diff] [blame] | 246 | monitor_flash_len = image_copy_end() - dest_addr; |
wdenk | b9a83a9 | 2003-05-30 12:48:29 +0000 | [diff] [blame] | 247 | |
Joe Hershberger | 7fe0ac8 | 2012-12-11 17:52:50 +0000 | [diff] [blame] | 248 | serial_initialize(); |
| 249 | |
Jean-Christophe PLAGNIOL-VILLARD | 3bd04ce | 2008-02-17 16:58:04 +0100 | [diff] [blame] | 250 | bd = gd->bd; |
| 251 | |
Peter Tyser | 781c9b8 | 2009-08-21 23:05:21 -0500 | [diff] [blame] | 252 | /* The Malloc area is immediately below the monitor copy in DRAM */ |
Peter Tyser | ed52770 | 2009-08-21 23:05:20 -0500 | [diff] [blame] | 253 | mem_malloc_init(CONFIG_SYS_MONITOR_BASE + gd->reloc_off - |
| 254 | TOTAL_MALLOC_LEN, TOTAL_MALLOC_LEN); |
Stefan Roese | b81464e | 2009-05-11 15:50:12 +0200 | [diff] [blame] | 255 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 256 | #ifndef CONFIG_SYS_NO_FLASH |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 257 | /* configure available FLASH banks */ |
| 258 | size = flash_init(); |
Wolfgang Denk | 11f9884 | 2011-12-08 02:01:49 +0000 | [diff] [blame] | 259 | display_flash_config(size); |
Daniel Schwierzeck | 0d15d2a | 2012-04-02 02:57:54 +0000 | [diff] [blame] | 260 | bd->bi_flashstart = CONFIG_SYS_FLASH_BASE; |
Jean-Christophe PLAGNIOL-VILLARD | 3bd04ce | 2008-02-17 16:58:04 +0100 | [diff] [blame] | 261 | bd->bi_flashsize = size; |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 262 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 263 | #if CONFIG_SYS_MONITOR_BASE == CONFIG_SYS_FLASH_BASE |
wdenk | b9a83a9 | 2003-05-30 12:48:29 +0000 | [diff] [blame] | 264 | bd->bi_flashoffset = monitor_flash_len; /* reserved area for U-Boot */ |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 265 | #else |
| 266 | bd->bi_flashoffset = 0; |
| 267 | #endif |
Daniel Schwierzeck | 0d15d2a | 2012-04-02 02:57:54 +0000 | [diff] [blame] | 268 | #else |
| 269 | bd->bi_flashstart = 0; |
| 270 | bd->bi_flashsize = 0; |
| 271 | bd->bi_flashoffset = 0; |
| 272 | #endif |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 273 | |
Stefan Roese | 1af2a0d | 2008-11-12 13:18:19 +0100 | [diff] [blame] | 274 | #ifdef CONFIG_CMD_NAND |
Wolfgang Denk | 11f9884 | 2011-12-08 02:01:49 +0000 | [diff] [blame] | 275 | puts("NAND: "); |
| 276 | nand_init(); /* go init the NAND */ |
Stefan Roese | 1af2a0d | 2008-11-12 13:18:19 +0100 | [diff] [blame] | 277 | #endif |
| 278 | |
| 279 | #if defined(CONFIG_CMD_ONENAND) |
| 280 | onenand_init(); |
| 281 | #endif |
| 282 | |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 283 | /* relocate environment function pointers etc. */ |
| 284 | env_relocate(); |
| 285 | |
wdenk | 5401de4 | 2004-02-07 01:27:10 +0000 | [diff] [blame] | 286 | #if defined(CONFIG_PCI) |
| 287 | /* |
| 288 | * Do pci configuration |
| 289 | */ |
| 290 | pci_init(); |
| 291 | #endif |
| 292 | |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 293 | /** leave this here (after malloc(), environment and PCI are working) **/ |
Jean-Christophe PLAGNIOL-VILLARD | 2a7a031 | 2009-05-16 12:14:54 +0200 | [diff] [blame] | 294 | /* Initialize stdio devices */ |
Wolfgang Denk | 11f9884 | 2011-12-08 02:01:49 +0000 | [diff] [blame] | 295 | stdio_init(); |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 296 | |
Wolfgang Denk | 11f9884 | 2011-12-08 02:01:49 +0000 | [diff] [blame] | 297 | jumptable_init(); |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 298 | |
| 299 | /* Initialize the console (after the relocation and devices init) */ |
Wolfgang Denk | 11f9884 | 2011-12-08 02:01:49 +0000 | [diff] [blame] | 300 | console_init_r(); |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 301 | /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **/ |
| 302 | |
wdenk | b02744a | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 303 | /* Initialize from environment */ |
Simon Glass | 8ccbef9 | 2011-10-13 14:43:11 +0000 | [diff] [blame] | 304 | load_addr = getenv_ulong("loadaddr", 16, load_addr); |
wdenk | b02744a | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 305 | |
Jason McMullan | 733ad78 | 2008-05-30 00:53:37 +0900 | [diff] [blame] | 306 | #ifdef CONFIG_CMD_SPI |
Wolfgang Denk | 11f9884 | 2011-12-08 02:01:49 +0000 | [diff] [blame] | 307 | puts("SPI: "); |
| 308 | spi_init(); /* go init the SPI */ |
| 309 | puts("ready\n"); |
Jason McMullan | 733ad78 | 2008-05-30 00:53:37 +0900 | [diff] [blame] | 310 | #endif |
| 311 | |
wdenk | b02744a | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 312 | #if defined(CONFIG_MISC_INIT_R) |
| 313 | /* miscellaneous platform dependent initialisations */ |
Wolfgang Denk | 11f9884 | 2011-12-08 02:01:49 +0000 | [diff] [blame] | 314 | misc_init_r(); |
wdenk | b02744a | 2003-04-05 00:53:31 +0000 | [diff] [blame] | 315 | #endif |
| 316 | |
Luigi 'Comio' Mantellini | 01db155 | 2009-10-10 12:42:21 +0200 | [diff] [blame] | 317 | #ifdef CONFIG_BITBANGMII |
| 318 | bb_miiphy_init(); |
| 319 | #endif |
Jon Loeliger | 6b23305 | 2007-07-09 18:02:11 -0500 | [diff] [blame] | 320 | #if defined(CONFIG_CMD_NET) |
Wolfgang Denk | 11f9884 | 2011-12-08 02:01:49 +0000 | [diff] [blame] | 321 | puts("Net: "); |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 322 | eth_initialize(gd->bd); |
| 323 | #endif |
| 324 | |
| 325 | /* main_loop() can return to retry autoboot, if so just run it again. */ |
Wolfgang Denk | 11f9884 | 2011-12-08 02:01:49 +0000 | [diff] [blame] | 326 | for (;;) |
| 327 | main_loop(); |
wdenk | bb1b826 | 2003-03-27 12:09:35 +0000 | [diff] [blame] | 328 | |
| 329 | /* NOTREACHED - no way out of command loop except booting */ |
| 330 | } |