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