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