From patchwork Wed Oct 3 11:20:00 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Figa X-Patchwork-Id: 1540981 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 241133FD56 for ; Wed, 3 Oct 2012 11:20:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753165Ab2JCLUS (ORCPT ); Wed, 3 Oct 2012 07:20:18 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:41489 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753138Ab2JCLUR (ORCPT ); Wed, 3 Oct 2012 07:20:17 -0400 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MBB00D5AE5HI9J0@mailout3.samsung.com>; Wed, 03 Oct 2012 20:20:16 +0900 (KST) X-AuditID: cbfee61b-b7f2b6d000000f14-4d-506c1f70d53c Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 83.FE.03860.07F1C605; Wed, 03 Oct 2012 20:20:16 +0900 (KST) Received: from mcdsrvbld02.digital.local ([106.116.37.23]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MBB001ISE5GJE80@mmp1.samsung.com>; Wed, 03 Oct 2012 20:20:16 +0900 (KST) From: Tomasz Figa To: linux-input@vger.kernel.org Cc: devicetree-discuss@lists.ozlabs.org, linux-samsung-soc@vger.kernel.org, kyungmin.park@samsung.com, m.szyprowski@samsung.com, t.figa@samsung.com, tomasz.figa@gmail.com, dmitry.torokhov@gmail.com Subject: [PATCH] input: keyboard: gpio-keys: Try to parse IRQ from device tree Date: Wed, 03 Oct 2012 13:20:00 +0200 Message-id: <1349263201-422-1-git-send-email-t.figa@samsung.com> X-Mailer: git-send-email 1.7.10 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrLJMWRmVeSWpSXmKPExsVy+t9jAd0C+ZwAg46lchY3P31jtZhxfh+T A5PH501yAYxRXDYpqTmZZalF+nYJXBmL1koVPBWoON3/lrmB8StvFyMnh4SAicTnfReZIWwx iQv31rN1MXJxCAksYpSY83c3M4TTxSSx491MRpAqNgE1ic8Nj4CqODhEBOQlbh0xBalhFjjJ KLHs/mI2kBphAT+Jd4cfgtWwCKhKHD5ZChLmFXCQ2H9vKTvEMnmJp/f72CYwci9gZFjFKJpa kFxQnJSea6RXnJhbXJqXrpecn7uJEezJZ9I7GFc1WBxiFOBgVOLh1eDNDhBiTSwrrsw9xCjB wawkwjtLNidAiDclsbIqtSg/vqg0J7X4EKM0B4uSOG+zR0qAkEB6YklqdmpqQWoRTJaJg1Oq gZHFNCy0Os+gJNvulnofm9CaJm8nM7f/U09wpEeGHTTfe/3Ww+e/2xcwrC7deyRN5urNqc46 X1YYv9hQYtnXdENj1b4s4QChmVZsKZasjhHrfH1uRs9m75zoGHWFffmqFbHiiZOdouXuxRnn 5pVyVmw4ce/DJLPj1teVWpRLM58eEah4ExmxUImlOCPRUIu5qDgRABZZwkngAQAA Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org On modern platforms using device tree and non-legacy IRQ domains there is usually no way to perform direct translation between GPIO and IRQ, because the IRQ of interest is not mapped yet into sparse IRQ namespace. This patch modifies the gpio_keys driver to parse IRQ from device tree and use gpio_to_irq only as a fallback. Signed-off-by: Tomasz Figa --- Documentation/devicetree/bindings/gpio/gpio_keys.txt | 2 ++ drivers/input/keyboard/gpio_keys.c | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/gpio/gpio_keys.txt b/Documentation/devicetree/bindings/gpio/gpio_keys.txt index 5c2c021..7f318a5 100644 --- a/Documentation/devicetree/bindings/gpio/gpio_keys.txt +++ b/Documentation/devicetree/bindings/gpio/gpio_keys.txt @@ -20,6 +20,8 @@ Optional subnode-properties: - debounce-interval: Debouncing interval time in milliseconds. If not specified defaults to 5. - gpio-key,wakeup: Boolean, button can wake-up the system. + - interrupt: Interrupt used for this key (required if no translation + between GPIO and IRQ is available). Example nodes: diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c index 6a68041..a33660c 100644 --- a/drivers/input/keyboard/gpio_keys.c +++ b/drivers/input/keyboard/gpio_keys.c @@ -28,6 +28,7 @@ #include #include #include +#include #include struct gpio_button_data { @@ -464,7 +465,7 @@ static int __devinit gpio_keys_setup_key(struct platform_device *pdev, button->debounce_interval; } - irq = gpio_to_irq(button->gpio); + irq = (button->irq) ? : gpio_to_irq(button->gpio); if (irq < 0) { error = irq; dev_err(dev, @@ -597,6 +598,7 @@ gpio_keys_get_devtree_pdata(struct device *dev) button = &pdata->buttons[i++]; + button->irq = irq_of_parse_and_map(pp, 0); button->gpio = of_get_gpio_flags(pp, 0, &flags); button->active_low = flags & OF_GPIO_ACTIVE_LOW;