1 /*
2  * Arm SCP/MCP Software
3  * Copyright (c) 2022, Linaro Limited and Contributors. All rights reserved.
4  *
5  * SPDX-License-Identifier: BSD-3-Clause
6  */
7 
8 #ifndef MOD_OPTEE_SMT_H
9 #define MOD_OPTEE_SMT_H
10 
11 #include <fwk_id.h>
12 #include <fwk_module_idx.h>
13 
14 #include <stddef.h>
15 #include <stdint.h>
16 
17 /*!
18  * \name Channel policies
19  *
20  * \details These policies define attributes that affect how the channel is
21  *      treated by the SMT component.
22  *
23  * \{
24  */
25 
26 /*! No policies */
27 #define MOD_SMT_POLICY_NONE         0
28 
29 /*! This channel is secure */
30 #define MOD_SMT_POLICY_SECURE       (1U << 0)
31 
32 /*! The mailbox for this channel requires initialization */
33 #define MOD_SMT_POLICY_INIT_MAILBOX (1U << 1)
34 
35 /*!
36  * \}
37  */
38 
39 /*!
40  * \brief Channel type
41  *
42  * \details Defines the role of an entity in a channel
43  */
44 enum mod_optee_smt_channel_type {
45     /*! Requester channel */
46     MOD_OPTEE_SMT_CHANNEL_TYPE_REQUESTER,
47 
48     /*! Completer channel */
49     MOD_OPTEE_SMT_CHANNEL_TYPE_COMPLETER,
50 
51     /*! Channel type count */
52     MOD_OPTEE_SMT_CHANNEL_TYPE_COUNT,
53 };
54 
55 /*!
56  * \brief Channel config.
57  */
58 struct mod_optee_smt_channel_config {
59     /*! Channel role (requester or completer) */
60     enum mod_optee_smt_channel_type type;
61 
62     /*! Channel policies */
63     uint32_t policies;
64 
65     /*! Shared mailbox address */
66     uintptr_t mailbox_address;
67 
68     /*! Shared mailbox size in bytes */
69     size_t mailbox_size;
70 
71     /*! Identifier of the driver */
72     fwk_id_t driver_id;
73 
74     /*! Identifier of the driver API to bind to */
75     fwk_id_t driver_api_id;
76 };
77 
78 /*!
79  * \brief Driver API
80  */
81 struct mod_optee_smt_driver_api {
82     /*!
83      * \brief Raise an interrupt on the receiver
84      *
85      * \param device_id Device identifier
86      *
87      * \retval ::FWK_SUCCESS The operation succeeded
88      * \retval ::FWK_E_PARAM The device_id parameter is invalid
89      * \return One of the standard error codes for implementation-defined
90      *      errors
91      */
92     int (*raise_interrupt)(fwk_id_t device_id);
93 };
94 
95 /*!
96  * \brief Driver input API (Implemented by SMT)
97  *
98  * \details Interface used for driver -> SMT communication.
99  */
100 struct mod_optee_smt_driver_input_api {
101     /*!
102      * \brief Signal an incoming message in the mailbox
103      *
104      * \param device_id Channel identifier
105      *
106      * \retval ::FWK_SUCCESS The operation succeeded.
107      * \return One of the standard error codes for implementation-defined
108      *      errors.
109      */
110     int (*signal_message)(fwk_id_t channel_id);
111 };
112 
113 /*!
114  * \brief Type of the interfaces exposed by the power domain module.
115  */
116 enum mod_optee_smt_api_idx {
117     MOD_OPTEE_SMT_API_IDX_DRIVER_INPUT,
118     MOD_OPTEE_SMT_API_IDX_SCMI_TRANSPORT,
119     MOD_OPTEE_SMT_API_IDX_COUNT,
120 };
121 
122 #endif /* MOD_OPTEE_SMT_H */
123