Commit 6e17375c authored by Mario Limonciello's avatar Mario Limonciello Committed by Herbert Xu

crypto: ccp - Add support for extended PSP mailbox commands

The PSP mailbox supports a number of extended sub-commands.  These
subcommands are placed in the header of the buffer sent to the mailbox.
Signed-off-by: default avatarMario Limonciello <mario.limonciello@amd.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 949a0c8d
...@@ -78,6 +78,30 @@ int psp_mailbox_command(struct psp_device *psp, enum psp_cmd cmd, void *cmdbuff, ...@@ -78,6 +78,30 @@ int psp_mailbox_command(struct psp_device *psp, enum psp_cmd cmd, void *cmdbuff,
return ret; return ret;
} }
int psp_extended_mailbox_cmd(struct psp_device *psp, unsigned int timeout_msecs,
struct psp_ext_request *req)
{
unsigned int reg;
int ret;
print_hex_dump_debug("->psp ", DUMP_PREFIX_OFFSET, 16, 2, req,
req->header.payload_size, false);
ret = psp_mailbox_command(psp, PSP_CMD_TEE_EXTENDED_CMD, (void *)req,
timeout_msecs, &reg);
if (ret) {
return ret;
} else if (FIELD_GET(PSP_CMDRESP_STS, reg)) {
req->header.status = FIELD_GET(PSP_CMDRESP_STS, reg);
return -EIO;
}
print_hex_dump_debug("<-psp ", DUMP_PREFIX_OFFSET, 16, 2, req,
req->header.payload_size, false);
return 0;
}
static struct psp_device *psp_alloc_struct(struct sp_device *sp) static struct psp_device *psp_alloc_struct(struct sp_device *sp)
{ {
struct device *dev = sp->dev; struct device *dev = sp->dev;
......
...@@ -78,15 +78,36 @@ struct psp_device *psp_get_master_device(void); ...@@ -78,15 +78,36 @@ struct psp_device *psp_get_master_device(void);
* enum psp_cmd - PSP mailbox commands * enum psp_cmd - PSP mailbox commands
* @PSP_CMD_TEE_RING_INIT: Initialize TEE ring buffer * @PSP_CMD_TEE_RING_INIT: Initialize TEE ring buffer
* @PSP_CMD_TEE_RING_DESTROY: Destroy TEE ring buffer * @PSP_CMD_TEE_RING_DESTROY: Destroy TEE ring buffer
* @PSP_CMD_TEE_EXTENDED_CMD: Extended command
* @PSP_CMD_MAX: Maximum command id * @PSP_CMD_MAX: Maximum command id
*/ */
enum psp_cmd { enum psp_cmd {
PSP_CMD_TEE_RING_INIT = 1, PSP_CMD_TEE_RING_INIT = 1,
PSP_CMD_TEE_RING_DESTROY = 2, PSP_CMD_TEE_RING_DESTROY = 2,
PSP_CMD_TEE_EXTENDED_CMD = 14,
PSP_CMD_MAX = 15, PSP_CMD_MAX = 15,
}; };
int psp_mailbox_command(struct psp_device *psp, enum psp_cmd cmd, void *cmdbuff, int psp_mailbox_command(struct psp_device *psp, enum psp_cmd cmd, void *cmdbuff,
unsigned int timeout_msecs, unsigned int *cmdresp); unsigned int timeout_msecs, unsigned int *cmdresp);
/**
* struct psp_ext_req_buffer_hdr - Structure of the extended command header
* @payload_size: total payload size
* @sub_cmd_id: extended command ID
* @status: status of command execution (out)
*/
struct psp_ext_req_buffer_hdr {
u32 payload_size;
u32 sub_cmd_id;
u32 status;
} __packed;
struct psp_ext_request {
struct psp_ext_req_buffer_hdr header;
void *buf;
} __packed;
int psp_extended_mailbox_cmd(struct psp_device *psp, unsigned int timeout_msecs,
struct psp_ext_request *req);
#endif /* __PSP_DEV_H */ #endif /* __PSP_DEV_H */
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