// SPDX-License-Identifier: GPL-2.0
//! CPU frequency scaling.
//!
//! This module provides rust abstractions for interacting with the cpufreq subsystem.
//!
//! C header: [`include/linux/cpufreq.h`](srctree/include/linux/cpufreq.h)
//!
//! Reference: <https://docs.kernel.org/admin-guide/pm/cpufreq.html>
use crate::{
clk::Hertz,
cpu::CpuId,
cpumask,
device::{Bound, Device},
devres,
error::{code::*, from_err_ptr, from_result, to_result, Result, VTABLE_DEFAULT_ERROR},
ffi::{c_char, c_ulong},
prelude::*,
types::ForeignOwnable,
types::Opaque,
};
#[cfg(CONFIG_COMMON_CLK)]
use crate::clk::Clk;
use core::{
cell::UnsafeCell,
marker::PhantomData,
ops::{Deref, DerefMut},
pin::Pin,
ptr,
};
use macros::vtable;
/// Maximum length of CPU frequency driver's name.
const CPUFREQ_NAME_LEN: usize = bindings::CPUFREQ_NAME_LEN as usize;
/// Default transition latency value in nanoseconds.
pub const DEFAULT_TRANSITION_LATENCY_NS: u32 = bindings::CPUFREQ_DEFAULT_TRANSITION_LATENCY_NS;
/// CPU frequency driver flags.
pub mod flags {
/// Driver needs to update internal limits even if frequency remains unchanged.
pub const NEED_UPDATE_LIMITS: u16 = 1 << 0;
/// Platform where constants like `loops_per_jiffy` are unaffected by frequency changes.
pub const CONST_LOOPS: u16 = 1 << 1;
/// Register driver as a thermal cooling device automatically.
pub const IS_COOLING_DEV: u16 = 1 << 2;
/// Supports multiple clock domains with per-policy governors in `cpu/cpuN/cpufreq/`.
pub const HAVE_GOVERNOR_PER_POLICY: u16 = 1 << 3;
/// Allows post-change notifications outside of the `target()` routine.
pub const ASYNC_NOTIFICATION: