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