/*
*
*/
#include <linux/module.h>
#include <linux/version.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/fs.h>
#include <linux/interrupt.h>
#include <linux/time.h>
#include <linux/spinlock.h>
#include <linux/irq.h>
#include <linux/poll.h>
#include <linux/delay.h>
#include <asm/uaccess.h>
#include <mach/regs-gpio.h>
#include <asm/io.h>
#include <linux/cdev.h>
#include <linux/ioctl.h>
#include <linux/device.h>
#include <linux/gpio.h>
#include <linux/ioport.h>
MODULE_LICENSE("Dual BSD/GPL");
struct key_intr
{
struct resource * r;
unsigned long *GPH3CON, GPH3DAT;
int irq;
};
struct key_intr k9 = {
.r = NULL,
.irq = IRQ_EINT(27),
};
void button_gpio_init(void)
{
k9.r = request_mem_region(0xE0200C60, 8, "GPH3");
if (k9.r == NULL)
{
}
k9.GPH3CON = ioremap(0xE0200C60, 4);
k9.GPH3DAT = ioremap(0xE0200C64, 4);
unsigned long r = ioread32(k9.GPH3CON);
r |= (0xf << 12);
iowrite32(r, k9.GPH3CON);
set_irq_type(k9.irq, IRQ_TYPE_EDGE_BOTH);
}
irqreturn_t key_handler(int irq, void *devid)
{
printk("__gpio_get_value(S5PV210_GPH3(3)) = %d\n",__gpio_get_value(S5PV210_GPH3(3)));
// __gpio_get_value(S5PV210_GPH3(3));
return IRQ_HANDLED;
}
static int button_init(void)
{
int result;
button_gpio_init();
result = request_irq (IRQ_EINT(27), key_handler,IRQF_SHARED, "k9", &k9);
if (result) {
printk(KERN_INFO "button: can't get assigned irq\n");
}
return 0;
}
static void button_cleanup(void)
{
printk("simple device uninstalled\n");
iounmap(k9.GPH3CON);
iounmap(k9.GPH3DAT);
release_mem_region(k9.r->start, 8);
free_irq(IRQ_EINT(27), &k9);
}
module_init(button_init);
module_exit(button_cleanup);
按键中断驱动
最新推荐文章于 2024-01-04 14:43:31 发布