1*6507f133STom Rini /* 2*6507f133STom Rini * (C) Copyright 2010-2012 3*6507f133STom Rini * Texas Instruments, <www.ti.com> 4*6507f133STom Rini * 5*6507f133STom Rini * Aneesh V <aneesh@ti.com> 6*6507f133STom Rini * Tom Rini <trini@ti.com> 7*6507f133STom Rini * 8*6507f133STom Rini * See file CREDITS for list of people who contributed to this 9*6507f133STom Rini * project. 10*6507f133STom Rini * 11*6507f133STom Rini * This program is free software; you can redistribute it and/or 12*6507f133STom Rini * modify it under the terms of the GNU General Public License as 13*6507f133STom Rini * published by the Free Software Foundation; either version 2 of 14*6507f133STom Rini * the License, or (at your option) any later version. 15*6507f133STom Rini * 16*6507f133STom Rini * This program is distributed in the hope that it will be useful, 17*6507f133STom Rini * but WITHOUT ANY WARRANTY; without even the implied warranty of 18*6507f133STom Rini * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19*6507f133STom Rini * GNU General Public License for more details. 20*6507f133STom Rini * 21*6507f133STom Rini * You should have received a copy of the GNU General Public License 22*6507f133STom Rini * along with this program; if not, write to the Free Software 23*6507f133STom Rini * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 24*6507f133STom Rini * MA 02111-1307 USA 25*6507f133STom Rini */ 26*6507f133STom Rini #include <common.h> 27*6507f133STom Rini #include <config.h> 28*6507f133STom Rini #include <spl.h> 29*6507f133STom Rini #include <image.h> 30*6507f133STom Rini #include <linux/compiler.h> 31*6507f133STom Rini 32*6507f133STom Rini /* Pointer to as well as the global data structure for SPL */ 33*6507f133STom Rini DECLARE_GLOBAL_DATA_PTR; 34*6507f133STom Rini gd_t gdata __attribute__ ((section(".data"))); 35*6507f133STom Rini 36*6507f133STom Rini /* 37*6507f133STom Rini * In the context of SPL, board_init_f must ensure that any clocks/etc for 38*6507f133STom Rini * DDR are enabled, ensure that the stack pointer is valid, clear the BSS 39*6507f133STom Rini * and call board_init_f. We provide this version by default but mark it 40*6507f133STom Rini * as __weak to allow for platforms to do this in their own way if needed. 41*6507f133STom Rini */ 42*6507f133STom Rini void __weak board_init_f(ulong dummy) 43*6507f133STom Rini { 44*6507f133STom Rini /* Set the stack pointer. */ 45*6507f133STom Rini asm volatile("mov sp, %0\n" : : "r"(CONFIG_SPL_STACK)); 46*6507f133STom Rini 47*6507f133STom Rini /* Clear the BSS. */ 48*6507f133STom Rini memset(__bss_start, 0, __bss_end__ - __bss_start); 49*6507f133STom Rini 50*6507f133STom Rini /* Set global data pointer. */ 51*6507f133STom Rini gd = &gdata; 52*6507f133STom Rini 53*6507f133STom Rini board_init_r(NULL, 0); 54*6507f133STom Rini } 55*6507f133STom Rini 56*6507f133STom Rini /* 57*6507f133STom Rini * This function jumps to an image with argument. Normally an FDT or ATAGS 58*6507f133STom Rini * image. 59*6507f133STom Rini * arg: Pointer to paramter image in RAM 60*6507f133STom Rini */ 61*6507f133STom Rini #ifdef CONFIG_SPL_OS_BOOT 62*6507f133STom Rini void __noreturn jump_to_image_linux(void *arg) 63*6507f133STom Rini { 64*6507f133STom Rini debug("Entering kernel arg pointer: 0x%p\n", arg); 65*6507f133STom Rini typedef void (*image_entry_arg_t)(int, int, void *) 66*6507f133STom Rini __attribute__ ((noreturn)); 67*6507f133STom Rini image_entry_arg_t image_entry = 68*6507f133STom Rini (image_entry_arg_t) spl_image.entry_point; 69*6507f133STom Rini cleanup_before_linux(); 70*6507f133STom Rini image_entry(0, CONFIG_MACH_TYPE, arg); 71*6507f133STom Rini } 72*6507f133STom Rini #endif 73