xref: /rk3399_rockchip-uboot/arch/arm/lib/spl.c (revision 1ee30aeed47724eb7c8f145f064b8d03cd294808)
16507f133STom Rini /*
26507f133STom Rini  * (C) Copyright 2010-2012
36507f133STom Rini  * Texas Instruments, <www.ti.com>
46507f133STom Rini  *
56507f133STom Rini  * Aneesh V <aneesh@ti.com>
66507f133STom Rini  * Tom Rini <trini@ti.com>
76507f133STom Rini  *
81a459660SWolfgang Denk  * SPDX-License-Identifier:	GPL-2.0+
96507f133STom Rini  */
106507f133STom Rini #include <common.h>
116507f133STom Rini #include <config.h>
126507f133STom Rini #include <spl.h>
136507f133STom Rini #include <image.h>
146507f133STom Rini #include <linux/compiler.h>
156507f133STom Rini 
166507f133STom Rini /* Pointer to as well as the global data structure for SPL */
176507f133STom Rini DECLARE_GLOBAL_DATA_PTR;
186507f133STom Rini gd_t gdata __attribute__ ((section(".data")));
196507f133STom Rini 
206507f133STom Rini /*
216507f133STom Rini  * In the context of SPL, board_init_f must ensure that any clocks/etc for
226507f133STom Rini  * DDR are enabled, ensure that the stack pointer is valid, clear the BSS
236507f133STom Rini  * and call board_init_f.  We provide this version by default but mark it
246507f133STom Rini  * as __weak to allow for platforms to do this in their own way if needed.
256507f133STom Rini  */
266507f133STom Rini void __weak board_init_f(ulong dummy)
276507f133STom Rini {
286507f133STom Rini 	/* Clear the BSS. */
293929fb0aSSimon Glass 	memset(__bss_start, 0, __bss_end - __bss_start);
306507f133STom Rini 
31*1ee30aeeSTom Rini 	/* Set global data pointer. */
32*1ee30aeeSTom Rini 	gd = &gdata;
33*1ee30aeeSTom Rini 
346507f133STom Rini 	board_init_r(NULL, 0);
356507f133STom Rini }
366507f133STom Rini 
376507f133STom Rini /*
386507f133STom Rini  * This function jumps to an image with argument. Normally an FDT or ATAGS
396507f133STom Rini  * image.
406507f133STom Rini  * arg: Pointer to paramter image in RAM
416507f133STom Rini  */
426507f133STom Rini #ifdef CONFIG_SPL_OS_BOOT
436507f133STom Rini void __noreturn jump_to_image_linux(void *arg)
446507f133STom Rini {
45ec101fdbSTom Rini 	unsigned long machid = 0xffffffff;
46ec101fdbSTom Rini #ifdef CONFIG_MACH_TYPE
47ec101fdbSTom Rini 	machid = CONFIG_MACH_TYPE;
48ec101fdbSTom Rini #endif
49ec101fdbSTom Rini 
506507f133STom Rini 	debug("Entering kernel arg pointer: 0x%p\n", arg);
516507f133STom Rini 	typedef void (*image_entry_arg_t)(int, int, void *)
526507f133STom Rini 		__attribute__ ((noreturn));
536507f133STom Rini 	image_entry_arg_t image_entry =
546507f133STom Rini 		(image_entry_arg_t) spl_image.entry_point;
556507f133STom Rini 	cleanup_before_linux();
56ec101fdbSTom Rini 	image_entry(0, machid, arg);
576507f133STom Rini }
586507f133STom Rini #endif
59