]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPkg/Include/Protocol/ArmScmiClockProtocol.h
ArmPkg: Introduce SCMI protocol
[mirror_edk2.git] / ArmPkg / Include / Protocol / ArmScmiClockProtocol.h
CommitLineData
4f2494cf
GP
1/** @file\r
2\r
3 Copyright (c) 2017-2018, Arm Limited. All rights reserved.\r
4\r
5 This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13 System Control and Management Interface V1.0\r
14 http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/\r
15 DEN0056A_System_Control_and_Management_Interface.pdf\r
16**/\r
17\r
18#ifndef ARM_SCMI_CLOCK_PROTOCOL_H_\r
19#define ARM_SCMI_CLOCK_PROTOCOL_H_\r
20\r
21#include <Protocol/ArmScmi.h>\r
22\r
23#define ARM_SCMI_CLOCK_PROTOCOL_GUID { \\r
24 0x91ce67a8, 0xe0aa, 0x4012, {0xb9, 0x9f, 0xb6, 0xfc, 0xf3, 0x4, 0x8e, 0xaa} \\r
25 }\r
26\r
27extern EFI_GUID gArmScmiClockProtocolGuid;\r
28\r
29// Message Type for clock management protocol.\r
30typedef enum {\r
31 SCMI_MESSAGE_ID_CLOCK_ATTRIBUTES = 0x3,\r
32 SCMI_MESSAGE_ID_CLOCK_DESCRIBE_RATES = 0x4,\r
33 SCMI_MESSAGE_ID_CLOCK_RATE_SET = 0x5,\r
34 SCMI_MESSAGE_ID_CLOCK_RATE_GET = 0x6,\r
35 SCMI_MESSAGE_ID_CLOCK_CONFIG_SET = 0x7\r
36} SCMI_MESSAGE_ID_CLOCK;\r
37\r
38typedef enum {\r
39 SCMI_CLOCK_RATE_FORMAT_DISCRETE, // Non-linear range.\r
40 SCMI_CLOCK_RATE_FORMAT_LINEAR // Linear range.\r
41} SCMI_CLOCK_RATE_FORMAT;\r
42\r
43// Clock management protocol version.\r
44#define SCMI_CLOCK_PROTOCOL_VERSION 0x10000\r
45\r
46#define SCMI_CLOCK_PROTOCOL_PENDING_ASYNC_RATES_MASK 0xFFU\r
47#define SCMI_CLOCK_PROTOCOL_PENDING_ASYNC_RATES_SHIFT 16\r
48#define SCMI_CLOCK_PROTOCOL_NUM_CLOCKS_MASK 0xFFFFU\r
49\r
50/** Total number of pending asynchronous clock rates changes\r
51 supported by the SCP, Attr Bits[23:16]\r
52*/\r
53#define SCMI_CLOCK_PROTOCOL_MAX_ASYNC_CLK_RATES(Attr) ( \\r
54 (Attr >> SCMI_CLOCK_PROTOCOL_PENDING_ASYNC_RATES_SHIFT) && \\r
55 SCMI_CLOCK_PROTOCOL_PENDING_ASYNC_RATES_MASK)\r
56\r
57// Total of clock devices supported by the SCP, Attr Bits[15:0]\r
58#define SCMI_CLOCK_PROTOCOL_TOTAL_CLKS(Attr) (Attr & SCMI_CLOCK_PROTOCOL_NUM_CLOCKS_MASK)\r
59\r
60#pragma pack(1)\r
61\r
62/* Depending on the format (linear/non-linear) supported by a clock device\r
63 either Rate or Min/Max/Step triplet is valid.\r
64*/\r
65typedef struct {\r
66 union {\r
67 UINT64 Min;\r
68 UINT64 Rate;\r
69 };\r
70 UINT64 Max;\r
71 UINT64 Step;\r
72} SCMI_CLOCK_RATE;\r
73\r
74#pragma pack()\r
75\r
76typedef struct _SCMI_CLOCK_PROTOCOL SCMI_CLOCK_PROTOCOL;\r
77\r
78// Protocol Interface functions.\r
79\r
80/** Return version of the clock management protocol supported by SCP firmware.\r
81\r
82 @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.\r
83\r
84 @param[out] Version Version of the supported SCMI Clock management protocol.\r
85\r
86 @retval EFI_SUCCESS The version is returned.\r
87 @retval EFI_DEVICE_ERROR SCP returns an SCMI error.\r
88 @retval !(EFI_SUCCESS) Other errors.\r
89**/\r
90typedef\r
91EFI_STATUS\r
92(EFIAPI *SCMI_CLOCK_GET_VERSION) (\r
93 IN SCMI_CLOCK_PROTOCOL *This,\r
94 OUT UINT32 *Version\r
95 );\r
96\r
97/** Return total number of clock devices supported by the clock management\r
98 protocol.\r
99\r
100 @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.\r
101\r
102 @param[out] TotalClocks Total number of clocks supported.\r
103\r
104 @retval EFI_SUCCESS Total number of clocks supported is returned.\r
105 @retval EFI_DEVICE_ERROR SCP returns an SCMI error.\r
106 @retval !(EFI_SUCCESS) Other errors.\r
107**/\r
108typedef\r
109EFI_STATUS\r
110(EFIAPI *SCMI_CLOCK_GET_TOTAL_CLOCKS) (\r
111 IN SCMI_CLOCK_PROTOCOL *This,\r
112 OUT UINT32 *TotalClocks\r
113 );\r
114\r
115/** Return attributes of a clock device.\r
116\r
117 @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.\r
118 @param[in] ClockId Identifier for the clock device.\r
119\r
120 @param[out] Enabled If TRUE, the clock device is enabled.\r
121 @param[out] ClockAsciiName A NULL terminated ASCII string with the clock\r
122 name, of up to 16 bytes.\r
123\r
124 @retval EFI_SUCCESS Clock device attributes are returned.\r
125 @retval EFI_DEVICE_ERROR SCP returns an SCMI error.\r
126 @retval !(EFI_SUCCESS) Other errors.\r
127**/\r
128typedef\r
129EFI_STATUS\r
130(EFIAPI *SCMI_CLOCK_GET_CLOCK_ATTRIBUTES) (\r
131 IN SCMI_CLOCK_PROTOCOL *This,\r
132 IN UINT32 ClockId,\r
133 OUT BOOLEAN *Enabled,\r
134 OUT CHAR8 *ClockAsciiName\r
135 );\r
136\r
137/** Return list of rates supported by a given clock device.\r
138\r
139 @param[in] This A pointer to SCMI_CLOCK_PROTOCOL Instance.\r
140 @param[in] ClockId Identifier for the clock device.\r
141\r
142 @param[out] Format SCMI_CLOCK_RATE_FORMAT_DISCRETE: Clock device\r
143 supports range of clock rates which are non-linear.\r
144\r
145 SCMI_CLOCK_RATE_FORMAT_LINEAR: Clock device supports\r
146 range of linear clock rates from Min to Max in steps.\r
147\r
148 @param[out] TotalRates Total number of rates.\r
149\r
150 @param[in,out] RateArraySize Size of the RateArray.\r
151\r
152 @param[out] RateArray List of clock rates.\r
153\r
154 @retval EFI_SUCCESS List of clock rates are returned.\r
155 @retval EFI_DEVICE_ERROR SCP returns an SCMI error.\r
156 @retval EFI_BUFFER_TOO_SMALL RateArraySize is too small for the result.\r
157 It has been updated to the size needed.\r
158 @retval !(EFI_SUCCESS) Other errors.\r
159**/\r
160typedef\r
161EFI_STATUS\r
162(EFIAPI *SCMI_CLOCK_DESCRIBE_RATES) (\r
163 IN SCMI_CLOCK_PROTOCOL *This,\r
164 IN UINT32 ClockId,\r
165 OUT SCMI_CLOCK_RATE_FORMAT *Format,\r
166 OUT UINT32 *TotalRates,\r
167 IN OUT UINT32 *RateArraySize,\r
168 OUT SCMI_CLOCK_RATE *RateArray\r
169 );\r
170\r
171/** Get clock rate.\r
172\r
173 @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.\r
174 @param[in] ClockId Identifier for the clock device.\r
175\r
176 @param[out] Rate Clock rate.\r
177\r
178 @retval EFI_SUCCESS Clock rate is returned.\r
179 @retval EFI_DEVICE_ERROR SCP returns an SCMI error.\r
180 @retval !(EFI_SUCCESS) Other errors.\r
181**/\r
182typedef\r
183EFI_STATUS\r
184(EFIAPI *SCMI_CLOCK_RATE_GET) (\r
185 IN SCMI_CLOCK_PROTOCOL *This,\r
186 IN UINT32 ClockId,\r
187 OUT UINT64 *Rate\r
188 );\r
189\r
190/** Set clock rate.\r
191\r
192 @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.\r
193 @param[in] ClockId Identifier for the clock device.\r
194 @param[in] Rate Clock rate.\r
195\r
196 @retval EFI_SUCCESS Clock rate set success.\r
197 @retval EFI_DEVICE_ERROR SCP returns an SCMI error.\r
198 @retval !(EFI_SUCCESS) Other errors.\r
199**/\r
200typedef\r
201EFI_STATUS\r
202(EFIAPI *SCMI_CLOCK_RATE_SET) (\r
203 IN SCMI_CLOCK_PROTOCOL *This,\r
204 IN UINT32 ClockId,\r
205 IN UINT64 Rate\r
206 );\r
207\r
208typedef struct _SCMI_CLOCK_PROTOCOL {\r
209 SCMI_CLOCK_GET_VERSION GetVersion;\r
210 SCMI_CLOCK_GET_TOTAL_CLOCKS GetTotalClocks;\r
211 SCMI_CLOCK_GET_CLOCK_ATTRIBUTES GetClockAttributes;\r
212 SCMI_CLOCK_DESCRIBE_RATES DescribeRates;\r
213 SCMI_CLOCK_RATE_GET RateGet;\r
214 SCMI_CLOCK_RATE_SET RateSet;\r
215} SCMI_CLOCK_PROTOCOL;\r
216\r
217#endif /* ARM_SCMI_CLOCK_PROTOCOL_H_ */\r
218\r