内核主要通过dev_pm_ops和dev_pm_info两个数据结构执行设备电源管理功能,其中dev_pm_ops结构体包含了在系统挂起和恢复流程的不同阶段,需要调用的设备相关回调函数。它一共包含两种类型函数,大部分普通回调用于通用系统休眠流程,而runtime_xxx格式的回调用于动态电源管理流程。以下为其结构体定义: struct dev_pm_ops {
dev_pm_ops 结构体中,有3个以 runtime 开头的成员函数:runtime_suspend()、runtime_resume()和runtime_idle(),它们辅助设备完成运行时的电源管理: 运行时 PM 与前文描述的系统级挂起到 RAM 时候的PM不太一样,它是针对单个设备,指系统在非睡眠状态的情况下,某个设备在空闲时可以进入运行时挂起状态,而在不...
在“struct device”的“power” 成员中的一些运行时PM字段(这是struct dev_pm_info类型,在include/linux/pm.h中定义),可用于同步设备彼此之间的运行时PM操作。 “struct dev_pm_ops”中的三个设备运行时PM回调函数(在include/linux/pm.h中定义)。 一组定义在drivers/base/power/runtime.c中的辅助函数,他们...
dev1,dev2是Bdev的子设备,也就是说dev1,dev2的parent是Bdev。 其中bus_type里会有一套runtime_pm的三个callback,Bdev自身还有另一套runtime_pm的三个callback。 当dev1的两个counter都为零了,就会调用bus_type里的runtime_idle,一般情况下这个idle会调用pm_runtime_suspend,仅按照上面的介绍,就会调用这个bus...
而直接填充platform_driver的suspend()、resume()做电源管理回调的方法目前已经过时,较好的做法是实现platfrom_driver的device_driver中dev_pm_ops结构体成员(详细的参考电源管理章节)。 2.2.1 device_driver 结构体 与platform_driver地位对等的i2c_driver、spi_driver、usb_driver、pci_driver中都包含了device_driver结...
file: include/linux/pm.h struct dev_pm_ops { int (*prepare)(struct device *dev); //准备 void (*complete)(struct device *dev);//完成 int (*suspend)(struct device *dev);//休眠 int (*resume)(struct device *dev);//唤醒 int (*freeze)(struct device *dev);//冻结 ...
structdev_pm_ops{...int(*runtime_suspend)(struct device *dev);int(*runtime_resume)(struct device *dev);int(*runtime_idle)(struct device *dev); }; 三个回调函数分别用于suspend device,resume device和idle device。通常Runtime PM framework会在合适的时机调用三个函数。 Device...
1. Runtime PM层次结构 2. Runtime PM状态 3. Runtime PM控制流程 每个设备或者子系统都会向Runtime PM core注册3个callback。 在struct dev_pm_ops结构体中,定义了这三个callback: struct dev_pm_ops { ... int (*runtime_suspend)(struct device *dev); ...
const struct dev_pm_ops *pm; struct driver_private *p; }; 其中: const char *name; 用于和硬件进行匹配。 内核描述硬件,必须包含struct device结构体成员: struct device { struct device *parent; struct device_private *p; struct kobject kobj; const char *init_name; /* initial name of the devi...
内核中Suspend功能相关的代码包括PM core、Device PM、Platform PM等几大块,具体如下: 1)PM核心 kernel/power/main.c---提供用户空间接口(/sys/power/state) kernel/power/suspend.c---Suspend功能的主逻辑 kernel/power/suspend_test.c---Suspend功能的测试逻辑 kernel...