在系统中增加一个可唤醒中断--简单实例

   在系统休眠的时候3G来电或者短信需要唤醒系统,使系统resume。从3G模块手册看到有WAKE#脚,当收到来电或者SMS时这个脚会有0.5S的拉低,就是cp_wakeup_ap,用这个脚做唤醒脚。查看AP的datasheet,挑选一个带有EINT功能的GPIO脚做接收此中断的脚,这里选GPX3(1)。开始写驱动来处理这个事件。

kernel\arch\arm\mach-exynos\setup-mu609.c

[cpp]  view plain  copy
  1. #include <linux/kernel.h>  
  2. #include <linux/init.h>  
  3. #include <linux/platform_device.h>  
  4. #include <linux/delay.h>  
  5. #include <linux/err.h>  
  6. #include <linux/skbuff.h>  
  7.   
  8. #include <plat/devs.h>  
  9. #include <plat/sdhci.h>  
  10. #include <plat/gpio-cfg.h>  
  11. #include <mach/regs-gpio.h>  
  12. #include <mach/gpio.h>  
  13. #include <linux/irq.h>  
  14. #include <linux/interrupt.h>  
  15. #include <linux/module.h>  
  16.   
  17. static irqreturn_t host_wake_isr(int irq, void *dev)  
  18. {  
  19.     /* 
  20.        do something when interrupt happen 
  21.     */  
  22.     return IRQ_HANDLED;  
  23. }  
  24.   
  25. static int mu609_probe(struct platform_device *pdev)  
  26. {  
  27.     int irq;  
  28.     int ret;  
  29.       
  30.     printk("%s: start\n", __FUNCTION__);  
  31.   
  32.     s3c_gpio_cfgpin(EXYNOS5410_GPX3(1), S3C_GPIO_INPUT); //stone++ for mu609  
  33.     s3c_gpio_setpull(EXYNOS5410_GPX3(1), S3C_GPIO_PULL_UP); //stone++ for mu609  
  34.       
  35.     irq = IRQ_EINT(25);  
  36.     ret = request_irq(irq, host_wake_isr, IRQF_TRIGGER_FALLING,  
  37.         "3g mu609_wake", NULL);  
  38.     if (ret) {  
  39.         pr_err("[3G] Request_host wake irq failed.\n");  
  40.         return ret;  
  41.     }  
  42.   
  43.     ret = irq_set_irq_wake(irq, 1);  
  44.     if (ret) {  
  45.         pr_err("[3G] Set_irq_wake failed.\n");  
  46.         return ret;  
  47.     }  
  48.       
  49.     return ret;  
  50. }  
  51.   
  52. static int mu609_remove(struct platform_device *pdev)  
  53. {  
  54.     return 0;  
  55. }  
  56.   
  57.   
  58. static struct platform_driver mu609_driver = {  
  59.     .probe = mu609_probe,  
  60.     .remove = mu609_remove,  
  61.     .driver = {  
  62.            .name = "mu609_3g",  
  63.            .owner = THIS_MODULE,  
  64.            },  
  65. };  
  66.   
  67.   
  68. static struct platform_device mu609_device = {  
  69.     .name   = "mu609_3g",  
  70.     .id     = -1,  
  71. };  
  72.   
  73. static int __init mu609_init(void)  
  74. {  
  75.     int ret;  
  76.   
  77.     ret = platform_driver_register(&mu609_driver);  
  78.     if(!ret){  
  79.         ret =  platform_device_register(&mu609_device);  
  80.         if (ret)  
  81.             platform_driver_unregister(&mu609_driver);  
  82.     }  
  83.     return ret;  
  84. }  
  85. late_initcall(mu609_init);  

 

kernel\arch\arm\mach-exynos\Makefile

[plain]  view plain  copy
  1. obj-$(CONFIG_EXYNOS_DEV_MU609)  += setup-mu609.o  


kernel\arch\arm\mach-exynos\Kconfig

[plain]  view plain  copy
  1. config EXYNOS_DEV_MU609  
  2.     bool "3G module MU609"  
  3.     default y  
  4.     help  
  5.       HuaWei mu609.  

 

cat /proc/interrupt可以查看中断有没有开始工作

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值