1 /* SPDX-License-Identifier: MIT */
3 * AMD Trusted Execution Environment (TEE) interface
5 * Author: Rijo Thomas <Rijo-john.Thomas@amd.com>
7 * Copyright 2019 Advanced Micro Devices, Inc.
14 #include <linux/types.h>
15 #include <linux/errno.h>
17 /* This file defines the Trusted Execution Environment (TEE) interface commands
18 * and the API exported by AMD Secure Processor driver to communicate with
23 * enum tee_cmd_id - TEE Interface Command IDs
24 * @TEE_CMD_ID_LOAD_TA: Load Trusted Application (TA) binary into
26 * @TEE_CMD_ID_UNLOAD_TA: Unload TA binary from TEE environment
27 * @TEE_CMD_ID_OPEN_SESSION: Open session with loaded TA
28 * @TEE_CMD_ID_CLOSE_SESSION: Close session with loaded TA
29 * @TEE_CMD_ID_INVOKE_CMD: Invoke a command with loaded TA
30 * @TEE_CMD_ID_MAP_SHARED_MEM: Map shared memory
31 * @TEE_CMD_ID_UNMAP_SHARED_MEM: Unmap shared memory
34 TEE_CMD_ID_LOAD_TA = 1,
36 TEE_CMD_ID_OPEN_SESSION,
37 TEE_CMD_ID_CLOSE_SESSION,
38 TEE_CMD_ID_INVOKE_CMD,
39 TEE_CMD_ID_MAP_SHARED_MEM,
40 TEE_CMD_ID_UNMAP_SHARED_MEM,
43 #ifdef CONFIG_CRYPTO_DEV_SP_PSP
45 * psp_tee_process_cmd() - Process command in Trusted Execution Environment
46 * @cmd_id: TEE command ID (&enum tee_cmd_id)
47 * @buf: Command buffer for TEE processing. On success, is updated
49 * @len: Length of command buffer in bytes
50 * @status: On success, holds the TEE command execution status
52 * This function submits a command to the Trusted OS for processing in the
53 * TEE environment and waits for a response or until the command times out.
56 * 0 if TEE successfully processed the command
57 * -%ENODEV if PSP device not available
58 * -%EINVAL if invalid input
59 * -%ETIMEDOUT if TEE command timed out
60 * -%EBUSY if PSP device is not responsive
62 int psp_tee_process_cmd(enum tee_cmd_id cmd_id, void *buf, size_t len,
66 * psp_check_tee_status() - Checks whether there is a TEE which a driver can
69 * This function can be used by AMD-TEE driver to query if there is TEE with
70 * which it can communicate.
73 * 0 if the device has TEE
74 * -%ENODEV if there is no TEE available
76 int psp_check_tee_status(void);
78 #else /* !CONFIG_CRYPTO_DEV_SP_PSP */
80 static inline int psp_tee_process_cmd(enum tee_cmd_id cmd_id, void *buf,
81 size_t len, u32 *status)
86 static inline int psp_check_tee_status(void)
90 #endif /* CONFIG_CRYPTO_DEV_SP_PSP */
91 #endif /* __PSP_TEE_H_ */