xref: /rk3399_rockchip-uboot/arch/arm/lib/spl.c (revision fc8fdc76e72e4ea57a7257e7054ca1a3b0966d34)
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 
16*fc8fdc76SSimon Glass #ifndef CONFIG_DM
176507f133STom Rini /* Pointer to as well as the global data structure for SPL */
186507f133STom Rini DECLARE_GLOBAL_DATA_PTR;
19480ca13eSSimon Glass 
20480ca13eSSimon Glass /*
21480ca13eSSimon Glass  * WARNING: This is going away very soon. Don't use it and don't submit
22480ca13eSSimon Glass  * pafches that rely on it. The global_data area is set up in crt0.S.
23480ca13eSSimon Glass  */
246507f133STom Rini gd_t gdata __attribute__ ((section(".data")));
25*fc8fdc76SSimon Glass #endif
266507f133STom Rini 
276507f133STom Rini /*
286507f133STom Rini  * In the context of SPL, board_init_f must ensure that any clocks/etc for
296507f133STom Rini  * DDR are enabled, ensure that the stack pointer is valid, clear the BSS
306507f133STom Rini  * and call board_init_f.  We provide this version by default but mark it
316507f133STom Rini  * as __weak to allow for platforms to do this in their own way if needed.
326507f133STom Rini  */
336507f133STom Rini void __weak board_init_f(ulong dummy)
346507f133STom Rini {
356507f133STom Rini 	/* Clear the BSS. */
363929fb0aSSimon Glass 	memset(__bss_start, 0, __bss_end - __bss_start);
376507f133STom Rini 
38*fc8fdc76SSimon Glass #ifndef CONFIG_DM
39480ca13eSSimon Glass 	/* TODO: Remove settings of the global data pointer here */
401ee30aeeSTom Rini 	gd = &gdata;
41*fc8fdc76SSimon Glass #endif
421ee30aeeSTom Rini 
436507f133STom Rini 	board_init_r(NULL, 0);
446507f133STom Rini }
456507f133STom Rini 
466507f133STom Rini /*
476507f133STom Rini  * This function jumps to an image with argument. Normally an FDT or ATAGS
486507f133STom Rini  * image.
496507f133STom Rini  * arg: Pointer to paramter image in RAM
506507f133STom Rini  */
516507f133STom Rini #ifdef CONFIG_SPL_OS_BOOT
526507f133STom Rini void __noreturn jump_to_image_linux(void *arg)
536507f133STom Rini {
54ec101fdbSTom Rini 	unsigned long machid = 0xffffffff;
55ec101fdbSTom Rini #ifdef CONFIG_MACH_TYPE
56ec101fdbSTom Rini 	machid = CONFIG_MACH_TYPE;
57ec101fdbSTom Rini #endif
58ec101fdbSTom Rini 
596507f133STom Rini 	debug("Entering kernel arg pointer: 0x%p\n", arg);
606507f133STom Rini 	typedef void (*image_entry_arg_t)(int, int, void *)
616507f133STom Rini 		__attribute__ ((noreturn));
626507f133STom Rini 	image_entry_arg_t image_entry =
636507f133STom Rini 		(image_entry_arg_t) spl_image.entry_point;
646507f133STom Rini 	cleanup_before_linux();
65ec101fdbSTom Rini 	image_entry(0, machid, arg);
666507f133STom Rini }
676507f133STom Rini #endif
68