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 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 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.