Trait Cppc

Source
pub trait Cppc {
    // Required methods
    fn probe(&self, reg_id: u32) -> SbiRet;
    fn read(&self, reg_id: u32) -> SbiRet;
    fn read_hi(&self, reg_id: u32) -> SbiRet;
    fn write(&self, reg_id: u32, val: u64) -> SbiRet;
}
Expand description

SBI CPPC support extension.

ACPI defines the Collaborative Processor Performance Control (CPPC) mechanism, which is an abstract and flexible mechanism for the supervisor-mode power-management software, to collaborate with an entity in the platform to manage the performance of the processors.

The SBI CPPC extension provides an abstraction to access the CPPC registers through SBI calls. The CPPC registers can be memory locations shared with a separate platform entity such as a BMC. Even though CPPC is defined in the ACPI specification, it may be possible to implement a CPPC driver based on a Device Tree.

The table below defines 32-bit identifiers for all CPPC registers to be used by the SBI CPPC functions. The first half of the 32-bit register space corresponds to the registers as defined by the ACPI specification. The second half provides the information not defined in the ACPI specification, but is additionally required by the supervisor-mode power-management software.

Register IDRegisterBit WidthAttributeDescription
0x00000000HighestPerformance32Read-onlyACPI Spec 6.5: 8.4.6.1.1.1
0x00000001NominalPerformance32Read-onlyACPI Spec 6.5: 8.4.6.1.1.2
0x00000002LowestNonlinearPerformance32Read-onlyACPI Spec 6.5: 8.4.6.1.1.4
0x00000003LowestPerformance32Read-onlyACPI Spec 6.5: 8.4.6.1.1.5
0x00000004GuaranteedPerformanceRegister32Read-onlyACPI Spec 6.5: 8.4.6.1.1.6
0x00000005DesiredPerformanceRegister32Read / WriteACPI Spec 6.5: 8.4.6.1.2.3
0x00000006MinimumPerformanceRegister32Read / WriteACPI Spec 6.5: 8.4.6.1.2.2
0x00000007MaximumPerformanceRegister32Read / WriteACPI Spec 6.5: 8.4.6.1.2.1
0x00000008PerformanceReductionToleranceRegister32Read / WriteACPI Spec 6.5: 8.4.6.1.2.4
0x00000009TimeWindowRegister32Read / WriteACPI Spec 6.5: 8.4.6.1.2.5
0x0000000ACounterWraparoundTime32 / 64Read-onlyACPI Spec 6.5: 8.4.6.1.3.1
0x0000000BReferencePerformanceCounterRegister32 / 64Read-onlyACPI Spec 6.5: 8.4.6.1.3.1
0x0000000CDeliveredPerformanceCounterRegister32 / 64Read-onlyACPI Spec 6.5: 8.4.6.1.3.1
0x0000000DPerformanceLimitedRegister32Read / WriteACPI Spec 6.5: 8.4.6.1.3.2
0x0000000ECPPCEnableRegister32Read / WriteACPI Spec 6.5: 8.4.6.1.4
0x0000000FAutonomousSelectionEnable32Read / WriteACPI Spec 6.5: 8.4.6.1.5
0x00000010AutonomousActivityWindowRegister32Read / WriteACPI Spec 6.5: 8.4.6.1.6
0x00000011EnergyPerformancePreferenceRegister32Read / WriteACPI Spec 6.5: 8.4.6.1.7
0x00000012ReferencePerformance32Read-onlyACPI Spec 6.5: 8.4.6.1.1.3
0x00000013LowestFrequency32Read-onlyACPI Spec 6.5: 8.4.6.1.1.7
0x00000014NominalFrequency32Read-onlyACPI Spec 6.5: 8.4.6.1.1.7
0x00000015 - 0x7FFFFFFFReserved for future use.
0x80000000TransitionLatency32Read-onlyProvides the maximum (worst-case) performance state transition latency in nanoseconds.
0x80000001 - 0xFFFFFFFFReserved for future use.

Required Methods§

Source

fn probe(&self, reg_id: u32) -> SbiRet

Probe whether the CPPC register as specified by the reg_id parameter is implemented or not by the platform.

§Return value

If the register is implemented, SbiRet.value will contain the register width. If the register is not implemented, SbiRet.value will be set to 0.

The possible return error codes returned in SbiRet.error are shown in the table below:

Error codeDescription
SbiRet::success()Probe completed successfully.
SbiRet::invalid_param()reg_id is reserved.
SbiRet::failed()The probe request failed for unspecified or unknown other reasons.
Source

fn read(&self, reg_id: u32) -> SbiRet

Reads the register as specified in the reg_id parameter.

§Return value

Returns the value of the register in SbiRet.value. When supervisor mode XLEN is 32, the SbiRet.value will only contain the lower 32 bits of the CPPC register value.

The possible return error codes returned in SbiRet.error are shown in the table below:

Error codeDescription
SbiRet::success()Read completed successfully.
SbiRet::invalid_param()reg_id is reserved.
SbiRet::not_supported()reg_id is not implemented by the platform.
SbiRet::denied()reg_id is a write-only register.
SbiRet::failed()The read request failed for unspecified or unknown other reasons.
Source

fn read_hi(&self, reg_id: u32) -> SbiRet

Reads the upper 32-bit value of the register specified in the reg_id parameter.

§Return value

Returns the value of the register in SbiRet.value. This function always returns zero in SbiRet.value when supervisor mode XLEN is 64 or higher.

The possible return error codes returned in SbiRet.error are shown in the table below:

Error codeDescription
SbiRet::success()Read completed successfully.
SbiRet::invalid_param()reg_id is reserved.
SbiRet::not_supported()reg_id is not implemented by the platform.
SbiRet::denied()reg_id is a write-only register.
SbiRet::failed()The read request failed for unspecified or unknown other reasons.
Source

fn write(&self, reg_id: u32, val: u64) -> SbiRet

Writes the value passed in the val parameter to the register as specified in the reg_id parameter.

§Return value

The possible return error codes returned in SbiRet.error are shown in the table below:

Error codeDescription
SbiRet::success()Write completed successfully.
SbiRet::invalid_param()reg_id is reserved.
SbiRet::not_supported()reg_id is not implemented by the platform.
SbiRet::denied()reg_id is a read-only register.
SbiRet::failed()The write-request failed for unspecified or unknown other reasons.

Implementations on Foreign Types§

Source§

impl<T: Cppc> Cppc for Option<T>

Source§

fn probe(&self, reg_id: u32) -> SbiRet

Source§

fn read(&self, reg_id: u32) -> SbiRet

Source§

fn read_hi(&self, reg_id: u32) -> SbiRet

Source§

fn write(&self, reg_id: u32, val: u64) -> SbiRet

Source§

impl<T: Cppc> Cppc for &T

Source§

fn probe(&self, reg_id: u32) -> SbiRet

Source§

fn read(&self, reg_id: u32) -> SbiRet

Source§

fn read_hi(&self, reg_id: u32) -> SbiRet

Source§

fn write(&self, reg_id: u32, val: u64) -> SbiRet

Implementors§