Stefan Roese | 50b5ac0 | 2012-08-16 17:53:18 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 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 | 50b5ac0 | 2012-08-16 17:53:18 +0200 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <spl.h> |
| 9 | |
| 10 | DECLARE_GLOBAL_DATA_PTR; |
| 11 | |
| 12 | /* |
| 13 | * Needed to align size SPL image to a 4-byte length |
| 14 | */ |
| 15 | u32 end_align __attribute__ ((section(".end_align"))); |
| 16 | |
| 17 | /* |
| 18 | * Return selected boot device. On MPC5200 its only NOR flash right now. |
| 19 | */ |
| 20 | u32 spl_boot_device(void) |
| 21 | { |
| 22 | return BOOT_DEVICE_NOR; |
| 23 | } |
| 24 | |
| 25 | /* |
| 26 | * SPL version of board_init_f() |
| 27 | */ |
| 28 | void board_init_f(ulong bootflag) |
| 29 | { |
| 30 | end_align = (u32)__spl_flash_end; |
| 31 | |
| 32 | /* |
Stefan Roese | e39447d | 2012-12-06 03:41:57 +0000 | [diff] [blame] | 33 | * On MPC5200, the initial RAM (and gd) is located in the internal |
| 34 | * SRAM. So we can actually call the preloader console init code |
| 35 | * before calling initdram(). This makes serial output (printf) |
| 36 | * available very early, even before SDRAM init, which has been |
| 37 | * an U-Boot priciple from day 1. |
Stefan Roese | 50b5ac0 | 2012-08-16 17:53:18 +0200 | [diff] [blame] | 38 | */ |
Stefan Roese | 50b5ac0 | 2012-08-16 17:53:18 +0200 | [diff] [blame] | 39 | |
| 40 | /* |
| 41 | * Init global_data pointer. Has to be done before calling |
| 42 | * get_clocks(), as it stores some clock values into gd needed |
| 43 | * later on in the serial driver. |
| 44 | */ |
| 45 | /* Pointer is writable since we allocated a register for it */ |
| 46 | gd = (gd_t *)(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET); |
| 47 | /* Clear initial global data */ |
| 48 | memset((void *)gd, 0, sizeof(gd_t)); |
| 49 | |
| 50 | /* |
| 51 | * get_clocks() needs to be called so that the serial driver |
| 52 | * works correctly |
| 53 | */ |
| 54 | get_clocks(); |
| 55 | |
| 56 | /* |
| 57 | * Do rudimental console / serial setup |
| 58 | */ |
| 59 | preloader_console_init(); |
| 60 | |
| 61 | /* |
Stefan Roese | e39447d | 2012-12-06 03:41:57 +0000 | [diff] [blame] | 62 | * First we need to initialize the SDRAM, so that the real |
| 63 | * U-Boot or the OS (Linux) can be loaded |
| 64 | */ |
| 65 | initdram(0); |
| 66 | |
| 67 | /* Clear bss */ |
Simon Glass | ed70c8f | 2013-03-14 06:54:53 +0000 | [diff] [blame] | 68 | memset(__bss_start, '\0', __bss_end - __bss_start); |
Stefan Roese | e39447d | 2012-12-06 03:41:57 +0000 | [diff] [blame] | 69 | |
| 70 | /* |
Stefan Roese | 50b5ac0 | 2012-08-16 17:53:18 +0200 | [diff] [blame] | 71 | * Call board_init_r() (SPL framework version) to load and boot |
| 72 | * real U-Boot or OS |
| 73 | */ |
| 74 | board_init_r(NULL, 0); |
| 75 | /* Does not return!!! */ |
| 76 | } |