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,
47 enum scmi_clock_message_id {
48 SCMI_CLOCK_RATE_SET = 0x5,
49 SCMI_CLOCK_RATE_GET = 0x6,
50 SCMI_CLOCK_CONFIG_SET = 0x7,
53 #define SCMI_CLK_RATE_ASYNC_NOTIFY BIT(0)
54 #define SCMI_CLK_RATE_ASYNC_NORESP (BIT(0) | BIT(1))
55 #define SCMI_CLK_RATE_ROUND_DOWN 0
56 #define SCMI_CLK_RATE_ROUND_UP BIT(2)
57 #define SCMI_CLK_RATE_ROUND_CLOSEST BIT(3)
60 * struct scmi_clk_state_in - Message payload for CLOCK_CONFIG_SET command
61 * @clock_id: SCMI clock ID
62 * @attributes: Attributes of the targets clock state
64 struct scmi_clk_state_in {
70 * struct scmi_clk_state_out - Response payload for CLOCK_CONFIG_SET command
71 * @status: SCMI command status
73 struct scmi_clk_state_out {
78 * struct scmi_clk_state_in - Message payload for CLOCK_RATE_GET command
79 * @clock_id: SCMI clock ID
80 * @attributes: Attributes of the targets clock state
82 struct scmi_clk_rate_get_in {
87 * struct scmi_clk_rate_get_out - Response payload for CLOCK_RATE_GET command
88 * @status: SCMI command status
89 * @rate_lsb: 32bit LSB of the clock rate in Hertz
90 * @rate_msb: 32bit MSB of the clock rate in Hertz
92 struct scmi_clk_rate_get_out {
99 * struct scmi_clk_state_in - Message payload for CLOCK_RATE_SET command
100 * @flags: Flags for the clock rate set request
101 * @clock_id: SCMI clock ID
102 * @rate_lsb: 32bit LSB of the clock rate in Hertz
103 * @rate_msb: 32bit MSB of the clock rate in Hertz
105 struct scmi_clk_rate_set_in {
113 * struct scmi_clk_rate_set_out - Response payload for CLOCK_RATE_SET command
114 * @status: SCMI command status
116 struct scmi_clk_rate_set_out {
121 * SCMI Reset Domain Protocol
124 enum scmi_reset_domain_message_id {
125 SCMI_RESET_DOMAIN_ATTRIBUTES = 0x3,
126 SCMI_RESET_DOMAIN_RESET = 0x4,
129 #define SCMI_RD_NAME_LEN 16
131 #define SCMI_RD_ATTRIBUTES_FLAG_ASYNC BIT(31)
132 #define SCMI_RD_ATTRIBUTES_FLAG_NOTIF BIT(30)
134 #define SCMI_RD_RESET_FLAG_ASYNC BIT(2)
135 #define SCMI_RD_RESET_FLAG_ASSERT BIT(1)
136 #define SCMI_RD_RESET_FLAG_CYCLE BIT(0)
139 * struct scmi_rd_attr_in - Payload for RESET_DOMAIN_ATTRIBUTES message
140 * @domain_id: SCMI reset domain ID
142 struct scmi_rd_attr_in {
147 * struct scmi_rd_attr_out - Payload for RESET_DOMAIN_ATTRIBUTES response
148 * @status: SCMI command status
149 * @attributes: Retrieved attributes of the reset domain
150 * @latency: Reset cycle max lantency
151 * @name: Reset domain name
153 struct scmi_rd_attr_out {
157 char name[SCMI_RD_NAME_LEN];
161 * struct scmi_rd_reset_in - Message payload for RESET command
162 * @domain_id: SCMI reset domain ID
163 * @flags: Flags for the reset request
164 * @reset_state: Reset target state
166 struct scmi_rd_reset_in {
173 * struct scmi_rd_reset_out - Response payload for RESET command
174 * @status: SCMI command status
176 struct scmi_rd_reset_out {
181 * SCMI Voltage Domain Protocol
184 enum scmi_voltage_domain_message_id {
185 SCMI_VOLTAGE_DOMAIN_ATTRIBUTES = 0x3,
186 SCMI_VOLTAGE_DOMAIN_CONFIG_SET = 0x5,
187 SCMI_VOLTAGE_DOMAIN_CONFIG_GET = 0x6,
188 SCMI_VOLTAGE_DOMAIN_LEVEL_SET = 0x7,
189 SCMI_VOLTAGE_DOMAIN_LEVEL_GET = 0x8,
192 #define SCMI_VOLTD_NAME_LEN 16
194 #define SCMI_VOLTD_CONFIG_MASK GENMASK(3, 0)
195 #define SCMI_VOLTD_CONFIG_OFF 0
196 #define SCMI_VOLTD_CONFIG_ON 0x7
199 * struct scmi_voltd_attr_in - Payload for VOLTAGE_DOMAIN_ATTRIBUTES message
200 * @domain_id: SCMI voltage domain ID
202 struct scmi_voltd_attr_in {
207 * struct scmi_voltd_attr_out - Payload for VOLTAGE_DOMAIN_ATTRIBUTES response
208 * @status: SCMI command status
209 * @attributes: Retrieved attributes of the voltage domain
210 * @name: Voltage domain name
212 struct scmi_voltd_attr_out {
215 char name[SCMI_VOLTD_NAME_LEN];
219 * struct scmi_voltd_config_set_in - Message payload for VOLTAGE_CONFIG_SET cmd
220 * @domain_id: SCMI voltage domain ID
221 * @config: Configuration data of the voltage domain
223 struct scmi_voltd_config_set_in {
229 * struct scmi_voltd_config_set_out - Response for VOLTAGE_CONFIG_SET command
230 * @status: SCMI command status
232 struct scmi_voltd_config_set_out {
237 * struct scmi_voltd_config_get_in - Message payload for VOLTAGE_CONFIG_GET cmd
238 * @domain_id: SCMI voltage domain ID
240 struct scmi_voltd_config_get_in {
245 * struct scmi_voltd_config_get_out - Response for VOLTAGE_CONFIG_GET command
246 * @status: SCMI command status
247 * @config: Configuration data of the voltage domain
249 struct scmi_voltd_config_get_out {
255 * struct scmi_voltd_level_set_in - Message payload for VOLTAGE_LEVEL_SET cmd
256 * @domain_id: SCMI voltage domain ID
257 * @flags: Parameter flags for configuring target level
258 * @voltage_level: Target voltage level in microvolts (uV)
260 struct scmi_voltd_level_set_in {
267 * struct scmi_voltd_level_set_out - Response for VOLTAGE_LEVEL_SET command
268 * @status: SCMI command status
270 struct scmi_voltd_level_set_out {
275 * struct scmi_voltd_level_get_in - Message payload for VOLTAGE_LEVEL_GET cmd
276 * @domain_id: SCMI voltage domain ID
278 struct scmi_voltd_level_get_in {
283 * struct scmi_voltd_level_get_out - Response for VOLTAGE_LEVEL_GET command
284 * @status: SCMI command status
285 * @voltage_level: Voltage level in microvolts (uV)
287 struct scmi_voltd_level_get_out {
292 #endif /* _SCMI_PROTOCOLS_H */