[PATCH 22/41] imx: ele_api: Add get_events API

Peng Fan (OSS) peng.fan at oss.nxp.com
Mon Jan 23 10:16:41 CET 2023


From: Peng Fan <peng.fan at nxp.com>

Add get_events API to retrieve any singular events that has occurred
since the FW has started from sentinel

Signed-off-by: Peng Fan <peng.fan at nxp.com>
---
 arch/arm/include/asm/mach-imx/ele_api.h |  2 ++
 drivers/misc/sentinel/ele_api.c         | 45 +++++++++++++++++++++++++
 2 files changed, 47 insertions(+)

diff --git a/arch/arm/include/asm/mach-imx/ele_api.h b/arch/arm/include/asm/mach-imx/ele_api.h
index 158e21971ea..5dc4a20c5fd 100644
--- a/arch/arm/include/asm/mach-imx/ele_api.h
+++ b/arch/arm/include/asm/mach-imx/ele_api.h
@@ -18,6 +18,7 @@
 #define ELE_FWD_LIFECYCLE_UP_REQ_CID   0x95
 #define ELE_READ_FUSE_REQ_CID	0x97
 #define ELE_GET_FW_VERSION_CID	0x9D
+#define ELE_GET_EVENTS_REQ_CID 0xA2
 #define ELE_RELEASE_RDC_REQ_CID   0xC4
 #define ELE_GET_FW_STATUS_CID   0xC5
 #define ELE_WRITE_FUSE_REQ_CID	0xD6
@@ -56,5 +57,6 @@ int ele_dump_buffer(u32 *buffer, u32 buffer_length);
 int ele_get_info(struct ele_get_info_data *info, u32 *response);
 int ele_get_fw_status(u32 *status, u32 *response);
 int ele_release_m33_trout(void);
+int ele_get_events(u32 *events, u32 *events_cnt, u32 *response);
 
 #endif
diff --git a/drivers/misc/sentinel/ele_api.c b/drivers/misc/sentinel/ele_api.c
index d9d37b7ea48..1e0640d192b 100644
--- a/drivers/misc/sentinel/ele_api.c
+++ b/drivers/misc/sentinel/ele_api.c
@@ -445,3 +445,48 @@ int ele_release_m33_trout(void)
 
 	return ret;
 }
+
+int ele_get_events(u32 *events, u32 *events_cnt, u32 *response)
+{
+	struct udevice *dev = gd->arch.s400_dev;
+	int size = sizeof(struct ele_msg);
+	struct ele_msg msg;
+	int ret, i = 0;
+	u32 actual_events;
+
+	if (!dev) {
+		printf("s400 dev is not initialized\n");
+		return -ENODEV;
+	}
+
+	if (!events || !events_cnt || *events_cnt == 0) {
+		printf("Invalid parameters for %s\n", __func__);
+		return -EINVAL;
+	}
+
+	msg.version = ELE_VERSION;
+	msg.tag = ELE_CMD_TAG;
+	msg.size = 1;
+	msg.command = ELE_GET_EVENTS_REQ_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];
+
+	if (!ret) {
+		actual_events = msg.data[1] & 0xffff;
+		if (*events_cnt < actual_events)
+			actual_events = *events_cnt;
+
+		for (; i < actual_events; i++)
+			events[i] = msg.data[i + 2];
+
+		*events_cnt = actual_events;
+	}
+
+	return ret;
+}
-- 
2.36.0



More information about the U-Boot mailing list