
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 ---
02: spl: fit: Add support for applying DT overlay aarch64: (for 1/1 boards) spl/u-boot-spl:all +4066.0 spl/u-boot-spl:rodata +206.0 spl/u-boot-spl:text +3860.0 xilinx_zynqmp_zcu100_revC: spl/u-boot-spl:all +4066 spl/u-boot-spl:rodata +206 spl/u-boot-spl:text +3860 spl-u-boot-spl: add: 11/0, grow: 1/0 bytes: 3860/0 (3860) function old new delta fdt_overlay_apply - 1640 +1640 overlay_update_local_node_references - 424 +424 fdt_get_path - 364 +364 overlay_apply_node - 300 +300 overlay_get_target - 216 +216 overlay_adjust_node_phandles - 168 +168 overlay_phandle_add_offset - 144 +144 fdt_setprop_inplace - 136 +136 fdt_overlay_apply_verbose - 128 +128 fdt_get_max_phandle - 128 +128 spl_fit_append_fdt 152 260 +108 fdt_setprop_inplace_namelen_partial - 104 +104
--- common/spl/spl_fit.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c index db436268cbcd..ee38dfea7816 100644 --- a/common/spl/spl_fit.c +++ b/common/spl/spl_fit.c @@ -278,10 +278,10 @@ 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; + int node, ret, index = 0;
/* 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__); return node; @@ -303,8 +303,31 @@ 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 defined(CONFIG_OF_LIBFDT_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)); + } +#endif return ret; }