1 /*
2  * Arm SCP/MCP Software
3  * Copyright (c) 2020-2024, Arm Limited and Contributors. All rights reserved.
4  *
5  * SPDX-License-Identifier: BSD-3-Clause
6  *
7  * Description:
8  *     System Control and Management Interface (SCMI) support.
9  */
10 
11 #ifndef MOD_SCMI_STD_H
12 #define MOD_SCMI_STD_H
13 
14 /*!
15  * \addtogroup GroupModules Modules
16  * \{
17  */
18 
19 /*!
20  * \defgroup GroupSCMI System Control & Management Interface (SCMI)
21  * \{
22  */
23 
24 /*!
25  * \brief SCMI identifier of the platform.
26  */
27 #define MOD_SCMI_PLATFORM_ID 0
28 
29 /*!
30  * \brief Maximum value for an agent identifier. The limit is derived from the
31  *      the base protocol's "PROTOCOL_ATTRIBUTES" command. This command returns
32  *      a 32-bits "attributes" value which, in turn, contains an 8-bit field
33  *      giving the number of agents in the system.
34  */
35 #define MOD_SCMI_AGENT_ID_MAX 0xFF
36 
37 /*! Maximum value of an SCMI protocol identifier */
38 #define MOD_SCMI_PROTOCOL_ID_MAX 0xFF
39 
40 /*! Minimum Protocol ID reserved for vendor or platform-specific extensions */
41 #define MOD_SCMI_PLATFORM_PROTOCOL_ID_MIN 0x80
42 /*! Maximum Protocol ID reserved for vendor or platform-specific extensions */
43 #define MOD_SCMI_PLATFORM_PROTOCOL_ID_MAX MOD_SCMI_PROTOCOL_ID_MAX
44 
45 /*!
46  * \brief SCMI error codes.
47  */
48 enum scmi_error {
49     SCMI_SUCCESS = 0,
50     SCMI_NOT_SUPPORTED = -1,
51     SCMI_INVALID_PARAMETERS = -2,
52     SCMI_DENIED = -3,
53     SCMI_NOT_FOUND = -4,
54     SCMI_OUT_OF_RANGE = -5,
55     SCMI_BUSY = -6,
56     SCMI_COMMS_ERROR = -7,
57     SCMI_GENERIC_ERROR = -8,
58     SCMI_HARDWARE_ERROR = -9,
59     SCMI_PROTOCOL_ERROR = -10,
60 };
61 
62 /*!
63  * \brief Common command identifiers.
64  */
65 enum scmi_command_id {
66     MOD_SCMI_PROTOCOL_VERSION = 0x000,
67     MOD_SCMI_PROTOCOL_ATTRIBUTES = 0x001,
68     MOD_SCMI_PROTOCOL_MESSAGE_ATTRIBUTES = 0x002
69 };
70 
71 /*!
72  * \brief SCMI message attribute index number.
73  */
74 #define MOD_SCMI_MESSAGE_ID_ATTRIBUTE UINT32_C(0x03)
75 
76 /*!
77  * \brief Definitions of the SCMI Protocol Identifiers and the command
78  *      identifiers for each protocol.
79  */
80 
81 /*!
82  * \brief SCMI Base Protocol
83  */
84 #define MOD_SCMI_PROTOCOL_ID_BASE UINT32_C(0x10)
85 
86 /*!
87  * \brief SCMI Base Protocol Message IDs
88  */
89 enum scmi_base_command_id {
90     MOD_SCMI_BASE_DISCOVER_VENDOR = 0x003,
91     MOD_SCMI_BASE_DISCOVER_SUB_VENDOR = 0x004,
92     MOD_SCMI_BASE_DISCOVER_IMPLEMENTATION_VERSION = 0x005,
93     MOD_SCMI_BASE_DISCOVER_LIST_PROTOCOLS = 0x006,
94     MOD_SCMI_BASE_DISCOVER_AGENT = 0x007,
95     MOD_SCMI_BASE_NOTIFY_ERRORS = 0x008,
96     MOD_SCMI_BASE_SET_DEVICE_PERMISSIONS = 0x009,
97     MOD_SCMI_BASE_SET_PROTOCOL_PERMISSIONS = 0x00A,
98     MOD_SCMI_BASE_RESET_AGENT_CONFIG = 0x00B,
99     MOD_SCMI_BASE_COMMAND_COUNT,
100 };
101 
102 /*!
103  * \brief SCMI Power Domain Protocol
104  */
105 #define MOD_SCMI_PROTOCOL_ID_POWER_DOMAIN UINT32_C(0x11)
106 
107 /*!
108  * \brief SCMI Power Domain Protocol Message IDs
109  */
110 enum scmi_pd_command_id {
111     MOD_SCMI_PD_POWER_DOMAIN_ATTRIBUTES = 0x03,
112     MOD_SCMI_PD_POWER_STATE_SET = 0x04,
113     MOD_SCMI_PD_POWER_STATE_GET = 0x05,
114     MOD_SCMI_PD_POWER_STATE_NOTIFY = 0x06,
115     MOD_SCMI_PD_POWER_STATE_CHANGE_REQUESTED_NOTIFY = 0x07,
116     MOD_SCMI_PD_POWER_COMMAND_COUNT,
117 };
118 
119 /*!
120  * \brief SCMI System Power Protocol
121  */
122 #define MOD_SCMI_PROTOCOL_ID_SYS_POWER UINT32_C(0x12)
123 
124 /*!
125  * \brief SCMI System Power Protocol Message IDs
126  */
127 enum scmi_sys_power_command_id {
128     MOD_SCMI_SYS_POWER_STATE_SET = 0x003,
129     MOD_SCMI_SYS_POWER_STATE_GET = 0x004,
130     MOD_SCMI_SYS_POWER_STATE_NOTIFY = 0x005,
131     MOD_SCMI_SYS_POWER_COMMAND_COUNT,
132 };
133 
134 /*!
135  * \brief SCMI Performance Protocol
136  */
137 #define MOD_SCMI_PROTOCOL_ID_PERF UINT32_C(0x13)
138 
139 /*!
140  * \brief SCMI Performance Protocol Message IDs
141  */
142 enum scmi_perf_command_id {
143     MOD_SCMI_PERF_DOMAIN_ATTRIBUTES = 0x003,
144     MOD_SCMI_PERF_DESCRIBE_LEVELS = 0x004,
145     MOD_SCMI_PERF_LIMITS_SET = 0x005,
146     MOD_SCMI_PERF_LIMITS_GET = 0x006,
147     MOD_SCMI_PERF_LEVEL_SET = 0x007,
148     MOD_SCMI_PERF_LEVEL_GET = 0x008,
149     MOD_SCMI_PERF_NOTIFY_LIMITS = 0x009,
150     MOD_SCMI_PERF_NOTIFY_LEVEL = 0x00A,
151     MOD_SCMI_PERF_DESCRIBE_FAST_CHANNEL = 0x00B,
152     MOD_SCMI_PERF_COMMAND_COUNT,
153 };
154 
155 /*!
156  * \brief SCMI Clock Protocol
157  */
158 #define MOD_SCMI_PROTOCOL_ID_CLOCK UINT32_C(0x14)
159 
160 /*!
161  * \brief SCMI Clock Protocol Message IDs
162  */
163 enum scmi_clock_command_id {
164     MOD_SCMI_CLOCK_ATTRIBUTES = 0x003,
165     MOD_SCMI_CLOCK_DESCRIBE_RATES = 0x004,
166     MOD_SCMI_CLOCK_RATE_SET = 0x005,
167     MOD_SCMI_CLOCK_RATE_GET = 0x006,
168     MOD_SCMI_CLOCK_CONFIG_SET = 0x007,
169     MOD_SCMI_CLOCK_COMMAND_COUNT,
170 };
171 
172 /*!
173  * \brief SCMI Sensor Protocol
174  */
175 #define MOD_SCMI_PROTOCOL_ID_SENSOR UINT32_C(0x15)
176 
177 /*!
178  * \brief SCMI Sensor Protocol Message IDs
179  */
180 enum scmi_sensor_command_id {
181     MOD_SCMI_SENSOR_DESCRIPTION_GET = 0x003,
182     MOD_SCMI_SENSOR_TRIP_POINT_NOTIFY = 0x004,
183     MOD_SCMI_SENSOR_TRIP_POINT_CONFIG = 0x005,
184     MOD_SCMI_SENSOR_READING_GET = 0x006,
185 #ifdef BUILD_HAS_SCMI_SENSOR_V2
186     MOD_SCMI_SENSOR_AXIS_DESCRIPTION_GET = 0x007,
187 #endif
188     MOD_SCMI_SENSOR_COMMAND_COUNT,
189 };
190 
191 /*!
192  * \brief SCMI Reset Domain Protocol
193  */
194 #define MOD_SCMI_PROTOCOL_ID_RESET_DOMAIN UINT32_C(0x16)
195 
196 /*!
197  * \brief SCMI Reset Domain Management Protocol Message IDs
198  */
199 enum scmi_reset_domain_command_id {
200     MOD_SCMI_RESET_DOMAIN_ATTRIBUTES = 0x03,
201     MOD_SCMI_RESET_REQUEST = 0x04,
202     MOD_SCMI_RESET_NOTIFY = 0x05,
203     MOD_SCMI_RESET_COMMAND_COUNT,
204 };
205 
206 /*!
207  * \brief SCMI Reset Domain Management Protocol Response IDs.
208  */
209 enum scmi_reset_domain_response_id {
210     MOD_SCMI_RESET_ISSUED = 0x00,
211     MOD_SCMI_RESET_COMPLETE = 0x04,
212 };
213 
214 /*!
215  * \brief SCMI Voltage Domain Protocol
216  */
217 #define MOD_SCMI_PROTOCOL_ID_VOLTAGE_DOMAIN UINT32_C(0x17)
218 
219 /*!
220  * \brief SCMI Voltage Domain Protocol Message IDs
221  */
222 enum scmi_voltd_command_id {
223     MOD_SCMI_VOLTD_DOMAIN_ATTRIBUTES = 0x003,
224     MOD_SCMI_VOLTD_DESCRIBE_LEVELS = 0x004,
225     MOD_SCMI_VOLTD_CONFIG_SET = 0x005,
226     MOD_SCMI_VOLTD_CONFIG_GET = 0x006,
227     MOD_SCMI_VOLTD_LEVEL_SET = 0x007,
228     MOD_SCMI_VOLTD_LEVEL_GET = 0x008,
229     MOD_SCMI_VOLTD_COMMAND_COUNT,
230 };
231 
232 /*!
233  * \brief SCMI power capping and monitoring protocol
234  */
235 #define MOD_SCMI_PROTOCOL_ID_POWER_CAPPING UINT32_C(0x18)
236 
237 /*!
238  * \brief SCMI power capping and monitoring protocol message IDs
239  */
240 enum scmi_power_capping_command_id {
241     MOD_SCMI_POWER_CAPPING_DOMAIN_ATTRIBUTES = 0x003,
242     MOD_SCMI_POWER_CAPPING_CAP_GET = 0x004,
243     MOD_SCMI_POWER_CAPPING_CAP_SET = 0x005,
244     MOD_SCMI_POWER_CAPPING_PAI_GET = 0x006,
245     MOD_SCMI_POWER_CAPPING_PAI_SET = 0x007,
246     MOD_SCMI_POWER_CAPPING_DOMAIN_NAME_GET = 0x008,
247     MOD_SCMI_POWER_CAPPING_MEASUREMENTS_GET = 0x009,
248     MOD_SCMI_POWER_CAPPING_CAP_NOTIFY = 0x00A,
249     MOD_SCMI_POWER_CAPPING_MEASUREMENTS_NOTIFY = 0x00B,
250     MOD_SCMI_POWER_CAPPING_DESCRIBE_FAST_CHANNEL = 0x00C,
251     MOD_SCMI_POWER_CAPPING_COMMAND_COUNT,
252 };
253 
254 /*!
255  * \}
256  */
257 
258 /*!
259  * \}
260  */
261 
262 #endif /* MOD_SCMI_STD_H */
263