3 Copyright (c) 2017-2018, Arm Limited. All rights reserved.
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 System Control and Management Interface V1.0
14 http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/
15 DEN0056A_System_Control_and_Management_Interface.pdf
18 #ifndef ARM_SCMI_CLOCK_PROTOCOL_H_
19 #define ARM_SCMI_CLOCK_PROTOCOL_H_
21 #include <Protocol/ArmScmi.h>
23 #define ARM_SCMI_CLOCK_PROTOCOL_GUID { \
24 0x91ce67a8, 0xe0aa, 0x4012, {0xb9, 0x9f, 0xb6, 0xfc, 0xf3, 0x4, 0x8e, 0xaa} \
27 extern EFI_GUID gArmScmiClockProtocolGuid
;
29 // Message Type for clock management protocol.
31 SCMI_MESSAGE_ID_CLOCK_ATTRIBUTES
= 0x3,
32 SCMI_MESSAGE_ID_CLOCK_DESCRIBE_RATES
= 0x4,
33 SCMI_MESSAGE_ID_CLOCK_RATE_SET
= 0x5,
34 SCMI_MESSAGE_ID_CLOCK_RATE_GET
= 0x6,
35 SCMI_MESSAGE_ID_CLOCK_CONFIG_SET
= 0x7
36 } SCMI_MESSAGE_ID_CLOCK
;
39 SCMI_CLOCK_RATE_FORMAT_DISCRETE
, // Non-linear range.
40 SCMI_CLOCK_RATE_FORMAT_LINEAR
// Linear range.
41 } SCMI_CLOCK_RATE_FORMAT
;
43 // Clock management protocol version.
44 #define SCMI_CLOCK_PROTOCOL_VERSION 0x10000
46 #define SCMI_CLOCK_PROTOCOL_PENDING_ASYNC_RATES_MASK 0xFFU
47 #define SCMI_CLOCK_PROTOCOL_PENDING_ASYNC_RATES_SHIFT 16
48 #define SCMI_CLOCK_PROTOCOL_NUM_CLOCKS_MASK 0xFFFFU
50 /** Total number of pending asynchronous clock rates changes
51 supported by the SCP, Attr Bits[23:16]
53 #define SCMI_CLOCK_PROTOCOL_MAX_ASYNC_CLK_RATES(Attr) ( \
54 (Attr >> SCMI_CLOCK_PROTOCOL_PENDING_ASYNC_RATES_SHIFT) && \
55 SCMI_CLOCK_PROTOCOL_PENDING_ASYNC_RATES_MASK)
57 // Total of clock devices supported by the SCP, Attr Bits[15:0]
58 #define SCMI_CLOCK_PROTOCOL_TOTAL_CLKS(Attr) (Attr & SCMI_CLOCK_PROTOCOL_NUM_CLOCKS_MASK)
62 /* Depending on the format (linear/non-linear) supported by a clock device
63 either Rate or Min/Max/Step triplet is valid.
76 typedef struct _SCMI_CLOCK_PROTOCOL SCMI_CLOCK_PROTOCOL
;
78 // Protocol Interface functions.
80 /** Return version of the clock management protocol supported by SCP firmware.
82 @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
84 @param[out] Version Version of the supported SCMI Clock management protocol.
86 @retval EFI_SUCCESS The version is returned.
87 @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
88 @retval !(EFI_SUCCESS) Other errors.
92 (EFIAPI
*SCMI_CLOCK_GET_VERSION
) (
93 IN SCMI_CLOCK_PROTOCOL
*This
,
97 /** Return total number of clock devices supported by the clock management
100 @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
102 @param[out] TotalClocks Total number of clocks supported.
104 @retval EFI_SUCCESS Total number of clocks supported is returned.
105 @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
106 @retval !(EFI_SUCCESS) Other errors.
110 (EFIAPI
*SCMI_CLOCK_GET_TOTAL_CLOCKS
) (
111 IN SCMI_CLOCK_PROTOCOL
*This
,
112 OUT UINT32
*TotalClocks
115 /** Return attributes of a clock device.
117 @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
118 @param[in] ClockId Identifier for the clock device.
120 @param[out] Enabled If TRUE, the clock device is enabled.
121 @param[out] ClockAsciiName A NULL terminated ASCII string with the clock
122 name, of up to 16 bytes.
124 @retval EFI_SUCCESS Clock device attributes are returned.
125 @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
126 @retval !(EFI_SUCCESS) Other errors.
130 (EFIAPI
*SCMI_CLOCK_GET_CLOCK_ATTRIBUTES
) (
131 IN SCMI_CLOCK_PROTOCOL
*This
,
133 OUT BOOLEAN
*Enabled
,
134 OUT CHAR8
*ClockAsciiName
137 /** Return list of rates supported by a given clock device.
139 @param[in] This A pointer to SCMI_CLOCK_PROTOCOL Instance.
140 @param[in] ClockId Identifier for the clock device.
142 @param[out] Format SCMI_CLOCK_RATE_FORMAT_DISCRETE: Clock device
143 supports range of clock rates which are non-linear.
145 SCMI_CLOCK_RATE_FORMAT_LINEAR: Clock device supports
146 range of linear clock rates from Min to Max in steps.
148 @param[out] TotalRates Total number of rates.
150 @param[in,out] RateArraySize Size of the RateArray.
152 @param[out] RateArray List of clock rates.
154 @retval EFI_SUCCESS List of clock rates are returned.
155 @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
156 @retval EFI_BUFFER_TOO_SMALL RateArraySize is too small for the result.
157 It has been updated to the size needed.
158 @retval !(EFI_SUCCESS) Other errors.
162 (EFIAPI
*SCMI_CLOCK_DESCRIBE_RATES
) (
163 IN SCMI_CLOCK_PROTOCOL
*This
,
165 OUT SCMI_CLOCK_RATE_FORMAT
*Format
,
166 OUT UINT32
*TotalRates
,
167 IN OUT UINT32
*RateArraySize
,
168 OUT SCMI_CLOCK_RATE
*RateArray
173 @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
174 @param[in] ClockId Identifier for the clock device.
176 @param[out] Rate Clock rate.
178 @retval EFI_SUCCESS Clock rate is returned.
179 @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
180 @retval !(EFI_SUCCESS) Other errors.
184 (EFIAPI
*SCMI_CLOCK_RATE_GET
) (
185 IN SCMI_CLOCK_PROTOCOL
*This
,
192 @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
193 @param[in] ClockId Identifier for the clock device.
194 @param[in] Rate Clock rate.
196 @retval EFI_SUCCESS Clock rate set success.
197 @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
198 @retval !(EFI_SUCCESS) Other errors.
202 (EFIAPI
*SCMI_CLOCK_RATE_SET
) (
203 IN SCMI_CLOCK_PROTOCOL
*This
,
208 typedef struct _SCMI_CLOCK_PROTOCOL
{
209 SCMI_CLOCK_GET_VERSION GetVersion
;
210 SCMI_CLOCK_GET_TOTAL_CLOCKS GetTotalClocks
;
211 SCMI_CLOCK_GET_CLOCK_ATTRIBUTES GetClockAttributes
;
212 SCMI_CLOCK_DESCRIBE_RATES DescribeRates
;
213 SCMI_CLOCK_RATE_GET RateGet
;
214 SCMI_CLOCK_RATE_SET RateSet
;
215 } SCMI_CLOCK_PROTOCOL
;
217 #endif /* ARM_SCMI_CLOCK_PROTOCOL_H_ */