diff mbox series

[U-Boot,v6,10/13] drivers: board: Add get_fit_loadable()

Message ID 20191022143922.10205-11-jjhiblot@ti.com
State Accepted
Commit d42730e8c67a0955c2f8236157b4723c585b9d24
Delegated to: Tom Rini
Headers show
Series Add support for applications of overlays in SPL | expand

Commit Message

Jean-Jacques Hiblot Oct. 22, 2019, 2:39 p.m. UTC
This function will be used by the SPL to get the names of images to load
from the FIT. This allows to load different images based on runtime HW
detection.

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

---

Changes in v6: None
Changes in v5:
- board_get_fit_loadable() returns an error code instead of a NULL string
  in case of failure

Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/board/board-uclass.c | 11 +++++++++++
 include/board.h              | 37 ++++++++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+)

Comments

Simon Glass Dec. 30, 2019, 1:21 a.m. UTC | #1
On Tue, 22 Oct 2019 at 08:40, Jean-Jacques Hiblot <jjhiblot@ti.com> wrote:
>
> This function will be used by the SPL to get the names of images to load
> from the FIT. This allows to load different images based on runtime HW
> detection.
>
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
>
> ---
>
> Changes in v6: None
> Changes in v5:
> - board_get_fit_loadable() returns an error code instead of a NULL string
>   in case of failure
>
> Changes in v4: None
> Changes in v3: None
> Changes in v2: None
>
>  drivers/board/board-uclass.c | 11 +++++++++++
>  include/board.h              | 37 ++++++++++++++++++++++++++++++++++++
>  2 files changed, 48 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>
Tom Rini Jan. 8, 2020, 8:11 p.m. UTC | #2
On Tue, Oct 22, 2019 at 04:39:19PM +0200, Jean-Jacques Hiblot wrote:

> This function will be used by the SPL to get the names of images to load
> from the FIT. This allows to load different images based on runtime HW
> detection.
> 
> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/drivers/board/board-uclass.c b/drivers/board/board-uclass.c
index a516ba4962..b5485e9895 100644
--- a/drivers/board/board-uclass.c
+++ b/drivers/board/board-uclass.c
@@ -23,6 +23,17 @@  int board_detect(struct udevice *dev)
 	return ops->detect(dev);
 }
 
+int board_get_fit_loadable(struct udevice *dev, int index,
+			   const char *type, const char **strp)
+{
+	struct board_ops *ops = board_get_ops(dev);
+
+	if (!ops->get_fit_loadable)
+		return -ENOSYS;
+
+	return ops->get_fit_loadable(dev, index, type, strp);
+}
+
 int board_get_bool(struct udevice *dev, int id, bool *val)
 {
 	struct board_ops *ops = board_get_ops(dev);
diff --git a/include/board.h b/include/board.h
index 9dc78684f8..fd6a486702 100644
--- a/include/board.h
+++ b/include/board.h
@@ -79,6 +79,24 @@  struct board_ops {
 	 * Return: 0 if OK, -ve on error.
 	 */
 	int (*get_str)(struct udevice *dev, int id, size_t size, char *val);
+
+	/**
+	 * get_fit_loadable - Get the name of an image to load from FIT
+	 * 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.
+	 *
+	 * @dev:	The board instance to gather the data.
+	 * @index:	Index of the image. Starts at 0 and gets incremented
+	 *		after each call to this function.
+	 * @type:	The type of image. For example, "fdt" for DTBs
+	 * @strp:	A pointer to string. Untouched if the function fails
+	 *
+	 * Return: 0 if OK, -ENOENT if no loadable is available else -ve on
+	 * error.
+	 */
+	int (*get_fit_loadable)(struct udevice *dev, int index,
+				const char *type, const char **strp);
 };
 
 #define board_get_ops(dev)	((struct board_ops *)(dev)->driver->ops)
@@ -137,3 +155,22 @@  int board_get_str(struct udevice *dev, int id, size_t size, char *val);
  * Return: 0 if OK, -ve on error.
  */
 int board_get(struct udevice **devp);
+
+/**
+ * board_get_fit_loadable - Get the name of an image to load from FIT
+ * 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.
+ *
+ * @dev:	The board instance to gather the data.
+ * @index:	Index of the image. Starts at 0 and gets incremented
+ *		after each call to this function.
+ * @type:	The type of image. For example, "fdt" for DTBs
+ * @strp:	A pointer to string. Untouched if the function fails
+ *
+ *
+ * Return: 0 if OK, -ENOENT if no loadable is available else -ve on
+ * error.
+ */
+int board_get_fit_loadable(struct udevice *dev, int index,
+			   const char *type, const char **strp);