mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-12-11 22:03:15 +00:00
b377d22264
Some Rockchip BROM versions (e.g. the RK3188 and RK3066) first read 1KB data from NAND into SRAM and executes it. Then, following a return to bootrom, the BROM loads additional code to SRAM (not overwriting the first block read) and reenters at the same address as the first time. To support booting either a TPL (on the RK3066) or SPL (on the RK3188) using this model of having to count entries, this commit adds code to the boot0 hook to track the number of entries and handle them accordingly. Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com> Signed-off-by: Paweł Jarosz <paweljarosz3691@gmail.com> Tested-by: Andy Yan <andy.yan@rock-chips.com>
55 lines
1.9 KiB
C
55 lines
1.9 KiB
C
/*
|
|
* Copyright 2017 Theobroma Systems Design und Consulting GmbH
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0+
|
|
*/
|
|
|
|
/*
|
|
* Execution starts on the instruction following this 4-byte header
|
|
* (containing the magic 'RK30', 'RK31', 'RK32' or 'RK33'). This
|
|
* magic constant will be written into the final image by the rkimage
|
|
* tool, but we need to reserve space for it here.
|
|
*
|
|
* To make life easier for everyone, we build the SPL binary with
|
|
* space for this 4-byte header already included in the binary.
|
|
*/
|
|
#ifdef CONFIG_SPL_BUILD
|
|
/*
|
|
* We need to add 4 bytes of space for the 'RK33' at the
|
|
* beginning of the executable. However, as we want to keep
|
|
* this generic and make it applicable to builds that are like
|
|
* the RK3368 (TPL needs this, SPL doesn't) or the RK3399 (no
|
|
* TPL, but extra space needed in the SPL), we simply insert
|
|
* a branch-to-next-instruction-word with the expectation that
|
|
* the first one may be overwritten, if this is the first stage
|
|
* contained in the final image created with mkimage)...
|
|
*/
|
|
b 1f /* if overwritten, entry-address is at the next word */
|
|
1:
|
|
#endif
|
|
#if CONFIG_IS_ENABLED(ROCKCHIP_EARLYRETURN_TO_BROM)
|
|
adr r3, entry_counter
|
|
ldr r0, [r3]
|
|
cmp r0, #1 /* check if entry_counter == 1 */
|
|
beq reset /* regular bootup */
|
|
add r0, #1
|
|
str r0, [r3] /* increment the entry_counter in memory */
|
|
mov r0, #0 /* return 0 to the BROM to signal 'OK' */
|
|
bx lr /* return control to the BROM */
|
|
entry_counter:
|
|
.word 0
|
|
#endif
|
|
b reset
|
|
#if !defined(CONFIG_ARM64)
|
|
/*
|
|
* For armv7, the addr '_start' will used as vector start address
|
|
* and write to VBAR register, which needs to aligned to 0x20.
|
|
*/
|
|
.align(5), 0x0
|
|
_start:
|
|
ARM_VECTORS
|
|
#endif
|
|
|
|
#if defined(CONFIG_ROCKCHIP_RK3399) && defined(CONFIG_SPL_BUILD)
|
|
.space CONFIG_ROCKCHIP_SPL_RESERVE_IRAM /* space for the ATF data */
|
|
#endif
|