aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Stein <alexander.stein@systec-electronic.com>2014-11-25 14:53:45 -0500
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2014-12-03 18:28:39 -0500
commitf2d347ff70be453e861304448cb2f32ff94d40e9 (patch)
tree206349299d3784d12d9c6eae11f299bb94a9a2ae
parente147af492e6c80855550908c86d6d11a501cbfaf (diff)
Input: gpio_keys - add device tree support for interrupt only keys
This features already exists for board config setups. Add support for device tree based systems. Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r--Documentation/devicetree/bindings/input/gpio-keys.txt10
-rw-r--r--drivers/input/keyboard/gpio_keys.c34
2 files changed, 29 insertions, 15 deletions
diff --git a/Documentation/devicetree/bindings/input/gpio-keys.txt b/Documentation/devicetree/bindings/input/gpio-keys.txt
index 5c2c02140a62..a4a38fcf2ed6 100644
--- a/Documentation/devicetree/bindings/input/gpio-keys.txt
+++ b/Documentation/devicetree/bindings/input/gpio-keys.txt
@@ -10,10 +10,13 @@ Optional properties:
10Each button (key) is represented as a sub-node of "gpio-keys": 10Each button (key) is represented as a sub-node of "gpio-keys":
11Subnode properties: 11Subnode properties:
12 12
13 - gpios: OF device-tree gpio specification.
14 - label: Descriptive name of the key. 13 - label: Descriptive name of the key.
15 - linux,code: Keycode to emit. 14 - linux,code: Keycode to emit.
16 15
16Required mutual exclusive subnode-properties:
17 - gpios: OF device-tree gpio specification.
18 - interrupts: the interrupt line for that input
19
17Optional subnode-properties: 20Optional subnode-properties:
18 - linux,input-type: Specify event type this button/key generates. 21 - linux,input-type: Specify event type this button/key generates.
19 If not specified defaults to <1> == EV_KEY. 22 If not specified defaults to <1> == EV_KEY.
@@ -33,4 +36,9 @@ Example nodes:
33 linux,code = <103>; 36 linux,code = <103>;
34 gpios = <&gpio1 0 1>; 37 gpios = <&gpio1 0 1>;
35 }; 38 };
39 button@22 {
40 label = "GPIO Key DOWN";
41 linux,code = <108>;
42 interrupts = <1 IRQ_TYPE_LEVEL_HIGH 7>;
43 };
36 ... 44 ...
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index 8c98e97f8e41..ce0d9090bbe9 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -29,6 +29,7 @@
29#include <linux/of.h> 29#include <linux/of.h>
30#include <linux/of_platform.h> 30#include <linux/of_platform.h>
31#include <linux/of_gpio.h> 31#include <linux/of_gpio.h>
32#include <linux/of_irq.h>
32#include <linux/spinlock.h> 33#include <linux/spinlock.h>
33 34
34struct gpio_button_data { 35struct gpio_button_data {
@@ -617,28 +618,33 @@ gpio_keys_get_devtree_pdata(struct device *dev)
617 618
618 i = 0; 619 i = 0;
619 for_each_child_of_node(node, pp) { 620 for_each_child_of_node(node, pp) {
620 int gpio; 621 int gpio = -1;
622 int irq;
621 enum of_gpio_flags flags; 623 enum of_gpio_flags flags;
622 624
623 if (!of_find_property(pp, "gpios", NULL)) { 625 if (!of_find_property(pp, "gpios", NULL)) {
624 pdata->nbuttons--; 626 irq = irq_of_parse_and_map(pp, 0);
625 dev_warn(dev, "Found button without gpios\n"); 627 if (irq == 0) {
626 continue; 628 pdata->nbuttons--;
627 } 629 dev_warn(dev, "Found button without gpios or irqs\n");
628 630 continue;
629 gpio = of_get_gpio_flags(pp, 0, &flags); 631 }
630 if (gpio < 0) { 632 } else {
631 error = gpio; 633 gpio = of_get_gpio_flags(pp, 0, &flags);
632 if (error != -EPROBE_DEFER) 634 if (gpio < 0) {
633 dev_err(dev, 635 error = gpio;
634 "Failed to get gpio flags, error: %d\n", 636 if (error != -EPROBE_DEFER)
635 error); 637 dev_err(dev,
636 return ERR_PTR(error); 638 "Failed to get gpio flags, error: %d\n",
639 error);
640 return ERR_PTR(error);
641 }
637 } 642 }
638 643
639 button = &pdata->buttons[i++]; 644 button = &pdata->buttons[i++];
640 645
641 button->gpio = gpio; 646 button->gpio = gpio;
647 button->irq = irq;
642 button->active_low = flags & OF_GPIO_ACTIVE_LOW; 648 button->active_low = flags & OF_GPIO_ACTIVE_LOW;
643 649
644 if (of_property_read_u32(pp, "linux,code", &button->code)) { 650 if (of_property_read_u32(pp, "linux,code", &button->code)) {