device wakeup system

本文深入解析设备唤醒系统的机制,介绍如何通过API如device_init_wakeup, device_wakeup_enable等配置设备使其能唤醒系统。探讨gpio电源按键等硬件如何实现系统唤醒,并提供gpio_keys.c等驱动代码作为参考。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

通过设备可以将系统唤醒,比如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电源锁
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值