lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [day] [month] [year] [list]
Date:	Mon, 27 Aug 2012 16:15:23 +0800
From:	Gong Tao <gongtao0607@...il.com>
To:	dmitry.torokhov@...il.com
Cc:	linux-input@...r.kernel.org, linux-kernel@...r.kernel.org,
	Gong Tao <gongtao0607@...il.com>
Subject: [PATCH] gpio-keys: register irq buttons from devtree

add support for registering irq buttons from devtree

Signed-off-by: Gong Tao <gongtao0607@...il.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@...tonic.nl>
+ * Copyright 2012 Gong Tao <gongtao0607@...il.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", &reg) == 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", &reg)) {
 			dev_err(dev, "Button without keycode: 0x%x\n", buttons[i].gpio);
-- 
1.7.12

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ