1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3  * Copyright (c) 2019-2022, Linaro Limited
4  */
5 #ifndef SCMI_SERVER_H
6 #define SCMI_SERVER_H
7 
8 #include <tee_api_types.h>
9 #include <types_ext.h>
10 
11 #ifdef CFG_SCMI_SCPFW
12 /*
13  * Request processing of an incoming event in the SCMI server for a target
14  * MHU/SMT mailbox.
15  *
16  * @channel_id: SCMI channel handler
17  */
18 TEE_Result scmi_server_smt_process_thread(unsigned int channel_id);
19 
20 /*
21  * Request processing of an incoming event in the SCMI server for a target
22  * MHU/MSG mailbox.
23  *
24  * @id: SCMI channel handler
25  * @in_buf: Input message MSG buffer
26  * @in_size: Input message MSG buffer size
27  * @out_buf: Output message MSG buffer
28  * @out_size: Reference to output message MSG buffer size
29  */
30 TEE_Result scmi_server_msg_process_thread(unsigned int channel_id, void *in_buf,
31 					  size_t in_size, void *out_buf,
32 					  size_t *out_size);
33 
34 /*
35  * Get SCP-firmware channel device ID from the client channel ID.
36  *
37  * @channel_id: SCMI channel handler
38  * @handle: Output SCP-firmware device ID for the target SCMI mailbox
39  */
40 TEE_Result scmi_server_get_channel(unsigned int channel_id, int *handle);
41 
42 /* Get number of channels supported by the SCMI platform/server */
43 int scmi_server_get_channels_count(void);
44 
45 #else /* CFG_SCMI_SCPFW */
46 static inline
scmi_server_smt_process_thread(unsigned int channel_id __unused)47 TEE_Result scmi_server_smt_process_thread(unsigned int channel_id __unused)
48 {
49 	return TEE_ERROR_NOT_SUPPORTED;
50 }
51 
52 static inline
scmi_server_msg_process_thread(unsigned int channel_id __unused,void * in_buf __unused,size_t in_size __unused,void * out_buf __unused,size_t * out_size __unused)53 TEE_Result scmi_server_msg_process_thread(unsigned int channel_id __unused,
54 					  void *in_buf __unused,
55 					  size_t in_size __unused,
56 					  void *out_buf __unused,
57 					  size_t *out_size __unused)
58 {
59 	return TEE_ERROR_NOT_SUPPORTED;
60 }
61 
scmi_server_get_channel(unsigned int id __unused,int * handle __unused)62 static inline TEE_Result scmi_server_get_channel(unsigned int id __unused,
63 						 int *handle __unused)
64 {
65 	return TEE_ERROR_NOT_SUPPORTED;
66 }
67 
scmi_server_get_channels_count(void)68 static inline int scmi_server_get_channels_count(void)
69 {
70 	return 0;
71 }
72 #endif /* CFG_SCMI_SCPFW */
73 #endif /* SCMI_SERVER_H */
74