1、SYSFS接口
终端目录:/sys/kernel/debug/wakeup_sources调试可以参考:休眠调试篇
为了方便查看系统的wakeup sources,此文件记录了系统的唤醒源的详细信息。
name active_count event_count wakeup_count expire_count active_since total_time max_time last_change prevent_suspend_time
2、Device power
2.1、device中的dev_pm_info结构体
可以唤醒系统的只有设备(struct device),但并不是每个设备都具备唤醒功能,那些具有唤醒功能的设备称作wakeup source。
文件: kernel/include/llinux/device.h
struct device {
...
struct dev_pm_info power;
...
}
struct device结构涉及到一个struct dev_pm_info类型的power变量:文件: kernel/include/llinuxl/pm.h
struct dev_pm_info {
pm_message_t power_state;
unsigned int can_wakeup:1;
...
#ifdef CONFIG_PM_SLEEP
struct list_head entry;
struct completion completion;
struct wakeup_source *wakeup;
bool wakeup_path:1;
bool syscore:1;
#else
unsigned int should_wakeup:1;
#endif
...
}
can_wakeup,标识本设备是否具有唤醒能力。只有具备唤醒能力的设备,才会在sysfs中有一个power目录。这个属性device 驱动可以通过device_may_wakeup 更改:
static inline bool device_may_wakeup(struct device *dev)
{
return dev->power.can_wakeup && !!dev->power.wakeup;
}