1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
3 * Copyright (c) 2015-2019, Arm Limited and Contributors. All rights reserved.
4 * Copyright (C) 2019-2020, Linaro Limited
6 #ifndef _SCMI_PROTOCOLS_H
7 #define _SCMI_PROTOCOLS_H
9 #include <linux/bitops.h>
10 #include <asm/types.h>
13 * Subset the SCMI protocols definition
14 * based on SCMI specification v2.0 (DEN0056B)
15 * https://developer.arm.com/docs/den0056/b
18 enum scmi_std_protocol {
19 SCMI_PROTOCOL_ID_BASE = 0x10,
20 SCMI_PROTOCOL_ID_POWER_DOMAIN = 0x11,
21 SCMI_PROTOCOL_ID_SYSTEM = 0x12,
22 SCMI_PROTOCOL_ID_PERF = 0x13,
23 SCMI_PROTOCOL_ID_CLOCK = 0x14,
24 SCMI_PROTOCOL_ID_SENSOR = 0x15,
25 SCMI_PROTOCOL_ID_RESET_DOMAIN = 0x16,
26 SCMI_PROTOCOL_ID_VOLTAGE_DOMAIN = 0x17,
29 enum scmi_status_code {
31 SCMI_NOT_SUPPORTED = -1,
32 SCMI_INVALID_PARAMETERS = -2,
35 SCMI_OUT_OF_RANGE = -5,
37 SCMI_COMMS_ERROR = -7,
38 SCMI_GENERIC_ERROR = -8,
39 SCMI_HARDWARE_ERROR = -9,
40 SCMI_PROTOCOL_ERROR = -10,
46 enum scmi_discovery_id {
47 SCMI_PROTOCOL_VERSION = 0x0,
48 SCMI_PROTOCOL_ATTRIBUTES = 0x1,
49 SCMI_PROTOCOL_MESSAGE_ATTRIBUTES = 0x2,
56 enum scmi_clock_message_id {
57 SCMI_CLOCK_ATTRIBUTES = 0x3,
58 SCMI_CLOCK_RATE_SET = 0x5,
59 SCMI_CLOCK_RATE_GET = 0x6,
60 SCMI_CLOCK_CONFIG_SET = 0x7,
63 #define SCMI_CLK_PROTO_ATTR_COUNT_MASK GENMASK(15, 0)
64 #define SCMI_CLK_RATE_ASYNC_NOTIFY BIT(0)
65 #define SCMI_CLK_RATE_ASYNC_NORESP (BIT(0) | BIT(1))
66 #define SCMI_CLK_RATE_ROUND_DOWN 0
67 #define SCMI_CLK_RATE_ROUND_UP BIT(2)
68 #define SCMI_CLK_RATE_ROUND_CLOSEST BIT(3)
70 #define SCMI_CLOCK_NAME_LENGTH_MAX 16
73 * struct scmi_clk_get_nb_out - Response for SCMI_PROTOCOL_ATTRIBUTES command
74 * @status: SCMI command status
75 * @attributes: Attributes of the clock protocol, mainly number of clocks exposed
77 struct scmi_clk_protocol_attr_out {
83 * struct scmi_clk_attribute_in - Message payload for SCMI_CLOCK_ATTRIBUTES command
84 * @clock_id: SCMI clock ID
86 struct scmi_clk_attribute_in {
91 * struct scmi_clk_get_nb_out - Response payload for SCMI_CLOCK_ATTRIBUTES command
92 * @status: SCMI command status
93 * @attributes: clock attributes
94 * @clock_name: name of the clock
96 struct scmi_clk_attribute_out {
99 char clock_name[SCMI_CLOCK_NAME_LENGTH_MAX];
103 * struct scmi_clk_state_in - Message payload for CLOCK_CONFIG_SET command
104 * @clock_id: SCMI clock ID
105 * @attributes: Attributes of the targets clock state
107 struct scmi_clk_state_in {
113 * struct scmi_clk_state_out - Response payload for CLOCK_CONFIG_SET command
114 * @status: SCMI command status
116 struct scmi_clk_state_out {
121 * struct scmi_clk_state_in - Message payload for CLOCK_RATE_GET command
122 * @clock_id: SCMI clock ID
123 * @attributes: Attributes of the targets clock state
125 struct scmi_clk_rate_get_in {
130 * struct scmi_clk_rate_get_out - Response payload for CLOCK_RATE_GET command
131 * @status: SCMI command status
132 * @rate_lsb: 32bit LSB of the clock rate in Hertz
133 * @rate_msb: 32bit MSB of the clock rate in Hertz
135 struct scmi_clk_rate_get_out {
142 * struct scmi_clk_state_in - Message payload for CLOCK_RATE_SET command
143 * @flags: Flags for the clock rate set request
144 * @clock_id: SCMI clock ID
145 * @rate_lsb: 32bit LSB of the clock rate in Hertz
146 * @rate_msb: 32bit MSB of the clock rate in Hertz
148 struct scmi_clk_rate_set_in {
156 * struct scmi_clk_rate_set_out - Response payload for CLOCK_RATE_SET command
157 * @status: SCMI command status
159 struct scmi_clk_rate_set_out {
164 * SCMI Reset Domain Protocol
167 enum scmi_reset_domain_message_id {
168 SCMI_RESET_DOMAIN_ATTRIBUTES = 0x3,
169 SCMI_RESET_DOMAIN_RESET = 0x4,
172 #define SCMI_RD_NAME_LEN 16
174 #define SCMI_RD_ATTRIBUTES_FLAG_ASYNC BIT(31)
175 #define SCMI_RD_ATTRIBUTES_FLAG_NOTIF BIT(30)
177 #define SCMI_RD_RESET_FLAG_ASYNC BIT(2)
178 #define SCMI_RD_RESET_FLAG_ASSERT BIT(1)
179 #define SCMI_RD_RESET_FLAG_CYCLE BIT(0)
182 * struct scmi_rd_attr_in - Payload for RESET_DOMAIN_ATTRIBUTES message
183 * @domain_id: SCMI reset domain ID
185 struct scmi_rd_attr_in {
190 * struct scmi_rd_attr_out - Payload for RESET_DOMAIN_ATTRIBUTES response
191 * @status: SCMI command status
192 * @attributes: Retrieved attributes of the reset domain
193 * @latency: Reset cycle max lantency
194 * @name: Reset domain name
196 struct scmi_rd_attr_out {
200 char name[SCMI_RD_NAME_LEN];
204 * struct scmi_rd_reset_in - Message payload for RESET command
205 * @domain_id: SCMI reset domain ID
206 * @flags: Flags for the reset request
207 * @reset_state: Reset target state
209 struct scmi_rd_reset_in {
216 * struct scmi_rd_reset_out - Response payload for RESET command
217 * @status: SCMI command status
219 struct scmi_rd_reset_out {
224 * SCMI Voltage Domain Protocol
227 enum scmi_voltage_domain_message_id {
228 SCMI_VOLTAGE_DOMAIN_ATTRIBUTES = 0x3,
229 SCMI_VOLTAGE_DOMAIN_CONFIG_SET = 0x5,
230 SCMI_VOLTAGE_DOMAIN_CONFIG_GET = 0x6,
231 SCMI_VOLTAGE_DOMAIN_LEVEL_SET = 0x7,
232 SCMI_VOLTAGE_DOMAIN_LEVEL_GET = 0x8,
235 #define SCMI_VOLTD_NAME_LEN 16
237 #define SCMI_VOLTD_CONFIG_MASK GENMASK(3, 0)
238 #define SCMI_VOLTD_CONFIG_OFF 0
239 #define SCMI_VOLTD_CONFIG_ON 0x7
242 * struct scmi_voltd_attr_in - Payload for VOLTAGE_DOMAIN_ATTRIBUTES message
243 * @domain_id: SCMI voltage domain ID
245 struct scmi_voltd_attr_in {
250 * struct scmi_voltd_attr_out - Payload for VOLTAGE_DOMAIN_ATTRIBUTES response
251 * @status: SCMI command status
252 * @attributes: Retrieved attributes of the voltage domain
253 * @name: Voltage domain name
255 struct scmi_voltd_attr_out {
258 char name[SCMI_VOLTD_NAME_LEN];
262 * struct scmi_voltd_config_set_in - Message payload for VOLTAGE_CONFIG_SET cmd
263 * @domain_id: SCMI voltage domain ID
264 * @config: Configuration data of the voltage domain
266 struct scmi_voltd_config_set_in {
272 * struct scmi_voltd_config_set_out - Response for VOLTAGE_CONFIG_SET command
273 * @status: SCMI command status
275 struct scmi_voltd_config_set_out {
280 * struct scmi_voltd_config_get_in - Message payload for VOLTAGE_CONFIG_GET cmd
281 * @domain_id: SCMI voltage domain ID
283 struct scmi_voltd_config_get_in {
288 * struct scmi_voltd_config_get_out - Response for VOLTAGE_CONFIG_GET command
289 * @status: SCMI command status
290 * @config: Configuration data of the voltage domain
292 struct scmi_voltd_config_get_out {
298 * struct scmi_voltd_level_set_in - Message payload for VOLTAGE_LEVEL_SET cmd
299 * @domain_id: SCMI voltage domain ID
300 * @flags: Parameter flags for configuring target level
301 * @voltage_level: Target voltage level in microvolts (uV)
303 struct scmi_voltd_level_set_in {
310 * struct scmi_voltd_level_set_out - Response for VOLTAGE_LEVEL_SET command
311 * @status: SCMI command status
313 struct scmi_voltd_level_set_out {
318 * struct scmi_voltd_level_get_in - Message payload for VOLTAGE_LEVEL_GET cmd
319 * @domain_id: SCMI voltage domain ID
321 struct scmi_voltd_level_get_in {
326 * struct scmi_voltd_level_get_out - Response for VOLTAGE_LEVEL_GET command
327 * @status: SCMI command status
328 * @voltage_level: Voltage level in microvolts (uV)
330 struct scmi_voltd_level_get_out {
335 #endif /* _SCMI_PROTOCOLS_H */