blob: e182dfbd45a34cb51d983f2a376c9d110600ae7b [file] [log] [blame]
Stefan Roese50b5ac02012-08-16 17:53:18 +02001/*
2 * Copyright (C) 2012 Stefan Roese <sr@denx.de>
3 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02004 * SPDX-License-Identifier: GPL-2.0+
Stefan Roese50b5ac02012-08-16 17:53:18 +02005 */
6
7#include <common.h>
8#include <spl.h>
9
10DECLARE_GLOBAL_DATA_PTR;
11
12/*
13 * Needed to align size SPL image to a 4-byte length
14 */
15u32 end_align __attribute__ ((section(".end_align")));
16
17/*
18 * Return selected boot device. On MPC5200 its only NOR flash right now.
19 */
20u32 spl_boot_device(void)
21{
22 return BOOT_DEVICE_NOR;
23}
24
25/*
26 * SPL version of board_init_f()
27 */
28void board_init_f(ulong bootflag)
29{
30 end_align = (u32)__spl_flash_end;
31
32 /*
Stefan Roesee39447d2012-12-06 03:41:57 +000033 * 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 Roese50b5ac02012-08-16 17:53:18 +020038 */
Stefan Roese50b5ac02012-08-16 17:53:18 +020039
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 Roesee39447d2012-12-06 03:41:57 +000062 * 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 Glassed70c8f2013-03-14 06:54:53 +000068 memset(__bss_start, '\0', __bss_end - __bss_start);
Stefan Roesee39447d2012-12-06 03:41:57 +000069
70 /*
Stefan Roese50b5ac02012-08-16 17:53:18 +020071 * 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}