xref: /linux/drivers/tee/optee/optee_rpc_cmd.h (revision c297aa7d3fb6755890b78b483e82c9cf07370d50)
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  * Notification from/to secure world.
32  *
33  * If secure world needs to wait for something, for instance a mutex, it
34  * does a notification wait request instead of spinning in secure world.
35  * Conversely can a synchronous notification can be sent when a secure
36  * world mutex with a thread waiting thread is unlocked.
37  *
38  * This interface can also be used to wait for a asynchronous notification
39  * which instead is sent via a non-secure interrupt.
40  *
41  * Waiting on notification
42  * [in]    value[0].a	    OPTEE_RPC_NOTIFICATION_WAIT
43  * [in]    value[0].b	    notification value
44  * [in]    value[0].c	    timeout in milliseconds or 0 if no timeout
45  *
46  * Sending a synchronous notification
47  * [in]    value[0].a	    OPTEE_RPC_NOTIFICATION_SEND
48  * [in]    value[0].b	    notification value
49  */
50 #define OPTEE_RPC_CMD_NOTIFICATION	4
51 #define OPTEE_RPC_NOTIFICATION_WAIT	0
52 #define OPTEE_RPC_NOTIFICATION_SEND	1
53 
54 /*
55  * Suspend execution
56  *
57  * [in]    value[0].a	Number of milliseconds to suspend
58  */
59 #define OPTEE_RPC_CMD_SUSPEND		5
60 
61 /*
62  * Allocate a piece of shared memory
63  *
64  * [in]    value[0].a	    Type of memory one of
65  *			    OPTEE_RPC_SHM_TYPE_* below
66  * [in]    value[0].b	    Requested size
67  * [in]    value[0].c	    Required alignment
68  * [out]   memref[0]	    Buffer
69  */
70 #define OPTEE_RPC_CMD_SHM_ALLOC		6
71 /* Memory that can be shared with a non-secure user space application */
72 #define OPTEE_RPC_SHM_TYPE_APPL		0
73 /* Memory only shared with non-secure kernel */
74 #define OPTEE_RPC_SHM_TYPE_KERNEL	1
75 
76 /*
77  * Free shared memory previously allocated with OPTEE_RPC_CMD_SHM_ALLOC
78  *
79  * [in]     value[0].a	    Type of memory one of
80  *			    OPTEE_RPC_SHM_TYPE_* above
81  * [in]     value[0].b	    Value of shared memory reference or cookie
82  */
83 #define OPTEE_RPC_CMD_SHM_FREE		7
84 
85 /*
86  * Issue master requests (read and write operations) to an I2C chip.
87  *
88  * [in]     value[0].a	    Transfer mode (OPTEE_RPC_I2C_TRANSFER_*)
89  * [in]     value[0].b	    The I2C bus (a.k.a adapter).
90  *				16 bit field.
91  * [in]     value[0].c	    The I2C chip (a.k.a address).
92  *				16 bit field (either 7 or 10 bit effective).
93  * [in]     value[1].a	    The I2C master control flags (ie, 10 bit address).
94  *				16 bit field.
95  * [in/out] memref[2]	    Buffer used for data transfers.
96  * [out]    value[3].a	    Number of bytes transferred by the REE.
97  */
98 #define OPTEE_RPC_CMD_I2C_TRANSFER	21
99 
100 /* I2C master transfer modes */
101 #define OPTEE_RPC_I2C_TRANSFER_RD	0
102 #define OPTEE_RPC_I2C_TRANSFER_WR	1
103 
104 /* I2C master control flags */
105 #define OPTEE_RPC_I2C_FLAGS_TEN_BIT	BIT(0)
106 
107 /*
108  * Reset RPMB probing
109  *
110  * Releases an eventually already used RPMB devices and starts over searching
111  * for RPMB devices. Returns the kind of shared memory to use in subsequent
112  * OPTEE_RPC_CMD_RPMB_PROBE_NEXT and OPTEE_RPC_CMD_RPMB calls.
113  *
114  * [out]    value[0].a	    OPTEE_RPC_SHM_TYPE_*, the parameter for
115  *			    OPTEE_RPC_CMD_SHM_ALLOC
116  */
117 #define OPTEE_RPC_CMD_RPMB_PROBE_RESET	22
118 
119 /*
120  * Probe next RPMB device
121  *
122  * [out]    value[0].a	    Type of RPMB device, OPTEE_RPC_RPMB_*
123  * [out]    value[0].b	    EXT CSD-slice 168 "RPMB Size"
124  * [out]    value[0].c	    EXT CSD-slice 222 "Reliable Write Sector Count"
125  * [out]    memref[1]       Buffer with the raw CID
126  */
127 #define OPTEE_RPC_CMD_RPMB_PROBE_NEXT	23
128 
129 /* Type of RPMB device */
130 #define OPTEE_RPC_RPMB_EMMC		0
131 #define OPTEE_RPC_RPMB_UFS		1
132 #define OPTEE_RPC_RPMB_NVME		2
133 
134 /*
135  * Replay Protected Memory Block access
136  *
137  * [in]     memref[0]	    Frames to device
138  * [out]    memref[1]	    Frames from device
139  */
140 #define OPTEE_RPC_CMD_RPMB_FRAMES	24
141 
142 #endif /*__OPTEE_RPC_CMD_H*/
143