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