[PATCH] i.MX8ULP: add display_ele_fw_version api

Gaurav Jain gaurav.jain at nxp.com
Wed May 11 10:37:55 CEST 2022


implement get f/w version api.
print ele f/w version in spl.

Signed-off-by: Gaurav Jain <gaurav.jain at nxp.com>
Reviewed-by: Peng Fan <peng.fan at nxp.com>
Reviewed-by: Pankaj Gupta <pankaj.gupta at nxp.com>
---
 arch/arm/include/asm/arch-imx8ulp/s400_api.h |  2 +
 board/freescale/imx8ulp_evk/spl.c            | 19 +++++++++
 drivers/misc/imx8ulp/s400_api.c              | 41 ++++++++++++++++++++
 3 files changed, 62 insertions(+)

diff --git a/arch/arm/include/asm/arch-imx8ulp/s400_api.h b/arch/arm/include/asm/arch-imx8ulp/s400_api.h
index 1856659877..b3e6b3fa45 100644
--- a/arch/arm/include/asm/arch-imx8ulp/s400_api.h
+++ b/arch/arm/include/asm/arch-imx8ulp/s400_api.h
@@ -17,6 +17,7 @@
 #define AHAB_WRITE_SECURE_FUSE_REQ_CID	0x91
 #define AHAB_FWD_LIFECYCLE_UP_REQ_CID   0x95
 #define AHAB_READ_FUSE_REQ_CID	0x97
+#define AHAB_GET_FW_VERSION_CID	0x9D
 #define AHAB_RELEASE_RDC_REQ_CID   0xC4
 #define AHAB_WRITE_FUSE_REQ_CID	0xD6
 #define AHAB_CAAM_RELEASE_CID 0xD7
@@ -39,6 +40,7 @@ int ahab_forward_lifecycle(u16 life_cycle, u32 *response);
 int ahab_write_fuse(u16 fuse_id, u32 fuse_val, bool lock, u32 *response);
 int ahab_read_common_fuse(u16 fuse_id, u32 *fuse_words, u32 fuse_num, u32 *response);
 int ahab_release_caam(u32 core_did, u32 *response);
+int ahab_get_fw_version(u32 *fw_version, u32 *sha1, u32 *response);
 int ahab_dump_buffer(u32 *buffer, u32 buffer_length);
 
 #endif
diff --git a/board/freescale/imx8ulp_evk/spl.c b/board/freescale/imx8ulp_evk/spl.c
index 66bfc2bd0c..ece9ff26e9 100644
--- a/board/freescale/imx8ulp_evk/spl.c
+++ b/board/freescale/imx8ulp_evk/spl.c
@@ -58,6 +58,23 @@ int power_init_board(void)
 	return 0;
 }
 
+void display_ele_fw_version(void)
+{
+	u32 fw_version, sha1, res;
+	int ret;
+
+	ret = ahab_get_fw_version(&fw_version, &sha1, &res);
+	if (ret) {
+		printf("ahab get firmware version failed %d, 0x%x\n", ret, res);
+	} else {
+		printf("ELE firmware version %u.%u.%u-%x",
+		       (fw_version & (0x00ff0000)) >> 16,
+		       (fw_version & (0x0000ff00)) >> 8,
+		       (fw_version & (0x000000ff)), sha1);
+		((fw_version & (0x80000000)) >> 31) == 1 ? puts("-dirty\n") : puts("\n");
+	}
+}
+
 void spl_board_init(void)
 {
 	struct udevice *dev;
@@ -77,6 +94,8 @@ void spl_board_init(void)
 
 	puts("Normal Boot\n");
 
+	display_ele_fw_version();
+
 	/* After AP set iomuxc0, the i2c can't work, Need M33 to set it now */
 
 	/* Load the lposc fuse to work around ROM issue. The fuse depends on S400 to read. */
diff --git a/drivers/misc/imx8ulp/s400_api.c b/drivers/misc/imx8ulp/s400_api.c
index 3ffdeb2ad2..87f5880ccb 100644
--- a/drivers/misc/imx8ulp/s400_api.c
+++ b/drivers/misc/imx8ulp/s400_api.c
@@ -272,6 +272,47 @@ int ahab_release_caam(u32 core_did, u32 *response)
 	return ret;
 }
 
+int ahab_get_fw_version(u32 *fw_version, u32 *sha1, u32 *response)
+{
+	struct udevice *dev = gd->arch.s400_dev;
+	int size = sizeof(struct imx8ulp_s400_msg);
+	struct imx8ulp_s400_msg msg;
+	int ret;
+
+	if (!dev) {
+		printf("s400 dev is not initialized\n");
+		return -ENODEV;
+	}
+
+	if (!fw_version) {
+		printf("Invalid parameters for f/w version read\n");
+		return -EINVAL;
+	}
+
+	if (!sha1) {
+		printf("Invalid parameters for commit sha1\n");
+		return -EINVAL;
+	}
+
+	msg.version = AHAB_VERSION;
+	msg.tag = AHAB_CMD_TAG;
+	msg.size = 1;
+	msg.command = AHAB_GET_FW_VERSION_CID;
+
+	ret = misc_call(dev, false, &msg, size, &msg, size);
+	if (ret)
+		printf("Error: %s: ret %d, response 0x%x\n",
+		       __func__, ret, msg.data[0]);
+
+	if (response)
+		*response = msg.data[0];
+
+	*fw_version = msg.data[1];
+	*sha1 = msg.data[2];
+
+	return ret;
+}
+
 int ahab_dump_buffer(u32 *buffer, u32 buffer_length)
 {
 	struct udevice *dev = gd->arch.s400_dev;
-- 
2.25.1



More information about the U-Boot mailing list