Tom Rini | ee5bce4 | 2012-08-08 17:03:10 -0700 | [diff] [blame] | 1 | /* |
| 2 | * A lowlevel_init function that sets up the stack to call a C function to |
| 3 | * perform further init. |
| 4 | * |
| 5 | * (C) Copyright 2010 |
| 6 | * Texas Instruments, <www.ti.com> |
| 7 | * |
| 8 | * Author : |
| 9 | * Aneesh V <aneesh@ti.com> |
| 10 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 11 | * SPDX-License-Identifier: GPL-2.0+ |
Tom Rini | ee5bce4 | 2012-08-08 17:03:10 -0700 | [diff] [blame] | 12 | */ |
| 13 | |
| 14 | #include <asm-offsets.h> |
| 15 | #include <config.h> |
| 16 | #include <linux/linkage.h> |
| 17 | |
Tom Rini | 2ca39ca | 2017-05-16 14:46:34 -0400 | [diff] [blame] | 18 | .pushsection .text.s_init, "ax" |
| 19 | WEAK(s_init) |
| 20 | bx lr |
| 21 | ENDPROC(s_init) |
| 22 | .popsection |
| 23 | |
| 24 | .pushsection .text.lowlevel_init, "ax" |
| 25 | WEAK(lowlevel_init) |
Tom Rini | ee5bce4 | 2012-08-08 17:03:10 -0700 | [diff] [blame] | 26 | /* |
Simon Glass | 8071c8e | 2015-03-03 08:02:57 -0700 | [diff] [blame] | 27 | * Setup a temporary stack. Global data is not available yet. |
Tom Rini | ee5bce4 | 2012-08-08 17:03:10 -0700 | [diff] [blame] | 28 | */ |
Siarhei Siamashka | 39cb834 | 2016-09-05 06:36:10 +0300 | [diff] [blame] | 29 | #if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_STACK) |
| 30 | ldr sp, =CONFIG_SPL_STACK |
| 31 | #else |
Tom Rini | ee5bce4 | 2012-08-08 17:03:10 -0700 | [diff] [blame] | 32 | ldr sp, =CONFIG_SYS_INIT_SP_ADDR |
Siarhei Siamashka | 39cb834 | 2016-09-05 06:36:10 +0300 | [diff] [blame] | 33 | #endif |
Tom Rini | 7b643a4 | 2012-08-09 08:22:06 -0700 | [diff] [blame] | 34 | bic sp, sp, #7 /* 8-byte alignment for ABI compliance */ |
Tom Rini | f295d9e | 2015-07-31 19:55:10 -0400 | [diff] [blame] | 35 | #ifdef CONFIG_SPL_DM |
Simon Glass | 8071c8e | 2015-03-03 08:02:57 -0700 | [diff] [blame] | 36 | mov r9, #0 |
| 37 | #else |
| 38 | /* |
| 39 | * Set up global data for boards that still need it. This will be |
| 40 | * removed soon. |
| 41 | */ |
SRICHARAN R | 3f30b0a | 2013-04-24 00:41:24 +0000 | [diff] [blame] | 42 | #ifdef CONFIG_SPL_BUILD |
Jeroen Hofstee | f2d6076 | 2013-09-21 14:04:41 +0200 | [diff] [blame] | 43 | ldr r9, =gdata |
SRICHARAN R | 3f30b0a | 2013-04-24 00:41:24 +0000 | [diff] [blame] | 44 | #else |
Andreas Bießmann | b65e2c1 | 2013-11-27 16:09:29 +0100 | [diff] [blame] | 45 | sub sp, sp, #GD_SIZE |
SRICHARAN R | 3f30b0a | 2013-04-24 00:41:24 +0000 | [diff] [blame] | 46 | bic sp, sp, #7 |
Jeroen Hofstee | f2d6076 | 2013-09-21 14:04:41 +0200 | [diff] [blame] | 47 | mov r9, sp |
SRICHARAN R | 3f30b0a | 2013-04-24 00:41:24 +0000 | [diff] [blame] | 48 | #endif |
Simon Glass | 8071c8e | 2015-03-03 08:02:57 -0700 | [diff] [blame] | 49 | #endif |
Tom Rini | ee5bce4 | 2012-08-08 17:03:10 -0700 | [diff] [blame] | 50 | /* |
| 51 | * Save the old lr(passed in ip) and the current lr to stack |
| 52 | */ |
| 53 | push {ip, lr} |
| 54 | |
| 55 | /* |
Simon Glass | 8071c8e | 2015-03-03 08:02:57 -0700 | [diff] [blame] | 56 | * Call the very early init function. This should do only the |
| 57 | * absolute bare minimum to get started. It should not: |
| 58 | * |
| 59 | * - set up DRAM |
| 60 | * - use global_data |
| 61 | * - clear BSS |
| 62 | * - try to start a console |
| 63 | * |
| 64 | * For boards with SPL this should be empty since SPL can do all of |
| 65 | * this init in the SPL board_init_f() function which is called |
| 66 | * immediately after this. |
Tom Rini | ee5bce4 | 2012-08-08 17:03:10 -0700 | [diff] [blame] | 67 | */ |
| 68 | bl s_init |
| 69 | pop {ip, pc} |
| 70 | ENDPROC(lowlevel_init) |
Tom Rini | 2ca39ca | 2017-05-16 14:46:34 -0400 | [diff] [blame] | 71 | .popsection |