misc: S400_API: New API for FW status and chip info
authorPeng Fan <peng.fan@nxp.com>
Tue, 26 Jul 2022 08:40:52 +0000 (16:40 +0800)
committerStefano Babic <sbabic@denx.de>
Tue, 26 Jul 2022 09:29:00 +0000 (11:29 +0200)
Add new API to get sentinel FW status and SoC chip info

Signed-off-by: Ye Li <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
arch/arm/include/asm/mach-imx/s400_api.h
drivers/misc/sentinel/s400_api.c

index d09c078..d95f822 100644 (file)
 #define AHAB_READ_FUSE_REQ_CID 0x97
 #define AHAB_GET_FW_VERSION_CID        0x9D
 #define AHAB_RELEASE_RDC_REQ_CID   0xC4
+#define AHAB_GET_FW_STATUS_CID   0xC5
 #define AHAB_WRITE_FUSE_REQ_CID        0xD6
 #define AHAB_CAAM_RELEASE_CID 0xD7
+#define AHAB_GET_INFO_CID 0xDA
 
 #define S400_MAX_MSG          255U
 
@@ -32,6 +34,15 @@ struct imx8ulp_s400_msg {
        u32 data[(S400_MAX_MSG - 1U)];
 };
 
+struct sentinel_get_info_data {
+       u32 hdr;
+       u32 soc;
+       u32 lc;
+       u32 uid[4];
+       u32 sha256_rom_patch[8];
+       u32 sha_fw[8];
+};
+
 int ahab_release_rdc(u8 core_id, u8 xrdc, u32 *response);
 int ahab_auth_oem_ctnr(ulong ctnr_addr, u32 *response);
 int ahab_release_container(u32 *response);
@@ -42,5 +53,7 @@ int ahab_read_common_fuse(u16 fuse_id, u32 *fuse_words, u32 fuse_num, u32 *respo
 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);
+int ahab_get_info(struct sentinel_get_info_data *info, u32 *response);
+int ahab_get_fw_status(u32 *status, u32 *response);
 
 #endif
index 4e90171..ca79036 100644 (file)
@@ -359,3 +359,64 @@ int ahab_dump_buffer(u32 *buffer, u32 buffer_length)
 
        return i;
 }
+
+int ahab_get_info(struct sentinel_get_info_data *info, 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;
+       }
+
+       msg.version = AHAB_VERSION;
+       msg.tag = AHAB_CMD_TAG;
+       msg.size = 4;
+       msg.command = AHAB_GET_INFO_CID;
+       msg.data[0] = upper_32_bits((ulong)info);
+       msg.data[1] = lower_32_bits((ulong)info);
+       msg.data[2] = sizeof(struct sentinel_get_info_data);
+
+       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];
+
+       return ret;
+}
+
+int ahab_get_fw_status(u32 *status, 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;
+       }
+
+       msg.version = AHAB_VERSION;
+       msg.tag = AHAB_CMD_TAG;
+       msg.size = 1;
+       msg.command = AHAB_GET_FW_STATUS_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];
+
+       *status = msg.data[1] & 0xF;
+
+       return ret;
+}