13d54eabcSPhilipp Tomsich /* 23d54eabcSPhilipp Tomsich * Copyright 2017 Theobroma Systems Design und Consulting GmbH 33d54eabcSPhilipp Tomsich * 43d54eabcSPhilipp Tomsich * SPDX-License-Identifier: GPL-2.0+ 53d54eabcSPhilipp Tomsich */ 63d54eabcSPhilipp Tomsich 73d54eabcSPhilipp Tomsich /* 83d54eabcSPhilipp Tomsich * Execution starts on the instruction following this 4-byte header 95577f854SKever Yang * (containing the magic 'RK30', 'RK31', 'RK32' or 'RK33'). This 105577f854SKever Yang * magic constant will be written into the final image by the rkimage 115577f854SKever Yang * tool, but we need to reserve space for it here. 123d54eabcSPhilipp Tomsich * 133d54eabcSPhilipp Tomsich * To make life easier for everyone, we build the SPL binary with 143d54eabcSPhilipp Tomsich * space for this 4-byte header already included in the binary. 153d54eabcSPhilipp Tomsich */ 163d54eabcSPhilipp Tomsich #ifdef CONFIG_SPL_BUILD 17700f3108SPhilipp Tomsich /* 18700f3108SPhilipp Tomsich * We need to add 4 bytes of space for the 'RK33' at the 19700f3108SPhilipp Tomsich * beginning of the executable. However, as we want to keep 20700f3108SPhilipp Tomsich * this generic and make it applicable to builds that are like 21700f3108SPhilipp Tomsich * the RK3368 (TPL needs this, SPL doesn't) or the RK3399 (no 22dff737c4SPhilipp Tomsich * TPL, but extra space needed in the SPL), we simply insert 23dff737c4SPhilipp Tomsich * a branch-to-next-instruction-word with the expectation that 24dff737c4SPhilipp Tomsich * the first one may be overwritten, if this is the first stage 25dff737c4SPhilipp Tomsich * contained in the final image created with mkimage)... 26700f3108SPhilipp Tomsich */ 27dff737c4SPhilipp Tomsich b 1f /* if overwritten, entry-address is at the next word */ 28dff737c4SPhilipp Tomsich 1: 2982c369d0SKever Yang #endif 30dff737c4SPhilipp Tomsich #if CONFIG_IS_ENABLED(ROCKCHIP_EARLYRETURN_TO_BROM) 31dff737c4SPhilipp Tomsich adr r3, entry_counter 32dff737c4SPhilipp Tomsich ldr r0, [r3] 33dff737c4SPhilipp Tomsich cmp r0, #1 /* check if entry_counter == 1 */ 34dff737c4SPhilipp Tomsich beq reset /* regular bootup */ 35dff737c4SPhilipp Tomsich add r0, #1 36dff737c4SPhilipp Tomsich str r0, [r3] /* increment the entry_counter in memory */ 37dff737c4SPhilipp Tomsich mov r0, #0 /* return 0 to the BROM to signal 'OK' */ 38dff737c4SPhilipp Tomsich bx lr /* return control to the BROM */ 39dff737c4SPhilipp Tomsich entry_counter: 40dff737c4SPhilipp Tomsich .word 0 413d54eabcSPhilipp Tomsich #endif 42*9d33a67dSKever Yang 43*9d33a67dSKever Yang #if (defined(CONFIG_SPL_BUILD) || defined(CONFIG_ARM64)) 44*9d33a67dSKever Yang /* U-Boot proper of armv7 do not need this */ 453d54eabcSPhilipp Tomsich b reset 46*9d33a67dSKever Yang #endif 47*9d33a67dSKever Yang 485577f854SKever Yang #if !defined(CONFIG_ARM64) 495577f854SKever Yang /* 505577f854SKever Yang * For armv7, the addr '_start' will used as vector start address 515577f854SKever Yang * and write to VBAR register, which needs to aligned to 0x20. 525577f854SKever Yang */ 53dff737c4SPhilipp Tomsich .align(5), 0x0 545577f854SKever Yang _start: 555577f854SKever Yang ARM_VECTORS 565577f854SKever Yang #endif 5782c369d0SKever Yang 58*9d33a67dSKever Yang #if defined(CONFIG_SPL_BUILD) && (CONFIG_ROCKCHIP_SPL_RESERVE_IRAM > 0) 5982c369d0SKever Yang .space CONFIG_ROCKCHIP_SPL_RESERVE_IRAM /* space for the ATF data */ 6082c369d0SKever Yang #endif 61