Documentation/cpu-freq/cpu-drivers.rst

Source file repositories/reference/linux-study-clean/Documentation/cpu-freq/cpu-drivers.rst

File Facts

System
Linux kernel
Corpus path
Documentation/cpu-freq/cpu-drivers.rst
Extension
.rst
Size
11291 bytes
Lines
291
Domain
Support Tooling And Documentation
Bucket
Documentation
Inferred role
Support Tooling And Documentation: exported/initcall integration point
Status
integration implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

First of all, in an __initcall level 7 (module_init()) or later
function check whether this kernel runs on the right CPU and the right
chipset. If so, register a struct cpufreq_driver with the CPUfreq core
using cpufreq_register_driver()

What shall this struct cpufreq_driver contain?

 .name - The name of this driver.

 .init - A pointer to the per-policy initialization function.

 .verify - A pointer to a "verification" function.

 .setpolicy _or_ .fast_switch _or_ .target _or_ .target_index - See
 below on the differences.

And optionally

 .flags - Hints for the cpufreq core.

 .driver_data - cpufreq driver specific data.

 .get_intermediate and target_intermediate - Used to switch to stable
 frequency while changing CPU frequency.

 .get - Returns current frequency of the CPU.

 .bios_limit - Returns HW/BIOS max frequency limitations for the CPU.

 .exit - A pointer to a per-policy cleanup function called during
 CPU_POST_DEAD phase of cpu hotplug process.

 .suspend - A pointer to a per-policy suspend function which is called
 with interrupts disabled and _after_ the governor is stopped for the
 policy.

 .resume - A pointer to a per-policy resume function which is called
 with interrupts disabled and _before_ the governor is started again.

 .ready - A pointer to a per-policy ready function which is called after
 the policy is fully initialized.

 .attr - A pointer to a NULL-terminated list of "struct freq_attr" which
 allow to export values to sysfs.

 .boost_enabled - If set, boost frequencies are enabled.

 .set_boost - A pointer to a per-policy function to enable/disable boost
 frequencies.


1.2 Per-CPU Initialization
--------------------------

Whenever a new CPU is registered with the device model, or after the
cpufreq driver registers itself, the per-policy initialization function
cpufreq_driver.init is called if no cpufreq policy existed for the CPU.
Note that the .init() and .exit() routines are called only once for the
policy and not for each CPU managed by the policy. It takes a ``struct
cpufreq_policy *policy`` as argument. What to do now?

If necessary, activate the CPUfreq support on your CPU.

Then, the driver must fill in the following values:

+-----------------------------------+--------------------------------------+
|policy->cpuinfo.min_freq _and_	    |					   |
|policy->cpuinfo.max_freq	    | the minimum and maximum frequency	   |
|				    | (in kHz) which is supported by	   |
|				    | this CPU				   |

Annotation

Implementation Notes