1 /*
2  * Arm SCP/MCP Software
3  * Copyright (c) 2019-2021, Arm Limited and Contributors. All rights reserved.
4  *
5  * SPDX-License-Identifier: BSD-3-Clause
6  *
7  * Description:
8  *     Reset domain HAL.
9  */
10 
11 #ifndef MOD_RESET_DOMAIN_H
12 #define MOD_RESET_DOMAIN_H
13 
14 #include <fwk_id.h>
15 #include <fwk_module_idx.h>
16 #include <stdint.h>
17 
18 /*!
19  * \addtogroup GroupModules Modules
20  * \{
21  */
22 
23 /*!
24  * \defgroup GroupResetDomain Reset Domain HAL
25  *
26  * \details Support for setting the state of reset domains.
27  *
28  * \{
29  */
30 
31 /*!
32  * \brief API indices.
33  */
34 enum mod_reset_domain_api_type {
35     /*!
36      * \brief HAL API.
37      *
38      * \note This API identifier implements the mod_reset_domain_api interface.
39      */
40     MOD_RESET_DOMAIN_API_TYPE_HAL,
41 
42     /*!
43      * \brief Number of defined APIs.
44      */
45     MOD_RESET_DOMAIN_API_COUNT,
46 };
47 
48 /*!
49  * \brief Reset domain modes.
50  */
51 enum mod_reset_domain_mode {
52     /*!
53      * \brief Indicates whether auto reset mode is supported by a reset domain.
54      */
55     MOD_RESET_DOMAIN_AUTO_RESET = (1UL << 0),
56 
57     /*!
58      * \brief Indicates whether async auto reset mode is supported
59      *     by a reset domain.
60      */
61     MOD_RESET_DOMAIN_MODE_AUTO_RESET_ASYNC = (1UL << 1),
62 
63     /*!
64      * \brief Indicates whether explicit reset mode is supported by a reset
65      *     domain
66      */
67     MOD_RESET_DOMAIN_MODE_EXPLICIT_ASSERT = (1UL << 2),
68 
69     /*!
70      * \brief Indicates whether explicit reset mode is supported by a reset
71      *     domain
72      */
73     MOD_RESET_DOMAIN_MODE_EXPLICIT_DEASSERT = (1UL << 3),
74 };
75 
76 
77 /*!
78  * \brief Reset domain capabilities.
79  */
80 enum mod_reset_domain_capabilities {
81     /*!
82      * \brief Indicates whether notifications are supported by a reset domain.
83      */
84     MOD_RESET_DOMAIN_CAP_NOTIFICATION = (1UL << 0),
85 
86     /*!
87      * \brief Indicates whether async reset is supported by a reset domain.
88      */
89     MOD_RESET_DOMAIN_CAP_ASYNC =  (1UL << 1)
90 };
91 
92 /*!
93  * \brief Reset domain module configuration data.
94  *
95  */
96 struct mod_reset_domain_config {
97     /*!
98      * \brief Identifier of the reset domain notification for auto reset status.
99      *
100      * \details Modules that are interested in the status of an auto reset of a
101      *     reset domain will use below notification identifier to subscribe to
102      *     the notification. For example, SCMI agents may request notification
103      *     for the status of an auto reset operation on a reset domain.
104      */
105     fwk_id_t notification_id;
106 };
107 
108 /*!
109  * \brief Reset domain element configuration data.
110  */
111 struct mod_reset_domain_dev_config {
112     /*! Driver identifier */
113     fwk_id_t driver_id;
114 
115     /*! Driver API identifier */
116     fwk_id_t driver_api_id;
117 
118      /*! Supported modes, see mod_reset_domain_mode */
119     enum mod_reset_domain_mode modes;
120 
121     /*! Supported capabilities, see mod_reset_domain_capabilities */
122     enum mod_reset_domain_capabilities capabilities;
123 
124     /*! Maximum time (in microseconds) required for the reset to take effect */
125     unsigned int latency;
126 };
127 
128 /*!
129  * \brief Reset domain HAL interface.
130  *
131  * \details The interface the reset domain clients relies on to perform
132  *      actions on a reset domain.
133  */
134 struct mod_reset_domain_api {
135     /*!
136      * \brief Change reset state of the domain \p element_id
137      *
138      * \param element_id Reset element identifier.
139      * \param mode Reset domain mode.
140      * \param reset_state Reset domain state as defined in SCMIv2 specification.
141      * \param cookie Context-specific value.
142      * \retval ::FWK_SUCCESS or one of FWK_E_* error codes.
143      */
144     int (*set_reset_state)(fwk_id_t element_id,
145                            enum mod_reset_domain_mode mode,
146                            uint32_t reset_state,
147                            uintptr_t cookie);
148 };
149 
150 /*!
151  * \brief Reset domain driver interface.
152  *
153  * \details The interface this reset domain module relies on to perform
154  *      actions on a reset domain.
155  */
156 struct mod_reset_domain_drv_api {
157     /*!
158      * \brief Change reset state of the device \p dev_id
159      *
160      * \param dev_id Reset domain driver identifier.
161      * \param mode Reset domain mode.
162      * \param reset_state Reset domain state as defined in SCMIv2 specification.
163      *
164      * \param cookie Context-specific value.
165      * \retval ::FWK_SUCCESS or one of FWK_E_* error codes.
166      */
167     int (*set_reset_state)(fwk_id_t dev_id,
168                            enum mod_reset_domain_mode mode,
169                            uint32_t reset_state,
170                            uintptr_t cookie);
171 };
172 
173 /*!
174  * \brief Reset domain notification indexes.
175  */
176 enum mod_reset_domain_notification_idx {
177     /*!
178      * \brief Auto reset state change notification index.
179      */
180     MOD_RESET_DOMAIN_NOTIFICATION_AUTORESET,
181 
182     /*!
183      * \brief Number of notifications available.
184      */
185     MOD_RESET_DOMAIN_NOTIFICATION_IDX_COUNT
186 };
187 
188 
189 /*!
190  * \brief Reset domain auto reset notification event parameters.
191  */
192 struct mod_reset_domain_notification_event_params {
193     /*!
194      * \brief Domain identifier associated with the notification.
195      */
196     uint32_t domain_id;
197 
198     /*!
199      * \brief Reset state as defined in SCMIv2 specification.
200      */
201     uint32_t reset_state;
202 
203     /*!
204      * \brief Context-specific value(e.g. agent_id) which is returned after
205      *     processing a set reset state request. The context-specific value
206      *     is the same value which is passed in a set_reset_state call.
207      */
208     uintptr_t cookie;
209 };
210 
211 /*!
212  * \brief Reset domain auto reset event parameters.
213  */
214 struct mod_reset_domain_autoreset_event_params {
215     /*!
216      * \brief Reset device identifier.
217      */
218     fwk_id_t dev_id;
219 
220     /*!
221      * \brief Reset state as defined in SCMIv2 specification.
222      */
223     uint32_t reset_state;
224 
225     /*!
226      * \brief Context-specific value(e.g. agent_id) which is returned after
227      *     processing a set reset state request. The context-specific value
228      *     is the same value which is passed in a set_reset_state call.
229      */
230     uintptr_t cookie;
231 };
232 
233 /*!
234  * \brief Reset domain event indexes.
235  */
236 enum mod_reset_domain_event_idx {
237     /*!
238      * \brief Auto reset state change event index.
239      */
240     MOD_RESET_DOMAIN_EVENT_AUTORESET,
241 
242     /*!
243      * \brief Total number of events available.
244      */
245     MOD_RESET_DOMAIN_EVENT_IDX_COUNT
246 };
247 
248 /*!
249  * Identifier auto reset event.
250  *
251  * \note The driver will send this event to this module
252  *     after completing the auto reset.
253  */
254 static const fwk_id_t mod_reset_domain_autoreset_event_id =
255     FWK_ID_EVENT_INIT(FWK_MODULE_IDX_RESET_DOMAIN,
256                       MOD_RESET_DOMAIN_EVENT_AUTORESET);
257 
258 /*!
259  * \}
260  */
261 
262 /*!
263  * \}
264  */
265 
266 #endif /* MOD_RESET_DOMAIN_H */
267