aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Simek <michal.simek@xilinx.com>2019-10-22 16:39:11 +0200
committerTom Rini <trini@konsulko.com>2020-01-07 11:12:47 -0500
commit9d13b8725481ee5651c6e881e5d336142b813b14 (patch)
tree4def4236ff4b9feff5f069b2f06aba616b64897c
parent6b8b98d54d8e74c8b4c6cfe431e88c90efcea72d (diff)
downloadu-boot-9d13b8725481ee5651c6e881e5d336142b813b14.zip
u-boot-9d13b8725481ee5651c6e881e5d336142b813b14.tar.gz
u-boot-9d13b8725481ee5651c6e881e5d336142b813b14.tar.bz2
spl: fit: Add support for applying DT overlay
doc/uImage.FIT/overlay-fdt-boot.txt is describing how to create FIT image with DT overlays in it. Add support for this feature to SPL. Here is the ZynqMP fragment where dtb points to full DT and dtbo is overlay which should be applied on the top of dtb. config { description = "ATF with full u-boot overlay"; firmware = "atf"; loadables = "uboot"; fdt = "dtb", "dtbo"; }; The whole feature depends on OF_LIBFDT_OVERLAY which is adding +4kB code and 0 for platforms which are not enabling this feature. Signed-off-by: Michal Simek <michal.simek@xilinx.com> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com> Reviewed-by: Simon Glass <sjg@chromium.org>
-rw-r--r--Kconfig9
-rw-r--r--common/spl/spl_fit.c30
2 files changed, 36 insertions, 3 deletions
diff --git a/Kconfig b/Kconfig
index 46a31f4..0edd4ec 100644
--- a/Kconfig
+++ b/Kconfig
@@ -444,6 +444,15 @@ config SPL_LOAD_FIT
particular it can handle selecting from multiple device tree
and passing the correct one to U-Boot.
+config SPL_LOAD_FIT_APPLY_OVERLAY
+ bool "Enable SPL applying DT overlays from FIT"
+ depends on SPL_LOAD_FIT
+ select OF_LIBFDT_OVERLAY
+ help
+ The device tree is loaded from the FIT image. Allow the SPL is to
+ also load device-tree overlays from the FIT image an apply them
+ over the device tree.
+
config SPL_LOAD_FIT_FULL
bool "Enable SPL loading U-Boot as a FIT (full fitImage features)"
select SPL_FIT
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index 346f9ed..39e406b 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -281,7 +281,7 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image,
void *fit, int images, ulong base_offset)
{
struct spl_image_info image_info;
- int node, ret = 0;
+ int node, ret = 0, index = 0;
/*
* Use the address following the image as target address for the
@@ -290,7 +290,7 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image,
image_info.load_addr = spl_image->load_addr + spl_image->size;
/* Figure out which device tree the board wants to use */
- node = spl_fit_get_image_node(fit, images, FIT_FDT_PROP, 0);
+ node = spl_fit_get_image_node(fit, images, FIT_FDT_PROP, index++);
if (node < 0) {
debug("%s: cannot find FDT node\n", __func__);
@@ -315,8 +315,32 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image,
#if !CONFIG_IS_ENABLED(FIT_IMAGE_TINY)
/* Try to make space, so we can inject details on the loadables */
ret = fdt_shrink_to_minimum(spl_image->fdt_addr, 8192);
+ if (ret < 0)
+ return ret;
#endif
-
+ if (CONFIG_IS_ENABLED(LOAD_FIT_APPLY_OVERLAY)) {
+ for (; ; index++) {
+ node = spl_fit_get_image_node(fit, images, FIT_FDT_PROP,
+ index);
+ if (node < 0) {
+ debug("%s: No additional FDT node\n", __func__);
+ return 0;
+ }
+
+ ret = spl_load_fit_image(info, sector, fit, base_offset,
+ node, &image_info);
+ if (ret < 0)
+ return ret;
+
+ ret = fdt_overlay_apply_verbose(spl_image->fdt_addr,
+ (void *)image_info.load_addr);
+ if (ret)
+ return ret;
+
+ debug("%s: DT overlay %s applied\n", __func__,
+ fit_get_name(fit, node, NULL));
+ }
+ }
return ret;
}