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

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

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

#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/skbuff.h>

#include <plat/devs.h>
#include <plat/sdhci.h>
#include <plat/gpio-cfg.h>
#include <mach/regs-gpio.h>
#include <mach/gpio.h>
#include <linux/irq.h>
#include <linux/interrupt.h>
#include <linux/module.h>

static irqreturn_t host_wake_isr(int irq, void *dev)
{
	/*
	   do something when interrupt happen
	*/
	return IRQ_HANDLED;
}

static int mu609_probe(struct platform_device *pdev)
{
	int irq;
	int ret;
	
	printk("%s: start\n", __FUNCTION__);

	s3c_gpio_cfgpin(EXYNOS5410_GPX3(1), S3C_GPIO_INPUT); //stone++ for mu609
	s3c_gpio_setpull(EXYNOS5410_GPX3(1), S3C_GPIO_PULL_UP); //stone++ for mu609
	
	irq = IRQ_EINT(25);
	ret = request_irq(irq, host_wake_isr, IRQF_TRIGGER_FALLING,
		"3g mu609_wake", NULL);
	if (ret) {
		pr_err("[3G] Request_host wake irq failed.\n");
		return ret;
	}

	ret = irq_set_irq_wake(irq, 1);
	if (ret) {
		pr_err("[3G] Set_irq_wake failed.\n");
		return ret;
	}
	
	return ret;
}

static int mu609_remove(struct platform_device *pdev)
{
	return 0;
}


static struct platform_driver mu609_driver = {
	.probe = mu609_probe,
	.remove = mu609_remove,
	.driver = {
		   .name = "mu609_3g",
		   .owner = THIS_MODULE,
		   },
};


static struct platform_device mu609_device = {
	.name	= "mu609_3g",
	.id		= -1,
};

static int __init mu609_init(void)
{
	int ret;

	ret = platform_driver_register(&mu609_driver);
	if(!ret){
		ret =  platform_device_register(&mu609_device);
		if (ret)
			platform_driver_unregister(&mu609_driver);
	}
	return ret;
}
late_initcall(mu609_init);

 

kernel\arch\arm\mach-exynos\Makefile

obj-$(CONFIG_EXYNOS_DEV_MU609)  += setup-mu609.o


kernel\arch\arm\mach-exynos\Kconfig

config EXYNOS_DEV_MU609
	bool "3G module MU609"
	default y
	help
	  HuaWei mu609.

 

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

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

suntao222

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值