From patchwork Fri May 24 09:47:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Damm X-Patchwork-Id: 2610871 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork1.kernel.org (Postfix) with ESMTP id 5857F3FD4E for ; Fri, 24 May 2013 12:20:48 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Ufofw-0000oj-BT; Fri, 24 May 2013 09:52:46 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Ufoca-0002Dl-Jx; Fri, 24 May 2013 09:49:12 +0000 Received: from mail-pb0-x22e.google.com ([2607:f8b0:400e:c01::22e]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UfobG-000270-R8 for linux-arm-kernel@lists.infradead.org; Fri, 24 May 2013 09:47:52 +0000 Received: by mail-pb0-f46.google.com with SMTP id rq2so4035147pbb.19 for ; Fri, 24 May 2013 02:47:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:date:message-id:subject; bh=lLz3yklUopFi3Y1eOGj20R3XULP5oUaMDbyDqVMx+dI=; b=w/ReV8aCjji7/a0G8M5NfG4SDqRPkCqYUzaQ8xqvk4U1xBUllXHxmP7lbkISf+LUzb QJIR6djKkcdIn+K+PGTRxmGnwIHDRX+OUHOg6Rq29Tc6xxtd04tDldD1smSKNPXqJsqg HSv9hA8uFe4STJ2Ht4cz+susHKhMHrjClhbxIjZJmtzPlq+jrLrLwrHQHdpkv+H/DRV4 WNNk8/po674CRkkQU+jIIksS8JQB7FmEIlwMVZK/dNUITZ9gmFUiyAl7fnXLgZUfhrdY t7EbQcbxJIeCEm51Qt7sSpYuroYvUp1pFLN0yTrTzbiomjbiibkTHaOBO3Ylmmx/PNfV NMLg== X-Received: by 10.68.226.39 with SMTP id rp7mr16818694pbc.97.1369388844990; Fri, 24 May 2013 02:47:24 -0700 (PDT) Received: from [127.0.0.1] (x242027.ppp.asahi-net.or.jp. [122.249.242.27]) by mx.google.com with ESMTPSA id b7sm15533606pba.39.2013.05.24.02.47.22 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 24 May 2013 02:47:23 -0700 (PDT) From: Magnus Damm To: linux-sh@vger.kernel.org Date: Fri, 24 May 2013 18:47:24 +0900 Message-Id: <20130524094724.1510.80331.sendpatchset@w520> Subject: [PATCH v2] gpio-rcar: Add support for IRQ_TYPE_EDGE_BOTH X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130524_054751_041207_93A48841 X-CRM114-Status: GOOD ( 14.34 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (magnus.damm[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: horms+renesas@verge.net.au, Magnus Damm , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Simon Horman As hardware support for this feature is not universal for all SoCs a flag, has_both_edge_trigger, has been added to the platform data of the driver to allow this feature to be enabled. The motivation for this is to allow use of the gpio-keys driver on the lager board which is based on the r8a7790 SoC. The V2 of this patch has been fully exercised using that driver on that board. Signed-off-by: Simon Horman Signed-off-by: Magnus Damm --- Changes since V1: - Modified code to always set BOTHEDGE register if available - Set BOTHEDGE before IOINTSEL - Successfully tested triggering on both edges with SW2 on Lager drivers/gpio/gpio-rcar.c | 26 +++++++++++++++++++++----- include/linux/platform_data/gpio-rcar.h | 1 + 2 files changed, 22 insertions(+), 5 deletions(-) --- 0001/drivers/gpio/gpio-rcar.c +++ work/drivers/gpio/gpio-rcar.c 2013-05-24 18:39:54.000000000 +0900 @@ -49,6 +49,7 @@ struct gpio_rcar_priv { #define POSNEG 0x20 #define EDGLEVEL 0x24 #define FILONOFF 0x28 +#define BOTHEDGE 0x4c static inline u32 gpio_rcar_read(struct gpio_rcar_priv *p, int offs) { @@ -91,7 +92,8 @@ static void gpio_rcar_irq_enable(struct static void gpio_rcar_config_interrupt_input_mode(struct gpio_rcar_priv *p, unsigned int hwirq, bool active_high_rising_edge, - bool level_trigger) + bool level_trigger, + bool both) { unsigned long flags; @@ -108,6 +110,10 @@ static void gpio_rcar_config_interrupt_i /* Configure edge or level trigger in EDGLEVEL */ gpio_rcar_modify_bit(p, EDGLEVEL, hwirq, !level_trigger); + /* Select one edge or both edges in BOTHEDGE */ + if (p->config.has_both_edge_trigger) + gpio_rcar_modify_bit(p, BOTHEDGE, hwirq, both); + /* Select "Interrupt Input Mode" in IOINTSEL */ gpio_rcar_modify_bit(p, IOINTSEL, hwirq, true); @@ -127,16 +133,26 @@ static int gpio_rcar_irq_set_type(struct switch (type & IRQ_TYPE_SENSE_MASK) { case IRQ_TYPE_LEVEL_HIGH: - gpio_rcar_config_interrupt_input_mode(p, hwirq, true, true); + gpio_rcar_config_interrupt_input_mode(p, hwirq, true, true, + false); break; case IRQ_TYPE_LEVEL_LOW: - gpio_rcar_config_interrupt_input_mode(p, hwirq, false, true); + gpio_rcar_config_interrupt_input_mode(p, hwirq, false, true, + false); break; case IRQ_TYPE_EDGE_RISING: - gpio_rcar_config_interrupt_input_mode(p, hwirq, true, false); + gpio_rcar_config_interrupt_input_mode(p, hwirq, true, false, + false); break; case IRQ_TYPE_EDGE_FALLING: - gpio_rcar_config_interrupt_input_mode(p, hwirq, false, false); + gpio_rcar_config_interrupt_input_mode(p, hwirq, false, false, + false); + break; + case IRQ_TYPE_EDGE_BOTH: + if (!p->config.has_both_edge_trigger) + return -EINVAL; + gpio_rcar_config_interrupt_input_mode(p, hwirq, true, false, + true); break; default: return -EINVAL; --- 0001/include/linux/platform_data/gpio-rcar.h +++ work/include/linux/platform_data/gpio-rcar.h 2013-05-24 18:25:06.000000000 +0900 @@ -21,6 +21,7 @@ struct gpio_rcar_config { unsigned int irq_base; unsigned int number_of_pins; const char *pctl_name; + unsigned has_both_edge_trigger:1; }; #define RCAR_GP_PIN(bank, pin) (((bank) * 32) + (pin))