35 return (Low | ((UINT64)High << 32));
73 OUT UINT32 *TotalClocks
80 if (EFI_ERROR (Status)) {
84 *TotalClocks = SCMI_CLOCK_PROTOCOL_TOTAL_CLKS (ReturnValues[0]);
107 OUT BOOLEAN *Enabled,
108 OUT CHAR8 *ClockAsciiName
113 UINT32 *MessageParams;
116 UINT32 PayloadLength;
119 if (EFI_ERROR (Status)) {
123 *MessageParams = ClockId;
125 Cmd.ProtocolId = ScmiProtocolIdClock;
126 Cmd.MessageId = ScmiMessageIdClockAttributes;
128 PayloadLength =
sizeof (ClockId);
133 (UINT32 **)&ClockAttributes
135 if (EFI_ERROR (Status)) {
140 *Enabled = CLOCK_ENABLED (ClockAttributes->Attributes);
145 (
CONST CHAR8 *)ClockAttributes->ClockName
179 OUT SCMI_CLOCK_RATE_FORMAT *Format,
180 OUT UINT32 *TotalRates,
181 IN OUT UINT32 *RateArraySize,
187 UINT32 PayloadLength;
189 UINT32 *MessageParams;
193 UINT32 RequiredArraySize;
199 RequiredArraySize = 0;
203 if (EFI_ERROR (Status)) {
207 Cmd.ProtocolId = ScmiProtocolIdClock;
208 Cmd.MessageId = ScmiMessageIdClockDescribeRates;
210 *MessageParams++ = ClockId;
213 *MessageParams = RateIndex;
216 PayloadLength =
sizeof (ClockId) +
sizeof (RateIndex);
222 (UINT32 **)&DescribeRates
224 if (EFI_ERROR (Status)) {
228 if (*TotalRates == 0) {
234 *Format = RATE_FORMAT (DescribeRates->NumRatesFlags);
236 *TotalRates = NUM_RATES (DescribeRates->NumRatesFlags)
237 + NUM_REMAIN_RATES (DescribeRates->NumRatesFlags);
239 RequiredArraySize = (*TotalRates) *
sizeof (UINT64);
241 if (RequiredArraySize > (*RateArraySize)) {
242 *RateArraySize = RequiredArraySize;
243 return EFI_BUFFER_TOO_SMALL;
249 if (*Format == ScmiClockRateFormatDiscrete) {
250 for (RateNo = 0; RateNo < NUM_RATES (DescribeRates->NumRatesFlags); RateNo++) {
251 Rate = &DescribeRates->Rates[RateOffset++];
253 RateArray[RateIndex++].DiscreteRate.Rate =
259 Rate = &DescribeRates->Rates[RateOffset++];
260 RateArray[RateIndex].ContinuousRate.Min =
263 Rate = &DescribeRates->Rates[RateOffset++];
265 RateArray[RateIndex].ContinuousRate.Max =
268 Rate = &DescribeRates->Rates[RateOffset++];
270 RateArray[RateIndex++].ContinuousRate.Step =
273 }
while (NUM_REMAIN_RATES (DescribeRates->NumRatesFlags) != 0);
276 *RateArraySize = RequiredArraySize;
302 UINT32 *MessageParams;
306 UINT32 PayloadLength;
309 if (EFI_ERROR (Status)) {
314 *MessageParams = ClockId;
316 Cmd.ProtocolId = ScmiProtocolIdClock;
317 Cmd.MessageId = ScmiMessageIdClockRateGet;
319 PayloadLength =
sizeof (ClockId);
325 (UINT32 **)&ClockRate
327 if (EFI_ERROR (Status)) {
357 UINT32 PayloadLength;
360 if (EFI_ERROR (Status)) {
365 ClockRateSetAttributes->ClockId = ClockId;
366 ClockRateSetAttributes->Flags = CLOCK_SET_DEFAULT_FLAGS;
367 ClockRateSetAttributes->Rate.Low = (UINT32)Rate;
368 ClockRateSetAttributes->Rate.High = (UINT32)(Rate >> 32);
370 Cmd.ProtocolId = ScmiProtocolIdClock;
371 Cmd.MessageId = ScmiMessageIdClockRateSet;
406 UINT32 PayloadLength;
409 if (EFI_ERROR (Status)) {
414 ClockConfigSetAttributes->ClockId = ClockId;
415 ClockConfigSetAttributes->Attributes = Enable ? BIT0 : 0;
417 Cmd.ProtocolId = ScmiProtocolIdClock;
418 Cmd.MessageId = ScmiMessageIdClockConfigSet;
450 SCMI_CLOCK2_PROTOCOL_VERSION,
465 return gBS->InstallMultipleProtocolInterfaces (
467 &gArmScmiClockProtocolGuid,
469 &gArmScmiClock2ProtocolGuid,
EFI_STATUS(EFIAPI * SCMI_CLOCK2_RATE_GET)(IN SCMI_CLOCK2_PROTOCOL *This, IN UINT32 ClockId, OUT UINT64 *Rate)
EFI_STATUS(EFIAPI * SCMI_CLOCK2_DESCRIBE_RATES)(IN SCMI_CLOCK2_PROTOCOL *This, IN UINT32 ClockId, OUT SCMI_CLOCK_RATE_FORMAT *Format, OUT UINT32 *TotalRates, IN OUT UINT32 *RateArraySize, OUT SCMI_CLOCK_RATE *RateArray)
EFI_STATUS(EFIAPI * SCMI_CLOCK2_GET_CLOCK_ATTRIBUTES)(IN SCMI_CLOCK2_PROTOCOL *This, IN UINT32 ClockId, OUT BOOLEAN *Enabled, OUT CHAR8 *ClockAsciiName)
EFI_STATUS(EFIAPI * SCMI_CLOCK2_GET_VERSION)(IN SCMI_CLOCK2_PROTOCOL *This, OUT UINT32 *Version)
EFI_STATUS(EFIAPI * SCMI_CLOCK2_GET_TOTAL_CLOCKS)(IN SCMI_CLOCK2_PROTOCOL *This, OUT UINT32 *TotalClocks)
EFI_STATUS(EFIAPI * SCMI_CLOCK2_RATE_SET)(IN SCMI_CLOCK2_PROTOCOL *This, IN UINT32 ClockId, IN UINT64 Rate)
RETURN_STATUS EFIAPI AsciiStrCpyS(OUT CHAR8 *Destination, IN UINTN DestMax, IN CONST CHAR8 *Source)
EFI_STATUS ScmiGetProtocolVersion(IN SCMI_PROTOCOL_ID ProtocolId, OUT UINT32 *Version)
EFI_STATUS ScmiCommandExecute(IN SCMI_COMMAND *Command, IN OUT UINT32 *PayloadLength, OUT UINT32 **ReturnValues OPTIONAL)
EFI_STATUS ScmiCommandGetPayload(OUT UINT32 **Payload)
EFI_STATUS ScmiGetProtocolAttributes(IN SCMI_PROTOCOL_ID ProtocolId, OUT UINT32 **ReturnValues)
STATIC UINT64 ConvertTo64Bit(IN UINT32 Low, IN UINT32 High)
STATIC EFI_STATUS ClockRateGet(IN SCMI_CLOCK_PROTOCOL *This, IN UINT32 ClockId, OUT UINT64 *Rate)
STATIC EFI_STATUS ClockRateSet(IN SCMI_CLOCK_PROTOCOL *This, IN UINT32 ClockId, IN UINT64 Rate)
STATIC EFI_STATUS ClockDescribeRates(IN SCMI_CLOCK_PROTOCOL *This, IN UINT32 ClockId, OUT SCMI_CLOCK_RATE_FORMAT *Format, OUT UINT32 *TotalRates, IN OUT UINT32 *RateArraySize, OUT SCMI_CLOCK_RATE *RateArray)
STATIC EFI_STATUS ClockEnable(IN SCMI_CLOCK2_PROTOCOL *This, IN UINT32 ClockId, IN BOOLEAN Enable)
STATIC EFI_STATUS ClockGetTotalClocks(IN SCMI_CLOCK_PROTOCOL *This, OUT UINT32 *TotalClocks)
STATIC EFI_STATUS ClockGetVersion(IN SCMI_CLOCK_PROTOCOL *This, OUT UINT32 *Version)
EFI_STATUS ScmiClockProtocolInit(IN EFI_HANDLE *Handle)
STATIC EFI_STATUS ClockGetClockAttributes(IN SCMI_CLOCK_PROTOCOL *This, IN UINT32 ClockId, OUT BOOLEAN *Enabled, OUT CHAR8 *ClockAsciiName)