[U-Boot] [RFC PATCH v1 8/9] sp: fit: Allow the board to dynamically select the DTB overlays it needs.
Jean-Jacques Hiblot
jjhiblot at ti.com
Fri Mar 22 14:39:55 UTC 2019
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 at 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
More information about the U-Boot
mailing list