Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Philipp Tomsich | c244871 | 2017-03-15 12:08:44 +0100 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2017 Theobroma Systems Design und Consulting GmbH |
Philipp Tomsich | c244871 | 2017-03-15 12:08:44 +0100 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | /* |
| 7 | * Execution starts on the instruction following this 4-byte header |
Kever Yang | b812286 | 2017-10-10 16:21:02 +0200 | [diff] [blame] | 8 | * (containing the magic 'RK30', 'RK31', 'RK32' or 'RK33'). This |
| 9 | * magic constant will be written into the final image by the rkimage |
| 10 | * tool, but we need to reserve space for it here. |
Philipp Tomsich | c244871 | 2017-03-15 12:08:44 +0100 | [diff] [blame] | 11 | * |
| 12 | * To make life easier for everyone, we build the SPL binary with |
| 13 | * space for this 4-byte header already included in the binary. |
| 14 | */ |
Simon Glass | 85ed77d | 2024-09-29 19:49:46 -0600 | [diff] [blame] | 15 | #ifdef CONFIG_XPL_BUILD |
Philipp Tomsich | 728aae4 | 2017-07-11 21:04:45 +0200 | [diff] [blame] | 16 | /* |
| 17 | * We need to add 4 bytes of space for the 'RK33' at the |
| 18 | * beginning of the executable. However, as we want to keep |
| 19 | * this generic and make it applicable to builds that are like |
| 20 | * the RK3368 (TPL needs this, SPL doesn't) or the RK3399 (no |
Philipp Tomsich | 9f1a447 | 2017-10-10 16:21:10 +0200 | [diff] [blame] | 21 | * TPL, but extra space needed in the SPL), we simply insert |
| 22 | * a branch-to-next-instruction-word with the expectation that |
| 23 | * the first one may be overwritten, if this is the first stage |
| 24 | * contained in the final image created with mkimage)... |
Philipp Tomsich | 728aae4 | 2017-07-11 21:04:45 +0200 | [diff] [blame] | 25 | */ |
Philipp Tomsich | 9f1a447 | 2017-10-10 16:21:10 +0200 | [diff] [blame] | 26 | b 1f /* if overwritten, entry-address is at the next word */ |
| 27 | 1: |
| 28 | #endif |
| 29 | #if CONFIG_IS_ENABLED(ROCKCHIP_EARLYRETURN_TO_BROM) |
| 30 | adr r3, entry_counter |
| 31 | ldr r0, [r3] |
| 32 | cmp r0, #1 /* check if entry_counter == 1 */ |
| 33 | beq reset /* regular bootup */ |
| 34 | add r0, #1 |
| 35 | str r0, [r3] /* increment the entry_counter in memory */ |
| 36 | mov r0, #0 /* return 0 to the BROM to signal 'OK' */ |
| 37 | bx lr /* return control to the BROM */ |
| 38 | entry_counter: |
| 39 | .word 0 |
Philipp Tomsich | c244871 | 2017-03-15 12:08:44 +0100 | [diff] [blame] | 40 | #endif |
Kever Yang | e9277e4 | 2017-12-18 15:05:41 +0800 | [diff] [blame] | 41 | |
Simon Glass | 85ed77d | 2024-09-29 19:49:46 -0600 | [diff] [blame] | 42 | #if (defined(CONFIG_XPL_BUILD) || defined(CONFIG_ARM64)) |
Kever Yang | e9277e4 | 2017-12-18 15:05:41 +0800 | [diff] [blame] | 43 | /* U-Boot proper of armv7 do not need this */ |
Philipp Tomsich | c244871 | 2017-03-15 12:08:44 +0100 | [diff] [blame] | 44 | b reset |
Kever Yang | e9277e4 | 2017-12-18 15:05:41 +0800 | [diff] [blame] | 45 | #endif |
| 46 | |
Kever Yang | b812286 | 2017-10-10 16:21:02 +0200 | [diff] [blame] | 47 | #if !defined(CONFIG_ARM64) |
| 48 | /* |
| 49 | * For armv7, the addr '_start' will used as vector start address |
| 50 | * and write to VBAR register, which needs to aligned to 0x20. |
| 51 | */ |
Philipp Tomsich | 9f1a447 | 2017-10-10 16:21:10 +0200 | [diff] [blame] | 52 | .align(5), 0x0 |
Kever Yang | b812286 | 2017-10-10 16:21:02 +0200 | [diff] [blame] | 53 | _start: |
| 54 | ARM_VECTORS |
| 55 | #endif |
Kever Yang | e484f77 | 2017-04-20 17:03:46 +0800 | [diff] [blame] | 56 | |
Simon Glass | 85ed77d | 2024-09-29 19:49:46 -0600 | [diff] [blame] | 57 | #if !defined(CONFIG_TPL_BUILD) && defined(CONFIG_XPL_BUILD) && \ |
Kever Yang | b091a98 | 2019-03-29 22:48:28 +0800 | [diff] [blame] | 58 | (CONFIG_ROCKCHIP_SPL_RESERVE_IRAM > 0) |
Kever Yang | e484f77 | 2017-04-20 17:03:46 +0800 | [diff] [blame] | 59 | .space CONFIG_ROCKCHIP_SPL_RESERVE_IRAM /* space for the ATF data */ |
| 60 | #endif |