From patchwork Mon Aug 27 08:15:23 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gong Tao X-Patchwork-Id: 1376851 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 16658DF215 for ; Mon, 27 Aug 2012 08:15:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752902Ab2H0IPg (ORCPT ); Mon, 27 Aug 2012 04:15:36 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:41138 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752805Ab2H0IPe (ORCPT ); Mon, 27 Aug 2012 04:15:34 -0400 Received: by pbbrr13 with SMTP id rr13so7011464pbb.19 for ; Mon, 27 Aug 2012 01:15:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=Txex04htRczwdSegoHAbKEAqwbfZqIjVfw+OcEpKYzg=; b=Y/dFpauMtLtVRg0ks3mmuOPOl/eGNND3nkY7qQs/7rroZDcHGFuAnnXVO6NFjZ0YRj Tg7qV2lL6uMFKBRL0Uqu+oxtFgT4uDNbG+2R1t6RFBd6+L0iiHWrOqAa6btEcI1Nz9D5 msdNomdGRmLGpXHSfglw42IzSAcO5t1Ak47ccbxLvTBiWQXOnUMkngcotFDJQxVca4Yp 5ej+53xRYjg6EvD9wmmckLecGoiorG8aovaRYZiITH5oguCJKRvRGUvuVgMPWYcAgbdT DpdtiapGEvKz27VGJjtRBb/J3XQNjVi7HNV7eDnSOZYSegIZUOQipFHtF+6ddfnueMdL 1gLg== Received: by 10.66.74.195 with SMTP id w3mr28276642pav.64.1346055334569; Mon, 27 Aug 2012 01:15:34 -0700 (PDT) Received: from Dyke.localdomain ([125.116.249.49]) by mx.google.com with ESMTPS id rm9sm14197885pbc.72.2012.08.27.01.15.30 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 27 Aug 2012 01:15:34 -0700 (PDT) From: Gong Tao To: dmitry.torokhov@gmail.com Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Gong Tao Subject: [PATCH] gpio-keys: register irq buttons from devtree Date: Mon, 27 Aug 2012 16:15:23 +0800 Message-Id: <1346055323-12941-1-git-send-email-gongtao0607@gmail.com> X-Mailer: git-send-email 1.7.12 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org add support for registering irq buttons from devtree Signed-off-by: Gong Tao --- 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 + * Copyright 2012 Gong Tao * * 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 #include @@ -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);