- UID
- 1029342
- 性别
- 男
|
/*gpio_mod.c*/
#include <linux/module.h>
#include <linux/init.h>
#include <linux/config.h>
#include <linux/errno.h>
#include <linux/kernel.h>
#include <linux/major.h>
#include <linux/sched.h>
#include <linux/devfs_fs_kernel.h>
#include <linux/slab.h>
#include <linux/fcntl.h>
#include <linux/delay.h>
#include <linux/poll.h>
#include <linux/console.h>
#include <linux/parport.h>
#include <linux/lp.h>
#include <linux/interrupt.h>
#include <asm/arch-s3c2410/irqs.h>
#include <asm/uaccess.h>
#include <asm/arch-s3c2410/regs-serial.h>
#include <asm/arch-s3c2410/regs-irq.h>
#define keyirq_MAJOR 242
#define NOKEY '0'
#define KEY1 '1'
#define KEY2 '2'
#define KEY3 '3'
#define KEY4 '4'
#define KEY5 '5'
static struct semaphore key_sem;
static char key=NOKEY;
static void inline clearIrq(void)
{
/*respond to EINT4-EINT7*/
__raw_writel(0xf0, S3C2410_EINTPEND);
__raw_writel(0x13, S3C2410_SRCPND);
__raw_writel(0x13, S3C2410_INTPND);
}
static void key1_irq_isr(int irq, void *dev_id, struct pt_regs *regs)
{
clearIrq();
key = KEY1;
up(&key_sem);
// return 0;
}
static irqreturn_t key2_irq_isr(int irq, void *dev_id, struct pt_regs *regs)
{
clearIrq();
key = KEY2;
up(&key_sem);
return 0;
}
static irqreturn_t key3_irq_isr(int irq, void *dev_id, struct pt_regs *regs)
{
clearIrq();
key = KEY3;
up(&key_sem);
return 0;
}
static ssize_t keyirq_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos)
{
down_interruptible(&key_sem);
put_user(key, buf);
key = NOKEY;
return 1;
} |
|