[PATCH v2 1/9] spl: Try to get SPL boot device via board_get_int

Jagan Teki jagan at amarulasolutions.com
Tue May 19 21:23:32 CEST 2020


Usually, the associated board would supply spl boot device
using spl_boot_device() but some boards have board driver
that are possible to supply boot device via board_get_int
with BOARD_SPL_BOOT_DEVICE id.

This patch add support for those.

Cc: Mario Six <mario.six at gdsys.cc>
Cc: Tom Rini <trini at konsulko.com>
Cc: Simon Glass <sjg at chromium.org>
Cc: Jean-Jacques Hiblot <jjhiblot at ti.com>
Signed-off-by: Jagan Teki <jagan at amarulasolutions.com>
---
Changes for v2:
- new patch

 common/spl/spl.c | 14 +++++++++++++-
 include/board.h  |  9 +++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/common/spl/spl.c b/common/spl/spl.c
index fc5cbbbeba..a07b71b3c1 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -9,6 +9,7 @@
 #include <common.h>
 #include <bloblist.h>
 #include <binman_sym.h>
+#include <board.h>
 #include <dm.h>
 #include <handoff.h>
 #include <hang.h>
@@ -483,9 +484,20 @@ int spl_init(void)
 #define BOOT_DEVICE_NONE 0xdeadbeef
 #endif
 
+__weak u32 spl_boot_device(void)
+{
+	return 0;
+}
+
 __weak void board_boot_order(u32 *spl_boot_list)
 {
-	spl_boot_list[0] = spl_boot_device();
+	struct udevice *board;
+
+	if (!board_get(&board))
+		board_get_int(board, BOARD_SPL_BOOT_DEVICE,
+			      (int *)&spl_boot_list[0]);
+	else
+		spl_boot_list[0] = spl_boot_device();
 }
 
 static struct spl_image_loader *spl_ll_find_loader(uint boot_device)
diff --git a/include/board.h b/include/board.h
index 678b652b0a..ce4eaba38d 100644
--- a/include/board.h
+++ b/include/board.h
@@ -211,3 +211,12 @@ static inline int board_get_fit_loadable(struct udevice *dev, int index,
 }
 
 #endif
+
+/**
+ * Common board unique identifier
+ *
+ * @BOARD_SPL_BOOT_DEVICE:	id to get SPL boot device.
+ */
+enum common_ids {
+	BOARD_SPL_BOOT_DEVICE,
+};
-- 
2.20.1



More information about the U-Boot mailing list