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