[PATCH 30/41] imx: spl_imx_romapi: Get and print boot stage
Peng Fan (OSS)
peng.fan at oss.nxp.com
Mon Jan 23 10:16:49 CET 2023
From: Peng Fan <peng.fan at nxp.com>
Get and print boot stage through ROM API in SPL
Signed-off-by: Ye Li <ye.li at nxp.com>
Signed-off-by: Peng Fan <peng.fan at nxp.com>
---
arch/arm/include/asm/mach-imx/sys_proto.h | 7 +++++++
arch/arm/mach-imx/spl_imx_romapi.c | 22 +++++++++++++++++++++-
2 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/arch/arm/include/asm/mach-imx/sys_proto.h b/arch/arm/include/asm/mach-imx/sys_proto.h
index de241c2450e..8d8f580a5aa 100644
--- a/arch/arm/include/asm/mach-imx/sys_proto.h
+++ b/arch/arm/include/asm/mach-imx/sys_proto.h
@@ -180,6 +180,13 @@ enum boot_dev_type_e {
BT_DEV_TYPE_INVALID = 0xFF
};
+enum boot_stage_type {
+ BT_STAGE_PRIMARY = 0x6,
+ BT_STAGE_SECONDARY = 0x9,
+ BT_STAGE_RECOVERY = 0xa,
+ BT_STAGE_USB = 0x5,
+};
+
#define QUERY_ROM_VER 1
#define QUERY_BT_DEV 2
#define QUERY_PAGE_SZ 3
diff --git a/arch/arm/mach-imx/spl_imx_romapi.c b/arch/arm/mach-imx/spl_imx_romapi.c
index 4480d3c7115..3a26fcc91a8 100644
--- a/arch/arm/mach-imx/spl_imx_romapi.c
+++ b/arch/arm/mach-imx/spl_imx_romapi.c
@@ -378,15 +378,35 @@ int board_return_to_bootrom(struct spl_image_info *spl_image,
struct spl_boot_device *bootdev)
{
int ret;
- u32 boot;
+ u32 boot, bstage;
ret = rom_api_query_boot_infor(QUERY_BT_DEV, &boot);
+ ret |= rom_api_query_boot_infor(QUERY_BT_STAGE, &bstage);
if (ret != ROM_API_OKAY) {
puts("ROMAPI: failure at query_boot_info\n");
return -1;
}
+ printf("Boot Stage: ");
+
+ switch (bstage) {
+ case BT_STAGE_PRIMARY:
+ printf("Primary boot\n");
+ break;
+ case BT_STAGE_SECONDARY:
+ printf("Secondary boot\n");
+ break;
+ case BT_STAGE_RECOVERY:
+ printf("Recovery boot\n");
+ break;
+ case BT_STAGE_USB:
+ printf("USB boot\n");
+ break;
+ default:
+ printf("Unknown (0x%x)\n", bstage);
+ }
+
if (is_boot_from_stream_device(boot))
return spl_romapi_load_image_stream(spl_image, bootdev);
--
2.36.0
More information about the U-Boot
mailing list