]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Include/Protocol/ArmScmiClock2Protocol.h
ArmPkg/ArmScmiDxe: Add clock enable function
[mirror_edk2.git] / ArmPkg / Include / Protocol / ArmScmiClock2Protocol.h
1 /** @file
2
3 Copyright (c) 2017-2018, Arm Limited. All rights reserved.
4
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
9
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.
12
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
16 **/
17
18 #ifndef ARM_SCMI_CLOCK2_PROTOCOL_H_
19 #define ARM_SCMI_CLOCK2_PROTOCOL_H_
20
21 #include <Protocol/ArmScmi.h>
22 #include <Protocol/ArmScmiClockProtocol.h>
23
24 #define ARM_SCMI_CLOCK2_PROTOCOL_GUID { \
25 0xb8d8caf2, 0x9e94, 0x462c, { 0xa8, 0x34, 0x6c, 0x99, 0xfc, 0x05, 0xef, 0xcf } \
26 }
27
28 extern EFI_GUID gArmScmiClock2ProtocolGuid;
29
30 #define SCMI_CLOCK2_PROTOCOL_VERSION 1
31
32 typedef struct _SCMI_CLOCK2_PROTOCOL SCMI_CLOCK2_PROTOCOL;
33
34 // Protocol Interface functions.
35
36 /** Return version of the clock management protocol supported by SCP firmware.
37
38 @param[in] This A Pointer to SCMI_CLOCK2_PROTOCOL Instance.
39
40 @param[out] Version Version of the supported SCMI Clock management protocol.
41
42 @retval EFI_SUCCESS The version is returned.
43 @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
44 @retval !(EFI_SUCCESS) Other errors.
45 **/
46 typedef
47 EFI_STATUS
48 (EFIAPI *SCMI_CLOCK2_GET_VERSION) (
49 IN SCMI_CLOCK2_PROTOCOL *This,
50 OUT UINT32 *Version
51 );
52
53 /** Return total number of clock devices supported by the clock management
54 protocol.
55
56 @param[in] This A Pointer to SCMI_CLOCK2_PROTOCOL Instance.
57
58 @param[out] TotalClocks Total number of clocks supported.
59
60 @retval EFI_SUCCESS Total number of clocks supported is returned.
61 @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
62 @retval !(EFI_SUCCESS) Other errors.
63 **/
64 typedef
65 EFI_STATUS
66 (EFIAPI *SCMI_CLOCK2_GET_TOTAL_CLOCKS) (
67 IN SCMI_CLOCK2_PROTOCOL *This,
68 OUT UINT32 *TotalClocks
69 );
70
71 /** Return attributes of a clock device.
72
73 @param[in] This A Pointer to SCMI_CLOCK2_PROTOCOL Instance.
74 @param[in] ClockId Identifier for the clock device.
75
76 @param[out] Enabled If TRUE, the clock device is enabled.
77 @param[out] ClockAsciiName A NULL terminated ASCII string with the clock
78 name, of up to 16 bytes.
79
80 @retval EFI_SUCCESS Clock device attributes are returned.
81 @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
82 @retval !(EFI_SUCCESS) Other errors.
83 **/
84 typedef
85 EFI_STATUS
86 (EFIAPI *SCMI_CLOCK2_GET_CLOCK_ATTRIBUTES) (
87 IN SCMI_CLOCK2_PROTOCOL *This,
88 IN UINT32 ClockId,
89 OUT BOOLEAN *Enabled,
90 OUT CHAR8 *ClockAsciiName
91 );
92
93 /** Return list of rates supported by a given clock device.
94
95 @param[in] This A pointer to SCMI_CLOCK2_PROTOCOL Instance.
96 @param[in] ClockId Identifier for the clock device.
97
98 @param[out] Format SCMI_CLOCK_RATE_FORMAT_DISCRETE: Clock device
99 supports range of clock rates which are non-linear.
100
101 SCMI_CLOCK_RATE_FORMAT_LINEAR: Clock device supports
102 range of linear clock rates from Min to Max in steps.
103
104 @param[out] TotalRates Total number of rates.
105
106 @param[in,out] RateArraySize Size of the RateArray.
107
108 @param[out] RateArray List of clock rates.
109
110 @retval EFI_SUCCESS List of clock rates are returned.
111 @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
112 @retval EFI_BUFFER_TOO_SMALL RateArraySize is too small for the result.
113 It has been updated to the size needed.
114 @retval !(EFI_SUCCESS) Other errors.
115 **/
116 typedef
117 EFI_STATUS
118 (EFIAPI *SCMI_CLOCK2_DESCRIBE_RATES) (
119 IN SCMI_CLOCK2_PROTOCOL *This,
120 IN UINT32 ClockId,
121 OUT SCMI_CLOCK_RATE_FORMAT *Format,
122 OUT UINT32 *TotalRates,
123 IN OUT UINT32 *RateArraySize,
124 OUT SCMI_CLOCK_RATE *RateArray
125 );
126
127 /** Get clock rate.
128
129 @param[in] This A Pointer to SCMI_CLOCK2_PROTOCOL Instance.
130 @param[in] ClockId Identifier for the clock device.
131
132 @param[out] Rate Clock rate.
133
134 @retval EFI_SUCCESS Clock rate is returned.
135 @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
136 @retval !(EFI_SUCCESS) Other errors.
137 **/
138 typedef
139 EFI_STATUS
140 (EFIAPI *SCMI_CLOCK2_RATE_GET) (
141 IN SCMI_CLOCK2_PROTOCOL *This,
142 IN UINT32 ClockId,
143 OUT UINT64 *Rate
144 );
145
146 /** Set clock rate.
147
148 @param[in] This A Pointer to SCMI_CLOCK2_PROTOCOL Instance.
149 @param[in] ClockId Identifier for the clock device.
150 @param[in] Rate Clock rate.
151
152 @retval EFI_SUCCESS Clock rate set success.
153 @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
154 @retval !(EFI_SUCCESS) Other errors.
155 **/
156 typedef
157 EFI_STATUS
158 (EFIAPI *SCMI_CLOCK2_RATE_SET) (
159 IN SCMI_CLOCK2_PROTOCOL *This,
160 IN UINT32 ClockId,
161 IN UINT64 Rate
162 );
163
164 /** Enable/Disable specified clock.
165 Function is only available under gArmScmiClock2ProtocolGuid
166
167 @param[in] This A Pointer to SCMI_CLOCK2_PROTOCOL Instance.
168 @param[in] ClockId Identifier for the clock device.
169 @param[in] Enable TRUE to enable, FALSE to disable.
170
171 @retval EFI_SUCCESS Clock enable/disable successful.
172 @retval EFI_DEVICE_ERROR SCP returns an SCMI error.
173 @retval !(EFI_SUCCESS) Other errors.
174 **/
175 typedef
176 EFI_STATUS
177 (EFIAPI *SCMI_CLOCK2_ENABLE) (
178 IN SCMI_CLOCK2_PROTOCOL *This,
179 IN UINT32 ClockId,
180 IN BOOLEAN Enable
181 );
182
183 typedef struct _SCMI_CLOCK2_PROTOCOL {
184 SCMI_CLOCK2_GET_VERSION GetVersion;
185 SCMI_CLOCK2_GET_TOTAL_CLOCKS GetTotalClocks;
186 SCMI_CLOCK2_GET_CLOCK_ATTRIBUTES GetClockAttributes;
187 SCMI_CLOCK2_DESCRIBE_RATES DescribeRates;
188 SCMI_CLOCK2_RATE_GET RateGet;
189 SCMI_CLOCK2_RATE_SET RateSet;
190
191 // Extension to original ClockProtocol, added here so SCMI_CLOCK2_PROTOCOL
192 // can be cast to SCMI_CLOCK_PROTOCOL
193 UINTN Version; // For future expandability
194 SCMI_CLOCK2_ENABLE Enable;
195 } SCMI_CLOCK2_PROTOCOL;
196
197 #endif /* ARM_SCMI_CLOCK2_PROTOCOL_H_ */