内核电源管理框架移植入门

📚 共计 30 章节
01
电源管理概述
为什么需要电源管理?Linux电源管理子系统整体架构(PM Core, PM QOS, Runtime PM, Suspend/Resume, CPUFreq, CPUIdle, Devfreq)。
PM CoreDVFS
02
硬件基础
SoC电源域划分、电压调节器(Regulator)、时钟门控(Clock Gating)、电源门控(Power Gating)、DVFS技术原理。
Power GatingRegulator
03
内核配置与编译
如何配置内核电源管理选项(menuconfig)、相关Kconfig分析、编译生成支持电源管理的内核镜像。
menuconfigKconfig
04
设备树中的电源管理
设备树中描述电源域、regulator、operating-points-v2、power-domains属性详解。
设备树OPP
05
Clock Framework基础
clk_prepare/clk_enable/clk_disable/unprepare API、时钟树概念、时钟驱动注册流程。
ClockAPI
06
Regulator Framework基础
regulator_get/regulator_enable/regulator_set_voltage API、regulator约束与消费者。
Regulator约束
07
Runtime PM框架(上)
Runtime PM核心数据结构(dev_pm_info)、pm_runtime_get_sync/pm_runtime_put_sync API、自动挂起与唤醒。
Runtime PMdev_pm_info
08
Runtime PM框架(下)
Runtime PM回调函数(runtime_suspend/runtime_resume/runtime_idle)、使用autosuspend优化频繁开关场景。
回调autosuspend
09
系统Suspend/Resume流程
PM核心的suspend/resume流程、suspend_ops注册、设备suspend/resume顺序、noirq阶段。
Suspendnoirq
10
Wakeup Source机制
wakeup_source结构体、pm_wakeup_event接口、wakeup count与autosleep、防止系统误唤醒。
Wakeupautosleep
11
CPUFreq框架(上)
CPUFreq核心层与驱动层分离、cpufreq_driver注册、cpufreq_policy概念、governor(performance/powersave/ondemand/schedutil)。
CPUFreqgovernor
12
CPUFreq框架(下)
CPUFreq驱动实现(以cpufreq-dt为例)、operating-points-v2解析、频率电压表切换、调节延迟。
cpufreq-dtOPP
13
CPUIdle框架
CPUIdle核心层、cpuidle_driver注册、cpuidle_state概念、governor(menu/ladder)、WFI与WFI深度睡眠。
CPUIdleWFI
14
Devfreq框架
Devfreq设备频率调节、devfreq_dev_profile注册、governor(simple_ondemand/powersave)、与CPUFreq的区别。
Devfreqgovernor
15
PM QOS框架
PM QOS分类(CPU DMA Latency/Network Latency等)、pm_qos_add_request接口、约束对CPUIDLE/CPUFreq的影响。
PM QOS延迟
16
电源管理IC(PMIC)驱动
PMIC MFD驱动框架、regulator子设备注册、ADC/温度监测、与内核PM框架的对接。
PMICMFD
17
电池驱动与充电管理
Power Supply类、psy_drv注册、电池状态上报(capacity/status/health)、充电曲线与温控策略。
电池Power Supply
18
热管理框架(Thermal)
Thermal核心层、thermal_zone_device_register、cooling device(cpufreq_cooling/devfreq_cooling)、温控策略(step_wise/power_allocator)。
Thermalcooling
19
功耗测量与调试
perf工具测量功耗、powertop工具使用、/sys/kernel/debug/pm*调试节点、trace event分析。
powertopperf
20
Suspend/Resume调试
suspend/resume失败排查、dmesg日志分析、/sys/power/state与pm_test、no_console_suspend参数。
调试pm_test
21
Runtime PM调试
runtime PM状态查看(/sys/devices/.../power/)、runtime PM统计信息、强制runtime suspend/resume。
sysfs强制
22
电源管理单元测试
编写简单的PM驱动测试模块、使用kunit进行PM框架单元测试、模拟suspend/resume场景。
kunit测试
23
常见SoC平台移植案例(上)
以全志H3为例,配置CPUFreq与CPUIdle、设备树编写、驱动适配。
全志H3移植
24
常见SoC平台移植案例(下)
以瑞芯微RK3399为例,配置DVFS与Devfreq、GPU频率调节、PMIC驱动对接。
RK3399DVFS
25
Android平台电源管理
Android wakelock机制、early_suspend/late_resume(已废弃)、Android 12+的电源管理变化、与内核PM框架的交互。
Androidwakelock
26
电源管理性能优化
降低动态功耗(DVFS优化)、降低静态功耗(Power Gating)、优化唤醒延迟、减少不必要的PM QOS请求。
优化Power Gating
27
电源管理安全与可靠性
电压/频率超出规格保护、热保护(thermal throttle)、欠压检测与关机、看门狗与PM交互。
安全thermal throttle
28
电源管理新特性
PM Domain框架(Generic PM Domain)、Energy Model(EM)与EAS调度器、S2Idle(Suspend-to-Idle)浅睡眠。
PM DomainEAS
29
电源管理代码审查指南
PM驱动代码风格、常见错误(忘记unprepare/不平衡的get/put)、review checklist。
代码审查checklist
30
综合实战项目
从零开始为一块开发板移植完整电源管理方案(CPUFreq+CPUIdle+Runtime PM+Suspend/Resume),输出移植报告。
实战移植报告