]>
Commit | Line | Data |
---|---|---|
4f2494cf GP |
1 | /** @file\r |
2 | \r | |
39b3e14c | 3 | Copyright (c) 2017-2021, Arm Limited. All rights reserved.\r |
4f2494cf | 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 | |
21 | extern EFI_GUID gArmScmiClockProtocolGuid;\r | |
22 | \r | |
23 | // Message Type for clock management protocol.\r | |
24 | typedef enum {\r | |
bd8efb4f PG |
25 | ScmiMessageIdClockAttributes = 0x3,\r |
26 | ScmiMessageIdClockDescribeRates = 0x4,\r | |
27 | ScmiMessageIdClockRateSet = 0x5,\r | |
28 | ScmiMessageIdClockRateGet = 0x6,\r | |
29 | ScmiMessageIdClockConfigSet = 0x7\r | |
4f2494cf GP |
30 | } SCMI_MESSAGE_ID_CLOCK;\r |
31 | \r | |
32 | typedef 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 | |
59 | typedef struct {\r | |
4f2494cf | 60 | UINT64 Min;\r |
4f2494cf GP |
61 | UINT64 Max;\r |
62 | UINT64 Step;\r | |
39b3e14c PG |
63 | } SCMI_CLOCK_RATE_CONTINUOUS;\r |
64 | \r | |
65 | typedef struct {\r | |
66 | UINT64 Rate;\r | |
67 | } SCMI_CLOCK_RATE_DISCRETE;\r | |
68 | \r | |
69 | typedef union {\r | |
70 | SCMI_CLOCK_RATE_CONTINUOUS ContinuousRate;\r | |
71 | SCMI_CLOCK_RATE_DISCRETE DiscreteRate;\r | |
4f2494cf GP |
72 | } SCMI_CLOCK_RATE;\r |
73 | \r | |
74 | #pragma pack()\r | |
75 | \r | |
76 | typedef 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 | |
90 | typedef\r | |
91 | EFI_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 | |
108 | typedef\r | |
109 | EFI_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 | |
128 | typedef\r | |
129 | EFI_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 | |
160 | typedef\r | |
161 | EFI_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 | |
182 | typedef\r | |
183 | EFI_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 | |
200 | typedef\r | |
201 | EFI_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 | |
208 | typedef 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 |