Stefan Roese | 07038ad | 2013-04-02 10:37:04 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 Stefan Roese <sr@denx.de> |
| 3 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 4 | * SPDX-License-Identifier: GPL-2.0+ |
Stefan Roese | 07038ad | 2013-04-02 10:37:04 +0200 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <spl.h> |
| 9 | |
| 10 | DECLARE_GLOBAL_DATA_PTR; |
| 11 | |
| 12 | /* |
| 13 | * Return selected boot device. On PPC4xx its only NOR flash right now. |
| 14 | */ |
| 15 | u32 spl_boot_device(void) |
| 16 | { |
| 17 | return BOOT_DEVICE_NOR; |
| 18 | } |
| 19 | |
| 20 | /* |
| 21 | * SPL version of board_init_f() |
| 22 | */ |
| 23 | void board_init_f(ulong bootflag) |
| 24 | { |
| 25 | /* |
| 26 | * First we need to initialize the SDRAM, so that the real |
| 27 | * U-Boot or the OS (Linux) can be loaded |
| 28 | */ |
Simon Glass | d35f338 | 2017-04-06 12:47:05 -0600 | [diff] [blame] | 29 | dram_init(); |
Stefan Roese | 07038ad | 2013-04-02 10:37:04 +0200 | [diff] [blame] | 30 | |
| 31 | /* Clear bss */ |
| 32 | memset(__bss_start, '\0', __bss_end - __bss_start); |
| 33 | |
| 34 | /* |
| 35 | * Init global_data pointer. Has to be done before calling |
| 36 | * get_clocks(), as it stores some clock values into gd needed |
| 37 | * later on in the serial driver. |
| 38 | */ |
| 39 | /* Pointer is writable since we allocated a register for it */ |
| 40 | gd = (gd_t *)(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET); |
| 41 | /* Clear initial global data */ |
| 42 | memset((void *)gd, 0, sizeof(gd_t)); |
| 43 | |
| 44 | /* |
| 45 | * get_clocks() needs to be called so that the serial driver |
| 46 | * works correctly |
| 47 | */ |
| 48 | get_clocks(); |
| 49 | |
| 50 | /* |
| 51 | * Do rudimental console / serial setup |
| 52 | */ |
| 53 | preloader_console_init(); |
| 54 | |
| 55 | /* |
| 56 | * Call board_init_r() (SPL framework version) to load and boot |
| 57 | * real U-Boot or OS |
| 58 | */ |
| 59 | board_init_r(NULL, 0); |
| 60 | /* Does not return!!! */ |
| 61 | } |