add support for registering irq buttons from devtree Signed-off-by: Gong Tao <gongtao0607@xxxxxxxxx> --- 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@xxxxxxxxxxx> + * Copyright 2012 Gong Tao <gongtao0607@xxxxxxxxx> * * 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 -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html