From: Gong Tao <gongtao0607@gmail.com>
To: dmitry.torokhov@gmail.com
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
Gong Tao <gongtao0607@gmail.com>
Subject: [PATCH] gpio-keys: register irq buttons from devtree
Date: Mon, 27 Aug 2012 16:15:23 +0800 [thread overview]
Message-ID: <1346055323-12941-1-git-send-email-gongtao0607@gmail.com> (raw)
add support for registering irq buttons from devtree
Signed-off-by: Gong Tao <gongtao0607@gmail.com>
---
drivers/input/keyboard/gpio_keys.c | 64 +++++++++++++++++++++++++++++++++++---
1 file changed, 59 insertions(+), 5 deletions(-)
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index 62bfce4..a89f101 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -3,12 +3,60 @@
*
* Copyright 2005 Phil Blundell
* Copyright 2010, 2011 David Jander <david@protonic.nl>
+ * Copyright 2012 Gong Tao <gongtao0607@gmail.com>
*
* 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.
*/
+/*
+ * Device tree configuration:
+ *
+ * Properties:
+ * - compatible : "gpio-keys"
+ * - interrupts : all interrupt numbers used by keys
+ * - autorepeat : optional, enable input subsystem auto repeat
+ *
+ * Child properties: please reffer to struct gpio_keys_button
+ * - label : gpio_keys_button.desc
+ * - gpios : gpio_keys_button.gpio
+ * - irq : gpio_keys_button.irq
+ * - linux,code : gpio_keys_button.code
+ * - linux,input-type : gpio_keys_button.type
+ * optional, default EV_KEY
+ * - gpio-key,wakeup : gpio_keys_button.wakeup
+ * optional
+ * - debounce-interval : gpio_keys_button.debounce_interval
+ * optional, default 5
+ * Example:
+ *
+ * gpio_keys {
+ * compatible = "gpio-keys";
+ * interrupts = <25>;
+ * autorepeat;
+ *
+ * key1 { //GPIO Button
+ * label = "key1";
+ * gpios = <&gpio0 7 0>;
+ * linux,code = <105>;
+ * linux,input-type = <1>;
+ * gpio-key,wakeup;
+ * debounce-interval = <5>;
+ * };
+ *
+ * key2 { //IRQ Button
+ * label = "key2";
+ * irq = <25>;
+ * linux,code = <106>;
+ * linux,input-type = <1>;
+ * gpio-key,wakeup;
+ * debounce-interval = <5>;
+ * };
+ * };
+ *
+ */
+
#include <linux/module.h>
#include <linux/init.h>
@@ -577,12 +625,18 @@ static int gpio_keys_get_devtree_pdata(struct device *dev,
enum of_gpio_flags flags;
if (!of_find_property(pp, "gpios", NULL)) {
- pdata->nbuttons--;
- dev_warn(dev, "Found button without gpios\n");
- continue;
+ if (of_property_read_u32(pp, "irq", ®) == 0) {
+ buttons[i].gpio = -1;
+ buttons[i].irq = reg;
+ } else {
+ pdata->nbuttons--;
+ dev_warn(dev, "Found button without gpios and irq\n");
+ continue;
+ }
+ } else {
+ buttons[i].gpio = of_get_gpio_flags(pp, 0, &flags);
+ buttons[i].active_low = flags & OF_GPIO_ACTIVE_LOW;
}
- buttons[i].gpio = of_get_gpio_flags(pp, 0, &flags);
- buttons[i].active_low = flags & OF_GPIO_ACTIVE_LOW;
if (of_property_read_u32(pp, "linux,code", ®)) {
dev_err(dev, "Button without keycode: 0x%x\n", buttons[i].gpio);
--
1.7.12
reply other threads:[~2012-08-27 8:15 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1346055323-12941-1-git-send-email-gongtao0607@gmail.com \
--to=gongtao0607@gmail.com \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).