pub struct Table { /* private fields */ }
Expand description
A reference-counted OPP table.
Rust abstraction for the C struct opp_table
.
§Invariants
The pointer stored in Self
is non-null and valid for the lifetime of the Table
.
Instances of this type are reference-counted.
§Examples
The following example demonstrates how to get OPP Table
for a Cpumask
and set its
frequency.
use kernel::clk::Hertz;
use kernel::cpumask::Cpumask;
use kernel::device::Device;
use kernel::error::Result;
use kernel::opp::Table;
use kernel::types::ARef;
fn get_table(dev: &ARef<Device>, mask: &mut Cpumask, freq: Hertz) -> Result<Table> {
let mut opp_table = Table::from_of_cpumask(dev, mask)?;
if opp_table.opp_count()? == 0 {
return Err(EINVAL);
}
pr_info!("Max transition latency is: {} ns\n", opp_table.max_transition_latency_ns());
pr_info!("Suspend frequency is: {:?}\n", opp_table.suspend_freq());
opp_table.set_rate(freq)?;
Ok(opp_table)
}
Implementations§
source§impl Table
impl Table
sourcepub fn from_of_cpumask(dev: &Device, cpumask: &mut Cpumask) -> Result<Self>
pub fn from_of_cpumask(dev: &Device, cpumask: &mut Cpumask) -> Result<Self>
sourcepub fn max_clock_latency_ns(&self) -> usize
pub fn max_clock_latency_ns(&self) -> usize
sourcepub fn max_volt_latency_ns(&self) -> usize
pub fn max_volt_latency_ns(&self) -> usize
sourcepub fn max_transition_latency_ns(&self) -> usize
pub fn max_transition_latency_ns(&self) -> usize
sourcepub fn suspend_freq(&self) -> Hertz
pub fn suspend_freq(&self) -> Hertz
Returns the suspend OPP
’s frequency.
sourcepub fn sync_regulators(&self) -> Result
pub fn sync_regulators(&self) -> Result
Synchronizes regulators used by the Table
.
sourcepub fn sharing_cpus(dev: &Device, cpumask: &mut Cpumask) -> Result
pub fn sharing_cpus(dev: &Device, cpumask: &mut Cpumask) -> Result
Gets sharing CPUs.
sourcepub fn set_sharing_cpus(&mut self, cpumask: &mut Cpumask) -> Result
pub fn set_sharing_cpus(&mut self, cpumask: &mut Cpumask) -> Result
Sets sharing CPUs.
sourcepub fn of_sharing_cpus(dev: &Device, cpumask: &mut Cpumask) -> Result
pub fn of_sharing_cpus(dev: &Device, cpumask: &mut Cpumask) -> Result
Gets sharing CPUs from device tree.
sourcepub fn adjust_voltage(
&self,
freq: Hertz,
volt: MicroVolt,
volt_min: MicroVolt,
volt_max: MicroVolt
) -> Result
pub fn adjust_voltage( &self, freq: Hertz, volt: MicroVolt, volt_min: MicroVolt, volt_max: MicroVolt ) -> Result
Updates the voltage value for an OPP
.
sourcepub fn set_rate(&self, freq: Hertz) -> Result
pub fn set_rate(&self, freq: Hertz) -> Result
Configures device with OPP
matching the frequency value.
sourcepub fn opp_from_freq(
&self,
freq: Hertz,
available: Option<bool>,
index: Option<u32>,
stype: SearchType
) -> Result<ARef<OPP>>
pub fn opp_from_freq( &self, freq: Hertz, available: Option<bool>, index: Option<u32>, stype: SearchType ) -> Result<ARef<OPP>>
Finds OPP
based on frequency.
sourcepub fn opp_from_level(&self, level: u32, stype: SearchType) -> Result<ARef<OPP>>
pub fn opp_from_level(&self, level: u32, stype: SearchType) -> Result<ARef<OPP>>
Finds OPP
based on level.
sourcepub fn opp_from_bw(
&self,
bw: u32,
index: i32,
stype: SearchType
) -> Result<ARef<OPP>>
pub fn opp_from_bw( &self, bw: u32, index: i32, stype: SearchType ) -> Result<ARef<OPP>>
Finds OPP
based on bandwidth.
sourcepub fn enable_opp(&self, freq: Hertz) -> Result
pub fn enable_opp(&self, freq: Hertz) -> Result
Enables the OPP
.
sourcepub fn disable_opp(&self, freq: Hertz) -> Result
pub fn disable_opp(&self, freq: Hertz) -> Result
Disables the OPP
.
sourcepub fn of_register_em(&mut self, cpumask: &mut Cpumask) -> Result
pub fn of_register_em(&mut self, cpumask: &mut Cpumask) -> Result
Registers with the Energy model.
Trait Implementations§
impl Send for Table
SAFETY: It is okay to send ownership of Table
across thread boundaries.
impl Sync for Table
SAFETY: It is okay to access Table
through shared references from other threads because
we’re either accessing properties that don’t change or that are properly synchronised by C code.