通过设备可以将系统唤醒,比如gpio电源按键能够将系统唤醒。

device wakeup相关的API

 /* include/linux/pm_wakeup.h */ 
 device_init_wakeup(struct device *dev, bool val); // 初始化设备能不能唤醒系统,并且使用这个功能 
 device_may_wakeup // 判断设备设备能不能够别唤醒,并且使用这个功能 
 device_wakeup_enable(struct device *dev); // Enable given device to be a wakeup source 
 device_wakeup_disable(struct device *dev); 
 device_set_wakeup_capable(struct device *dev, bool capable); 
 device_set_wakeup_enable(struct device *dev, bool enable); //Enable or disable a device to wake up the system. 
 pm_stay_awake(struct device *dev); 
 pm_relax(struct device *dev); 
 pm_wakeup_event(struct device *dev, unsigned int msec);

//incllude/linux/interrupt.h
enable_irq_wake

参考代码

drivers/input/misc/gpio_keys.c

//probe中将设备设置为可将系统唤醒
gpio_keys_probe
	device_init_wakeup(&pdev->dev, wakeup);

//当设备suspend时,将其触发的中断设置为可以将系统唤醒并使能
gpio_keys_suspend
	if (device_may_wakeup(dev))
		enable_irq_wake(bdata->irq);

另外拿drivers/tty/serial/serial_core.c和drivers/misc/fsa9480.c文件中的device wakeup设置作参考


参考文章

  1. device wakeup 功能 & wake_lock电源锁
Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐