Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2011 The Chromium OS Authors. |
| 3 | * (C) Copyright 2002-2006 |
| 4 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 5 | * |
| 6 | * (C) Copyright 2002 |
| 7 | * Sysgo Real-Time Solutions, GmbH <www.elinos.com> |
| 8 | * Marius Groeger <mgroeger@sysgo.de> |
| 9 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 10 | * SPDX-License-Identifier: GPL-2.0+ |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 11 | */ |
| 12 | |
| 13 | #include <common.h> |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 14 | /* TODO: can we just include all these headers whether needed or not? */ |
| 15 | #if defined(CONFIG_CMD_BEDBUG) |
| 16 | #include <bedbug/type.h> |
| 17 | #endif |
Tom Rini | cbb2df2 | 2015-12-07 08:23:29 -0500 | [diff] [blame] | 18 | #include <command.h> |
Simon Glass | 24b852a | 2015-11-08 23:47:45 -0700 | [diff] [blame] | 19 | #include <console.h> |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 20 | #ifdef CONFIG_HAS_DATAFLASH |
| 21 | #include <dataflash.h> |
| 22 | #endif |
Simon Glass | 1ce6017 | 2014-02-26 15:59:20 -0700 | [diff] [blame] | 23 | #include <dm.h> |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 24 | #include <environment.h> |
| 25 | #include <fdtdec.h> |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 26 | #if defined(CONFIG_CMD_IDE) |
| 27 | #include <ide.h> |
| 28 | #endif |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 29 | #include <initcall.h> |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 30 | #ifdef CONFIG_PS2KBD |
| 31 | #include <keyboard.h> |
| 32 | #endif |
| 33 | #if defined(CONFIG_CMD_KGDB) |
| 34 | #include <kgdb.h> |
| 35 | #endif |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 36 | #include <logbuff.h> |
| 37 | #include <malloc.h> |
Joe Hershberger | 0eb25b6 | 2015-03-22 17:08:59 -0500 | [diff] [blame] | 38 | #include <mapmem.h> |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 39 | #ifdef CONFIG_BITBANGMII |
| 40 | #include <miiphy.h> |
| 41 | #endif |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 42 | #include <mmc.h> |
| 43 | #include <nand.h> |
| 44 | #include <onenand_uboot.h> |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 45 | #include <scsi.h> |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 46 | #include <serial.h> |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 47 | #include <spi.h> |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 48 | #include <stdio_dev.h> |
Simon Glass | 71c52db | 2013-06-11 11:14:42 -0700 | [diff] [blame] | 49 | #include <trace.h> |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 50 | #include <watchdog.h> |
Francois Retief | 3f33f6a | 2014-10-27 13:39:03 +0200 | [diff] [blame] | 51 | #ifdef CONFIG_CMD_AMBAPP |
| 52 | #include <ambapp.h> |
| 53 | #endif |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 54 | #ifdef CONFIG_ADDR_MAP |
| 55 | #include <asm/mmu.h> |
| 56 | #endif |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 57 | #include <asm/sections.h> |
Simon Glass | be274b9 | 2013-03-05 14:39:53 +0000 | [diff] [blame] | 58 | #ifdef CONFIG_X86 |
| 59 | #include <asm/init_helpers.h> |
| 60 | #endif |
Simon Glass | 1ce6017 | 2014-02-26 15:59:20 -0700 | [diff] [blame] | 61 | #include <dm/root.h> |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 62 | #include <linux/compiler.h> |
Simon Glass | 1ce6017 | 2014-02-26 15:59:20 -0700 | [diff] [blame] | 63 | #include <linux/err.h> |
Andreas Bießmann | a752a8b | 2015-02-06 23:06:48 +0100 | [diff] [blame] | 64 | #ifdef CONFIG_AVR32 |
| 65 | #include <asm/arch/mmu.h> |
| 66 | #endif |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 67 | |
| 68 | DECLARE_GLOBAL_DATA_PTR; |
| 69 | |
Francois Retief | 1e85cce | 2015-11-23 13:05:44 +0200 | [diff] [blame] | 70 | #if defined(CONFIG_SPARC) |
| 71 | extern int prom_init(void); |
| 72 | #endif |
| 73 | |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 74 | ulong monitor_flash_len; |
| 75 | |
Jeroen Hofstee | dd2a6cd | 2014-10-08 22:57:22 +0200 | [diff] [blame] | 76 | __weak int board_flash_wp_on(void) |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 77 | { |
| 78 | /* |
| 79 | * Most flashes can't be detected when write protection is enabled, |
| 80 | * so provide a way to let U-Boot gracefully ignore write protected |
| 81 | * devices. |
| 82 | */ |
| 83 | return 0; |
| 84 | } |
| 85 | |
Jeroen Hofstee | dd2a6cd | 2014-10-08 22:57:22 +0200 | [diff] [blame] | 86 | __weak void cpu_secondary_init_r(void) |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 87 | { |
| 88 | } |
| 89 | |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 90 | static int initr_secondary_cpu(void) |
| 91 | { |
| 92 | /* |
| 93 | * after non-volatile devices & environment is setup and cpu code have |
| 94 | * another round to deal with any initialization that might require |
| 95 | * full access to the environment or loading of some image (firmware) |
| 96 | * from a non-volatile device |
| 97 | */ |
| 98 | /* TODO: maybe define this for all archs? */ |
| 99 | cpu_secondary_init_r(); |
| 100 | |
| 101 | return 0; |
| 102 | } |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 103 | |
Simon Glass | 71c52db | 2013-06-11 11:14:42 -0700 | [diff] [blame] | 104 | static int initr_trace(void) |
| 105 | { |
| 106 | #ifdef CONFIG_TRACE |
| 107 | trace_init(gd->trace_buff, CONFIG_TRACE_BUFFER_SIZE); |
| 108 | #endif |
| 109 | |
| 110 | return 0; |
| 111 | } |
| 112 | |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 113 | static int initr_reloc(void) |
| 114 | { |
Simon Glass | c9356be | 2014-11-10 17:16:43 -0700 | [diff] [blame] | 115 | /* tell others: relocation done */ |
| 116 | gd->flags |= GD_FLG_RELOC | GD_FLG_FULL_MALLOC_INIT; |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 117 | |
| 118 | return 0; |
| 119 | } |
| 120 | |
| 121 | #ifdef CONFIG_ARM |
| 122 | /* |
| 123 | * Some of these functions are needed purely because the functions they |
| 124 | * call return void. If we change them to return 0, these stubs can go away. |
| 125 | */ |
| 126 | static int initr_caches(void) |
| 127 | { |
| 128 | /* Enable caches */ |
| 129 | enable_caches(); |
| 130 | return 0; |
| 131 | } |
| 132 | #endif |
| 133 | |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 134 | __weak int fixup_cpu(void) |
| 135 | { |
| 136 | return 0; |
| 137 | } |
| 138 | |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 139 | static int initr_reloc_global_data(void) |
| 140 | { |
Albert ARIBAUD | b60eff3 | 2014-02-22 17:53:43 +0100 | [diff] [blame] | 141 | #ifdef __ARM__ |
| 142 | monitor_flash_len = _end - __image_copy_start; |
Kun-Hua Huang | 2e88bb2 | 2015-08-24 14:52:35 +0800 | [diff] [blame] | 143 | #elif defined(CONFIG_NDS32) |
| 144 | monitor_flash_len = (ulong)&_end - (ulong)&_start; |
Thomas Chou | 5ff10aa | 2014-08-22 11:36:47 +0800 | [diff] [blame] | 145 | #elif !defined(CONFIG_SANDBOX) && !defined(CONFIG_NIOS2) |
Masahiro Yamada | a0ba279 | 2013-05-27 00:37:30 +0000 | [diff] [blame] | 146 | monitor_flash_len = (ulong)&__init_end - gd->relocaddr; |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 147 | #endif |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 148 | #if defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx) |
| 149 | /* |
| 150 | * The gd->cpu pointer is set to an address in flash before relocation. |
| 151 | * We need to update it to point to the same CPU entry in RAM. |
| 152 | * TODO: why not just add gd->reloc_ofs? |
| 153 | */ |
Masahiro Yamada | a0ba279 | 2013-05-27 00:37:30 +0000 | [diff] [blame] | 154 | gd->arch.cpu += gd->relocaddr - CONFIG_SYS_MONITOR_BASE; |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 155 | |
| 156 | /* |
| 157 | * If we didn't know the cpu mask & # cores, we can save them of |
| 158 | * now rather than 'computing' them constantly |
| 159 | */ |
| 160 | fixup_cpu(); |
| 161 | #endif |
| 162 | #ifdef CONFIG_SYS_EXTRA_ENV_RELOC |
| 163 | /* |
| 164 | * Some systems need to relocate the env_addr pointer early because the |
| 165 | * location it points to will get invalidated before env_relocate is |
| 166 | * called. One example is on systems that might use a L2 or L3 cache |
| 167 | * in SRAM mode and initialize that cache from SRAM mode back to being |
| 168 | * a cache in cpu_init_r. |
| 169 | */ |
Masahiro Yamada | a0ba279 | 2013-05-27 00:37:30 +0000 | [diff] [blame] | 170 | gd->env_addr += gd->relocaddr - CONFIG_SYS_MONITOR_BASE; |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 171 | #endif |
Siva Durga Prasad Paladugu | e9acb9e | 2015-12-03 15:46:03 +0100 | [diff] [blame] | 172 | #ifdef CONFIG_OF_EMBED |
| 173 | /* |
| 174 | * The fdt_blob needs to be moved to new relocation address |
| 175 | * incase of FDT blob is embedded with in image |
| 176 | */ |
| 177 | gd->fdt_blob += gd->reloc_off; |
| 178 | #endif |
| 179 | |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 180 | return 0; |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 181 | } |
| 182 | |
| 183 | static int initr_serial(void) |
| 184 | { |
| 185 | serial_initialize(); |
| 186 | return 0; |
| 187 | } |
| 188 | |
angelo@sysam.it | e310b93 | 2015-02-12 01:40:17 +0100 | [diff] [blame] | 189 | #if defined(CONFIG_PPC) || defined(CONFIG_M68K) |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 190 | static int initr_trap(void) |
| 191 | { |
| 192 | /* |
| 193 | * Setup trap handlers |
| 194 | */ |
angelo@sysam.it | e310b93 | 2015-02-12 01:40:17 +0100 | [diff] [blame] | 195 | #if defined(CONFIG_PPC) |
Masahiro Yamada | a0ba279 | 2013-05-27 00:37:30 +0000 | [diff] [blame] | 196 | trap_init(gd->relocaddr); |
angelo@sysam.it | e310b93 | 2015-02-12 01:40:17 +0100 | [diff] [blame] | 197 | #else |
| 198 | trap_init(CONFIG_SYS_SDRAM_BASE); |
| 199 | #endif |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 200 | return 0; |
| 201 | } |
| 202 | #endif |
| 203 | |
| 204 | #ifdef CONFIG_ADDR_MAP |
| 205 | static int initr_addr_map(void) |
| 206 | { |
| 207 | init_addr_map(); |
| 208 | |
| 209 | return 0; |
| 210 | } |
| 211 | #endif |
| 212 | |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 213 | #ifdef CONFIG_LOGBUFFER |
| 214 | unsigned long logbuffer_base(void) |
| 215 | { |
| 216 | return gd->ram_top - LOGBUFF_LEN; |
| 217 | } |
| 218 | |
| 219 | static int initr_logbuffer(void) |
| 220 | { |
| 221 | logbuff_init_ptrs(); |
| 222 | return 0; |
| 223 | } |
| 224 | #endif |
| 225 | |
| 226 | #ifdef CONFIG_POST |
| 227 | static int initr_post_backlog(void) |
| 228 | { |
| 229 | post_output_backlog(); |
| 230 | return 0; |
| 231 | } |
| 232 | #endif |
| 233 | |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 234 | #ifdef CONFIG_SYS_DELAYED_ICACHE |
| 235 | static int initr_icache_enable(void) |
| 236 | { |
| 237 | return 0; |
| 238 | } |
| 239 | #endif |
| 240 | |
| 241 | #if defined(CONFIG_SYS_INIT_RAM_LOCK) && defined(CONFIG_E500) |
| 242 | static int initr_unlock_ram_in_cache(void) |
| 243 | { |
| 244 | unlock_ram_in_cache(); /* it's time to unlock D-cache in e500 */ |
| 245 | return 0; |
| 246 | } |
| 247 | #endif |
| 248 | |
| 249 | #ifdef CONFIG_PCI |
| 250 | static int initr_pci(void) |
| 251 | { |
Simon Glass | ff3e077 | 2015-03-05 12:25:25 -0700 | [diff] [blame] | 252 | #ifndef CONFIG_DM_PCI |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 253 | pci_init(); |
Simon Glass | ff3e077 | 2015-03-05 12:25:25 -0700 | [diff] [blame] | 254 | #endif |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 255 | |
| 256 | return 0; |
| 257 | } |
| 258 | #endif |
| 259 | |
| 260 | #ifdef CONFIG_WINBOND_83C553 |
| 261 | static int initr_w83c553f(void) |
| 262 | { |
| 263 | /* |
| 264 | * Initialise the ISA bridge |
| 265 | */ |
| 266 | initialise_w83c553f(); |
| 267 | return 0; |
| 268 | } |
| 269 | #endif |
| 270 | |
| 271 | static int initr_barrier(void) |
| 272 | { |
| 273 | #ifdef CONFIG_PPC |
| 274 | /* TODO: Can we not use dmb() macros for this? */ |
| 275 | asm("sync ; isync"); |
| 276 | #endif |
| 277 | return 0; |
| 278 | } |
| 279 | |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 280 | static int initr_malloc(void) |
| 281 | { |
| 282 | ulong malloc_start; |
| 283 | |
Simon Glass | d59476b | 2014-07-10 22:23:28 -0600 | [diff] [blame] | 284 | #ifdef CONFIG_SYS_MALLOC_F_LEN |
| 285 | debug("Pre-reloc malloc() used %#lx bytes (%ld KB)\n", gd->malloc_ptr, |
| 286 | gd->malloc_ptr / 1024); |
| 287 | #endif |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 288 | /* The malloc area is immediately below the monitor copy in DRAM */ |
Masahiro Yamada | a0ba279 | 2013-05-27 00:37:30 +0000 | [diff] [blame] | 289 | malloc_start = gd->relocaddr - TOTAL_MALLOC_LEN; |
Simon Glass | a733b06 | 2013-04-26 02:53:43 +0000 | [diff] [blame] | 290 | mem_malloc_init((ulong)map_sysmem(malloc_start, TOTAL_MALLOC_LEN), |
| 291 | TOTAL_MALLOC_LEN); |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 292 | return 0; |
| 293 | } |
| 294 | |
Simon Glass | 9854a87 | 2015-11-08 23:47:48 -0700 | [diff] [blame] | 295 | static int initr_console_record(void) |
| 296 | { |
| 297 | #if defined(CONFIG_CONSOLE_RECORD) |
| 298 | return console_record_init(); |
| 299 | #else |
| 300 | return 0; |
| 301 | #endif |
| 302 | } |
| 303 | |
Jan Kiszka | 671fa63 | 2015-03-09 07:47:18 +0100 | [diff] [blame] | 304 | #ifdef CONFIG_SYS_NONCACHED_MEMORY |
| 305 | static int initr_noncached(void) |
| 306 | { |
| 307 | noncached_init(); |
| 308 | return 0; |
| 309 | } |
| 310 | #endif |
| 311 | |
Simon Glass | 1ce6017 | 2014-02-26 15:59:20 -0700 | [diff] [blame] | 312 | #ifdef CONFIG_DM |
| 313 | static int initr_dm(void) |
| 314 | { |
Simon Glass | ab7cd62 | 2014-07-23 06:55:04 -0600 | [diff] [blame] | 315 | /* Save the pre-reloc driver model and start a new one */ |
| 316 | gd->dm_root_f = gd->dm_root; |
| 317 | gd->dm_root = NULL; |
Thomas Chou | 8f41b87 | 2015-10-09 13:48:56 +0800 | [diff] [blame] | 318 | #ifdef CONFIG_TIMER |
| 319 | gd->timer = NULL; |
| 320 | #endif |
Simon Glass | ab7cd62 | 2014-07-23 06:55:04 -0600 | [diff] [blame] | 321 | return dm_init_and_scan(false); |
Simon Glass | 1ce6017 | 2014-02-26 15:59:20 -0700 | [diff] [blame] | 322 | } |
| 323 | #endif |
| 324 | |
Simon Glass | 881c124 | 2015-11-28 22:16:35 -0700 | [diff] [blame] | 325 | static int initr_bootstage(void) |
| 326 | { |
| 327 | /* We cannot do this before initr_dm() */ |
| 328 | bootstage_mark_name(BOOTSTAGE_ID_START_UBOOT_R, "board_init_r"); |
| 329 | |
| 330 | return 0; |
| 331 | } |
| 332 | |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 333 | __weak int power_init_board(void) |
| 334 | { |
| 335 | return 0; |
| 336 | } |
| 337 | |
| 338 | static int initr_announce(void) |
| 339 | { |
Masahiro Yamada | a0ba279 | 2013-05-27 00:37:30 +0000 | [diff] [blame] | 340 | debug("Now running in RAM - U-Boot at: %08lx\n", gd->relocaddr); |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 341 | return 0; |
| 342 | } |
| 343 | |
Andreas Bießmann | 61d7b1b | 2015-01-20 00:29:05 +0100 | [diff] [blame] | 344 | #ifdef CONFIG_NEEDS_MANUAL_RELOC |
| 345 | static int initr_manual_reloc_cmdtable(void) |
| 346 | { |
| 347 | fixup_cmdtable(ll_entry_start(cmd_tbl_t, cmd), |
| 348 | ll_entry_count(cmd_tbl_t, cmd)); |
| 349 | return 0; |
| 350 | } |
| 351 | #endif |
| 352 | |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 353 | #if !defined(CONFIG_SYS_NO_FLASH) |
| 354 | static int initr_flash(void) |
| 355 | { |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 356 | ulong flash_size = 0; |
| 357 | bd_t *bd = gd->bd; |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 358 | |
| 359 | puts("Flash: "); |
| 360 | |
Masahiro Yamada | 70879a9 | 2014-12-05 12:20:58 +0900 | [diff] [blame] | 361 | if (board_flash_wp_on()) |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 362 | printf("Uninitialized - Write Protect On\n"); |
Masahiro Yamada | 70879a9 | 2014-12-05 12:20:58 +0900 | [diff] [blame] | 363 | else |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 364 | flash_size = flash_init(); |
Masahiro Yamada | 70879a9 | 2014-12-05 12:20:58 +0900 | [diff] [blame] | 365 | |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 366 | print_size(flash_size, ""); |
| 367 | #ifdef CONFIG_SYS_FLASH_CHECKSUM |
| 368 | /* |
| 369 | * Compute and print flash CRC if flashchecksum is set to 'y' |
| 370 | * |
| 371 | * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX |
| 372 | */ |
| 373 | if (getenv_yesno("flashchecksum") == 1) { |
| 374 | printf(" CRC: %08X", crc32(0, |
| 375 | (const unsigned char *) CONFIG_SYS_FLASH_BASE, |
| 376 | flash_size)); |
| 377 | } |
| 378 | #endif /* CONFIG_SYS_FLASH_CHECKSUM */ |
| 379 | putc('\n'); |
| 380 | |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 381 | /* update start of FLASH memory */ |
| 382 | #ifdef CONFIG_SYS_FLASH_BASE |
| 383 | bd->bi_flashstart = CONFIG_SYS_FLASH_BASE; |
| 384 | #endif |
| 385 | /* size of FLASH memory (final value) */ |
| 386 | bd->bi_flashsize = flash_size; |
| 387 | |
| 388 | #if defined(CONFIG_SYS_UPDATE_FLASH_SIZE) |
| 389 | /* Make a update of the Memctrl. */ |
| 390 | update_flash_size(flash_size); |
| 391 | #endif |
| 392 | |
| 393 | |
| 394 | #if defined(CONFIG_OXC) || defined(CONFIG_RMU) |
| 395 | /* flash mapped at end of memory map */ |
| 396 | bd->bi_flashoffset = CONFIG_SYS_TEXT_BASE + flash_size; |
| 397 | #elif CONFIG_SYS_MONITOR_BASE == CONFIG_SYS_FLASH_BASE |
| 398 | bd->bi_flashoffset = monitor_flash_len; /* reserved area for monitor */ |
| 399 | #endif |
| 400 | return 0; |
| 401 | } |
| 402 | #endif |
| 403 | |
Simon Glass | ebe76a2 | 2014-10-13 23:41:54 -0600 | [diff] [blame] | 404 | #if defined(CONFIG_PPC) && !defined(CONFIG_DM_SPI) |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 405 | static int initr_spi(void) |
| 406 | { |
| 407 | /* PPC does this here */ |
| 408 | #ifdef CONFIG_SPI |
| 409 | #if !defined(CONFIG_ENV_IS_IN_EEPROM) |
| 410 | spi_init_f(); |
| 411 | #endif |
| 412 | spi_init_r(); |
| 413 | #endif |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 414 | return 0; |
| 415 | } |
| 416 | #endif |
| 417 | |
| 418 | #ifdef CONFIG_CMD_NAND |
| 419 | /* go init the NAND */ |
Jeroen Hofstee | 2588ba1 | 2014-10-08 22:57:32 +0200 | [diff] [blame] | 420 | static int initr_nand(void) |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 421 | { |
| 422 | puts("NAND: "); |
| 423 | nand_init(); |
| 424 | return 0; |
| 425 | } |
| 426 | #endif |
| 427 | |
| 428 | #if defined(CONFIG_CMD_ONENAND) |
| 429 | /* go init the NAND */ |
Jeroen Hofstee | 2588ba1 | 2014-10-08 22:57:32 +0200 | [diff] [blame] | 430 | static int initr_onenand(void) |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 431 | { |
| 432 | puts("NAND: "); |
| 433 | onenand_init(); |
| 434 | return 0; |
| 435 | } |
| 436 | #endif |
| 437 | |
| 438 | #ifdef CONFIG_GENERIC_MMC |
Jeroen Hofstee | 2588ba1 | 2014-10-08 22:57:32 +0200 | [diff] [blame] | 439 | static int initr_mmc(void) |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 440 | { |
| 441 | puts("MMC: "); |
| 442 | mmc_initialize(gd->bd); |
| 443 | return 0; |
| 444 | } |
| 445 | #endif |
| 446 | |
| 447 | #ifdef CONFIG_HAS_DATAFLASH |
Jeroen Hofstee | 2588ba1 | 2014-10-08 22:57:32 +0200 | [diff] [blame] | 448 | static int initr_dataflash(void) |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 449 | { |
| 450 | AT91F_DataflashInit(); |
| 451 | dataflash_print_info(); |
| 452 | return 0; |
| 453 | } |
| 454 | #endif |
| 455 | |
| 456 | /* |
| 457 | * Tell if it's OK to load the environment early in boot. |
| 458 | * |
| 459 | * If CONFIG_OF_CONFIG is defined, we'll check with the FDT to see |
| 460 | * if this is OK (defaulting to saying it's OK). |
| 461 | * |
| 462 | * NOTE: Loading the environment early can be a bad idea if security is |
| 463 | * important, since no verification is done on the environment. |
| 464 | * |
| 465 | * @return 0 if environment should not be loaded, !=0 if it is ok to load |
| 466 | */ |
| 467 | static int should_load_env(void) |
| 468 | { |
| 469 | #ifdef CONFIG_OF_CONTROL |
| 470 | return fdtdec_get_config_int(gd->fdt_blob, "load-environment", 1); |
| 471 | #elif defined CONFIG_DELAY_ENVIRONMENT |
| 472 | return 0; |
| 473 | #else |
| 474 | return 1; |
| 475 | #endif |
| 476 | } |
| 477 | |
| 478 | static int initr_env(void) |
| 479 | { |
| 480 | /* initialize environment */ |
| 481 | if (should_load_env()) |
| 482 | env_relocate(); |
| 483 | else |
| 484 | set_default_env(NULL); |
Thomas Chou | 545dfd1 | 2015-10-16 08:44:51 +0800 | [diff] [blame] | 485 | #ifdef CONFIG_OF_CONTROL |
| 486 | setenv_addr("fdtcontroladdr", gd->fdt_blob); |
| 487 | #endif |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 488 | |
| 489 | /* Initialize from environment */ |
| 490 | load_addr = getenv_ulong("loadaddr", 16, load_addr); |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 491 | #if defined(CONFIG_SYS_EXTBDINFO) |
| 492 | #if defined(CONFIG_405GP) || defined(CONFIG_405EP) |
| 493 | #if defined(CONFIG_I2CFAST) |
| 494 | /* |
| 495 | * set bi_iic_fast for linux taking environment variable |
| 496 | * "i2cfast" into account |
| 497 | */ |
| 498 | { |
| 499 | char *s = getenv("i2cfast"); |
| 500 | |
| 501 | if (s && ((*s == 'y') || (*s == 'Y'))) { |
| 502 | gd->bd->bi_iic_fast[0] = 1; |
| 503 | gd->bd->bi_iic_fast[1] = 1; |
| 504 | } |
| 505 | } |
| 506 | #endif /* CONFIG_I2CFAST */ |
| 507 | #endif /* CONFIG_405GP, CONFIG_405EP */ |
| 508 | #endif /* CONFIG_SYS_EXTBDINFO */ |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 509 | return 0; |
| 510 | } |
| 511 | |
Andreas Bießmann | c722f0b | 2015-02-06 23:06:47 +0100 | [diff] [blame] | 512 | #ifdef CONFIG_SYS_BOOTPARAMS_LEN |
| 513 | static int initr_malloc_bootparams(void) |
| 514 | { |
| 515 | gd->bd->bi_boot_params = (ulong)malloc(CONFIG_SYS_BOOTPARAMS_LEN); |
| 516 | if (!gd->bd->bi_boot_params) { |
| 517 | puts("WARNING: Cannot allocate space for boot parameters\n"); |
| 518 | return -ENOMEM; |
| 519 | } |
| 520 | return 0; |
| 521 | } |
| 522 | #endif |
| 523 | |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 524 | static int initr_jumptable(void) |
| 525 | { |
| 526 | jumptable_init(); |
| 527 | return 0; |
| 528 | } |
| 529 | |
| 530 | #if defined(CONFIG_API) |
| 531 | static int initr_api(void) |
| 532 | { |
| 533 | /* Initialize API */ |
| 534 | api_init(); |
| 535 | return 0; |
| 536 | } |
| 537 | #endif |
| 538 | |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 539 | /* enable exceptions */ |
Andreas Bießmann | a752a8b | 2015-02-06 23:06:48 +0100 | [diff] [blame] | 540 | #if defined(CONFIG_ARM) || defined(CONFIG_AVR32) |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 541 | static int initr_enable_interrupts(void) |
| 542 | { |
| 543 | enable_interrupts(); |
| 544 | return 0; |
| 545 | } |
Simon Glass | e424c15 | 2013-03-11 07:40:13 +0000 | [diff] [blame] | 546 | #endif |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 547 | |
| 548 | #ifdef CONFIG_CMD_NET |
| 549 | static int initr_ethaddr(void) |
| 550 | { |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 551 | bd_t *bd = gd->bd; |
| 552 | |
| 553 | /* kept around for legacy kernels only ... ignore the next section */ |
| 554 | eth_getenv_enetaddr("ethaddr", bd->bi_enetaddr); |
| 555 | #ifdef CONFIG_HAS_ETH1 |
| 556 | eth_getenv_enetaddr("eth1addr", bd->bi_enet1addr); |
| 557 | #endif |
| 558 | #ifdef CONFIG_HAS_ETH2 |
| 559 | eth_getenv_enetaddr("eth2addr", bd->bi_enet2addr); |
| 560 | #endif |
| 561 | #ifdef CONFIG_HAS_ETH3 |
| 562 | eth_getenv_enetaddr("eth3addr", bd->bi_enet3addr); |
| 563 | #endif |
| 564 | #ifdef CONFIG_HAS_ETH4 |
| 565 | eth_getenv_enetaddr("eth4addr", bd->bi_enet4addr); |
| 566 | #endif |
| 567 | #ifdef CONFIG_HAS_ETH5 |
| 568 | eth_getenv_enetaddr("eth5addr", bd->bi_enet5addr); |
| 569 | #endif |
| 570 | return 0; |
| 571 | } |
| 572 | #endif /* CONFIG_CMD_NET */ |
| 573 | |
| 574 | #ifdef CONFIG_CMD_KGDB |
| 575 | static int initr_kgdb(void) |
| 576 | { |
| 577 | puts("KGDB: "); |
| 578 | kgdb_init(); |
| 579 | return 0; |
| 580 | } |
| 581 | #endif |
| 582 | |
Bernhard Nortmann | 13cfbe5 | 2015-08-21 15:13:21 +0200 | [diff] [blame] | 583 | #if defined(CONFIG_STATUS_LED) |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 584 | static int initr_status_led(void) |
| 585 | { |
Bernhard Nortmann | 13cfbe5 | 2015-08-21 15:13:21 +0200 | [diff] [blame] | 586 | #if defined(STATUS_LED_BOOT) |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 587 | status_led_set(STATUS_LED_BOOT, STATUS_LED_BLINKING); |
Bernhard Nortmann | 13cfbe5 | 2015-08-21 15:13:21 +0200 | [diff] [blame] | 588 | #else |
| 589 | status_led_init(); |
| 590 | #endif |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 591 | return 0; |
| 592 | } |
| 593 | #endif |
| 594 | |
Francois Retief | 3f33f6a | 2014-10-27 13:39:03 +0200 | [diff] [blame] | 595 | #if defined(CONFIG_CMD_AMBAPP) && defined(CONFIG_SYS_AMBAPP_PRINT_ON_STARTUP) |
| 596 | extern int do_ambapp_print(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); |
| 597 | |
| 598 | static int initr_ambapp_print(void) |
| 599 | { |
| 600 | puts("AMBA:\n"); |
| 601 | do_ambapp_print(NULL, 0, 0, NULL); |
| 602 | |
| 603 | return 0; |
| 604 | } |
| 605 | #endif |
| 606 | |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 607 | #if defined(CONFIG_CMD_SCSI) |
| 608 | static int initr_scsi(void) |
| 609 | { |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 610 | puts("SCSI: "); |
| 611 | scsi_init(); |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 612 | |
| 613 | return 0; |
| 614 | } |
Ian Campbell | 2c997e7 | 2014-07-21 19:23:18 +0100 | [diff] [blame] | 615 | #endif |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 616 | |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 617 | #if defined(CONFIG_CMD_DOC) |
| 618 | static int initr_doc(void) |
| 619 | { |
| 620 | puts("DOC: "); |
| 621 | doc_init(); |
Ian Campbell | 19ad527 | 2014-07-24 09:29:57 +0100 | [diff] [blame] | 622 | return 0; |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 623 | } |
| 624 | #endif |
| 625 | |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 626 | #ifdef CONFIG_BITBANGMII |
| 627 | static int initr_bbmii(void) |
| 628 | { |
| 629 | bb_miiphy_init(); |
| 630 | return 0; |
| 631 | } |
| 632 | #endif |
| 633 | |
| 634 | #ifdef CONFIG_CMD_NET |
| 635 | static int initr_net(void) |
| 636 | { |
| 637 | puts("Net: "); |
Joe Hershberger | d2eaec6 | 2015-03-22 17:09:06 -0500 | [diff] [blame] | 638 | eth_initialize(); |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 639 | #if defined(CONFIG_RESET_PHY_R) |
| 640 | debug("Reset Ethernet PHY\n"); |
| 641 | reset_phy(); |
| 642 | #endif |
| 643 | return 0; |
| 644 | } |
| 645 | #endif |
| 646 | |
| 647 | #ifdef CONFIG_POST |
| 648 | static int initr_post(void) |
| 649 | { |
| 650 | post_run(NULL, POST_RAM | post_bootmode_get(0)); |
| 651 | return 0; |
| 652 | } |
| 653 | #endif |
| 654 | |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 655 | #if defined(CONFIG_CMD_PCMCIA) && !defined(CONFIG_CMD_IDE) |
| 656 | static int initr_pcmcia(void) |
| 657 | { |
| 658 | puts("PCMCIA:"); |
| 659 | pcmcia_init(); |
| 660 | return 0; |
| 661 | } |
| 662 | #endif |
| 663 | |
| 664 | #if defined(CONFIG_CMD_IDE) |
| 665 | static int initr_ide(void) |
| 666 | { |
| 667 | #ifdef CONFIG_IDE_8xx_PCCARD |
| 668 | puts("PCMCIA:"); |
| 669 | #else |
| 670 | puts("IDE: "); |
| 671 | #endif |
| 672 | #if defined(CONFIG_START_IDE) |
| 673 | if (board_start_ide()) |
| 674 | ide_init(); |
| 675 | #else |
| 676 | ide_init(); |
| 677 | #endif |
| 678 | return 0; |
| 679 | } |
| 680 | #endif |
| 681 | |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 682 | #if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER) |
| 683 | /* |
| 684 | * Export available size of memory for Linux, taking into account the |
| 685 | * protected RAM at top of memory |
| 686 | */ |
| 687 | int initr_mem(void) |
| 688 | { |
| 689 | ulong pram = 0; |
| 690 | char memsz[32]; |
| 691 | |
| 692 | # ifdef CONFIG_PRAM |
| 693 | pram = getenv_ulong("pram", 10, CONFIG_PRAM); |
| 694 | # endif |
| 695 | # if defined(CONFIG_LOGBUFFER) && !defined(CONFIG_ALT_LB_ADDR) |
| 696 | /* Also take the logbuffer into account (pram is in kB) */ |
| 697 | pram += (LOGBUFF_LEN + LOGBUFF_OVERHEAD) / 1024; |
| 698 | # endif |
Valentin Longchamp | ae1a74e | 2014-10-03 11:16:19 +0200 | [diff] [blame] | 699 | sprintf(memsz, "%ldk", (long int) ((gd->ram_size / 1024) - pram)); |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 700 | setenv("mem", memsz); |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 701 | |
| 702 | return 0; |
| 703 | } |
| 704 | #endif |
| 705 | |
| 706 | #ifdef CONFIG_CMD_BEDBUG |
| 707 | static int initr_bedbug(void) |
| 708 | { |
| 709 | bedbug_init(); |
| 710 | |
| 711 | return 0; |
| 712 | } |
| 713 | #endif |
| 714 | |
| 715 | #ifdef CONFIG_PS2KBD |
| 716 | static int initr_kbd(void) |
| 717 | { |
| 718 | puts("PS/2: "); |
| 719 | kbd_init(); |
| 720 | return 0; |
| 721 | } |
| 722 | #endif |
| 723 | |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 724 | static int run_main_loop(void) |
| 725 | { |
Simon Glass | a733b06 | 2013-04-26 02:53:43 +0000 | [diff] [blame] | 726 | #ifdef CONFIG_SANDBOX |
| 727 | sandbox_main_loop_init(); |
| 728 | #endif |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 729 | /* main_loop() can return to retry autoboot, if so just run it again */ |
| 730 | for (;;) |
| 731 | main_loop(); |
| 732 | return 0; |
| 733 | } |
| 734 | |
| 735 | /* |
| 736 | * Over time we hope to remove these functions with code fragments and |
| 737 | * stub funtcions, and instead call the relevant function directly. |
| 738 | * |
| 739 | * We also hope to remove most of the driver-related init and do it if/when |
| 740 | * the driver is later used. |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 741 | * |
| 742 | * TODO: perhaps reset the watchdog in the initcall function after each call? |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 743 | */ |
| 744 | init_fnc_t init_sequence_r[] = { |
Simon Glass | 71c52db | 2013-06-11 11:14:42 -0700 | [diff] [blame] | 745 | initr_trace, |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 746 | initr_reloc, |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 747 | /* TODO: could x86/PPC have this also perhaps? */ |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 748 | #ifdef CONFIG_ARM |
| 749 | initr_caches, |
York Sun | 12eaf31 | 2015-03-20 19:28:11 -0700 | [diff] [blame] | 750 | /* Note: For Freescale LS2 SoCs, new MMU table is created in DDR. |
| 751 | * A temporary mapping of IFC high region is since removed, |
| 752 | * so environmental variables in NOR flash is not availble |
| 753 | * until board_init() is called below to remap IFC to high |
| 754 | * region. |
| 755 | */ |
Simon Glass | 9fb0249 | 2014-09-03 17:37:01 -0600 | [diff] [blame] | 756 | #endif |
| 757 | initr_reloc_global_data, |
York Sun | fef3e25 | 2014-10-02 15:20:10 -0700 | [diff] [blame] | 758 | #if defined(CONFIG_SYS_INIT_RAM_LOCK) && defined(CONFIG_E500) |
| 759 | initr_unlock_ram_in_cache, |
| 760 | #endif |
Simon Glass | 9fb0249 | 2014-09-03 17:37:01 -0600 | [diff] [blame] | 761 | initr_barrier, |
| 762 | initr_malloc, |
Simon Glass | 9854a87 | 2015-11-08 23:47:48 -0700 | [diff] [blame] | 763 | initr_console_record, |
Jan Kiszka | 671fa63 | 2015-03-09 07:47:18 +0100 | [diff] [blame] | 764 | #ifdef CONFIG_SYS_NONCACHED_MEMORY |
| 765 | initr_noncached, |
| 766 | #endif |
Simon Glass | 9fb0249 | 2014-09-03 17:37:01 -0600 | [diff] [blame] | 767 | bootstage_relocate, |
| 768 | #ifdef CONFIG_DM |
| 769 | initr_dm, |
| 770 | #endif |
Simon Glass | 881c124 | 2015-11-28 22:16:35 -0700 | [diff] [blame] | 771 | initr_bootstage, |
Kun-Hua Huang | 2e88bb2 | 2015-08-24 14:52:35 +0800 | [diff] [blame] | 772 | #if defined(CONFIG_ARM) || defined(CONFIG_NDS32) |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 773 | board_init, /* Setup chipselects */ |
| 774 | #endif |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 775 | /* |
| 776 | * TODO: printing of the clock inforamtion of the board is now |
| 777 | * implemented as part of bdinfo command. Currently only support for |
| 778 | * davinci SOC's is added. Remove this check once all the board |
| 779 | * implement this. |
| 780 | */ |
| 781 | #ifdef CONFIG_CLOCKS |
| 782 | set_cpu_clk_info, /* Setup clock information */ |
| 783 | #endif |
Simon Glass | 9fb0249 | 2014-09-03 17:37:01 -0600 | [diff] [blame] | 784 | stdio_init_tables, |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 785 | initr_serial, |
| 786 | initr_announce, |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 787 | INIT_FUNC_WATCHDOG_RESET |
Andreas Bießmann | 61d7b1b | 2015-01-20 00:29:05 +0100 | [diff] [blame] | 788 | #ifdef CONFIG_NEEDS_MANUAL_RELOC |
| 789 | initr_manual_reloc_cmdtable, |
| 790 | #endif |
angelo@sysam.it | e310b93 | 2015-02-12 01:40:17 +0100 | [diff] [blame] | 791 | #if defined(CONFIG_PPC) || defined(CONFIG_M68K) |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 792 | initr_trap, |
| 793 | #endif |
| 794 | #ifdef CONFIG_ADDR_MAP |
| 795 | initr_addr_map, |
| 796 | #endif |
| 797 | #if defined(CONFIG_BOARD_EARLY_INIT_R) |
| 798 | board_early_init_r, |
| 799 | #endif |
| 800 | INIT_FUNC_WATCHDOG_RESET |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 801 | #ifdef CONFIG_LOGBUFFER |
| 802 | initr_logbuffer, |
| 803 | #endif |
| 804 | #ifdef CONFIG_POST |
| 805 | initr_post_backlog, |
| 806 | #endif |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 807 | INIT_FUNC_WATCHDOG_RESET |
| 808 | #ifdef CONFIG_SYS_DELAYED_ICACHE |
| 809 | initr_icache_enable, |
| 810 | #endif |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 811 | #if defined(CONFIG_PCI) && defined(CONFIG_SYS_EARLY_PCI_INIT) |
| 812 | /* |
| 813 | * Do early PCI configuration _before_ the flash gets initialised, |
| 814 | * because PCU ressources are crucial for flash access on some boards. |
| 815 | */ |
| 816 | initr_pci, |
| 817 | #endif |
| 818 | #ifdef CONFIG_WINBOND_83C553 |
| 819 | initr_w83c553f, |
| 820 | #endif |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 821 | #ifdef CONFIG_ARCH_EARLY_INIT_R |
| 822 | arch_early_init_r, |
| 823 | #endif |
| 824 | power_init_board, |
| 825 | #ifndef CONFIG_SYS_NO_FLASH |
| 826 | initr_flash, |
| 827 | #endif |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 828 | INIT_FUNC_WATCHDOG_RESET |
Francois Retief | e17c520 | 2015-10-28 14:29:32 +0200 | [diff] [blame] | 829 | #if defined(CONFIG_PPC) || defined(CONFIG_M68K) || defined(CONFIG_X86) || \ |
| 830 | defined(CONFIG_SPARC) |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 831 | /* initialize higher level parts of CPU like time base and timers */ |
| 832 | cpu_init_r, |
Simon Glass | be274b9 | 2013-03-05 14:39:53 +0000 | [diff] [blame] | 833 | #endif |
| 834 | #ifdef CONFIG_PPC |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 835 | initr_spi, |
| 836 | #endif |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 837 | #ifdef CONFIG_CMD_NAND |
| 838 | initr_nand, |
| 839 | #endif |
| 840 | #ifdef CONFIG_CMD_ONENAND |
| 841 | initr_onenand, |
| 842 | #endif |
| 843 | #ifdef CONFIG_GENERIC_MMC |
| 844 | initr_mmc, |
| 845 | #endif |
| 846 | #ifdef CONFIG_HAS_DATAFLASH |
| 847 | initr_dataflash, |
| 848 | #endif |
| 849 | initr_env, |
Andreas Bießmann | c722f0b | 2015-02-06 23:06:47 +0100 | [diff] [blame] | 850 | #ifdef CONFIG_SYS_BOOTPARAMS_LEN |
| 851 | initr_malloc_bootparams, |
| 852 | #endif |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 853 | INIT_FUNC_WATCHDOG_RESET |
| 854 | initr_secondary_cpu, |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 855 | #if defined(CONFIG_ID_EEPROM) || defined(CONFIG_SYS_I2C_MAC_OFFSET) |
| 856 | mac_read_from_eeprom, |
| 857 | #endif |
| 858 | INIT_FUNC_WATCHDOG_RESET |
| 859 | #if defined(CONFIG_PCI) && !defined(CONFIG_SYS_EARLY_PCI_INIT) |
| 860 | /* |
| 861 | * Do pci configuration |
| 862 | */ |
| 863 | initr_pci, |
| 864 | #endif |
Simon Glass | 9fb0249 | 2014-09-03 17:37:01 -0600 | [diff] [blame] | 865 | stdio_add_devices, |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 866 | initr_jumptable, |
| 867 | #ifdef CONFIG_API |
| 868 | initr_api, |
| 869 | #endif |
| 870 | console_init_r, /* fully init console as a device */ |
| 871 | #ifdef CONFIG_DISPLAY_BOARDINFO_LATE |
Masahiro Yamada | 0365ffc | 2015-01-14 17:07:05 +0900 | [diff] [blame] | 872 | show_board_info, |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 873 | #endif |
| 874 | #ifdef CONFIG_ARCH_MISC_INIT |
| 875 | arch_misc_init, /* miscellaneous arch-dependent init */ |
| 876 | #endif |
| 877 | #ifdef CONFIG_MISC_INIT_R |
| 878 | misc_init_r, /* miscellaneous platform-dependent init */ |
| 879 | #endif |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 880 | INIT_FUNC_WATCHDOG_RESET |
| 881 | #ifdef CONFIG_CMD_KGDB |
| 882 | initr_kgdb, |
| 883 | #endif |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 884 | interrupt_init, |
Andreas Bießmann | a752a8b | 2015-02-06 23:06:48 +0100 | [diff] [blame] | 885 | #if defined(CONFIG_ARM) || defined(CONFIG_AVR32) |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 886 | initr_enable_interrupts, |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 887 | #endif |
Bin Meng | 643b0f7 | 2015-10-22 19:13:33 -0700 | [diff] [blame] | 888 | #if defined(CONFIG_MICROBLAZE) || defined(CONFIG_AVR32) || defined(CONFIG_M68K) |
Simon Glass | be274b9 | 2013-03-05 14:39:53 +0000 | [diff] [blame] | 889 | timer_init, /* initialize timer */ |
| 890 | #endif |
Bernhard Nortmann | 13cfbe5 | 2015-08-21 15:13:21 +0200 | [diff] [blame] | 891 | #if defined(CONFIG_STATUS_LED) |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 892 | initr_status_led, |
| 893 | #endif |
| 894 | /* PPC has a udelay(20) here dating from 2002. Why? */ |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 895 | #ifdef CONFIG_CMD_NET |
| 896 | initr_ethaddr, |
| 897 | #endif |
| 898 | #ifdef CONFIG_BOARD_LATE_INIT |
| 899 | board_late_init, |
| 900 | #endif |
Francois Retief | 3f33f6a | 2014-10-27 13:39:03 +0200 | [diff] [blame] | 901 | #if defined(CONFIG_CMD_AMBAPP) |
| 902 | ambapp_init_reloc, |
| 903 | #if defined(CONFIG_SYS_AMBAPP_PRINT_ON_STARTUP) |
| 904 | initr_ambapp_print, |
| 905 | #endif |
| 906 | #endif |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 907 | #ifdef CONFIG_CMD_SCSI |
| 908 | INIT_FUNC_WATCHDOG_RESET |
| 909 | initr_scsi, |
| 910 | #endif |
| 911 | #ifdef CONFIG_CMD_DOC |
| 912 | INIT_FUNC_WATCHDOG_RESET |
| 913 | initr_doc, |
| 914 | #endif |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 915 | #ifdef CONFIG_BITBANGMII |
| 916 | initr_bbmii, |
| 917 | #endif |
| 918 | #ifdef CONFIG_CMD_NET |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 919 | INIT_FUNC_WATCHDOG_RESET |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 920 | initr_net, |
| 921 | #endif |
| 922 | #ifdef CONFIG_POST |
| 923 | initr_post, |
| 924 | #endif |
Simon Glass | c2240d4 | 2013-03-14 07:20:12 +0000 | [diff] [blame] | 925 | #if defined(CONFIG_CMD_PCMCIA) && !defined(CONFIG_CMD_IDE) |
| 926 | initr_pcmcia, |
| 927 | #endif |
| 928 | #if defined(CONFIG_CMD_IDE) |
| 929 | initr_ide, |
| 930 | #endif |
| 931 | #ifdef CONFIG_LAST_STAGE_INIT |
| 932 | INIT_FUNC_WATCHDOG_RESET |
| 933 | /* |
| 934 | * Some parts can be only initialized if all others (like |
| 935 | * Interrupts) are up and running (i.e. the PC-style ISA |
| 936 | * keyboard). |
| 937 | */ |
| 938 | last_stage_init, |
| 939 | #endif |
| 940 | #ifdef CONFIG_CMD_BEDBUG |
| 941 | INIT_FUNC_WATCHDOG_RESET |
| 942 | initr_bedbug, |
| 943 | #endif |
| 944 | #if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER) |
| 945 | initr_mem, |
| 946 | #endif |
| 947 | #ifdef CONFIG_PS2KBD |
| 948 | initr_kbd, |
| 949 | #endif |
Francois Retief | 1e85cce | 2015-11-23 13:05:44 +0200 | [diff] [blame] | 950 | #if defined(CONFIG_SPARC) |
| 951 | prom_init, |
| 952 | #endif |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 953 | run_main_loop, |
| 954 | }; |
| 955 | |
| 956 | void board_init_r(gd_t *new_gd, ulong dest_addr) |
| 957 | { |
Alexey Brodkin | 7395398 | 2014-01-20 14:30:39 +0400 | [diff] [blame] | 958 | #ifdef CONFIG_NEEDS_MANUAL_RELOC |
| 959 | int i; |
| 960 | #endif |
| 961 | |
Andreas Bießmann | a752a8b | 2015-02-06 23:06:48 +0100 | [diff] [blame] | 962 | #ifdef CONFIG_AVR32 |
| 963 | mmu_init_r(dest_addr); |
| 964 | #endif |
| 965 | |
Jeroen Hofstee | 47a602e | 2014-07-30 21:54:49 +0200 | [diff] [blame] | 966 | #if !defined(CONFIG_X86) && !defined(CONFIG_ARM) && !defined(CONFIG_ARM64) |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 967 | gd = new_gd; |
Simon Glass | be274b9 | 2013-03-05 14:39:53 +0000 | [diff] [blame] | 968 | #endif |
Alexey Brodkin | 7395398 | 2014-01-20 14:30:39 +0400 | [diff] [blame] | 969 | |
| 970 | #ifdef CONFIG_NEEDS_MANUAL_RELOC |
| 971 | for (i = 0; i < ARRAY_SIZE(init_sequence_r); i++) |
| 972 | init_sequence_r[i] += gd->reloc_off; |
| 973 | #endif |
| 974 | |
Simon Glass | 6f6430d | 2013-03-11 14:30:37 +0000 | [diff] [blame] | 975 | if (initcall_run_list(init_sequence_r)) |
| 976 | hang(); |
| 977 | |
| 978 | /* NOTREACHED - run_main_loop() does not return */ |
| 979 | hang(); |
| 980 | } |