Documentation/translations/zh_CN/cpu-freq/cpu-drivers.rst
Source file repositories/reference/linux-study-clean/Documentation/translations/zh_CN/cpu-freq/cpu-drivers.rst
File Facts
- System
- Linux kernel
- Corpus path
Documentation/translations/zh_CN/cpu-freq/cpu-drivers.rst- Extension
.rst- Size
- 11312 bytes
- Lines
- 257
- 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.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
function cpufreq_for_each_entry
Annotated Snippet
首先,在 __initcall level 7 (module_init())或更靠后的函数中检查这个内核是否
运行在正确的CPU和正确的芯片组上。如果是,则使用cpufreq_register_driver()向
CPUfreq核心层注册一个cpufreq_driver结构体。
结构体cpufreq_driver应该包含什么成员?
.name - 驱动的名字。
.init - 一个指向per-policy初始化函数的指针。
.verify - 一个指向"verification"函数的指针。
.setpolicy 或 .fast_switch 或 .target 或 .target_index - 差异见
下文。
其它可选成员
.flags - 给cpufreq核心的提示。
.driver_data - cpufreq驱动程序的特有数据。
.get_intermediate 和 target_intermediate - 用于在改变CPU频率时切换到稳定
的频率。
.get - 返回CPU的当前频率。
.bios_limit - 返回HW/BIOS对CPU的最大频率限制值。
.exit - 一个指向per-policy清理函数的指针,该函数在CPU热插拔过程的CPU_POST_DEAD
阶段被调用。
.suspend - 一个指向per-policy暂停函数的指针,该函数在关中断且在该策略的调节器停止
后被调用。
.resume - 一个指向per-policy恢复函数的指针,该函数在关中断且在调节器再一次启动前被
调用。
.ready - 一个指向per-policy准备函数的指针,该函数在策略完全初始化之后被调用。
.attr - 一个指向NULL结尾的"struct freq_attr"列表的指针,该列表允许导出值到
sysfs。
.boost_enabled - 如果设置,则启用提升(boost)频率。
.set_boost - 一个指向per-policy函数的指针,该函数用来开启/关闭提升(boost)频率功能。
1.2 Per-CPU 初始化
------------------
每当一个新的CPU被注册到设备模型中,或者当cpufreq驱动注册自身之后,如果此CPU的cpufreq策
略不存在,则会调用per-policy的初始化函数cpufreq_driver.init。请注意,.init()和.exit()例程
只为某个策略调用一次,而不是对该策略管理的每个CPU调用一次。它需要一个 ``struct cpufreq_policy
*policy`` 作为参数。现在该怎么做呢?
如果有必要,请在你的CPU上激活CPUfreq功能支持。
然后,驱动程序必须填写以下值:
+-----------------------------------+--------------------------------------+
|policy->cpuinfo.min_freq和 | 该CPU支持的最低和最高频率(kHz) |
|policy->cpuinfo.max_freq | |
| | |
+-----------------------------------+--------------------------------------+
|policy->cpuinfo.transition_latency | CPU在两个频率之间切换所需的时间,以 |
| | 纳秒为单位 |
| | |
+-----------------------------------+--------------------------------------+
|policy->cur | 该CPU当前的工作频率(如适用) |
| | |
Annotation
- Detected declarations: `function cpufreq_for_each_entry`.
- Atlas domain: Support Tooling And Documentation / Documentation.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.