1/*
2 * A lowlevel_init function that sets up the stack to call a C function to
3 * perform further init.
4 *
5 * SPDX-License-Identifier:	GPL-2.0+
6 */
7
8#include <asm-offsets.h>
9#include <config.h>
10#include <linux/linkage.h>
11
12ENTRY(lowlevel_init)
13	/*
14	 * Setup a temporary stack. Global data is not available yet.
15	 */
16#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_STACK)
17	ldr	w0, =CONFIG_SPL_STACK
18#else
19	ldr	w0, =CONFIG_SYS_INIT_SP_ADDR
20#endif
21	bic	sp, x0, #0xf	/* 16-byte alignment for ABI compliance */
22
23	/*
24	 * Save the old LR(passed in x29) and the current LR to stack
25	 */
26	stp	x29, x30, [sp, #-16]!
27
28	/*
29	 * Call the very early init function. This should do only the
30	 * absolute bare minimum to get started. It should not:
31	 *
32	 * - set up DRAM
33	 * - use global_data
34	 * - clear BSS
35	 * - try to start a console
36	 *
37	 * For boards with SPL this should be empty since SPL can do all of
38	 * this init in the SPL board_init_f() function which is called
39	 * immediately after this.
40	 */
41	bl	s_init
42	ldp	x29, x30, [sp]
43	ret
44ENDPROC(lowlevel_init)
45