]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Include/Protocol/ArmScmiPerformanceProtocol.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / ArmPkg / Include / Protocol / ArmScmiPerformanceProtocol.h
1 /** @file
2
3 Copyright (c) 2017-2018, Arm Limited. All rights reserved.
4
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 System Control and Management Interface V1.0
8 http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/
9 DEN0056A_System_Control_and_Management_Interface.pdf
10 **/
11
12 #ifndef ARM_SCMI_PERFORMANCE_PROTOCOL_H_
13 #define ARM_SCMI_PERFORMANCE_PROTOCOL_H_
14
15 #include <Protocol/ArmScmi.h>
16
17 #define PERFORMANCE_PROTOCOL_VERSION 0x10000
18
19 #define ARM_SCMI_PERFORMANCE_PROTOCOL_GUID { \
20 0x9b8ba84, 0x3dd3, 0x49a6, {0xa0, 0x5a, 0x31, 0x34, 0xa5, 0xf0, 0x7b, 0xad} \
21 }
22
23 extern EFI_GUID gArmScmiPerformanceProtocolGuid;
24
25 typedef struct _SCMI_PERFORMANCE_PROTOCOL SCMI_PERFORMANCE_PROTOCOL;
26
27 #pragma pack(1)
28
29 #define POWER_IN_MW_SHIFT 16
30 #define POWER_IN_MW_MASK 0x1
31 #define NUM_PERF_DOMAINS_MASK 0xFFFF
32
33 // Total number of performance domains, Attr Bits [15:0]
34 #define SCMI_PERF_TOTAL_DOMAINS(Attr) (Attr & NUM_PERF_DOMAINS_MASK)
35
36 // A flag to express power values in mW or platform specific way, Attr Bit [16]
37 #define SCMI_PERF_POWER_IN_MW(Attr) ((Attr >> POWER_IN_MW_SHIFT) & \
38 POWER_IN_MW_MASK)
39
40 // Performance protocol attributes return values.
41 typedef struct {
42 UINT32 Attributes;
43 UINT64 StatisticsAddress;
44 UINT32 StatisticsLen;
45 } SCMI_PERFORMANCE_PROTOCOL_ATTRIBUTES;
46
47 #define SCMI_PERF_SUPPORT_LVL_CHANGE_NOTIFY(Attr) ((Attr >> 28) & 0x1)
48 #define SCMI_PERF_SUPPORT_LIM_CHANGE_NOTIFY(Attr) ((Attr >> 29) & 0x1)
49 #define SCMI_PERF_SUPPORT_SET_LVL(Attr) ((Attr >> 30) & 0x1)
50 #define SCMI_PERF_SUPPORT_SET_LIM(Attr) ((Attr >> 31) & 0x1)
51 #define SCMI_PERF_RATE_LIMIT(RateLimit) (RateLimit & 0xFFF)
52
53 // Performance protocol domain attributes.
54 typedef struct {
55 UINT32 Attributes;
56 UINT32 RateLimit;
57 UINT32 SustainedFreq;
58 UINT32 SustainedPerfLevel;
59 UINT8 Name[SCMI_MAX_STR_LEN];
60 } SCMI_PERFORMANCE_DOMAIN_ATTRIBUTES;
61
62 // Worst case latency in microseconds, Bits[15:0]
63 #define PERF_LATENCY_MASK 0xFFFF
64 #define SCMI_PERFORMANCE_PROTOCOL_LATENCY(Latency) (Latency & PERF_LATENCY_MASK)
65
66 // Performance protocol performance level.
67 typedef struct {
68 UINT32 Level;
69 UINT32 PowerCost;
70 UINT32 Latency;
71 } SCMI_PERFORMANCE_LEVEL;
72
73 // Performance protocol performance limit.
74 typedef struct {
75 UINT32 RangeMax;
76 UINT32 RangeMin;
77 } SCMI_PERFORMANCE_LIMITS;
78
79 #pragma pack()
80
81 /** Return version of the performance management protocol supported by SCP.
82 firmware.
83
84 @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
85
86 @param[out] Version Version of the supported SCMI performance management
87 protocol.
88
89 @retval EFI_SUCCESS The version is returned.
90 @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
91 @retval !(EFI_SUCCESS) Other errors.
92 **/
93 typedef
94 EFI_STATUS
95 (EFIAPI *SCMI_PERFORMANCE_GET_VERSION) (
96 IN SCMI_PERFORMANCE_PROTOCOL *This,
97 OUT UINT32 *Version
98 );
99
100 /** Return protocol attributes of the performance management protocol.
101
102 @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
103
104 @param[out] Attributes Protocol attributes.
105
106 @retval EFI_SUCCESS Protocol attributes are returned.
107 @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
108 @retval !(EFI_SUCCESS) Other errors.
109 **/
110 typedef
111 EFI_STATUS
112 (EFIAPI *SCMI_PERFORMANCE_GET_ATTRIBUTES) (
113 IN SCMI_PERFORMANCE_PROTOCOL *This,
114 OUT SCMI_PERFORMANCE_PROTOCOL_ATTRIBUTES *Attributes
115
116 );
117
118 /** Return performance domain attributes.
119
120 @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
121 @param[in] DomainId Identifier for the performance domain.
122
123 @param[out] Attributes Performance domain attributes.
124
125 @retval EFI_SUCCESS Domain attributes are returned.
126 @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
127 @retval !(EFI_SUCCESS) Other errors.
128 **/
129 typedef
130 EFI_STATUS
131 (EFIAPI *SCMI_PERFORMANCE_GET_DOMAIN_ATTRIBUTES) (
132 IN SCMI_PERFORMANCE_PROTOCOL *This,
133 IN UINT32 DomainId,
134 OUT SCMI_PERFORMANCE_DOMAIN_ATTRIBUTES *DomainAttributes
135 );
136
137 /** Return list of performance domain levels of a given domain.
138
139 @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
140 @param[in] DomainId Identifier for the performance domain.
141
142 @param[out] NumLevels Total number of levels a domain can support.
143
144 @param[in,out] LevelArraySize Size of the performance level array.
145
146 @param[out] LevelArray Array of the performance levels.
147
148 @retval EFI_SUCCESS Domain levels are returned.
149 @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
150 @retval EFI_BUFFER_TOO_SMALL LevelArraySize is too small for the result.
151 It has been updated to the size needed.
152 @retval !(EFI_SUCCESS) Other errors.
153 **/
154 typedef
155 EFI_STATUS
156 (EFIAPI *SCMI_PERFORMANCE_DESCRIBE_LEVELS) (
157 IN SCMI_PERFORMANCE_PROTOCOL *This,
158 IN UINT32 DomainId,
159 OUT UINT32 *NumLevels,
160 IN OUT UINT32 *LevelArraySize,
161 OUT SCMI_PERFORMANCE_LEVEL *LevelArray
162 );
163
164 /** Set performance limits of a domain.
165
166 @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
167 @param[in] DomainId Identifier for the performance domain.
168 @param[in] Limit Performance limit to set.
169
170 @retval EFI_SUCCESS Performance limits set successfully.
171 @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
172 @retval !(EFI_SUCCESS) Other errors.
173 **/
174 typedef
175 EFI_STATUS
176 (EFIAPI *SCMI_PERFORMANCE_LIMITS_SET) (
177 IN SCMI_PERFORMANCE_PROTOCOL *This,
178 IN UINT32 DomainId,
179 IN SCMI_PERFORMANCE_LIMITS *Limits
180 );
181
182 /** Get performance limits of a domain.
183
184 @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
185 @param[in] DomainId Identifier for the performance domain.
186
187 @param[out] Limit Performance Limits of the domain.
188
189 @retval EFI_SUCCESS Performance limits are returned.
190 @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
191 @retval !(EFI_SUCCESS) Other errors.
192 **/
193 typedef
194 EFI_STATUS
195 (EFIAPI *SCMI_PERFORMANCE_LIMITS_GET) (
196 SCMI_PERFORMANCE_PROTOCOL *This,
197 UINT32 DomainId,
198 SCMI_PERFORMANCE_LIMITS *Limits
199 );
200
201 /** Set performance level of a domain.
202
203 @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
204 @param[in] DomainId Identifier for the performance domain.
205 @param[in] Level Performance level of the domain.
206
207 @retval EFI_SUCCESS Performance level set successfully.
208 @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
209 @retval !(EFI_SUCCESS) Other errors.
210 **/
211 typedef
212 EFI_STATUS
213 (EFIAPI *SCMI_PERFORMANCE_LEVEL_SET) (
214 IN SCMI_PERFORMANCE_PROTOCOL *This,
215 IN UINT32 DomainId,
216 IN UINT32 Level
217 );
218
219 /** Get performance level of a domain.
220
221 @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
222 @param[in] DomainId Identifier for the performance domain.
223
224 @param[out] Level Performance level of the domain.
225
226 @retval EFI_SUCCESS Performance level got successfully.
227 @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
228 @retval !(EFI_SUCCESS) Other errors.
229 **/
230 typedef
231 EFI_STATUS
232 (EFIAPI *SCMI_PERFORMANCE_LEVEL_GET) (
233 IN SCMI_PERFORMANCE_PROTOCOL *This,
234 IN UINT32 DomainId,
235 OUT UINT32 *Level
236 );
237
238 typedef struct _SCMI_PERFORMANCE_PROTOCOL {
239 SCMI_PERFORMANCE_GET_VERSION GetVersion;
240 SCMI_PERFORMANCE_GET_ATTRIBUTES GetProtocolAttributes;
241 SCMI_PERFORMANCE_GET_DOMAIN_ATTRIBUTES GetDomainAttributes;
242 SCMI_PERFORMANCE_DESCRIBE_LEVELS DescribeLevels;
243 SCMI_PERFORMANCE_LIMITS_SET LimitsSet;
244 SCMI_PERFORMANCE_LIMITS_GET LimitsGet;
245 SCMI_PERFORMANCE_LEVEL_SET LevelSet;
246 SCMI_PERFORMANCE_LEVEL_GET LevelGet;
247 } SCMI_PERFORMANCE_PROTOCOL;
248
249 typedef enum {
250 SCMI_MESSAGE_ID_PERFORMANCE_DOMAIN_ATTRIBUTES = 0x3,
251 SCMI_MESSAGE_ID_PERFORMANCE_DESCRIBE_LEVELS = 0x4,
252 SCMI_MESSAGE_ID_PERFORMANCE_LIMITS_SET = 0x5,
253 SCMI_MESSAGE_ID_PERFORMANCE_LIMITS_GET = 0x6,
254 SCMI_MESSAGE_ID_PERFORMANCE_LEVEL_SET = 0x7,
255 SCMI_MESSAGE_ID_PERFORMANCE_LEVEL_GET = 0x8,
256 } SCMI_MESSAGE_ID_PERFORMANCE;
257
258 #endif /* ARM_SCMI_PERFORMANCE_PROTOCOL_H_ */
259