1 我在驱动程序中开启了按键中断
在porbe函数中,使用函数device_init_wakeup(&pdev->dev, 1)
2 通过SIMPLE_DEV_PM_OPS注册了key_drv_suspend函数,并在该函数里面通过enable_irq_wake(),使能了可以通过按键来唤醒系统
3 通过SIMPLE_DEV_PM_OPS注册了key_drv_resume函数,并在该函数里面通过disable_irq_wake(),关闭了可以通过按键来唤醒系统
SIMPLE_DEV_PM_OPS(wj_key_pm_ops, key_drv_suspend,key_drv_resume)
4 在driver中
.pm = &wj_key_pm_ops
最后加载驱动
5 在应用程序中通过调用echo mem > /sys/power/state让设备进入低功耗状态,但是按下按键,系统没有恢复。
这种情况大概是哪里出现问题了呢
//这个是我的驱动里面的suspend和resume函数
static int key_drv_suspend(struct device * dev, pm_message_t state)
{
printk("key supend\r\n");
printk("key_drv_suspend's which_irq[0] is %d\n", which_irq[0]);
printk("pm_message_t is %x\r\n", state.event);
enable_irq_wake(which_irq[0]);//使能中断唤醒
return 0;
}
static int key_drv_resume(struct device * dev)
{
printk("key resume\r\n");
is_dev_sleep_or_run = 2;
printk("key_drv_resume key is down: 按下按键, 唤醒设备\r\n");
disable_irq_wake(which_irq[0]);//关闭中断唤醒
return 0;
}
//static SIMPLE_DEV_PM_OPS(wj_key_pm_ops, key_drv_suspend, key_drv_resume);
static const struct dev_pm_ops wj_key_pm_ops = {
.suspend = key_drv_suspend,
.resume = key_drv_resume,
};
static struct platform_device_id key_drv_ids[] = {
{.name = "nuc977-key"},//匹配的名字
{}
};
static struct platform_driver key_driver = {
.driver = {
.name = "nuc977-key",
.owner = THIS_MODULE,
.pm = &wj_key_pm_ops,
},
.probe = key_drv_probe,
.remove = key_drv_remove,
.id_table = key_drv_ids,
// .suspend = key_drv_suspend,
// .resume = key_drv_resume,
};
|
去油香收