aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandru Gagniuc <mr.nuke.me@gmail.com>2021-01-20 10:46:56 -0600
committerTom Rini <trini@konsulko.com>2021-02-17 17:12:45 -0500
commit46c5613dcb3b0553b6474de907268e2450b279a7 (patch)
tree88f61ff7e1a9455d6c2abe1caa545346c4c3b891
parent3557476de59fef68dda42fc597ae2e2e3fc1e2e4 (diff)
downloadu-boot-WIP/2021-02-17-SPL-FIT-improvements.zip
u-boot-WIP/2021-02-17-SPL-FIT-improvements.tar.gz
u-boot-WIP/2021-02-17-SPL-FIT-improvements.tar.bz2
spl: fit: Load devicetree when a Linux payload is foundWIP/2021-02-17-SPL-FIT-improvements
When a FIT config specifies a devicetree, we should load it, no questions asked. In the case of the "simple" FIT loading path, a difficulty arises in selecting the load address of the FDT. The default FDT location is right after the "kernel" or "firmware" image. However, if that is an OP-TEE image, then the FDT may end up in secure DRAM, and not be accessible to normal world kernels. Although the best solution is to be more careful about the FDT address, a viable workaround is to only append the FDT after a u-boot or Linux image. This is identical to the previous logic, except that FDT loading is extended to IH_OS_LINUX images. Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
-rw-r--r--common/spl/spl_fit.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index 2c25522..3d78ce1 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -336,6 +336,18 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector,
return 0;
}
+static bool os_takes_devicetree(uint8_t os)
+{
+ switch (os) {
+ case IH_OS_U_BOOT:
+ return true;
+ case IH_OS_LINUX:
+ return IS_ENABLED(CONFIG_SPL_OS_BOOT);
+ default:
+ return false;
+ }
+}
+
static int spl_fit_append_fdt(struct spl_image_info *spl_image,
struct spl_load_info *info, ulong sector,
const struct spl_fit_info *ctx)
@@ -662,9 +674,9 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
* Booting a next-stage U-Boot may require us to append the FDT.
* We allow this to fail, as the U-Boot image might embed its FDT.
*/
- if (spl_image->os == IH_OS_U_BOOT) {
+ if (os_takes_devicetree(spl_image->os)) {
ret = spl_fit_append_fdt(spl_image, info, sector, &ctx);
- if (!IS_ENABLED(CONFIG_OF_EMBED) && ret < 0)
+ if (ret < 0 && spl_image->os != IH_OS_U_BOOT)
return ret;
}
@@ -695,7 +707,7 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
if (!spl_fit_image_get_os(ctx.fit, node, &os_type))
debug("Loadable is %s\n", genimg_get_os_name(os_type));
- if (os_type == IH_OS_U_BOOT) {
+ if (os_takes_devicetree(os_type)) {
spl_fit_append_fdt(&image_info, info, sector, &ctx);
spl_image->fdt_addr = image_info.fdt_addr;
}