xref: /OK3568_Linux_fs/u-boot/arch/arm/include/asm/arch-rockchip/boot0.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * Copyright 2017 Theobroma Systems Design und Consulting GmbH
3  *
4  * SPDX-License-Identifier:	GPL-2.0+
5  */
6 
7 /*
8  * Execution starts on the instruction following this 4-byte header
9  * (containing the magic 'RK30', 'RK31', 'RK32' or 'RK33').  This
10  * magic constant will be written into the final image by the rkimage
11  * tool, but we need to reserve space for it here.
12  *
13  * To make life easier for everyone, we build the SPL binary with
14  * space for this 4-byte header already included in the binary.
15  */
16 #ifdef CONFIG_SPL_BUILD
17 	/*
18 	 * We need to add 4 bytes of space for the 'RK33' at the
19 	 * beginning of the executable.	 However, as we want to keep
20 	 * this generic and make it applicable to builds that are like
21 	 * the RK3368 (TPL needs this, SPL doesn't) or the RK3399 (no
22 	 * TPL, but extra space needed in the SPL), we simply insert
23 	 * a branch-to-next-instruction-word with the expectation that
24 	 * the first one may be overwritten, if this is the first stage
25 	 * contained in the final image created with mkimage)...
26 	 */
27 	b 1f	 /* if overwritten, entry-address is at the next word */
28 1:
29 #endif
30 #if CONFIG_IS_ENABLED(ROCKCHIP_EARLYRETURN_TO_BROM)
31 	adr     r3, entry_counter
32 	ldr	r0, [r3]
33 	cmp	r0, #1           /* check if entry_counter == 1 */
34 	beq	reset            /* regular bootup */
35 	add     r0, #1
36 	str	r0, [r3]         /* increment the entry_counter in memory */
37 	mov     r0, #0           /* return 0 to the BROM to signal 'OK' */
38 	bx	lr               /* return control to the BROM */
39 entry_counter:
40 	.word   0
41 #endif
42 
43 #if (defined(CONFIG_SPL_BUILD) || defined(CONFIG_ARM64))
44 	/* U-Boot proper of armv7 do not need this */
45 #if CONFIG_IS_ENABLED(TINY_FRAMEWORK)
46 #if !defined(CONFIG_ARM64)
47 	/*
48 	 * For armv7, the addr '_start' will check by u-boot-tpl.lds file.
49 	 */
50 _start:
51 #endif
52 	/* Allow the board to save important registers */
53 	b save_boot_params
54 
55 .type   save_boot_params_ret, % function
56 .globl	save_boot_params_ret
57 save_boot_params_ret:
58 	/* Init gd as null */
59 #ifdef CONFIG_ARM64
60 	mov	x18, #0
61 #else
62 	mov	r9, #0
63 #endif
64 	b board_init_f
65 #else
66 	b reset
67 #endif
68 
69 #endif
70 
71 #if !defined(CONFIG_ARM64) && !CONFIG_IS_ENABLED(TINY_FRAMEWORK)
72 	/*
73 	 * For armv7, the addr '_start' will used as vector start address
74 	 * and write to VBAR register, which needs to aligned to 0x20.
75 	 */
76 	.align(5), 0x0
77 _start:
78 	ARM_VECTORS
79 #endif
80 
81 #if !defined(CONFIG_TPL_BUILD) && defined(CONFIG_SPL_BUILD) && (CONFIG_ROCKCHIP_SPL_RESERVE_IRAM > 0)
82 	.space CONFIG_ROCKCHIP_SPL_RESERVE_IRAM	/* space for the ATF data */
83 #endif
84