xref: /optee_os/core/include/drivers/scmi-msg.h (revision a286b03f4e99344f3cade5fc01e6c1a6c3cc9e86)
1ae8c8068SEtienne Carriere /* SPDX-License-Identifier: BSD-3-Clause */
2ae8c8068SEtienne Carriere /*
3ae8c8068SEtienne Carriere  * Copyright (c) 2015-2019, Arm Limited and Contributors. All rights reserved.
4659a1f88SEtienne Carriere  * Copyright (c) 2019-2021, Linaro Limited
5ae8c8068SEtienne Carriere  */
6ae8c8068SEtienne Carriere 
7fbe66cf8SEtienne Carriere #ifndef __DRIVERS_SCMI_MSG_H
8fbe66cf8SEtienne Carriere #define __DRIVERS_SCMI_MSG_H
9ae8c8068SEtienne Carriere 
10ae8c8068SEtienne Carriere #include <compiler.h>
11ae8c8068SEtienne Carriere #include <kernel/panic.h>
12ae8c8068SEtienne Carriere #include <mm/core_memprot.h>
13ae8c8068SEtienne Carriere #include <stdbool.h>
14ae8c8068SEtienne Carriere #include <stddef.h>
15ae8c8068SEtienne Carriere #include <stdint.h>
16ae8c8068SEtienne Carriere 
17ae8c8068SEtienne Carriere /* Minimum size expected for SMT based shared memory message buffers */
18b4bfc9a9SJens Wiklander #define SMT_BUF_SLOT_SIZE	U(128)
19ae8c8068SEtienne Carriere 
20c22983c9SEtienne Carriere /* Standard values for SCMI voltage domain protocol configuration state */
21b4bfc9a9SJens Wiklander #define SCMI_VOLTAGE_DOMAIN_CONFIG_ARCH_ON	U(0x7)
22b4bfc9a9SJens Wiklander #define SCMI_VOLTAGE_DOMAIN_CONFIG_ARCH_OFF	U(0)
23c22983c9SEtienne Carriere 
24ae8c8068SEtienne Carriere /* A channel abstract a communication path between agent and server */
25ae8c8068SEtienne Carriere struct scmi_msg_channel;
26ae8c8068SEtienne Carriere 
27ae8c8068SEtienne Carriere /*
28ae8c8068SEtienne Carriere  * struct scmi_msg_channel - Shared memory buffer for a agent-to-server channel
29ae8c8068SEtienne Carriere  *
30ae8c8068SEtienne Carriere  * @shm_addr: Address of the shared memory for the SCMI channel
31ae8c8068SEtienne Carriere  * @shm_size: Byte size of the shared memory for the SCMI channel
32ae8c8068SEtienne Carriere  * @busy: True when channel is busy, flase when channel is free
33ae8c8068SEtienne Carriere  * @threaded: True is executed in a threaded context, false otherwise
34ae8c8068SEtienne Carriere  */
35ae8c8068SEtienne Carriere struct scmi_msg_channel {
36ae8c8068SEtienne Carriere 	struct io_pa_va shm_addr;
37ae8c8068SEtienne Carriere 	size_t shm_size;
38ae8c8068SEtienne Carriere 	bool busy;
39ae8c8068SEtienne Carriere 	bool threaded;
40ae8c8068SEtienne Carriere };
41ae8c8068SEtienne Carriere 
429ed56ecdSEtienne Carriere #ifdef CFG_SCMI_MSG_SMT
43a58c4d70SEtienne Carriere /*
44a58c4d70SEtienne Carriere  * Initialize SMT memory buffer, called by platform at init for each
45a58c4d70SEtienne Carriere  * agent channel using the SMT header format.
46a58c4d70SEtienne Carriere  * This function depends on CFG_SCMI_MSG_SMT.
47a58c4d70SEtienne Carriere  *
480c43202eSEtienne Carriere  * @channel: Pointer to the channel shared memory to be initialized
49a58c4d70SEtienne Carriere  */
509ed56ecdSEtienne Carriere void scmi_smt_init_agent_channel(struct scmi_msg_channel *channel);
5148f04743SEtienne Carriere 
5248f04743SEtienne Carriere /*
5348f04743SEtienne Carriere  * Set SMT shared buffer location
5448f04743SEtienne Carriere  *
5548f04743SEtienne Carriere  * @channel: SCMI channel reference
5648f04743SEtienne Carriere  * @base: virtual address of the shared buffer or NULL to clear the reference
5748f04743SEtienne Carriere  */
5848f04743SEtienne Carriere void scmi_smt_set_shared_buffer(struct scmi_msg_channel *channel, void *base);
599ed56ecdSEtienne Carriere #else
609ed56ecdSEtienne Carriere static inline
619ed56ecdSEtienne Carriere void scmi_smt_init_agent_channel(struct scmi_msg_channel *channel __unused)
629ed56ecdSEtienne Carriere {
639ed56ecdSEtienne Carriere 	panic();
649ed56ecdSEtienne Carriere }
6548f04743SEtienne Carriere 
6648f04743SEtienne Carriere static inline
6748f04743SEtienne Carriere void scmi_smt_set_shared_buffer(struct scmi_msg_channel *channel __unused,
6848f04743SEtienne Carriere 				void *base __unused)
6948f04743SEtienne Carriere {
7048f04743SEtienne Carriere }
7148f04743SEtienne Carriere #endif /* CFG_SCMI_MSG_SMT */
72a58c4d70SEtienne Carriere 
739ed56ecdSEtienne Carriere #ifdef CFG_SCMI_MSG_SMT_FASTCALL_ENTRY
74a58c4d70SEtienne Carriere /*
75064bf8dcSEtienne Carriere  * Process SMT formatted message in a fastcall SMC execution context.
76a58c4d70SEtienne Carriere  * Called by platform on SMC entry. When returning, output message is
77a58c4d70SEtienne Carriere  * available in shared memory for agent to read the response.
78a58c4d70SEtienne Carriere  * This function depends on CFG_SCMI_MSG_SMT_FASTCALL_ENTRY.
79a58c4d70SEtienne Carriere  *
80659a1f88SEtienne Carriere  * @channel_id: SCMI channel ID the SMT belongs to
81a58c4d70SEtienne Carriere  */
82659a1f88SEtienne Carriere void scmi_smt_fastcall_smc_entry(unsigned int channel_id);
839ed56ecdSEtienne Carriere #else
849ed56ecdSEtienne Carriere static inline void scmi_smt_fastcall_smc_entry(unsigned int channel_id __unused)
859ed56ecdSEtienne Carriere {
869ed56ecdSEtienne Carriere }
879ed56ecdSEtienne Carriere #endif
88a58c4d70SEtienne Carriere 
899ed56ecdSEtienne Carriere #ifdef CFG_SCMI_MSG_SMT_INTERRUPT_ENTRY
90a58c4d70SEtienne Carriere /*
91a58c4d70SEtienne Carriere  * Process SMT formatted message in a secure interrupt execution context.
92a58c4d70SEtienne Carriere  * Called by platform interrupt handler. When returning, output message is
93a58c4d70SEtienne Carriere  * available in shared memory for agent to read the response.
94a58c4d70SEtienne Carriere  * This function depends on CFG_SCMI_MSG_SMT_INTERRUPT_ENTRY.
95a58c4d70SEtienne Carriere  *
96659a1f88SEtienne Carriere  * @channel_id: SCMI channel ID the SMT belongs to
97a58c4d70SEtienne Carriere  */
98659a1f88SEtienne Carriere void scmi_smt_interrupt_entry(unsigned int channel_id);
999ed56ecdSEtienne Carriere #else
1009ed56ecdSEtienne Carriere static inline void scmi_smt_interrupt_entry(unsigned int channel_id __unused)
1019ed56ecdSEtienne Carriere {
1029ed56ecdSEtienne Carriere }
1039ed56ecdSEtienne Carriere #endif
104a58c4d70SEtienne Carriere 
1059ed56ecdSEtienne Carriere #ifdef CFG_SCMI_MSG_SMT_THREAD_ENTRY
106a58c4d70SEtienne Carriere /*
107a58c4d70SEtienne Carriere  * Process SMT formatted message in a TEE thread execution context.
108a58c4d70SEtienne Carriere  * When returning, output message is available in shared memory for
109a58c4d70SEtienne Carriere  * agent to read the response.
110a58c4d70SEtienne Carriere  * This function depends on CFG_SCMI_MSG_SMT_THREAD_ENTRY.
111a58c4d70SEtienne Carriere  *
112659a1f88SEtienne Carriere  * @channel_id: SCMI channel ID the SMT belongs to
113a58c4d70SEtienne Carriere  */
114659a1f88SEtienne Carriere void scmi_smt_threaded_entry(unsigned int channel_id);
1159ed56ecdSEtienne Carriere #else
1169ed56ecdSEtienne Carriere static inline void scmi_smt_threaded_entry(unsigned int channel_id __unused)
1179ed56ecdSEtienne Carriere {
1189ed56ecdSEtienne Carriere }
1199ed56ecdSEtienne Carriere #endif
120a58c4d70SEtienne Carriere 
121916cc52aSEtienne Carriere #ifdef CFG_SCMI_MSG_SHM_MSG
122916cc52aSEtienne Carriere /*
123916cc52aSEtienne Carriere  * Process MSG formatted message in a TEE thread execution context.
124916cc52aSEtienne Carriere  * When returning, output message is available in shared memory for
125916cc52aSEtienne Carriere  * agent to read the response.
126916cc52aSEtienne Carriere  * This function depends on CFG_SCMI_MSG_MSG_THREAD_ENTRY.
127916cc52aSEtienne Carriere  *
128916cc52aSEtienne Carriere  * @channel_id: SCMI channel ID
129916cc52aSEtienne Carriere  * @in_buf: Shared buffer storing input SCMI message
130916cc52aSEtienne Carriere  * @in_size: Byte size of @in_buf, including MSG header and message payload
131916cc52aSEtienne Carriere  * @out_buf: Shared buffer storing input SCMI message
132916cc52aSEtienne Carriere  * @out_size: [in] @out_buf max byte size
133916cc52aSEtienne Carriere  *            [out] @out_buf output byte size (MSG header and message payload)
134916cc52aSEtienne Carriere  */
135916cc52aSEtienne Carriere TEE_Result scmi_msg_threaded_entry(unsigned int channel_id,
136916cc52aSEtienne Carriere 				   void *in_buf, size_t in_size,
137916cc52aSEtienne Carriere 				   void *out_buf, size_t *out_size);
138916cc52aSEtienne Carriere #else
139916cc52aSEtienne Carriere static inline TEE_Result scmi_msg_threaded_entry(unsigned int chan_id __unused,
140916cc52aSEtienne Carriere 						 void *in_buf __unused,
141916cc52aSEtienne Carriere 						 size_t in_size __unused,
142916cc52aSEtienne Carriere 						 void *out_buf __unused,
143916cc52aSEtienne Carriere 						 size_t *out_size __unused)
144916cc52aSEtienne Carriere {
145916cc52aSEtienne Carriere 	return TEE_ERROR_NOT_SUPPORTED;
146916cc52aSEtienne Carriere }
147916cc52aSEtienne Carriere #endif
148916cc52aSEtienne Carriere 
149e80130f6SClément Léger struct clk;
150e80130f6SClément Léger 
151e80130f6SClément Léger #ifdef CFG_SCMI_MSG_USE_CLK
152e80130f6SClément Léger /*
153e80130f6SClément Léger  * Expose a clock through SCMI
154e80130f6SClément Léger  * @clk: Clock to be exposed
155e80130f6SClément Léger  * @channel_id: SCMI server channel exposing the clock
156e80130f6SClément Léger  * @scmi_id: SCMI ID of the clock within the channel
157e80130f6SClément Léger  */
158e80130f6SClément Léger TEE_Result scmi_clk_add(struct clk *clk, unsigned int channel_id,
159e80130f6SClément Léger 			unsigned int scmi_id);
160e80130f6SClément Léger #else
161e80130f6SClément Léger static inline TEE_Result scmi_clk_add(struct clk *clk __unused,
162e80130f6SClément Léger 				      unsigned int channel_id __unused,
163e80130f6SClément Léger 				      unsigned int scmi_id __unused)
164e80130f6SClément Léger {
165e80130f6SClément Léger 	return TEE_ERROR_NOT_SUPPORTED;
166e80130f6SClément Léger }
167e80130f6SClément Léger #endif
168e80130f6SClément Léger 
169ae8c8068SEtienne Carriere /* Platform callback functions */
170ae8c8068SEtienne Carriere 
171ae8c8068SEtienne Carriere /*
172ae8c8068SEtienne Carriere  * Return the SCMI channel related to an agent
173659a1f88SEtienne Carriere  * @channel_id: SCMI channel ID
174ae8c8068SEtienne Carriere  * Return a pointer to channel on success, NULL otherwise
175ae8c8068SEtienne Carriere  */
176659a1f88SEtienne Carriere struct scmi_msg_channel *plat_scmi_get_channel(unsigned int channel_id);
177ae8c8068SEtienne Carriere 
1783e530666SEtienne Carriere /* Scmi-msg uses the channel ID as handle. Must channel_id is valid */
1793e530666SEtienne Carriere static inline unsigned int scmi_smt_channel_handle(unsigned int channel_id)
1803e530666SEtienne Carriere {
1813e530666SEtienne Carriere 	assert(plat_scmi_get_channel(channel_id));
1823e530666SEtienne Carriere 
1833e530666SEtienne Carriere 	return channel_id;
1843e530666SEtienne Carriere }
1853e530666SEtienne Carriere 
186ae8c8068SEtienne Carriere /*
187ae8c8068SEtienne Carriere  * Return how many SCMI protocols supported by the platform
188ae8c8068SEtienne Carriere  * According to the SCMI specification, this function does not target
189659a1f88SEtienne Carriere  * a specific channel ID and shall return all platform known capabilities.
190ae8c8068SEtienne Carriere  */
191ae8c8068SEtienne Carriere size_t plat_scmi_protocol_count(void);
192ae8c8068SEtienne Carriere 
193ae8c8068SEtienne Carriere /*
194ae8c8068SEtienne Carriere  * Get the count and list of SCMI protocols (but base) supported for an agent
195ae8c8068SEtienne Carriere  *
196659a1f88SEtienne Carriere  * @channel_id: SCMI channel ID
197ae8c8068SEtienne Carriere  * Return a pointer to a null terminated array supported protocol IDs.
198ae8c8068SEtienne Carriere  */
199659a1f88SEtienne Carriere const uint8_t *plat_scmi_protocol_list(unsigned int channel_id);
200ae8c8068SEtienne Carriere 
201ae8c8068SEtienne Carriere /* Get the name of the SCMI vendor for the platform */
202ae8c8068SEtienne Carriere const char *plat_scmi_vendor_name(void);
203ae8c8068SEtienne Carriere 
204ae8c8068SEtienne Carriere /* Get the name of the SCMI sub-vendor for the platform */
205ae8c8068SEtienne Carriere const char *plat_scmi_sub_vendor_name(void);
206ae8c8068SEtienne Carriere 
207a7a9e3baSEtienne Carriere /* Handlers for SCMI Clock protocol services */
208a7a9e3baSEtienne Carriere 
209a7a9e3baSEtienne Carriere /*
210a7a9e3baSEtienne Carriere  * Return number of clock controllers for an agent
211659a1f88SEtienne Carriere  * @channel_id: SCMI channel ID
212a7a9e3baSEtienne Carriere  * Return number of clock controllers
213a7a9e3baSEtienne Carriere  */
214659a1f88SEtienne Carriere size_t plat_scmi_clock_count(unsigned int channel_id);
215a7a9e3baSEtienne Carriere 
216a7a9e3baSEtienne Carriere /*
217a7a9e3baSEtienne Carriere  * Get clock controller string ID (aka name)
218659a1f88SEtienne Carriere  * @channel_id: SCMI channel ID
219a7a9e3baSEtienne Carriere  * @scmi_id: SCMI clock ID
220a7a9e3baSEtienne Carriere  * Return pointer to name or NULL
221a7a9e3baSEtienne Carriere  */
222659a1f88SEtienne Carriere const char *plat_scmi_clock_get_name(unsigned int channel_id,
223a7a9e3baSEtienne Carriere 				     unsigned int scmi_id);
224a7a9e3baSEtienne Carriere 
225a7a9e3baSEtienne Carriere /*
226a7a9e3baSEtienne Carriere  * Get clock possible rate as an array of frequencies in Hertz.
227a7a9e3baSEtienne Carriere  *
228659a1f88SEtienne Carriere  * @channel_id: SCMI channel ID
229a7a9e3baSEtienne Carriere  * @scmi_id: SCMI clock ID
230d9be1b35SEtienne Carriere  * @start_index: Requested start index for the exposed rates array
2310c43202eSEtienne Carriere  * @rates: Output rates array or NULL if only querying @nb_elts
2320c43202eSEtienne Carriere  * @nb_elts: [in] Array size of @rates, [out] Number of rates loaded in @rates
233a7a9e3baSEtienne Carriere  * Return an SCMI compliant error code
234a7a9e3baSEtienne Carriere  */
235659a1f88SEtienne Carriere int32_t plat_scmi_clock_rates_array(unsigned int channel_id,
236659a1f88SEtienne Carriere 				    unsigned int scmi_id, size_t start_index,
237659a1f88SEtienne Carriere 				    unsigned long *rates, size_t *nb_elts);
238a7a9e3baSEtienne Carriere 
239a7a9e3baSEtienne Carriere /*
240a7a9e3baSEtienne Carriere  * Get clock possible rate as range with regular steps in Hertz
241a7a9e3baSEtienne Carriere  *
242659a1f88SEtienne Carriere  * @channel_id: SCMI channel ID
243a7a9e3baSEtienne Carriere  * @scmi_id: SCMI clock ID
244a7a9e3baSEtienne Carriere  * @min_max_step: 3 cell array for min, max and step rate data
245a7a9e3baSEtienne Carriere  * Return an SCMI compliant error code
246a7a9e3baSEtienne Carriere  */
247659a1f88SEtienne Carriere int32_t plat_scmi_clock_rates_by_step(unsigned int channel_id,
248a7a9e3baSEtienne Carriere 				      unsigned int scmi_id,
249a7a9e3baSEtienne Carriere 				      unsigned long *min_max_step);
250a7a9e3baSEtienne Carriere 
251a7a9e3baSEtienne Carriere /*
252a7a9e3baSEtienne Carriere  * Get clock rate in Hertz
253659a1f88SEtienne Carriere  * @channel_id: SCMI channel ID
254a7a9e3baSEtienne Carriere  * @scmi_id: SCMI clock ID
255a7a9e3baSEtienne Carriere  * Return clock rate or 0 if not supported
256a7a9e3baSEtienne Carriere  */
257659a1f88SEtienne Carriere unsigned long plat_scmi_clock_get_rate(unsigned int channel_id,
258a7a9e3baSEtienne Carriere 				       unsigned int scmi_id);
259a7a9e3baSEtienne Carriere 
260a7a9e3baSEtienne Carriere /*
261a7a9e3baSEtienne Carriere  * Set clock rate in Hertz
262659a1f88SEtienne Carriere  * @channel_id: SCMI channel ID
263a7a9e3baSEtienne Carriere  * @scmi_id: SCMI clock ID
264a7a9e3baSEtienne Carriere  * @rate: Target clock frequency in Hertz
265a7a9e3baSEtienne Carriere  * Return a compliant SCMI error code
266a7a9e3baSEtienne Carriere  */
267659a1f88SEtienne Carriere int32_t plat_scmi_clock_set_rate(unsigned int channel_id, unsigned int scmi_id,
268a7a9e3baSEtienne Carriere 				 unsigned long rate);
269a7a9e3baSEtienne Carriere 
270a7a9e3baSEtienne Carriere /*
271a7a9e3baSEtienne Carriere  * Get clock state (enabled or disabled)
272659a1f88SEtienne Carriere  * @channel_id: SCMI channel ID
273a7a9e3baSEtienne Carriere  * @scmi_id: SCMI clock ID
274a7a9e3baSEtienne Carriere  * Return 1 if clock is enabled, 0 if disables, or a negative SCMI error code
275a7a9e3baSEtienne Carriere  */
276659a1f88SEtienne Carriere int32_t plat_scmi_clock_get_state(unsigned int channel_id,
277659a1f88SEtienne Carriere 				  unsigned int scmi_id);
278a7a9e3baSEtienne Carriere 
279a7a9e3baSEtienne Carriere /*
280a7a9e3baSEtienne Carriere  * Get clock state (enabled or disabled)
281659a1f88SEtienne Carriere  * @channel_id: SCMI channel ID
282a7a9e3baSEtienne Carriere  * @scmi_id: SCMI clock ID
283a7a9e3baSEtienne Carriere  * @enable_not_disable: Enable clock if true, disable clock otherwise
284a7a9e3baSEtienne Carriere  * Return a compliant SCMI error code
285a7a9e3baSEtienne Carriere  */
286659a1f88SEtienne Carriere int32_t plat_scmi_clock_set_state(unsigned int channel_id, unsigned int scmi_id,
287a7a9e3baSEtienne Carriere 				  bool enable_not_disable);
28856a1f10eSEtienne Carriere 
28956a1f10eSEtienne Carriere /* Handlers for SCMI Reset Domain protocol services */
29056a1f10eSEtienne Carriere 
29156a1f10eSEtienne Carriere /*
29256a1f10eSEtienne Carriere  * Return number of reset domains for the agent
293659a1f88SEtienne Carriere  * @channel_id: SCMI channel ID
29456a1f10eSEtienne Carriere  * Return number of reset domains
29556a1f10eSEtienne Carriere  */
296659a1f88SEtienne Carriere size_t plat_scmi_rd_count(unsigned int channel_id);
29756a1f10eSEtienne Carriere 
29856a1f10eSEtienne Carriere /*
29956a1f10eSEtienne Carriere  * Get reset domain string ID (aka name)
300659a1f88SEtienne Carriere  * @channel_id: SCMI channel ID
30156a1f10eSEtienne Carriere  * @scmi_id: SCMI reset domain ID
30256a1f10eSEtienne Carriere  * Return pointer to name or NULL
30356a1f10eSEtienne Carriere  */
304659a1f88SEtienne Carriere const char *plat_scmi_rd_get_name(unsigned int channel_id,
305659a1f88SEtienne Carriere 				  unsigned int scmi_id);
30656a1f10eSEtienne Carriere 
30756a1f10eSEtienne Carriere /*
30856a1f10eSEtienne Carriere  * Perform a reset cycle on a target reset domain
309659a1f88SEtienne Carriere  * @channel_id: SCMI channel ID
31056a1f10eSEtienne Carriere  * @scmi_id: SCMI reset domain ID
31156a1f10eSEtienne Carriere  * @state: Target reset state (see SCMI specification, 0 means context loss)
31256a1f10eSEtienne Carriere  * Return a compliant SCMI error code
31356a1f10eSEtienne Carriere  */
314659a1f88SEtienne Carriere int32_t plat_scmi_rd_autonomous(unsigned int channel_id, unsigned int scmi_id,
31556a1f10eSEtienne Carriere 				unsigned int state);
31656a1f10eSEtienne Carriere 
31756a1f10eSEtienne Carriere /*
31856a1f10eSEtienne Carriere  * Assert or deassert target reset domain
319659a1f88SEtienne Carriere  * @channel_id: SCMI channel ID
32056a1f10eSEtienne Carriere  * @scmi_id: SCMI reset domain ID
32156a1f10eSEtienne Carriere  * @assert_not_deassert: Assert domain if true, otherwise deassert domain
32256a1f10eSEtienne Carriere  * Return a compliant SCMI error code
32356a1f10eSEtienne Carriere  */
324659a1f88SEtienne Carriere int32_t plat_scmi_rd_set_state(unsigned int channel_id, unsigned int scmi_id,
32556a1f10eSEtienne Carriere 			       bool assert_not_deassert);
32656a1f10eSEtienne Carriere 
327006d89b8SEtienne Carriere /* Handlers for SCMI Voltage Domain protocol services */
328006d89b8SEtienne Carriere 
329006d89b8SEtienne Carriere /*
330006d89b8SEtienne Carriere  * Return number of voltage domain for an agent
331659a1f88SEtienne Carriere  * @channel_id: SCMI channel ID
332006d89b8SEtienne Carriere  * Return number of voltage domains
333006d89b8SEtienne Carriere  */
334659a1f88SEtienne Carriere size_t plat_scmi_voltd_count(unsigned int channel_id);
335006d89b8SEtienne Carriere 
336006d89b8SEtienne Carriere /*
337*a286b03fSEtienne Carriere  * Get voltage domain string ID (aka name)
338659a1f88SEtienne Carriere  * @channel_id: SCMI channel ID
339006d89b8SEtienne Carriere  * @scmi_id: SCMI voltage domain ID
340006d89b8SEtienne Carriere  * Return pointer to name or NULL
341006d89b8SEtienne Carriere  */
342659a1f88SEtienne Carriere const char *plat_scmi_voltd_get_name(unsigned int channel_id,
343006d89b8SEtienne Carriere 				     unsigned int scmi_id);
344006d89b8SEtienne Carriere 
345006d89b8SEtienne Carriere /*
346006d89b8SEtienne Carriere  * Get voltage domain possible levels as an array of voltages in microvolt.
347006d89b8SEtienne Carriere  *
348659a1f88SEtienne Carriere  * @channel_id: SCMI channel ID
349006d89b8SEtienne Carriere  * @scmi_id: SCMI voltage domain ID
350006d89b8SEtienne Carriere  * @start_index: Level index to start from.
351ec8c2914SEtienne Carriere  * @levels: If NULL, function returns, else output rates array
352006d89b8SEtienne Carriere  * @nb_elts: Array size of @levels.
353006d89b8SEtienne Carriere  * Return an SCMI compliant error code
354006d89b8SEtienne Carriere  */
355659a1f88SEtienne Carriere int32_t plat_scmi_voltd_levels_array(unsigned int channel_id,
356006d89b8SEtienne Carriere 				     unsigned int scmi_id, size_t start_index,
357006d89b8SEtienne Carriere 				     long *levels, size_t *nb_elts);
358006d89b8SEtienne Carriere 
359006d89b8SEtienne Carriere /*
360006d89b8SEtienne Carriere  * Get voltage domain possible levels as range with regular steps in microvolt
361006d89b8SEtienne Carriere  *
362659a1f88SEtienne Carriere  * @channel_id: SCMI channel ID
363006d89b8SEtienne Carriere  * @scmi_id: SCMI voltage domain ID
364006d89b8SEtienne Carriere  * @min_max_step: 3 cell array for min, max and step voltage data
365006d89b8SEtienne Carriere  * Return an SCMI compliant error code
366006d89b8SEtienne Carriere  */
367659a1f88SEtienne Carriere int32_t plat_scmi_voltd_levels_by_step(unsigned int channel_id,
368006d89b8SEtienne Carriere 				       unsigned int scmi_id,
369006d89b8SEtienne Carriere 				       long *min_max_step);
370006d89b8SEtienne Carriere 
371006d89b8SEtienne Carriere /*
372006d89b8SEtienne Carriere  * Get current voltage domain level in microvolt
373659a1f88SEtienne Carriere  * @channel_id: SCMI channel ID
374006d89b8SEtienne Carriere  * @scmi_id: SCMI voltage domain ID
3754afbdbddSAnton Eliasson  * @level: Out parameter for the current voltage level
3764afbdbddSAnton Eliasson  * Return an SCMI compliant error code
377006d89b8SEtienne Carriere  */
3784afbdbddSAnton Eliasson int32_t plat_scmi_voltd_get_level(unsigned int channel_id, unsigned int scmi_id,
3794afbdbddSAnton Eliasson 				  long *level);
380006d89b8SEtienne Carriere 
381006d89b8SEtienne Carriere /*
382006d89b8SEtienne Carriere  * Set voltage domain level voltage domain
383659a1f88SEtienne Carriere  * @channel_id: SCMI channel ID
384*a286b03fSEtienne Carriere  * @scmi_id: SCMI voltage domain ID
385006d89b8SEtienne Carriere  * @level: Target voltage domain level in microvolt
386006d89b8SEtienne Carriere  * Return a compliant SCMI error code
387006d89b8SEtienne Carriere  */
388659a1f88SEtienne Carriere int32_t plat_scmi_voltd_set_level(unsigned int channel_id, unsigned int scmi_id,
389006d89b8SEtienne Carriere 				  long level);
390006d89b8SEtienne Carriere 
391006d89b8SEtienne Carriere /*
392006d89b8SEtienne Carriere  * Get voltage domain state configuration (enabled or disabled)
393659a1f88SEtienne Carriere  * @channel_id: SCMI channel ID
394006d89b8SEtienne Carriere  * @scmi_id: SCMI voltage domain ID
395ec8c2914SEtienne Carriere  * @config: output state configuration value SCMI_VOLTAGE_DOMAIN_CONFIG_*
396006d89b8SEtienne Carriere  * Return a compliant SCMI error code
397006d89b8SEtienne Carriere  */
398659a1f88SEtienne Carriere int32_t plat_scmi_voltd_get_config(unsigned int channel_id,
399659a1f88SEtienne Carriere 				   unsigned int scmi_id, uint32_t *config);
400006d89b8SEtienne Carriere 
401006d89b8SEtienne Carriere /*
402006d89b8SEtienne Carriere  * Get voltage domain state configuration (enabled or disabled)
403659a1f88SEtienne Carriere  * @channel_id: SCMI channel ID
404ec8c2914SEtienne Carriere  * @scmi_id: SCMI voltage domain ID
405ec8c2914SEtienne Carriere  * @config: Target state configuration value SCMI_VOLTAGE_DOMAIN_CONFIG_*
406006d89b8SEtienne Carriere  * Return a compliant SCMI error code
407006d89b8SEtienne Carriere  */
408659a1f88SEtienne Carriere int32_t plat_scmi_voltd_set_config(unsigned int channel_id,
409659a1f88SEtienne Carriere 				   unsigned int scmi_id, uint32_t config);
410006d89b8SEtienne Carriere 
411fbe66cf8SEtienne Carriere #endif /* __DRIVERS_SCMI_MSG_H */
412