#include <linux/module.h>
#include <linux/init.h>
#include <linux/fs.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/sched.h>
#include <linux/pm.h>
#include <linux/sysctl.h>
#include <linux/proc_fs.h>
#include <linux/delay.h>
#include <linux/platform_device.h>
#include <linux/input.h>
#include <linux/io.h>
struct pin_desc {
int irq;
int pin;
int val;
char *name;
};
static struct pin_desc pins_desc[] = {
{S3C_EINT(0), 0, KEY_TAB, "S2"},
{S3C_EINT(1), 1, KEY_LEFTSHIFT, "S3"},
{S3C_EINT(2), 2, KEY_L, "S4"},
{S3C_EINT(3), 3, KEY_ENTER, "S5"},
{S3C_EINT(4), 4, KEY_BACKSPACE, "S6"},
{S3C_EINT(5), 5, KEY_S, "S7"},
};
static struct input_dev *buttons_dev;
static volatile unsigned long *gpndat;
static irqreturn_t buttons_irq(int irq, void *dev_id)
{
int pin_val;
struct pin_desc *pd = (struct pin_desc *)dev_id;
pin_val = *gpndat & (1<<pd->pin);
if (pin_val)
{
input_event(buttons_dev, EV_KEY, pd->val, 0);
input_sync(buttons_dev);
}
else
{
input_event(buttons_dev, EV_KEY, pd->val, 1);
input_sync(buttons_dev);
}
return IRQ_HANDLED;
}
static int buttons_init(void)
{
int i;
buttons_dev = input_allocate_device();
set_bit(EV_KEY, buttons_dev->evbit);
set_bit(EV_REP, buttons_dev->evbit);
set_bit(KEY_L, buttons_dev->keybit);
set_bit(KEY_S, buttons_dev->keybit);
set_bit(KEY_ENTER, buttons_dev->keybit);
set_bit(KEY_LEFTSHIFT, buttons_dev->keybit);
set_bit(KEY_BACKSPACE, buttons_dev->keybit);
set_bit(KEY_TAB, buttons_dev->keybit);
input_register_device(buttons_dev);
gpndat = ioremap(0x7F008834, 4);
for (i = 0; i < 6; i++)
{
request_irq(pins_desc[i].irq, buttons_irq, IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING, pins_desc[i].name, &pins_desc[i]);
}
return 0;
}
static void buttons_exit(void)
{
int i;
for (i = 0; i < 6; i++)
{
free_irq(pins_desc[i].irq, &pins_desc[i]);
}
iounmap(gpndat);
input_unregister_device(buttons_dev);
input_free_device(buttons_dev);
}
module_init(buttons_init);
module_exit(buttons_exit);
MODULE_LICENSE("GPL");