Skip to contentSkip to conversation

Add for imx8x SoC get_boot_type command

PATCH New Heiko Schocher 1 participant 3 messages Feb 13

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover Add for imx8x SoC get_boot_type command

add function sc_misc_get_boot_type() which requests from the SC the current used boottype and add a comand "boottype" which saves the current boot_type in environment variable "boottype", so we can use this later.

Changes in v2:
- rebase to mainline
b99da05e153 - (tag: v2026.04-rc2, origin/master, origin/HEAD) Prepare v2026.04-rc2
- add Reviewed-by from Peng
- add description for the values returned, as suggested from Peng

Heiko Schocher (2):
imx: scu_api: implement sc_misc_get_boot_type
imx8qx: misc: add command for getting boottype

 arch/arm/mach-imx/imx8/misc.c  | 33 +++++++++++++++++++++++++++++++++
 drivers/misc/imx8/scu_api.c    | 25 +++++++++++++++++++++++++
 include/firmware/imx/sci/sci.h |  1 +
 3 files changed, 59 insertions(+)
Signature · 3 lines
2.20.1

base-commit: f2b1dd4c6d1d549f5afddbc2323a9e8b74fce5df
#1 lore raw

PATCH v2 1/2 imx: scu_api: implement sc_misc_get_boot_type

add function sc_misc_get_boot_type() which returns the boot type.

---

Changes in v2:
- rebase to mainline
b99da05e153 - (tag: v2026.04-rc2, origin/master, origin/HEAD) Prepare v2026.04-rc2
- add Reviewed-by from Peng

 drivers/misc/imx8/scu_api.c    | 25 +++++++++++++++++++++++++
 include/firmware/imx/sci/sci.h |  1 +
 2 files changed, 26 insertions(+)
drivers/misc/imx8/scu_api.c +25 -0
index d9cc7acb970..c15a4a629ad 100644
@@ -374,6 +374,31 @@ void sc_misc_boot_status(sc_ipc_t ipc, sc_misc_boot_status_t status)
 		       __func__, status, RPC_R8(&msg));
 }
 
+int sc_misc_get_boot_type(sc_ipc_t ipc, sc_misc_bt_t *type)
+{
+	struct udevice *dev = gd->arch.scu_dev;
+	int size = sizeof(struct sc_rpc_msg_s);
+	struct sc_rpc_msg_s msg;
+	int ret;
+
+	if (!dev)
+		hang();
+
+	RPC_VER(&msg) = SC_RPC_VERSION;
+	RPC_SIZE(&msg) = 1U;
+	RPC_SVC(&msg) = (u8)SC_RPC_SVC_MISC;
+	RPC_FUNC(&msg) = (u8)MISC_FUNC_GET_BOOT_TYPE;
+
+	ret = misc_call(dev, SC_FALSE, &msg, size, &msg, size);
+	if (ret < 0)
+		return ret;
+
+	if (type)
+		*type = (u8)RPC_U8(&msg, 0U);
+
+	return 0;
+}
+
 int sc_misc_get_boot_container(sc_ipc_t ipc, u8 *idx)
 {
 	struct udevice *dev = gd->arch.scu_dev;
include/firmware/imx/sci/sci.h +1 -0
index 876d52cac35..7f4ca735663 100644
@@ -86,6 +86,7 @@ int sc_misc_get_control(sc_ipc_t ipc, sc_rsrc_t resource, sc_ctrl_t ctrl,
 			u32 *val);
 void sc_misc_get_boot_dev(sc_ipc_t ipc, sc_rsrc_t *boot_dev);
 void sc_misc_boot_status(sc_ipc_t ipc, sc_misc_boot_status_t status);
+int sc_misc_get_boot_type(sc_ipc_t ipc, sc_misc_bt_t *type);
 int sc_misc_get_boot_container(sc_ipc_t ipc, u8 *idx);
 void sc_misc_build_info(sc_ipc_t ipc, u32 *build, u32 *commit);
 int sc_misc_otp_fuse_read(sc_ipc_t ipc, u32 word, u32 *val);
Signature · 1 line
2.20.1
#2 lore raw

PATCH v2 2/2 imx8qx: misc: add command for getting boottype

In reply to Heiko Schocher

add boottype command, which saves the boot_type primary (0) or fallback (1) in environment variable "boottype". If argument "print" is passed, it also prints the boottype on console.

---

Changes in v2:
- add description for the values returned, as suggested from Peng

 arch/arm/mach-imx/imx8/misc.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
arch/arm/mach-imx/imx8/misc.c +33 -0
index c77104d0338..22d6959f74f 100644
@@ -1,4 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0+
+#include <command.h>
+#include <env.h>
 #include <log.h>
 #include <firmware/imx/sci/sci.h>
 #include <asm/mach-imx/sys_proto.h>
@@ -62,3 +64,34 @@ void build_info(void)
 	printf("Build: SCFW %08x, SECO-FW %08x, ATF %s\n",
 	       sc_commit, seco_commit, (char *)&atf_commit);
 }
+
+int do_boottype(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[])
+{
+	sc_misc_bt_t boot_type;
+
+	if (argc > 2)
+		return CMD_RET_USAGE;
+
+	if (sc_misc_get_boot_type(-1, &boot_type) != 0) {
+		puts("boottype cannot be retrieved\n");
+		return CMD_RET_FAILURE;
+	}
+
+	if (argc > 1)
+		printf("Boottype: %d\n", boot_type);
+
+	env_set_ulong("boottype", boot_type);
+
+	return CMD_RET_SUCCESS;
+}
+
+U_BOOT_CMD(boottype, CONFIG_SYS_MAXARGS, 2, do_boottype,
+	   "save current boot-container in env variable 'boottype'",
+	   "possible values for boottype:\n"
+	   "0: SC_MISC_BT_PRIMARY\n"
+	   "1: SC_MISC_BT_SECONDARY\n"
+	   "2: SC_MISC_BT_RECOVERY\n"
+	   "3: SC_MISC_BT_MANUFACTURE\n"
+	   "4: SC_MISC_BT_SERIAL\n"
+	   "[print] - print current boottype"
+);
Signature · 1 line
2.20.1