From af1a266670d040d2f4083ff309d732d648afba2a Mon Sep 17 00:00:00 2001 From: Angelos Mouzakitis Date: Tue, 10 Oct 2023 14:33:42 +0000 Subject: Add submodule dependency files Change-Id: Iaf8d18082d3991dec7c0ebbea540f092188eb4ec --- roms/edk2/ArmPkg/Include/Protocol/ArmScmi.h | 21 ++ .../ArmPkg/Include/Protocol/ArmScmiBaseProtocol.h | 168 +++++++++++++ .../Include/Protocol/ArmScmiClock2Protocol.h | 191 +++++++++++++++ .../ArmPkg/Include/Protocol/ArmScmiClockProtocol.h | 212 +++++++++++++++++ .../Include/Protocol/ArmScmiPerformanceProtocol.h | 259 +++++++++++++++++++++ 5 files changed, 851 insertions(+) create mode 100644 roms/edk2/ArmPkg/Include/Protocol/ArmScmi.h create mode 100644 roms/edk2/ArmPkg/Include/Protocol/ArmScmiBaseProtocol.h create mode 100644 roms/edk2/ArmPkg/Include/Protocol/ArmScmiClock2Protocol.h create mode 100644 roms/edk2/ArmPkg/Include/Protocol/ArmScmiClockProtocol.h create mode 100644 roms/edk2/ArmPkg/Include/Protocol/ArmScmiPerformanceProtocol.h (limited to 'roms/edk2/ArmPkg/Include/Protocol') diff --git a/roms/edk2/ArmPkg/Include/Protocol/ArmScmi.h b/roms/edk2/ArmPkg/Include/Protocol/ArmScmi.h new file mode 100644 index 000000000..aedea8f61 --- /dev/null +++ b/roms/edk2/ArmPkg/Include/Protocol/ArmScmi.h @@ -0,0 +1,21 @@ +/** @file + + Copyright (c) 2017-2018, Arm Limited. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + + System Control and Management Interface V1.0 + http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/ + DEN0056A_System_Control_and_Management_Interface.pdf +**/ + +#ifndef ARM_SCMI_H_ +#define ARM_SCMI_H_ + +/* As per SCMI specification, maximum allowed ASCII string length + for various return values/parameters of a SCMI message. +*/ +#define SCMI_MAX_STR_LEN 16 + +#endif /* ARM_SCMI_H_ */ + diff --git a/roms/edk2/ArmPkg/Include/Protocol/ArmScmiBaseProtocol.h b/roms/edk2/ArmPkg/Include/Protocol/ArmScmiBaseProtocol.h new file mode 100644 index 000000000..2f93ec923 --- /dev/null +++ b/roms/edk2/ArmPkg/Include/Protocol/ArmScmiBaseProtocol.h @@ -0,0 +1,168 @@ +/** @file + + Copyright (c) 2017-2018, Arm Limited. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + + System Control and Management Interface V1.0 + http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/ + DEN0056A_System_Control_and_Management_Interface.pdf +**/ + +#ifndef ARM_SCMI_BASE_PROTOCOL_H_ +#define ARM_SCMI_BASE_PROTOCOL_H_ + +#include + +#define BASE_PROTOCOL_VERSION 0x10000 + +#define NUM_PROTOCOL_MASK 0xFFU +#define NUM_AGENT_MASK 0xFFU + +#define NUM_AGENT_SHIFT 0x8 + +/** Returns total number of protocols that are + implemented (excluding the Base protocol) +*/ +#define SCMI_TOTAL_PROTOCOLS(Attr) (Attr & NUM_PROTOCOL_MASK) + +// Returns total number of agents in the system. +#define SCMI_TOTAL_AGENTS(Attr) ((Attr >> NUM_AGENT_SHIFT) & NUM_AGENT_MASK) + +#define ARM_SCMI_BASE_PROTOCOL_GUID { \ + 0xd7e5abe9, 0x33ab, 0x418e, {0x9f, 0x91, 0x72, 0xda, 0xe2, 0xba, 0x8e, 0x2f} \ + } + +extern EFI_GUID gArmScmiBaseProtocolGuid; + +typedef struct _SCMI_BASE_PROTOCOL SCMI_BASE_PROTOCOL; + +/** Return version of the Base protocol supported by SCP firmware. + + @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance. + + @param[out] Version Version of the supported SCMI Base protocol. + + @retval EFI_SUCCESS The version of the protocol is returned. + @retval EFI_DEVICE_ERROR SCP returns an SCMI error. + @retval !(EFI_SUCCESS) Other errors. +**/ +typedef +EFI_STATUS +(EFIAPI *SCMI_BASE_GET_VERSION) ( + IN SCMI_BASE_PROTOCOL *This, + OUT UINT32 *Version + ); + +/** Return total number of SCMI protocols supported by the SCP firmware. + + @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance. + + @param[out] TotalProtocols Total number of SCMI protocols supported. + + @retval EFI_SUCCESS Total number of protocols supported are returned. + @retval EFI_DEVICE_ERROR SCP returns a SCMI error. + @retval !(EFI_SUCCESS) Other errors. +**/ +typedef +EFI_STATUS +(EFIAPI *SCMI_BASE_GET_TOTAL_PROTOCOLS) ( + IN SCMI_BASE_PROTOCOL *This, + OUT UINT32 *TotalProtocols + ); + +/** Return vendor name. + + @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance. + + @param[out] VendorIdentifier Null terminated ASCII string of up to + 16 bytes with a vendor name. + + @retval EFI_SUCCESS VendorIdentifier is returned. + @retval EFI_DEVICE_ERROR SCP returns a SCMI error. + @retval !(EFI_SUCCESS) Other errors. +**/ +typedef +EFI_STATUS +(EFIAPI *SCMI_BASE_DISCOVER_VENDOR) ( + IN SCMI_BASE_PROTOCOL *This, + OUT UINT8 VendorIdentifier[SCMI_MAX_STR_LEN] + ); + +/** Return sub vendor name. + + @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance. + + @param[out] VendorIdentifier Null terminated ASCII string of up to + 16 bytes with a vendor name. + + @retval EFI_SUCCESS VendorIdentifier is returned. + @retval EFI_DEVICE_ERROR SCP returns a SCMI error. + @retval !(EFI_SUCCESS) Other errors. +**/ +typedef +EFI_STATUS +(EFIAPI *SCMI_BASE_DISCOVER_SUB_VENDOR) ( + IN SCMI_BASE_PROTOCOL *This, + OUT UINT8 VendorIdentifier[SCMI_MAX_STR_LEN] + ); + +/** Return implementation version. + + @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance. + + @param[out] ImplementationVersion Vendor specific implementation version. + + @retval EFI_SUCCESS Implementation version is returned. + @retval EFI_DEVICE_ERROR SCP returns a SCMI error. + @retval !(EFI_SUCCESS) Other errors. +**/ +typedef +EFI_STATUS +(EFIAPI *SCMI_BASE_DISCOVER_IMPLEMENTATION_VERSION) ( + IN SCMI_BASE_PROTOCOL *This, + OUT UINT32 *ImplementationVersion + ); + +/** Return list of protocols. + + @param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance. + + @param[out] ProtocolListSize Size of the ProtocolList. + + @param[out] ProtocolList Protocol list. + + @retval EFI_SUCCESS List of protocols is returned. + @retval EFI_BUFFER_TOO_SMALL ProtocolListSize is too small for the result. + It has been updated to the size needed. + @retval EFI_DEVICE_ERROR SCP returns a SCMI error. + @retval !(EFI_SUCCESS) Other errors. +**/ +typedef +EFI_STATUS +(EFIAPI *SCMI_BASE_DISCOVER_LIST_PROTOCOLS) ( + IN SCMI_BASE_PROTOCOL *This, + IN OUT UINT32 *ProtocolListSize, + OUT UINT8 *ProtocolList + ); + +// Base protocol. +typedef struct _SCMI_BASE_PROTOCOL { + SCMI_BASE_GET_VERSION GetVersion; + SCMI_BASE_GET_TOTAL_PROTOCOLS GetTotalProtocols; + SCMI_BASE_DISCOVER_VENDOR DiscoverVendor; + SCMI_BASE_DISCOVER_SUB_VENDOR DiscoverSubVendor; + SCMI_BASE_DISCOVER_IMPLEMENTATION_VERSION DiscoverImplementationVersion; + SCMI_BASE_DISCOVER_LIST_PROTOCOLS DiscoverListProtocols; +} SCMI_BASE_PROTOCOL; + +// SCMI Message IDs for Base protocol. +typedef enum { + SCMI_MESSAGE_ID_BASE_DISCOVER_VENDOR = 0x3, + SCMI_MESSAGE_ID_BASE_DISCOVER_SUB_VENDOR = 0x4, + SCMI_MESSAGE_ID_BASE_DISCOVER_IMPLEMENTATION_VERSION = 0x5, + SCMI_MESSAGE_ID_BASE_DISCOVER_LIST_PROTOCOLS = 0x6 +} SCMI_MESSAGE_ID_BASE; + +#endif /* ARM_SCMI_BASE_PROTOCOL_H_ */ + diff --git a/roms/edk2/ArmPkg/Include/Protocol/ArmScmiClock2Protocol.h b/roms/edk2/ArmPkg/Include/Protocol/ArmScmiClock2Protocol.h new file mode 100644 index 000000000..950141cbd --- /dev/null +++ b/roms/edk2/ArmPkg/Include/Protocol/ArmScmiClock2Protocol.h @@ -0,0 +1,191 @@ +/** @file + + Copyright (c) 2017-2018, Arm Limited. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + + System Control and Management Interface V1.0 + http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/ + DEN0056A_System_Control_and_Management_Interface.pdf +**/ + +#ifndef ARM_SCMI_CLOCK2_PROTOCOL_H_ +#define ARM_SCMI_CLOCK2_PROTOCOL_H_ + +#include +#include + +#define ARM_SCMI_CLOCK2_PROTOCOL_GUID { \ + 0xb8d8caf2, 0x9e94, 0x462c, { 0xa8, 0x34, 0x6c, 0x99, 0xfc, 0x05, 0xef, 0xcf } \ + } + +extern EFI_GUID gArmScmiClock2ProtocolGuid; + +#define SCMI_CLOCK2_PROTOCOL_VERSION 1 + +typedef struct _SCMI_CLOCK2_PROTOCOL SCMI_CLOCK2_PROTOCOL; + +// Protocol Interface functions. + +/** Return version of the clock management protocol supported by SCP firmware. + + @param[in] This A Pointer to SCMI_CLOCK2_PROTOCOL Instance. + + @param[out] Version Version of the supported SCMI Clock management protocol. + + @retval EFI_SUCCESS The version is returned. + @retval EFI_DEVICE_ERROR SCP returns an SCMI error. + @retval !(EFI_SUCCESS) Other errors. +**/ +typedef +EFI_STATUS +(EFIAPI *SCMI_CLOCK2_GET_VERSION) ( + IN SCMI_CLOCK2_PROTOCOL *This, + OUT UINT32 *Version + ); + +/** Return total number of clock devices supported by the clock management + protocol. + + @param[in] This A Pointer to SCMI_CLOCK2_PROTOCOL Instance. + + @param[out] TotalClocks Total number of clocks supported. + + @retval EFI_SUCCESS Total number of clocks supported is returned. + @retval EFI_DEVICE_ERROR SCP returns an SCMI error. + @retval !(EFI_SUCCESS) Other errors. +**/ +typedef +EFI_STATUS +(EFIAPI *SCMI_CLOCK2_GET_TOTAL_CLOCKS) ( + IN SCMI_CLOCK2_PROTOCOL *This, + OUT UINT32 *TotalClocks + ); + +/** Return attributes of a clock device. + + @param[in] This A Pointer to SCMI_CLOCK2_PROTOCOL Instance. + @param[in] ClockId Identifier for the clock device. + + @param[out] Enabled If TRUE, the clock device is enabled. + @param[out] ClockAsciiName A NULL terminated ASCII string with the clock + name, of up to 16 bytes. + + @retval EFI_SUCCESS Clock device attributes are returned. + @retval EFI_DEVICE_ERROR SCP returns an SCMI error. + @retval !(EFI_SUCCESS) Other errors. +**/ +typedef +EFI_STATUS +(EFIAPI *SCMI_CLOCK2_GET_CLOCK_ATTRIBUTES) ( + IN SCMI_CLOCK2_PROTOCOL *This, + IN UINT32 ClockId, + OUT BOOLEAN *Enabled, + OUT CHAR8 *ClockAsciiName + ); + +/** Return list of rates supported by a given clock device. + + @param[in] This A pointer to SCMI_CLOCK2_PROTOCOL Instance. + @param[in] ClockId Identifier for the clock device. + + @param[out] Format SCMI_CLOCK_RATE_FORMAT_DISCRETE: Clock device + supports range of clock rates which are non-linear. + + SCMI_CLOCK_RATE_FORMAT_LINEAR: Clock device supports + range of linear clock rates from Min to Max in steps. + + @param[out] TotalRates Total number of rates. + + @param[in,out] RateArraySize Size of the RateArray. + + @param[out] RateArray List of clock rates. + + @retval EFI_SUCCESS List of clock rates are returned. + @retval EFI_DEVICE_ERROR SCP returns an SCMI error. + @retval EFI_BUFFER_TOO_SMALL RateArraySize is too small for the result. + It has been updated to the size needed. + @retval !(EFI_SUCCESS) Other errors. +**/ +typedef +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 + ); + +/** Get clock rate. + + @param[in] This A Pointer to SCMI_CLOCK2_PROTOCOL Instance. + @param[in] ClockId Identifier for the clock device. + + @param[out] Rate Clock rate. + + @retval EFI_SUCCESS Clock rate is returned. + @retval EFI_DEVICE_ERROR SCP returns an SCMI error. + @retval !(EFI_SUCCESS) Other errors. +**/ +typedef +EFI_STATUS +(EFIAPI *SCMI_CLOCK2_RATE_GET) ( + IN SCMI_CLOCK2_PROTOCOL *This, + IN UINT32 ClockId, + OUT UINT64 *Rate + ); + +/** Set clock rate. + + @param[in] This A Pointer to SCMI_CLOCK2_PROTOCOL Instance. + @param[in] ClockId Identifier for the clock device. + @param[in] Rate Clock rate. + + @retval EFI_SUCCESS Clock rate set success. + @retval EFI_DEVICE_ERROR SCP returns an SCMI error. + @retval !(EFI_SUCCESS) Other errors. +**/ +typedef +EFI_STATUS +(EFIAPI *SCMI_CLOCK2_RATE_SET) ( + IN SCMI_CLOCK2_PROTOCOL *This, + IN UINT32 ClockId, + IN UINT64 Rate + ); + +/** Enable/Disable specified clock. + Function is only available under gArmScmiClock2ProtocolGuid + + @param[in] This A Pointer to SCMI_CLOCK2_PROTOCOL Instance. + @param[in] ClockId Identifier for the clock device. + @param[in] Enable TRUE to enable, FALSE to disable. + + @retval EFI_SUCCESS Clock enable/disable successful. + @retval EFI_DEVICE_ERROR SCP returns an SCMI error. + @retval !(EFI_SUCCESS) Other errors. +**/ +typedef +EFI_STATUS +(EFIAPI *SCMI_CLOCK2_ENABLE) ( + IN SCMI_CLOCK2_PROTOCOL *This, + IN UINT32 ClockId, + IN BOOLEAN Enable + ); + +typedef struct _SCMI_CLOCK2_PROTOCOL { + SCMI_CLOCK2_GET_VERSION GetVersion; + SCMI_CLOCK2_GET_TOTAL_CLOCKS GetTotalClocks; + SCMI_CLOCK2_GET_CLOCK_ATTRIBUTES GetClockAttributes; + SCMI_CLOCK2_DESCRIBE_RATES DescribeRates; + SCMI_CLOCK2_RATE_GET RateGet; + SCMI_CLOCK2_RATE_SET RateSet; + + // Extension to original ClockProtocol, added here so SCMI_CLOCK2_PROTOCOL + // can be cast to SCMI_CLOCK_PROTOCOL + UINTN Version; // For future expandability + SCMI_CLOCK2_ENABLE Enable; +} SCMI_CLOCK2_PROTOCOL; + +#endif /* ARM_SCMI_CLOCK2_PROTOCOL_H_ */ diff --git a/roms/edk2/ArmPkg/Include/Protocol/ArmScmiClockProtocol.h b/roms/edk2/ArmPkg/Include/Protocol/ArmScmiClockProtocol.h new file mode 100644 index 000000000..b4d970dee --- /dev/null +++ b/roms/edk2/ArmPkg/Include/Protocol/ArmScmiClockProtocol.h @@ -0,0 +1,212 @@ +/** @file + + Copyright (c) 2017-2018, Arm Limited. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + + System Control and Management Interface V1.0 + http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/ + DEN0056A_System_Control_and_Management_Interface.pdf +**/ + +#ifndef ARM_SCMI_CLOCK_PROTOCOL_H_ +#define ARM_SCMI_CLOCK_PROTOCOL_H_ + +#include + +#define ARM_SCMI_CLOCK_PROTOCOL_GUID { \ + 0x91ce67a8, 0xe0aa, 0x4012, {0xb9, 0x9f, 0xb6, 0xfc, 0xf3, 0x4, 0x8e, 0xaa} \ + } + +extern EFI_GUID gArmScmiClockProtocolGuid; + +// Message Type for clock management protocol. +typedef enum { + SCMI_MESSAGE_ID_CLOCK_ATTRIBUTES = 0x3, + SCMI_MESSAGE_ID_CLOCK_DESCRIBE_RATES = 0x4, + SCMI_MESSAGE_ID_CLOCK_RATE_SET = 0x5, + SCMI_MESSAGE_ID_CLOCK_RATE_GET = 0x6, + SCMI_MESSAGE_ID_CLOCK_CONFIG_SET = 0x7 +} SCMI_MESSAGE_ID_CLOCK; + +typedef enum { + SCMI_CLOCK_RATE_FORMAT_DISCRETE, // Non-linear range. + SCMI_CLOCK_RATE_FORMAT_LINEAR // Linear range. +} SCMI_CLOCK_RATE_FORMAT; + +// Clock management protocol version. +#define SCMI_CLOCK_PROTOCOL_VERSION 0x10000 + +#define SCMI_CLOCK_PROTOCOL_PENDING_ASYNC_RATES_MASK 0xFFU +#define SCMI_CLOCK_PROTOCOL_PENDING_ASYNC_RATES_SHIFT 16 +#define SCMI_CLOCK_PROTOCOL_NUM_CLOCKS_MASK 0xFFFFU + +/** Total number of pending asynchronous clock rates changes + supported by the SCP, Attr Bits[23:16] +*/ +#define SCMI_CLOCK_PROTOCOL_MAX_ASYNC_CLK_RATES(Attr) ( \ + (Attr >> SCMI_CLOCK_PROTOCOL_PENDING_ASYNC_RATES_SHIFT) && \ + SCMI_CLOCK_PROTOCOL_PENDING_ASYNC_RATES_MASK) + +// Total of clock devices supported by the SCP, Attr Bits[15:0] +#define SCMI_CLOCK_PROTOCOL_TOTAL_CLKS(Attr) (Attr & SCMI_CLOCK_PROTOCOL_NUM_CLOCKS_MASK) + +#pragma pack(1) + +/* Depending on the format (linear/non-linear) supported by a clock device + either Rate or Min/Max/Step triplet is valid. +*/ +typedef struct { + union { + UINT64 Min; + UINT64 Rate; + }; + UINT64 Max; + UINT64 Step; +} SCMI_CLOCK_RATE; + +#pragma pack() + +typedef struct _SCMI_CLOCK_PROTOCOL SCMI_CLOCK_PROTOCOL; + +// Protocol Interface functions. + +/** Return version of the clock management protocol supported by SCP firmware. + + @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance. + + @param[out] Version Version of the supported SCMI Clock management protocol. + + @retval EFI_SUCCESS The version is returned. + @retval EFI_DEVICE_ERROR SCP returns an SCMI error. + @retval !(EFI_SUCCESS) Other errors. +**/ +typedef +EFI_STATUS +(EFIAPI *SCMI_CLOCK_GET_VERSION) ( + IN SCMI_CLOCK_PROTOCOL *This, + OUT UINT32 *Version + ); + +/** Return total number of clock devices supported by the clock management + protocol. + + @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance. + + @param[out] TotalClocks Total number of clocks supported. + + @retval EFI_SUCCESS Total number of clocks supported is returned. + @retval EFI_DEVICE_ERROR SCP returns an SCMI error. + @retval !(EFI_SUCCESS) Other errors. +**/ +typedef +EFI_STATUS +(EFIAPI *SCMI_CLOCK_GET_TOTAL_CLOCKS) ( + IN SCMI_CLOCK_PROTOCOL *This, + OUT UINT32 *TotalClocks + ); + +/** Return attributes of a clock device. + + @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance. + @param[in] ClockId Identifier for the clock device. + + @param[out] Enabled If TRUE, the clock device is enabled. + @param[out] ClockAsciiName A NULL terminated ASCII string with the clock + name, of up to 16 bytes. + + @retval EFI_SUCCESS Clock device attributes are returned. + @retval EFI_DEVICE_ERROR SCP returns an SCMI error. + @retval !(EFI_SUCCESS) Other errors. +**/ +typedef +EFI_STATUS +(EFIAPI *SCMI_CLOCK_GET_CLOCK_ATTRIBUTES) ( + IN SCMI_CLOCK_PROTOCOL *This, + IN UINT32 ClockId, + OUT BOOLEAN *Enabled, + OUT CHAR8 *ClockAsciiName + ); + +/** Return list of rates supported by a given clock device. + + @param[in] This A pointer to SCMI_CLOCK_PROTOCOL Instance. + @param[in] ClockId Identifier for the clock device. + + @param[out] Format SCMI_CLOCK_RATE_FORMAT_DISCRETE: Clock device + supports range of clock rates which are non-linear. + + SCMI_CLOCK_RATE_FORMAT_LINEAR: Clock device supports + range of linear clock rates from Min to Max in steps. + + @param[out] TotalRates Total number of rates. + + @param[in,out] RateArraySize Size of the RateArray. + + @param[out] RateArray List of clock rates. + + @retval EFI_SUCCESS List of clock rates are returned. + @retval EFI_DEVICE_ERROR SCP returns an SCMI error. + @retval EFI_BUFFER_TOO_SMALL RateArraySize is too small for the result. + It has been updated to the size needed. + @retval !(EFI_SUCCESS) Other errors. +**/ +typedef +EFI_STATUS +(EFIAPI *SCMI_CLOCK_DESCRIBE_RATES) ( + 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 + ); + +/** Get clock rate. + + @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance. + @param[in] ClockId Identifier for the clock device. + + @param[out] Rate Clock rate. + + @retval EFI_SUCCESS Clock rate is returned. + @retval EFI_DEVICE_ERROR SCP returns an SCMI error. + @retval !(EFI_SUCCESS) Other errors. +**/ +typedef +EFI_STATUS +(EFIAPI *SCMI_CLOCK_RATE_GET) ( + IN SCMI_CLOCK_PROTOCOL *This, + IN UINT32 ClockId, + OUT UINT64 *Rate + ); + +/** Set clock rate. + + @param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance. + @param[in] ClockId Identifier for the clock device. + @param[in] Rate Clock rate. + + @retval EFI_SUCCESS Clock rate set success. + @retval EFI_DEVICE_ERROR SCP returns an SCMI error. + @retval !(EFI_SUCCESS) Other errors. +**/ +typedef +EFI_STATUS +(EFIAPI *SCMI_CLOCK_RATE_SET) ( + IN SCMI_CLOCK_PROTOCOL *This, + IN UINT32 ClockId, + IN UINT64 Rate + ); + +typedef struct _SCMI_CLOCK_PROTOCOL { + SCMI_CLOCK_GET_VERSION GetVersion; + SCMI_CLOCK_GET_TOTAL_CLOCKS GetTotalClocks; + SCMI_CLOCK_GET_CLOCK_ATTRIBUTES GetClockAttributes; + SCMI_CLOCK_DESCRIBE_RATES DescribeRates; + SCMI_CLOCK_RATE_GET RateGet; + SCMI_CLOCK_RATE_SET RateSet; +} SCMI_CLOCK_PROTOCOL; + +#endif /* ARM_SCMI_CLOCK_PROTOCOL_H_ */ + diff --git a/roms/edk2/ArmPkg/Include/Protocol/ArmScmiPerformanceProtocol.h b/roms/edk2/ArmPkg/Include/Protocol/ArmScmiPerformanceProtocol.h new file mode 100644 index 000000000..96a4d6673 --- /dev/null +++ b/roms/edk2/ArmPkg/Include/Protocol/ArmScmiPerformanceProtocol.h @@ -0,0 +1,259 @@ +/** @file + + Copyright (c) 2017-2018, Arm Limited. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + + System Control and Management Interface V1.0 + http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/ + DEN0056A_System_Control_and_Management_Interface.pdf +**/ + +#ifndef ARM_SCMI_PERFORMANCE_PROTOCOL_H_ +#define ARM_SCMI_PERFORMANCE_PROTOCOL_H_ + +#include + +#define PERFORMANCE_PROTOCOL_VERSION 0x10000 + +#define ARM_SCMI_PERFORMANCE_PROTOCOL_GUID { \ + 0x9b8ba84, 0x3dd3, 0x49a6, {0xa0, 0x5a, 0x31, 0x34, 0xa5, 0xf0, 0x7b, 0xad} \ + } + +extern EFI_GUID gArmScmiPerformanceProtocolGuid; + +typedef struct _SCMI_PERFORMANCE_PROTOCOL SCMI_PERFORMANCE_PROTOCOL; + +#pragma pack(1) + +#define POWER_IN_MW_SHIFT 16 +#define POWER_IN_MW_MASK 0x1 +#define NUM_PERF_DOMAINS_MASK 0xFFFF + +// Total number of performance domains, Attr Bits [15:0] +#define SCMI_PERF_TOTAL_DOMAINS(Attr) (Attr & NUM_PERF_DOMAINS_MASK) + +// A flag to express power values in mW or platform specific way, Attr Bit [16] +#define SCMI_PERF_POWER_IN_MW(Attr) ((Attr >> POWER_IN_MW_SHIFT) & \ + POWER_IN_MW_MASK) + +// Performance protocol attributes return values. +typedef struct { + UINT32 Attributes; + UINT64 StatisticsAddress; + UINT32 StatisticsLen; +} SCMI_PERFORMANCE_PROTOCOL_ATTRIBUTES; + +#define SCMI_PERF_SUPPORT_LVL_CHANGE_NOTIFY(Attr) ((Attr >> 28) & 0x1) +#define SCMI_PERF_SUPPORT_LIM_CHANGE_NOTIFY(Attr) ((Attr >> 29) & 0x1) +#define SCMI_PERF_SUPPORT_SET_LVL(Attr) ((Attr >> 30) & 0x1) +#define SCMI_PERF_SUPPORT_SET_LIM(Attr) ((Attr >> 31) & 0x1) +#define SCMI_PERF_RATE_LIMIT(RateLimit) (RateLimit & 0xFFF) + +// Performance protocol domain attributes. +typedef struct { + UINT32 Attributes; + UINT32 RateLimit; + UINT32 SustainedFreq; + UINT32 SustainedPerfLevel; + UINT8 Name[SCMI_MAX_STR_LEN]; +} SCMI_PERFORMANCE_DOMAIN_ATTRIBUTES; + +// Worst case latency in microseconds, Bits[15:0] +#define PERF_LATENCY_MASK 0xFFFF +#define SCMI_PERFORMANCE_PROTOCOL_LATENCY(Latency) (Latency & PERF_LATENCY_MASK) + +// Performance protocol performance level. +typedef struct { + UINT32 Level; + UINT32 PowerCost; + UINT32 Latency; +} SCMI_PERFORMANCE_LEVEL; + +// Performance protocol performance limit. +typedef struct { + UINT32 RangeMax; + UINT32 RangeMin; +} SCMI_PERFORMANCE_LIMITS; + +#pragma pack() + +/** Return version of the performance management protocol supported by SCP. + firmware. + + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance. + + @param[out] Version Version of the supported SCMI performance management + protocol. + + @retval EFI_SUCCESS The version is returned. + @retval EFI_DEVICE_ERROR SCP returns an SCMI error. + @retval !(EFI_SUCCESS) Other errors. +**/ +typedef +EFI_STATUS +(EFIAPI *SCMI_PERFORMANCE_GET_VERSION) ( + IN SCMI_PERFORMANCE_PROTOCOL *This, + OUT UINT32 *Version + ); + +/** Return protocol attributes of the performance management protocol. + + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance. + + @param[out] Attributes Protocol attributes. + + @retval EFI_SUCCESS Protocol attributes are returned. + @retval EFI_DEVICE_ERROR SCP returns an SCMI error. + @retval !(EFI_SUCCESS) Other errors. +**/ +typedef +EFI_STATUS +(EFIAPI *SCMI_PERFORMANCE_GET_ATTRIBUTES) ( + IN SCMI_PERFORMANCE_PROTOCOL *This, + OUT SCMI_PERFORMANCE_PROTOCOL_ATTRIBUTES *Attributes + + ); + +/** Return performance domain attributes. + + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance. + @param[in] DomainId Identifier for the performance domain. + + @param[out] Attributes Performance domain attributes. + + @retval EFI_SUCCESS Domain attributes are returned. + @retval EFI_DEVICE_ERROR SCP returns an SCMI error. + @retval !(EFI_SUCCESS) Other errors. +**/ +typedef +EFI_STATUS +(EFIAPI *SCMI_PERFORMANCE_GET_DOMAIN_ATTRIBUTES) ( + IN SCMI_PERFORMANCE_PROTOCOL *This, + IN UINT32 DomainId, + OUT SCMI_PERFORMANCE_DOMAIN_ATTRIBUTES *DomainAttributes + ); + +/** Return list of performance domain levels of a given domain. + + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance. + @param[in] DomainId Identifier for the performance domain. + + @param[out] NumLevels Total number of levels a domain can support. + + @param[in,out] LevelArraySize Size of the performance level array. + + @param[out] LevelArray Array of the performance levels. + + @retval EFI_SUCCESS Domain levels are returned. + @retval EFI_DEVICE_ERROR SCP returns an SCMI error. + @retval EFI_BUFFER_TOO_SMALL LevelArraySize is too small for the result. + It has been updated to the size needed. + @retval !(EFI_SUCCESS) Other errors. +**/ +typedef +EFI_STATUS +(EFIAPI *SCMI_PERFORMANCE_DESCRIBE_LEVELS) ( + IN SCMI_PERFORMANCE_PROTOCOL *This, + IN UINT32 DomainId, + OUT UINT32 *NumLevels, + IN OUT UINT32 *LevelArraySize, + OUT SCMI_PERFORMANCE_LEVEL *LevelArray + ); + +/** Set performance limits of a domain. + + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance. + @param[in] DomainId Identifier for the performance domain. + @param[in] Limit Performance limit to set. + + @retval EFI_SUCCESS Performance limits set successfully. + @retval EFI_DEVICE_ERROR SCP returns an SCMI error. + @retval !(EFI_SUCCESS) Other errors. +**/ +typedef +EFI_STATUS +(EFIAPI *SCMI_PERFORMANCE_LIMITS_SET) ( + IN SCMI_PERFORMANCE_PROTOCOL *This, + IN UINT32 DomainId, + IN SCMI_PERFORMANCE_LIMITS *Limits + ); + +/** Get performance limits of a domain. + + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance. + @param[in] DomainId Identifier for the performance domain. + + @param[out] Limit Performance Limits of the domain. + + @retval EFI_SUCCESS Performance limits are returned. + @retval EFI_DEVICE_ERROR SCP returns an SCMI error. + @retval !(EFI_SUCCESS) Other errors. +**/ +typedef +EFI_STATUS +(EFIAPI *SCMI_PERFORMANCE_LIMITS_GET) ( + SCMI_PERFORMANCE_PROTOCOL *This, + UINT32 DomainId, + SCMI_PERFORMANCE_LIMITS *Limits + ); + +/** Set performance level of a domain. + + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance. + @param[in] DomainId Identifier for the performance domain. + @param[in] Level Performance level of the domain. + + @retval EFI_SUCCESS Performance level set successfully. + @retval EFI_DEVICE_ERROR SCP returns an SCMI error. + @retval !(EFI_SUCCESS) Other errors. +**/ +typedef +EFI_STATUS +(EFIAPI *SCMI_PERFORMANCE_LEVEL_SET) ( + IN SCMI_PERFORMANCE_PROTOCOL *This, + IN UINT32 DomainId, + IN UINT32 Level + ); + +/** Get performance level of a domain. + + @param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance. + @param[in] DomainId Identifier for the performance domain. + + @param[out] Level Performance level of the domain. + + @retval EFI_SUCCESS Performance level got successfully. + @retval EFI_DEVICE_ERROR SCP returns an SCMI error. + @retval !(EFI_SUCCESS) Other errors. +**/ +typedef +EFI_STATUS +(EFIAPI *SCMI_PERFORMANCE_LEVEL_GET) ( + IN SCMI_PERFORMANCE_PROTOCOL *This, + IN UINT32 DomainId, + OUT UINT32 *Level + ); + +typedef struct _SCMI_PERFORMANCE_PROTOCOL { + SCMI_PERFORMANCE_GET_VERSION GetVersion; + SCMI_PERFORMANCE_GET_ATTRIBUTES GetProtocolAttributes; + SCMI_PERFORMANCE_GET_DOMAIN_ATTRIBUTES GetDomainAttributes; + SCMI_PERFORMANCE_DESCRIBE_LEVELS DescribeLevels; + SCMI_PERFORMANCE_LIMITS_SET LimitsSet; + SCMI_PERFORMANCE_LIMITS_GET LimitsGet; + SCMI_PERFORMANCE_LEVEL_SET LevelSet; + SCMI_PERFORMANCE_LEVEL_GET LevelGet; +} SCMI_PERFORMANCE_PROTOCOL; + +typedef enum { + SCMI_MESSAGE_ID_PERFORMANCE_DOMAIN_ATTRIBUTES = 0x3, + SCMI_MESSAGE_ID_PERFORMANCE_DESCRIBE_LEVELS = 0x4, + SCMI_MESSAGE_ID_PERFORMANCE_LIMITS_SET = 0x5, + SCMI_MESSAGE_ID_PERFORMANCE_LIMITS_GET = 0x6, + SCMI_MESSAGE_ID_PERFORMANCE_LEVEL_SET = 0x7, + SCMI_MESSAGE_ID_PERFORMANCE_LEVEL_GET = 0x8, +} SCMI_MESSAGE_ID_PERFORMANCE; + +#endif /* ARM_SCMI_PERFORMANCE_PROTOCOL_H_ */ + -- cgit 1.2.3-korg