All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jean-Jacques Hiblot <jjhiblot@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH PATCH v3 01/12] spl: fit: Add support for applying DT overlay
Date: Thu, 23 May 2019 12:39:01 +0200	[thread overview]
Message-ID: <20190523103912.3790-2-jjhiblot@ti.com> (raw)
In-Reply-To: <20190523103912.3790-1-jjhiblot@ti.com>

From: Michal Simek <michal.simek@xilinx.com>

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>

---

Changes in v3:
- Add a new config option: SPL_LOAD_FIT_APPLY_OVERLAY. By default, it is
not selected.

Changes in v2: None

 Kconfig              | 10 ++++++++++
 common/spl/spl_fit.c | 27 +++++++++++++++++++++++++--
 2 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/Kconfig b/Kconfig
index 5f5c5ccfd6..8197c9066a 100644
--- a/Kconfig
+++ b/Kconfig
@@ -398,6 +398,16 @@ 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
+	default n
+	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"
 	select SPL_FIT
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index 87ecf0bb9e..3fbcb969f8 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_SPL_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));
+	}
+#endif
 	return ret;
 }
 
-- 
2.17.1

  reply	other threads:[~2019-05-23 10:39 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-23 10:39 [U-Boot] [PATCH PATCH v3 00/12] Add support for applications of overlays in SPL Jean-Jacques Hiblot
2019-05-23 10:39 ` Jean-Jacques Hiblot [this message]
2019-05-24 11:29   ` [U-Boot] [PATCH PATCH v3 01/12] spl: fit: Add support for applying DT overlay Michal Simek
2019-06-22 19:09   ` Simon Glass
2019-05-23 10:39 ` [U-Boot] [PATCH PATCH v3 02/12] spl: fit: Make room in the FDT before applying overlays Jean-Jacques Hiblot
2019-06-22 19:09   ` Simon Glass
2019-05-23 10:39 ` [U-Boot] [PATCH PATCH v3 03/12] spl: fit: allocate a temporary buffer to load the overlays Jean-Jacques Hiblot
2019-06-22 19:09   ` Simon Glass
2019-05-23 10:39 ` [U-Boot] [PATCH PATCH v3 04/12] spl: fit: Do not fail immediately if an overlay is not available Jean-Jacques Hiblot
2019-06-22 19:09   ` Simon Glass
2019-05-23 10:39 ` [U-Boot] [PATCH PATCH v3 05/12] spl: fit: be more verbose when an error occurs when applying the overlays Jean-Jacques Hiblot
2019-06-22 19:09   ` Simon Glass
2019-05-23 10:39 ` [U-Boot] [PATCH PATCH v3 06/12] Makefile.lib: include /__symbols__ in dtb if SPL_LOAD_FIT_APPLY_OVERLAY is enabled Jean-Jacques Hiblot
2019-06-22 19:09   ` Simon Glass
2019-05-23 10:39 ` [U-Boot] [PATCH PATCH v3 07/12] Makefile: Fix tests for CONFIG_SPL_LOAD_FIT and CONFIG_SPL_FIT_GENERATOR Jean-Jacques Hiblot
2019-06-22 19:09   ` Simon Glass
2019-05-23 10:39 ` [U-Boot] [PATCH PATCH v3 08/12] Makefile: Fix u-boot.itb generation when building outside the source tree Jean-Jacques Hiblot
2019-06-22 19:09   ` Simon Glass
2019-05-23 10:39 ` [U-Boot] [PATCH PATCH v3 09/12] Makefile: Pass the board name to the FIT generator scripts Jean-Jacques Hiblot
2019-06-22 19:09   ` Simon Glass
2019-05-23 10:39 ` [U-Boot] [PATCH PATCH v3 10/12] Makefile: Query the SPL Fit Generator for its dependencies Jean-Jacques Hiblot
2019-06-22 19:09   ` Simon Glass
2019-05-23 10:39 ` [U-Boot] [PATCH PATCH v3 11/12] spl: fit: constify the output parameter of spl_fit_get_image_name() Jean-Jacques Hiblot
2019-06-22 19:09   ` Simon Glass
2019-05-23 10:39 ` [U-Boot] [PATCH PATCH v3 12/12] spl: fit: Allow the board to tell if more images must be loaded from FIT Jean-Jacques Hiblot
2019-06-22 19:09   ` Simon Glass
2019-06-22 19:09 ` [U-Boot] [PATCH PATCH v3 00/12] Add support for applications of overlays in SPL Simon Glass
2019-06-25 19:10   ` Jean-Jacques Hiblot
2019-06-26 15:07     ` Simon Glass
2019-07-26 19:46 ` Tom Rini
2019-07-29 16:49   ` Jean-Jacques Hiblot
2019-07-30  8:08   ` Michal Simek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190523103912.3790-2-jjhiblot@ti.com \
    --to=jjhiblot@ti.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.