uboot-d1: add bootloader for upcoming d1 target
[openwrt/staging/mans0n.git] / package / boot / uboot-d1 / patches / 0025-sunxi-binman-Enable-SPL-FIT-loading-for-32-bit-SoCs.patch
1 From b641ca5f4d272b83ef77ebcf5c75678cf139c69a Mon Sep 17 00:00:00 2001
2 From: Samuel Holland <samuel@sholland.org>
3 Date: Sat, 17 Apr 2021 13:33:54 -0500
4 Subject: [PATCH 25/90] sunxi: binman: Enable SPL FIT loading for 32-bit SoCs
5
6 Now that Crust (SCP firmware) has support for H3, we need a FIT image to
7 load it. H3 also needs to load a SoC-specific eGon blob to support CPU 0
8 hotplug. Let's first enable FIT support before adding extra firmware.
9
10 Update the binman description to work on either 32-bit or 64-bit SoCs:
11 - Make BL31 optional, since it is not used on 32-bit SoCs (though BL32
12 may be used in the future).
13 - Explicitly set the minimum offset of the FIT to 32 KiB, since SPL on
14 some boards is still only 24 KiB large even with FIT support enabled.
15 CONFIG_SPL_PAD_TO cannot be used because it is not defined for H616.
16
17 FIT unlocks more features (signatures, multiple DTBs, etc.), so enable
18 it by default. A10 (sun4i) only has 24 KiB of SRAM A1, so it needs
19 SPL_FIT_IMAGE_TINY. For simplicity, enable that option everywhere.
20
21 Cover-letter:
22 sunxi: SPL FIT support for 32-bit sunxi SoCs
23 This series makes the necessary changes so 32-bit sunxi SoCs can load
24 additional device trees or firmware from SPL along with U-Boot proper.
25
26 There was no existing binman entry property that put the FIT at the
27 right offset. The minimum offset is 32k, but this matches neither the
28 SPL size (which is no more than 24k on some SoCs) nor the FIT alignment
29 (which is 512 bytes in practice due to SPL size constraints). So instead
30 of adding a new property, I fixed what is arguably a bug in the offset
31 property -- though this strategy will not work if someone is
32 intentionally creating overlapping entries.
33 END
34 Series-to: sunxi
35 Series-to: sjg
36 Signed-off-by: Samuel Holland <samuel@sholland.org>
37 ---
38 arch/arm/Kconfig | 1 +
39 arch/arm/dts/sunxi-u-boot.dtsi | 46 ++++++++++++++++++++++------------
40 common/spl/Kconfig | 9 +++----
41 3 files changed, 35 insertions(+), 21 deletions(-)
42
43 --- a/arch/arm/Kconfig
44 +++ b/arch/arm/Kconfig
45 @@ -1135,6 +1135,7 @@ config ARCH_SUNXI
46 imply SPL_GPIO
47 imply SPL_LIBCOMMON_SUPPORT
48 imply SPL_LIBGENERIC_SUPPORT
49 + imply SPL_LOAD_FIT
50 imply SPL_MMC if MMC
51 imply SPL_POWER
52 imply SPL_SERIAL
53 --- a/arch/arm/dts/sunxi-u-boot.dtsi
54 +++ b/arch/arm/dts/sunxi-u-boot.dtsi
55 @@ -1,13 +1,19 @@
56 #include <config.h>
57
58 -#ifdef CONFIG_MACH_SUN50I_H6
59 -#define BL31_ADDR 0x104000
60 -#define SCP_ADDR 0x114000
61 -#elif defined(CONFIG_MACH_SUN50I_H616)
62 -#define BL31_ADDR 0x40000000
63 +#ifdef CONFIG_ARM64
64 +#define ARCH "arm64"
65 #else
66 -#define BL31_ADDR 0x44000
67 -#define SCP_ADDR 0x50000
68 +#define ARCH "arm"
69 +#endif
70 +
71 +#if defined(CONFIG_MACH_SUN50I) || defined(CONFIG_MACH_SUN50I_H5)
72 +#define BL31_ADDR 0x00044000
73 +#define SCP_ADDR 0x00050000
74 +#elif defined(CONFIG_MACH_SUN50I_H6)
75 +#define BL31_ADDR 0x00104000
76 +#define SCP_ADDR 0x00114000
77 +#elif defined(CONFIG_MACH_SUN50I_H616)
78 +#define BL31_ADDR 0x40000000
79 #endif
80
81 / {
82 @@ -34,30 +40,33 @@
83 filename = "spl/sunxi-spl.bin";
84 };
85
86 -#ifdef CONFIG_ARM64
87 +#ifdef CONFIG_SPL_LOAD_FIT
88 fit {
89 - description = "Configuration to load ATF before U-Boot";
90 + description = "Configuration to load U-Boot and firmware";
91 + offset = <32768>;
92 #address-cells = <1>;
93 fit,fdt-list = "of-list";
94
95 images {
96 uboot {
97 - description = "U-Boot (64-bit)";
98 + description = "U-Boot";
99 type = "standalone";
100 os = "u-boot";
101 - arch = "arm64";
102 + arch = ARCH;
103 compression = "none";
104 load = <CONFIG_TEXT_BASE>;
105 + entry = <CONFIG_TEXT_BASE>;
106
107 u-boot-nodtb {
108 };
109 };
110
111 +#ifdef BL31_ADDR
112 atf {
113 description = "ARM Trusted Firmware";
114 type = "firmware";
115 os = "arm-trusted-firmware";
116 - arch = "arm64";
117 + arch = ARCH;
118 compression = "none";
119 load = <BL31_ADDR>;
120 entry = <BL31_ADDR>;
121 @@ -67,6 +76,7 @@
122 missing-msg = "atf-bl31-sunxi";
123 };
124 };
125 +#endif
126
127 #ifdef SCP_ADDR
128 scp {
129 @@ -95,19 +105,23 @@
130
131 @config-SEQ {
132 description = "NAME";
133 +#ifdef BL31_ADDR
134 firmware = "atf";
135 -#ifndef SCP_ADDR
136 - loadables = "uboot";
137 #else
138 - loadables = "scp", "uboot";
139 + firmware = "uboot";
140 +#endif
141 + loadables =
142 +#ifdef SCP_ADDR
143 + "scp",
144 #endif
145 + "uboot";
146 fdt = "fdt-SEQ";
147 };
148 };
149 };
150 #else
151 u-boot-img {
152 - offset = <CONFIG_SPL_PAD_TO>;
153 + offset = <32768>;
154 };
155 #endif
156 };
157 --- a/common/spl/Kconfig
158 +++ b/common/spl/Kconfig
159 @@ -76,12 +76,12 @@ config SPL_SIZE_LIMIT_PROVIDE_STACK
160
161 config SPL_MAX_SIZE
162 hex "Maximum size of the SPL image, excluding BSS"
163 + default 0x37fa0 if MACH_SUN50I_H616
164 default 0x30000 if ARCH_MX6 && MX6_OCRAM_256KB
165 + default 0x25fa0 if MACH_SUN50I_H6
166 default 0x1b000 if AM33XX && !TI_SECURE_DEVICE
167 default 0x10000 if ARCH_MX6 && !MX6_OCRAM_256KB
168 default 0x7fa0 if SUNXI_SRAM_ADDRESS = 0x10000
169 - default 0x7fa0 if SUNXI_SRAM_ADDRESS = 0x20000 && !MACH_SUN50I_H616
170 - default 0xbfa0 if MACH_SUN50I_H616
171 default 0x7000 if RCAR_GEN3
172 default 0x5fa0 if SUNXI_SRAM_ADDRESS = 0x0
173 default 0x10000 if ASPEED_AST2600
174 @@ -97,7 +97,7 @@ config SPL_PAD_TO
175 default 0x31000 if ARCH_MX6 && MX6_OCRAM_256KB
176 default 0x11000 if ARCH_MX7 || (ARCH_MX6 && !MX6_OCRAM_256KB)
177 default 0x10000 if ARCH_KEYSTONE
178 - default 0x8000 if ARCH_SUNXI && !MACH_SUN50I_H616
179 + default 0x0 if ARCH_SUNXI
180 default 0x0 if ARCH_MTMIPS
181 default TPL_MAX_SIZE if TPL_MAX_SIZE > SPL_MAX_SIZE
182 default SPL_MAX_SIZE
183 @@ -575,8 +575,7 @@ config SPL_MD5
184 config SPL_FIT_IMAGE_TINY
185 bool "Remove functionality from SPL FIT loading to reduce size"
186 depends on SPL_FIT
187 - default y if MACH_SUN50I || MACH_SUN50I_H5 || SUN50I_GEN_H6
188 - default y if ARCH_IMX8M || ARCH_IMX9
189 + default y if ARCH_IMX8M || ARCH_IMX9 || ARCH_SUNXI
190 help
191 Enable this to reduce the size of the FIT image loading code
192 in SPL, if space for the SPL binary is very tight.