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