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