Commit 6306f75d authored by Ye Li's avatar Ye Li Committed by Stefano Babic
Browse files

drivers: misc: imx8ulp: Add S400 API for image authentication



Add S400 API for image authentication
Signed-off-by: default avatarYe Li <ye.li@nxp.com>
Signed-off-by: Peng Fan's avatarPeng Fan <peng.fan@nxp.com>
parent a6ffde5e
......@@ -15,6 +15,7 @@
#define AHAB_VERIFY_IMG_CID 0x88
#define AHAB_RELEASE_CTNR_CID 0x89
#define AHAB_RELEASE_RDC_REQ_CID 0xC4
#define AHAB_FWD_LIFECYCLE_UP_REQ_CID 0x95
#define S400_MAX_MSG 8U
......@@ -26,5 +27,10 @@ struct imx8ulp_s400_msg {
u32 data[(S400_MAX_MSG - 1U)];
};
int ahab_release_rdc(u8 core_id);
int ahab_release_rdc(u8 core_id, u32 *response);
int ahab_auth_oem_ctnr(ulong ctnr_addr, u32 *response);
int ahab_release_container(u32 *response);
int ahab_verify_image(u32 img_id, u32 *response);
int ahab_forward_lifecycle(u16 life_cycle, u32 *response);
#endif
......@@ -14,7 +14,7 @@
DECLARE_GLOBAL_DATA_PTR;
int ahab_release_rdc(u8 core_id)
int ahab_release_rdc(u8 core_id, u32 *response)
{
struct udevice *dev = gd->arch.s400_dev;
int size = sizeof(struct imx8ulp_s400_msg);
......@@ -37,5 +37,124 @@ int ahab_release_rdc(u8 core_id)
printf("Error: %s: ret %d, core id %u, response 0x%x\n",
__func__, ret, core_id, msg.data[0]);
if (response)
*response = msg.data[0];
return ret;
}
int ahab_auth_oem_ctnr(ulong ctnr_addr, 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 = 3;
msg.command = AHAB_AUTH_OEM_CTNR_CID;
msg.data[0] = upper_32_bits(ctnr_addr);
msg.data[1] = lower_32_bits(ctnr_addr);
ret = misc_call(dev, false, &msg, size, &msg, size);
if (ret)
printf("Error: %s: ret %d, cntr_addr 0x%lx, response 0x%x\n",
__func__, ret, ctnr_addr, msg.data[0]);
if (response)
*response = msg.data[0];
return ret;
}
int ahab_release_container(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_RELEASE_CTNR_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];
return ret;
}
int ahab_verify_image(u32 img_id, 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 = 2;
msg.command = AHAB_VERIFY_IMG_CID;
msg.data[0] = 1 << img_id;
ret = misc_call(dev, false, &msg, size, &msg, size);
if (ret)
printf("Error: %s: ret %d, img_id %u, response 0x%x\n",
__func__, ret, img_id, msg.data[0]);
if (response)
*response = msg.data[0];
return ret;
}
int ahab_forward_lifecycle(u16 life_cycle, 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 = 2;
msg.command = AHAB_FWD_LIFECYCLE_UP_REQ_CID;
msg.data[0] = life_cycle;
ret = misc_call(dev, false, &msg, size, &msg, size);
if (ret)
printf("Error: %s: ret %d, life_cycle 0x%x, response 0x%x\n",
__func__, ret, life_cycle, msg.data[0]);
if (response)
*response = msg.data[0];
return ret;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment