blob: c93c455004999eb8644fc57fe290393c178b3dee [file] [log] [blame]
Etienne Carriere13b353c2019-11-28 09:13:34 +01001/* SPDX-License-Identifier: BSD-3-Clause */
2/*
3 * Copyright (c) 2015-2019, Arm Limited and Contributors. All rights reserved.
4 * Copyright (c) 2019, Linaro Limited
5 */
6
7#ifndef SCMI_MSG_H
8#define SCMI_MSG_H
9
10#include <stdbool.h>
11#include <stddef.h>
12#include <stdint.h>
13
14/* Minimum size expected for SMT based shared memory message buffers */
15#define SMT_BUF_SLOT_SIZE 128U
16
17/* A channel abstract a communication path between agent and server */
18struct scmi_msg_channel;
19
20/*
21 * struct scmi_msg_channel - Shared memory buffer for a agent-to-server channel
22 *
23 * @shm_addr: Address of the shared memory for the SCMI channel
24 * @shm_size: Byte size of the shared memory for the SCMI channel
Michal Simek1545d802023-03-21 13:27:39 +010025 * @busy: True when channel is busy, false when channel is free
Etienne Carriere13b353c2019-11-28 09:13:34 +010026 * @agent_name: Agent name, SCMI protocol exposes 16 bytes max, or NULL
27 */
28struct scmi_msg_channel {
29 uintptr_t shm_addr;
30 size_t shm_size;
31 bool busy;
32 const char *agent_name;
33};
34
Etienne Carriere66685f72020-05-01 10:36:03 +020035/*
36 * Initialize SMT memory buffer, called by platform at init for each
37 * agent channel using the SMT header format.
38 *
39 * @chan: Pointer to the channel shared memory to be initialized
40 */
41void scmi_smt_init_agent_channel(struct scmi_msg_channel *chan);
42
43/*
44 * Process SMT formatted message in a fastcall SMC execution context.
45 * Called by platform on SMC entry. When returning, output message is
46 * available in shared memory for agent to read the response.
47 *
48 * @agent_id: SCMI agent ID the SMT belongs to
49 */
50void scmi_smt_fastcall_smc_entry(unsigned int agent_id);
51
52/*
53 * Process SMT formatted message in a secure interrupt execution context.
54 * Called by platform interrupt handler. When returning, output message is
55 * available in shared memory for agent to read the response.
56 *
57 * @agent_id: SCMI agent ID the SMT belongs to
58 */
59void scmi_smt_interrupt_entry(unsigned int agent_id);
60
Etienne Carriere13b353c2019-11-28 09:13:34 +010061/* Platform callback functions */
62
63/*
64 * Return the SCMI channel related to an agent
65 * @agent_id: SCMI agent ID
66 * Return a pointer to channel on success, NULL otherwise
67 */
68struct scmi_msg_channel *plat_scmi_get_channel(unsigned int agent_id);
69
70/*
71 * Return how many SCMI protocols supported by the platform
72 * According to the SCMI specification, this function does not target
73 * a specific agent ID and shall return all platform known capabilities.
74 */
75size_t plat_scmi_protocol_count(void);
76
77/*
78 * Get the count and list of SCMI protocols (but base) supported for an agent
79 *
80 * @agent_id: SCMI agent ID
81 * Return a pointer to a null terminated array supported protocol IDs.
82 */
83const uint8_t *plat_scmi_protocol_list(unsigned int agent_id);
84
85/* Get the name of the SCMI vendor for the platform */
86const char *plat_scmi_vendor_name(void);
87
88/* Get the name of the SCMI sub-vendor for the platform */
89const char *plat_scmi_sub_vendor_name(void);
90
Etienne Carriere76b3cc62020-05-01 10:32:02 +020091/* Handlers for SCMI Clock protocol services */
92
93/*
94 * Return number of clock controllers for an agent
95 * @agent_id: SCMI agent ID
96 * Return number of clock controllers
97 */
98size_t plat_scmi_clock_count(unsigned int agent_id);
99
100/*
101 * Get clock controller string ID (aka name)
102 * @agent_id: SCMI agent ID
103 * @scmi_id: SCMI clock ID
104 * Return pointer to name or NULL
105 */
106const char *plat_scmi_clock_get_name(unsigned int agent_id,
107 unsigned int scmi_id);
108
109/*
110 * Get clock possible rate as an array of frequencies in Hertz.
111 *
112 * @agent_id: SCMI agent ID
113 * @scmi_id: SCMI clock ID
114 * @rates: If NULL, function returns, else output rates array
115 * @nb_elts: Array size of @rates.
XiaoDong Huang95177e62023-06-26 20:40:43 +0800116 * @start_idx: Start index of rates array
Etienne Carriere76b3cc62020-05-01 10:32:02 +0200117 * Return an SCMI compliant error code
118 */
119int32_t plat_scmi_clock_rates_array(unsigned int agent_id, unsigned int scmi_id,
XiaoDong Huang95177e62023-06-26 20:40:43 +0800120 unsigned long *rates, size_t *nb_elts,
121 uint32_t start_idx);
Etienne Carriere76b3cc62020-05-01 10:32:02 +0200122
123/*
124 * Get clock possible rate as range with regular steps in Hertz
125 *
126 * @agent_id: SCMI agent ID
127 * @scmi_id: SCMI clock ID
128 * @min_max_step: 3 cell array for min, max and step rate data
129 * Return an SCMI compliant error code
130 */
131int32_t plat_scmi_clock_rates_by_step(unsigned int agent_id,
132 unsigned int scmi_id,
133 unsigned long *min_max_step);
134
135/*
136 * Get clock rate in Hertz
137 * @agent_id: SCMI agent ID
138 * @scmi_id: SCMI clock ID
139 * Return clock rate or 0 if not supported
140 */
141unsigned long plat_scmi_clock_get_rate(unsigned int agent_id,
142 unsigned int scmi_id);
143
144/*
145 * Set clock rate in Hertz
146 * @agent_id: SCMI agent ID
147 * @scmi_id: SCMI clock ID
148 * @rate: Target clock frequency in Hertz
149 * Return a compliant SCMI error code
150 */
151int32_t plat_scmi_clock_set_rate(unsigned int agent_id, unsigned int scmi_id,
152 unsigned long rate);
153
154/*
155 * Get clock state (enabled or disabled)
156 * @agent_id: SCMI agent ID
157 * @scmi_id: SCMI clock ID
158 * Return 1 if clock is enabled, 0 if disables, or a negative SCMI error code
159 */
160int32_t plat_scmi_clock_get_state(unsigned int agent_id, unsigned int scmi_id);
161
162/*
163 * Get clock state (enabled or disabled)
164 * @agent_id: SCMI agent ID
165 * @scmi_id: SCMI clock ID
166 * @enable_not_disable: Enable clock if true, disable clock otherwise
167 * Return a compliant SCMI error code
168 */
169int32_t plat_scmi_clock_set_state(unsigned int agent_id, unsigned int scmi_id,
170 bool enable_not_disable);
171
Etienne Carriere02a4ba52020-05-01 10:33:22 +0200172/* Handlers for SCMI Reset Domain protocol services */
173
174/*
175 * Return number of reset domains for the agent
176 * @agent_id: SCMI agent ID
177 * Return number of reset domains
178 */
179size_t plat_scmi_rstd_count(unsigned int agent_id);
180
181/*
182 * Get reset domain string ID (aka name)
183 * @agent_id: SCMI agent ID
184 * @scmi_id: SCMI reset domain ID
185 * Return pointer to name or NULL
186 */
187const char *plat_scmi_rstd_get_name(unsigned int agent_id, unsigned int scmi_id);
188
189/*
190 * Perform a reset cycle on a target reset domain
191 * @agent_id: SCMI agent ID
192 * @scmi_id: SCMI reset domain ID
193 * @state: Target reset state (see SCMI specification, 0 means context loss)
194 * Return a compliant SCMI error code
195 */
196int32_t plat_scmi_rstd_autonomous(unsigned int agent_id, unsigned int scmi_id,
197 unsigned int state);
198
199/*
200 * Assert or deassert target reset domain
201 * @agent_id: SCMI agent ID
202 * @scmi_id: SCMI reset domain ID
203 * @assert_not_deassert: Assert domain if true, otherwise deassert domain
204 * Return a compliant SCMI error code
205 */
206int32_t plat_scmi_rstd_set_state(unsigned int agent_id, unsigned int scmi_id,
207 bool assert_not_deassert);
208
Etienne Carriere13b353c2019-11-28 09:13:34 +0100209#endif /* SCMI_MSG_H */