@@ -318,16 +318,34 @@ pub fn min(&self) -> u32 {
self.as_ref().min
}
+ /// Set the minimum frequency for a cpufreq policy.
+ pub fn set_min(&mut self, min: u32) -> &mut Self {
+ self.as_mut_ref().min = min;
+ self
+ }
+
/// Returns the maximum frequency for a cpufreq policy.
pub fn max(&self) -> u32 {
self.as_ref().max
}
+ /// Set the maximum frequency for a cpufreq policy.
+ pub fn set_max(&mut self, max: u32) -> &mut Self {
+ self.as_mut_ref().max = max;
+ self
+ }
+
/// Returns the current frequency for a cpufreq policy.
pub fn cur(&self) -> u32 {
self.as_ref().cur
}
+ /// Set the current frequency for a cpufreq policy.
+ pub fn set_cur(&mut self, cur: u32) -> &mut Self {
+ self.as_mut_ref().cur = cur;
+ self
+ }
+
/// Sets the suspend frequency for a cpufreq policy.
pub fn set_suspend_freq(&mut self, freq: u32) -> &mut Self {
self.as_mut_ref().suspend_freq = freq;
@@ -378,12 +396,47 @@ pub fn set_dvfs_possible_from_any_cpu(&mut self) -> &mut Self {
self
}
+ /// Get fast_switch_possible value.
+ pub fn fast_switch_possible(&self) -> bool {
+ self.as_ref().fast_switch_possible
+ }
+
+ /// Enable/disable fast frequency switching.
+ pub fn set_fast_switch_possible(&mut self, val: bool) -> &mut Self {
+ self.as_mut_ref().fast_switch_possible = val;
+ self
+ }
+
/// Sets transition latency for a cpufreq policy.
pub fn set_transition_latency(&mut self, latency: u32) -> &mut Self {
self.as_mut_ref().cpuinfo.transition_latency = latency;
self
}
+ /// Set cpuinfo.min_freq.
+ pub fn set_cpuinfo_min_freq(&mut self, min_freq: u32) -> &mut Self {
+ self.as_mut_ref().cpuinfo.min_freq = min_freq;
+ self
+ }
+
+ /// Set cpuinfo.max_freq.
+ pub fn set_cpuinfo_max_freq(&mut self, max_freq: u32) -> &mut Self {
+ self.as_mut_ref().cpuinfo.max_freq = max_freq;
+ self
+ }
+
+ /// Set transition_delay_us, i.e. time between successive freq. change requests.
+ pub fn set_transition_delay_us(&mut self, transition_delay_us: u32) -> &mut Self {
+ self.as_mut_ref().transition_delay_us = transition_delay_us;
+ self
+ }
+
+ /// Set shared_type, how CPUs coordinate freq. requests (ACPI only).
+ pub fn set_shared_type(&mut self, shared_type: u32) -> &mut Self {
+ self.as_mut_ref().shared_type = shared_type;
+ self
+ }
+
/// Returns the cpufreq table for a cpufreq policy. The cpufreq table is recreated in a
/// light-weight manner from the raw pointer. The table in C code is not freed once this table
/// is dropped.
The following methods are added and seamlessly allow to get/set the matching fields in the C definition of the `struct cpufreq`: - set_min() - set_max() - set_cur() - fast_switch_possible() - set_fast_switch_possible() - set_cpuinfo_min_freq() - set_cpuinfo_max_freq() - set_transition_delay_us() - set_shared_type() Signed-off-by: Pierre Gondois <pierre.gondois@arm.com> --- rust/kernel/cpufreq.rs | 53 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+)