Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 47817
b: refs/heads/master
c: 78a56aa
h: refs/heads/master
i:
  47815: df886e6
v: v3
  • Loading branch information
Phil Blundell authored and Dmitry Torokhov committed Jan 18, 2007
1 parent c93ce93 commit d61646a
Show file tree
Hide file tree
Showing 5 changed files with 184 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 285b0b62bc8f1a3cb18ce3f2d9806f1d99736784
refs/heads/master: 78a56aab11234e53b7e94e5a255cc3d27ab0a62b
19 changes: 16 additions & 3 deletions trunk/drivers/input/keyboard/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,12 @@ config KEYBOARD_STOWAWAY
config KEYBOARD_CORGI
tristate "Corgi keyboard"
depends on PXA_SHARPSL
default y
default y
help
Say Y here to enable the keyboard on the Sharp Zaurus SL-C7xx
Say Y here to enable the keyboard on the Sharp Zaurus SL-C7xx
series of PDAs.

To compile this driver as a module, choose M here: the
To compile this driver as a module, choose M here: the
module will be called corgikbd.

config KEYBOARD_SPITZ
Expand Down Expand Up @@ -214,4 +214,17 @@ config KEYBOARD_AAED2000
To compile this driver as a module, choose M here: the
module will be called aaed2000_kbd.

config KEYBOARD_GPIO
tristate "Buttons on CPU GPIOs (PXA)"
depends on ARCH_PXA
help
This driver implements support for buttons connected
directly to GPIO pins of PXA CPUs.

Say Y here if your device has buttons connected
directly to GPIO pins of the CPU.

To compile this driver as a module, choose M here: the
module will be called gpio-keys.

endif
5 changes: 3 additions & 2 deletions trunk/drivers/input/keyboard/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ obj-$(CONFIG_KEYBOARD_CORGI) += corgikbd.o
obj-$(CONFIG_KEYBOARD_SPITZ) += spitzkbd.o
obj-$(CONFIG_KEYBOARD_HIL) += hil_kbd.o
obj-$(CONFIG_KEYBOARD_HIL_OLD) += hilkbd.o
obj-$(CONFIG_KEYBOARD_OMAP) += omap-keypad.o
obj-$(CONFIG_KEYBOARD_AAED2000) += aaed2000_kbd.o
obj-$(CONFIG_KEYBOARD_OMAP) += omap-keypad.o
obj-$(CONFIG_KEYBOARD_AAED2000) += aaed2000_kbd.o
obj-$(CONFIG_KEYBOARD_GPIO) += gpio_keys.o

147 changes: 147 additions & 0 deletions trunk/drivers/input/keyboard/gpio_keys.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
/*
* Driver for keys on GPIO lines capable of generating interrupts.
*
* Copyright 2005 Phil Blundell
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/

#include <linux/module.h>
#include <linux/version.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/irq.h>

#include <asm/arch/pxa-regs.h>
#include <asm/arch/hardware.h>

#include <asm/hardware/gpio_keys.h>

static irqreturn_t gpio_keys_isr(int irq, void *dev_id)
{
int i;
struct platform_device *pdev = dev_id;
struct gpio_keys_platform_data *pdata = pdev->dev.platform_data;
struct input_dev *input = platform_get_drvdata(pdev);

for (i = 0; i < pdata->nbuttons; i++) {
int gpio = pdata->buttons[i].gpio;
if (irq == IRQ_GPIO(gpio)) {
int state = ((GPLR(gpio) & GPIO_bit(gpio)) ? 1 : 0) ^ (pdata->buttons[i].active_low);

input_report_key(input, pdata->buttons[i].keycode, state);
input_sync(input);
}
}

return IRQ_HANDLED;
}

static int __devinit gpio_keys_probe(struct platform_device *pdev)
{
struct gpio_keys_platform_data *pdata = pdev->dev.platform_data;
struct input_dev *input;
int i, error;

input = input_allocate_device();
if (!input)
return -ENOMEM;

platform_set_drvdata(pdev, input);

input->evbit[0] = BIT(EV_KEY);

input->name = pdev->name;
input->phys = "gpio-keys/input0";
input->cdev.dev = &pdev->dev;
input->private = pdata;

input->id.bustype = BUS_HOST;
input->id.vendor = 0x0001;
input->id.product = 0x0001;
input->id.version = 0x0100;

for (i = 0; i < pdata->nbuttons; i++) {
int code = pdata->buttons[i].keycode;
int irq = IRQ_GPIO(pdata->buttons[i].gpio);

set_irq_type(irq, IRQ_TYPE_EDGE_BOTH);
error = request_irq(irq, gpio_keys_isr, SA_SAMPLE_RANDOM,
pdata->buttons[i].desc ? pdata->buttons[i].desc : "gpio_keys",
pdev);
if (error) {
printk(KERN_ERR "gpio-keys: unable to claim irq %d; error %d\n", irq, ret);
goto fail;
}
set_bit(code, input->keybit);
}

error = input_register_device(input);
if (error) {
printk(KERN_ERR "Unable to register gpio-keys input device\n");
goto fail;
}

return 0;

fail:
for (i = i - 1; i >= 0; i--)
free_irq(IRQ_GPIO(pdata->buttons[i].gpio), pdev);

input_free_device(input);

return error;
}

static int __devexit gpio_keys_remove(struct platform_device *pdev)
{
struct gpio_keys_platform_data *pdata = pdev->dev.platform_data;
struct input_dev *input = platform_get_drvdata(pdev);
int i;

for (i = 0; i < pdata->nbuttons; i++) {
int irq = IRQ_GPIO(pdata->buttons[i].gpio);
free_irq(irq, pdev);
}

input_unregister_device(input);

return 0;
}

struct platform_driver gpio_keys_device_driver = {
.probe = gpio_keys_probe,
.remove = __devexit_p(gpio_keys_remove),
.driver = {
.name = "gpio-keys",
}
};

static int __init gpio_keys_init(void)
{
return platform_driver_register(&gpio_keys_device_driver);
}

static void __exit gpio_keys_exit(void)
{
platform_driver_unregister(&gpio_keys_device_driver);
}

module_init(gpio_keys_init);
module_exit(gpio_keys_exit);

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Phil Blundell <pb@handhelds.org>");
MODULE_DESCRIPTION("Keyboard driver for CPU GPIOs");
17 changes: 17 additions & 0 deletions trunk/include/asm-arm/hardware/gpio_keys.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#ifndef _GPIO_KEYS_H
#define _GPIO_KEYS_H

struct gpio_keys_button {
/* Configuration parameters */
int keycode;
int gpio;
int active_low;
char *desc;
};

struct gpio_keys_platform_data {
struct gpio_keys_button *buttons;
int nbuttons;
};

#endif

0 comments on commit d61646a

Please sign in to comment.