141aebf81STom Rini/* 241aebf81STom Rini * A lowlevel_init function that sets up the stack to call a C function to 341aebf81STom Rini * perform further init. 441aebf81STom Rini * 541aebf81STom Rini * (C) Copyright 2010 641aebf81STom Rini * Texas Instruments, <www.ti.com> 741aebf81STom Rini * 841aebf81STom Rini * Author : 941aebf81STom Rini * Aneesh V <aneesh@ti.com> 1041aebf81STom Rini * 111a459660SWolfgang Denk * SPDX-License-Identifier: GPL-2.0+ 1241aebf81STom Rini */ 1341aebf81STom Rini 1441aebf81STom Rini#include <asm-offsets.h> 1541aebf81STom Rini#include <config.h> 1641aebf81STom Rini#include <linux/linkage.h> 1741aebf81STom Rini 18*ffb56568STom Rini.pushsection .text.s_init, "ax" 19*ffb56568STom RiniWEAK(s_init) 20*ffb56568STom Rini bx lr 21*ffb56568STom RiniENDPROC(s_init) 22*ffb56568STom Rini.popsection 23*ffb56568STom Rini 24*ffb56568STom Rini.pushsection .text.lowlevel_init, "ax" 25*ffb56568STom RiniWEAK(lowlevel_init) 2641aebf81STom Rini /* 2724a6bc01SSimon Glass * Setup a temporary stack. Global data is not available yet. 2841aebf81STom Rini */ 2922a402f0SSiarhei Siamashka#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_STACK) 3022a402f0SSiarhei Siamashka ldr sp, =CONFIG_SPL_STACK 3122a402f0SSiarhei Siamashka#else 3241aebf81STom Rini ldr sp, =CONFIG_SYS_INIT_SP_ADDR 3322a402f0SSiarhei Siamashka#endif 34975b71bcSTom Rini bic sp, sp, #7 /* 8-byte alignment for ABI compliance */ 35b5d92ba1STom Rini#ifdef CONFIG_SPL_DM 3624a6bc01SSimon Glass mov r9, #0 3724a6bc01SSimon Glass#else 3824a6bc01SSimon Glass /* 3924a6bc01SSimon Glass * Set up global data for boards that still need it. This will be 4024a6bc01SSimon Glass * removed soon. 4124a6bc01SSimon Glass */ 424a0eb757SSRICHARAN R#ifdef CONFIG_SPL_BUILD 43fe1378a9SJeroen Hofstee ldr r9, =gdata 444a0eb757SSRICHARAN R#else 456ba2bc8fSAndreas Bießmann sub sp, sp, #GD_SIZE 464a0eb757SSRICHARAN R bic sp, sp, #7 47fe1378a9SJeroen Hofstee mov r9, sp 484a0eb757SSRICHARAN R#endif 4924a6bc01SSimon Glass#endif 5041aebf81STom Rini /* 5141aebf81STom Rini * Save the old lr(passed in ip) and the current lr to stack 5241aebf81STom Rini */ 5341aebf81STom Rini push {ip, lr} 5441aebf81STom Rini 5541aebf81STom Rini /* 5624a6bc01SSimon Glass * Call the very early init function. This should do only the 5724a6bc01SSimon Glass * absolute bare minimum to get started. It should not: 5824a6bc01SSimon Glass * 5924a6bc01SSimon Glass * - set up DRAM 6024a6bc01SSimon Glass * - use global_data 6124a6bc01SSimon Glass * - clear BSS 6224a6bc01SSimon Glass * - try to start a console 6324a6bc01SSimon Glass * 6424a6bc01SSimon Glass * For boards with SPL this should be empty since SPL can do all of 6524a6bc01SSimon Glass * this init in the SPL board_init_f() function which is called 6624a6bc01SSimon Glass * immediately after this. 6741aebf81STom Rini */ 6841aebf81STom Rini bl s_init 6941aebf81STom Rini pop {ip, pc} 7041aebf81STom RiniENDPROC(lowlevel_init) 71*ffb56568STom Rini.popsection 72