[PATCH 15/27] misc: S400_API: Update S400 API for buffer dump

Peng Fan (OSS) peng.fan at oss.nxp.com
Mon Feb 14 13:47:23 CET 2022


From: Ye Li <ye.li at nxp.com>

Add ahab_dump_buffer API to dump AHAB buffer for debug purpose

Signed-off-by: Ye Li <ye.li at nxp.com>
Signed-off-by: Peng Fan <peng.fan at nxp.com>
---
 arch/arm/include/asm/arch-imx8ulp/s400_api.h |  3 +-
 drivers/misc/imx8ulp/s400_api.c              | 34 ++++++++++++++++++++
 2 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/arch/arm/include/asm/arch-imx8ulp/s400_api.h b/arch/arm/include/asm/arch-imx8ulp/s400_api.h
index b788661b09..1856659877 100644
--- a/arch/arm/include/asm/arch-imx8ulp/s400_api.h
+++ b/arch/arm/include/asm/arch-imx8ulp/s400_api.h
@@ -21,7 +21,7 @@
 #define AHAB_WRITE_FUSE_REQ_CID	0xD6
 #define AHAB_CAAM_RELEASE_CID 0xD7
 
-#define S400_MAX_MSG          8U
+#define S400_MAX_MSG          255U
 
 struct imx8ulp_s400_msg {
 	u8 version;
@@ -39,5 +39,6 @@ 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_dump_buffer(u32 *buffer, u32 buffer_length);
 
 #endif
diff --git a/drivers/misc/imx8ulp/s400_api.c b/drivers/misc/imx8ulp/s400_api.c
index dd5f9f25da..3ffdeb2ad2 100644
--- a/drivers/misc/imx8ulp/s400_api.c
+++ b/drivers/misc/imx8ulp/s400_api.c
@@ -271,3 +271,37 @@ int ahab_release_caam(u32 core_did, u32 *response)
 
 	return ret;
 }
+
+int ahab_dump_buffer(u32 *buffer, u32 buffer_length)
+{
+	struct udevice *dev = gd->arch.s400_dev;
+	int size = sizeof(struct imx8ulp_s400_msg);
+	struct imx8ulp_s400_msg msg;
+	int ret, i = 0;
+
+	if (!dev) {
+		printf("s400 dev is not initialized\n");
+		return -ENODEV;
+	}
+
+	msg.version = AHAB_VERSION;
+	msg.tag = AHAB_CMD_TAG;
+	msg.size = 1;
+	msg.command = AHAB_LOG_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]);
+
+		return ret;
+	}
+
+	if (buffer) {
+		buffer[i++] = *(u32 *)&msg; /* Need dump the response header */
+		for (; i < buffer_length && i < msg.size; i++)
+			buffer[i] = msg.data[i - 1];
+	}
+
+	return i;
+}
-- 
2.30.0



More information about the U-Boot mailing list