xref: /rk3399_rockchip-uboot/arch/arm/lib/spl.c (revision c62db35d52c6ba5f31ac36e690c58ec54b273298)
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>
15*c62db35dSSimon Glass #include <asm/mach-types.h>
166507f133STom Rini 
17b5d92ba1STom Rini #ifndef CONFIG_SPL_DM
186507f133STom Rini /* Pointer to as well as the global data structure for SPL */
196507f133STom Rini DECLARE_GLOBAL_DATA_PTR;
20480ca13eSSimon Glass 
21480ca13eSSimon Glass /*
22480ca13eSSimon Glass  * WARNING: This is going away very soon. Don't use it and don't submit
23480ca13eSSimon Glass  * pafches that rely on it. The global_data area is set up in crt0.S.
24480ca13eSSimon Glass  */
256507f133STom Rini gd_t gdata __attribute__ ((section(".data")));
26fc8fdc76SSimon Glass #endif
276507f133STom Rini 
286507f133STom Rini /*
29b8cb51d0SJeremy Hunt  * In the context of SPL, board_init_f() prepares the hardware for execution
30b8cb51d0SJeremy Hunt  * from system RAM (DRAM, DDR...). As system RAM may not be available yet,
31b8cb51d0SJeremy Hunt  * board_init_f() must use the current GD to store any data which must be
32b8cb51d0SJeremy Hunt  * passed on to later stages. These data include the relocation destination,
33b8cb51d0SJeremy Hunt  * the future stack, and the future GD location. BSS is cleared after this
34b8cb51d0SJeremy Hunt  * function (and therefore must be accessible).
35b8cb51d0SJeremy Hunt  *
36b8cb51d0SJeremy Hunt  * We provide this version by default but mark it as __weak to allow for
37b8cb51d0SJeremy Hunt  * platforms to do this in their own way if needed. Please see the top
38b8cb51d0SJeremy Hunt  * level U-Boot README "Board Initialization Flow" section for info on what
39b8cb51d0SJeremy Hunt  * to put in this function.
406507f133STom Rini  */
board_init_f(ulong dummy)416507f133STom Rini void __weak board_init_f(ulong dummy)
426507f133STom Rini {
436507f133STom Rini }
446507f133STom Rini 
456507f133STom Rini /*
466507f133STom Rini  * This function jumps to an image with argument. Normally an FDT or ATAGS
476507f133STom Rini  * image.
486507f133STom Rini  */
496507f133STom Rini #ifdef CONFIG_SPL_OS_BOOT
jump_to_image_linux(struct spl_image_info * spl_image)505bf5250eSVikas Manocha void __noreturn jump_to_image_linux(struct spl_image_info *spl_image)
516507f133STom Rini {
52ec101fdbSTom Rini 	unsigned long machid = 0xffffffff;
53ec101fdbSTom Rini #ifdef CONFIG_MACH_TYPE
54ec101fdbSTom Rini 	machid = CONFIG_MACH_TYPE;
55ec101fdbSTom Rini #endif
56ec101fdbSTom Rini 
575bf5250eSVikas Manocha 	debug("Entering kernel arg pointer: 0x%p\n", spl_image->arg);
586507f133STom Rini 	typedef void (*image_entry_arg_t)(int, int, void *)
596507f133STom Rini 		__attribute__ ((noreturn));
606507f133STom Rini 	image_entry_arg_t image_entry =
61ca12e65cSSimon Glass 		(image_entry_arg_t)(uintptr_t) spl_image->entry_point;
626507f133STom Rini 	cleanup_before_linux();
635bf5250eSVikas Manocha 	image_entry(0, machid, spl_image->arg);
646507f133STom Rini }
656507f133STom Rini #endif
66