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] [RFC PATCH v1 8/9] sp: fit: Allow the board to dynamically select the DTB overlays it needs.
Date: Fri, 22 Mar 2019 15:39:55 +0100	[thread overview]
Message-ID: <20190322143956.14767-9-jjhiblot@ti.com> (raw)
In-Reply-To: <20190322143956.14767-1-jjhiblot@ti.com>

Currently the list of DTB overlays to apply on top of the DTB is described
in a configuration node. With this scheme, it becomes quickly hard to
manage combinations of more than a hand few of DTB overlays. Instead the
board could tell for each overlay if it is needed or not.
This is the role of board_fit_get_additionnal_images().
Note that it is not limited to dtb overlays, it could be used for kind of
images (fpga, loadables, etc.)

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
---

 common/spl/spl_fit.c | 28 ++++++++++++++++++++++++++++
 include/spl.h        | 20 ++++++++++++++++++++
 2 files changed, 48 insertions(+)

diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index ebce93ec1f..6e39bfa2b4 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -25,6 +25,12 @@ __weak ulong board_spl_fit_size_align(ulong size)
 	return size;
 }
 
+__weak int board_fit_get_additionnal_images(int index, const char *type,
+					    const char **name)
+{
+	return -ENOENT;
+}
+
 /**
  * spl_fit_get_image_name(): By using the matching configuration subnode,
  * retrieve the name of an image, specified by a property name and an index
@@ -374,6 +380,28 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image,
 		if (ret)
 			return ret;
 	}
+
+	/* Apply overlays, the name of which are provided by board-level code */
+	for (index = 0; ; index++) {
+		const char *str;
+
+		ret = board_fit_get_additionnal_images(index, FIT_FDT_PROP,
+						       &str);
+		if (ret)
+			break;
+		if (!str)
+			continue;
+
+		node = fdt_subnode_offset(fit, images, str);
+		if (node < 0) {
+			pr_err("cannot find image node '%s': %d\n", str, node);
+			continue;
+		}
+		ret = load_and_apply_overlay(spl_image->fdt_addr, info, sector,
+					     fit, base_offset, node);
+		if (ret)
+			return ret;
+	}
 #endif
 #if !CONFIG_IS_ENABLED(FIT_IMAGE_TINY)
 	/* Try to make space, so we can inject details on the loadables */
diff --git a/include/spl.h b/include/spl.h
index f09909e189..5acc0a6c6e 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -370,6 +370,26 @@ void board_spl_fit_post_load(ulong load_addr, size_t length);
  */
 ulong board_spl_fit_size_align(ulong size);
 
+/**
+ * board_fit_get_additionnal_images - Get additional image names from board-
+ *				      level code.
+ * This function can be used to provide the image names based on runtime
+ * detection. A classic use-case would when DTBOs are used to describe
+ * additionnal daughter cards.
+ *
+ * @param index	Index of the image. Starts at 0 and gets incremented after each
+ *		call to this function.
+ * @param type	The type of image. For example, "fdt" for DTBs
+ * @param name	Output. The name of the node describing the image. If  NULL, it
+ *		should be ignored by the caller but it does not indicate that
+ *		there no more images to get from this function.
+ *
+ * @return 0 if there are still images to get of this type to get from
+ *	   this function. Otherwise error code.
+ */
+int board_fit_get_additionnal_images(int index, const char *type,
+				     const char **name);
+
 /**
  * spl_perform_fixups() - arch/board-specific callback before processing
  *                        the boot-payload
-- 
2.17.1

  parent reply	other threads:[~2019-03-22 14:39 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-22 14:39 [U-Boot] [RFC PATCH v1 0/9] Add support for applications of overlays in SPL Jean-Jacques Hiblot
2019-03-22 14:39 ` [U-Boot] [RFC PATCH v1 1/9] dtbo: also generate dtbo from dtso Jean-Jacques Hiblot
2019-03-25  7:57   ` Michal Simek
2019-03-22 14:39 ` [U-Boot] [RFC PATCH v1 2/9] Makefile.lib: include /__symbols__ in dtb if OF_LIBFDT_OVERLAY is enabled Jean-Jacques Hiblot
2019-03-25  7:33   ` Michal Simek
2019-03-22 14:39 ` [U-Boot] [RFC PATCH v1 3/9] Makefile: Fix u-boot.itb generation when building outside the source tree Jean-Jacques Hiblot
2019-03-30 21:18   ` Simon Glass
2019-03-22 14:39 ` [U-Boot] [RFC PATCH v1 4/9] Makefile: Pass the board name to the FIT generator scripts Jean-Jacques Hiblot
2019-03-30 21:18   ` Simon Glass
2019-03-22 14:39 ` [U-Boot] [RFC PATCH v1 5/9] Makefile: use custom ITS to build u-boot.img if SPL_FIT_SOURCE or SPL_FIT_GENERATOR are set Jean-Jacques Hiblot
2019-03-30 21:18   ` Simon Glass
2019-03-22 14:39 ` [U-Boot] [RFC PATCH v1 6/9] spl: fit: Allow calling spl_load_fit_image() to only get the image size Jean-Jacques Hiblot
2019-03-25  8:12   ` Michal Simek
2019-03-22 14:39 ` [U-Boot] [RFC PATCH v1 7/9] spl: fit: Add support for applying DT overlay Jean-Jacques Hiblot
2019-03-25  8:18   ` Michal Simek
2019-03-25 11:40     ` Jean-Jacques Hiblot
2019-03-25 11:58       ` Michal Simek
2019-03-22 14:39 ` Jean-Jacques Hiblot [this message]
2019-03-25  9:44   ` [U-Boot] [RFC PATCH v1 8/9] sp: fit: Allow the board to dynamically select the DTB overlays it needs Michal Simek
2019-03-22 14:39 ` [U-Boot] [RFC PATCH v1 9/9] !!! TEMP !!! For demonstration only !!! DRA76: Usage of overlays in SPL Jean-Jacques Hiblot
2019-03-25  8:08 ` [U-Boot] [RFC PATCH v1 0/9] Add support for applications " Michal Simek
2019-03-28 13:54   ` Michal Simek
2019-03-29 10:13     ` Jean-Jacques Hiblot
2019-03-29 10:26       ` Michal Simek
2019-03-29 12:50         ` Jean-Jacques Hiblot
2019-03-29 16:48           ` Michal Simek
2019-03-27  9:39 ` Lukasz Majewski
2019-03-27 17:41   ` Jean-Jacques Hiblot
2019-03-28  6:45     ` Lukasz Majewski

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=20190322143956.14767-9-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.