xref: /linux/drivers/tee/optee/optee_rpc_cmd.h (revision 172cdcaefea5c297fdb3d20b7d5aff60ae4fbce6)
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3  * Copyright (c) 2016-2021, Linaro Limited
4  */
5 
6 #ifndef __OPTEE_RPC_CMD_H
7 #define __OPTEE_RPC_CMD_H
8 
9 /*
10  * All RPC is done with a struct optee_msg_arg as bearer of information,
11  * struct optee_msg_arg::arg holds values defined by OPTEE_RPC_CMD_* below.
12  * Only the commands handled by the kernel driver are defined here.
13  *
14  * RPC communication with tee-supplicant is reversed compared to normal
15  * client communication described above. The supplicant receives requests
16  * and sends responses.
17  */
18 
19 /*
20  * Get time
21  *
22  * Returns number of seconds and nano seconds since the Epoch,
23  * 1970-01-01 00:00:00 +0000 (UTC).
24  *
25  * [out]    value[0].a	    Number of seconds
26  * [out]    value[0].b	    Number of nano seconds.
27  */
28 #define OPTEE_RPC_CMD_GET_TIME		3
29 
30 /*
31  * Wait queue primitive, helper for secure world to implement a wait queue.
32  *
33  * If secure world needs to wait for a secure world mutex it issues a sleep
34  * request instead of spinning in secure world. Conversely is a wakeup
35  * request issued when a secure world mutex with a thread waiting thread is
36  * unlocked.
37  *
38  * Waiting on a key
39  * [in]    value[0].a	    OPTEE_RPC_WAIT_QUEUE_SLEEP
40  * [in]    value[0].b	    Wait key
41  *
42  * Waking up a key
43  * [in]    value[0].a	    OPTEE_RPC_WAIT_QUEUE_WAKEUP
44  * [in]    value[0].b	    Wakeup key
45  */
46 #define OPTEE_RPC_CMD_WAIT_QUEUE	4
47 #define OPTEE_RPC_WAIT_QUEUE_SLEEP	0
48 #define OPTEE_RPC_WAIT_QUEUE_WAKEUP	1
49 
50 /*
51  * Suspend execution
52  *
53  * [in]    value[0].a	Number of milliseconds to suspend
54  */
55 #define OPTEE_RPC_CMD_SUSPEND		5
56 
57 /*
58  * Allocate a piece of shared memory
59  *
60  * [in]    value[0].a	    Type of memory one of
61  *			    OPTEE_RPC_SHM_TYPE_* below
62  * [in]    value[0].b	    Requested size
63  * [in]    value[0].c	    Required alignment
64  * [out]   memref[0]	    Buffer
65  */
66 #define OPTEE_RPC_CMD_SHM_ALLOC		6
67 /* Memory that can be shared with a non-secure user space application */
68 #define OPTEE_RPC_SHM_TYPE_APPL		0
69 /* Memory only shared with non-secure kernel */
70 #define OPTEE_RPC_SHM_TYPE_KERNEL	1
71 
72 /*
73  * Free shared memory previously allocated with OPTEE_RPC_CMD_SHM_ALLOC
74  *
75  * [in]     value[0].a	    Type of memory one of
76  *			    OPTEE_RPC_SHM_TYPE_* above
77  * [in]     value[0].b	    Value of shared memory reference or cookie
78  */
79 #define OPTEE_RPC_CMD_SHM_FREE		7
80 
81 /*
82  * Issue master requests (read and write operations) to an I2C chip.
83  *
84  * [in]     value[0].a	    Transfer mode (OPTEE_RPC_I2C_TRANSFER_*)
85  * [in]     value[0].b	    The I2C bus (a.k.a adapter).
86  *				16 bit field.
87  * [in]     value[0].c	    The I2C chip (a.k.a address).
88  *				16 bit field (either 7 or 10 bit effective).
89  * [in]     value[1].a	    The I2C master control flags (ie, 10 bit address).
90  *				16 bit field.
91  * [in/out] memref[2]	    Buffer used for data transfers.
92  * [out]    value[3].a	    Number of bytes transferred by the REE.
93  */
94 #define OPTEE_RPC_CMD_I2C_TRANSFER	21
95 
96 /* I2C master transfer modes */
97 #define OPTEE_RPC_I2C_TRANSFER_RD	0
98 #define OPTEE_RPC_I2C_TRANSFER_WR	1
99 
100 /* I2C master control flags */
101 #define OPTEE_RPC_I2C_FLAGS_TEN_BIT	BIT(0)
102 
103 #endif /*__OPTEE_RPC_CMD_H*/
104