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