From patchwork Mon May 13 08:53:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 2557161 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork2.kernel.org (Postfix) with ESMTP id 2E695DF2E5 for ; Mon, 13 May 2013 09:00:52 +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 1UboYO-0003Ir-MR; Mon, 13 May 2013 08:56:24 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UboWf-0007ww-4M; Mon, 13 May 2013 08:54:33 +0000 Received: from kirsty.vergenet.net ([202.4.237.240]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UboWS-0007tz-Pt for linux-arm-kernel@lists.infradead.org; Mon, 13 May 2013 08:54:23 +0000 Received: from ayumi.akashicho.tokyo.vergenet.net (p5212-ipbfp1903kobeminato.hyogo.ocn.ne.jp [114.172.132.212]) by kirsty.vergenet.net (Postfix) with ESMTP id AAFA1266CF0; Mon, 13 May 2013 18:53:55 +1000 (EST) Received: by ayumi.akashicho.tokyo.vergenet.net (Postfix, from userid 7100) id 49D576CE06A; Mon, 13 May 2013 17:53:54 +0900 (JST) From: Simon Horman To: linux-sh@vger.kernel.org Subject: [PATCH 3/3] ARM: mach-shmobile: lager: support GPIO switches Date: Mon, 13 May 2013 17:53:53 +0900 Message-Id: <1368435233-8587-4-git-send-email-horms+renesas@verge.net.au> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1368435233-8587-1-git-send-email-horms+renesas@verge.net.au> References: <1368435233-8587-1-git-send-email-horms+renesas@verge.net.au> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130513_045421_391770_84CC7F03 X-CRM114-Status: GOOD ( 13.27 ) X-Spam-Score: -3.2 (---) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-3.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [202.4.237.240 listed in list.dnswl.org] -0.6 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Simon Horman , 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 The lager board has pins 1 - 4 of SW2 wired up to GPIO pins. This patch allows access to those pins as KEYS 1 - 4 using gpio-keys. Signed-off-by: Simon Horman --- This patch has run time dependencies on 1. "gpio-rcar: Add support for IRQ_TYPE_EDGE_BOTH" 2. "ARM: shmobile: r8a7790: Configure R-Car GPIO for IRQ_TYPE_EDGE_BOTH" Without those dependencies satisfied the gpio-keys driver will fail to be initialise itself. The boot should be otherwise successful and the board otherwise functional. --- arch/arm/mach-shmobile/board-lager.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/arch/arm/mach-shmobile/board-lager.c b/arch/arm/mach-shmobile/board-lager.c index 6a1ba38..4d1b42b 100644 --- a/arch/arm/mach-shmobile/board-lager.c +++ b/arch/arm/mach-shmobile/board-lager.c @@ -18,7 +18,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include +#include #include +#include #include #include #include @@ -52,6 +55,22 @@ static struct gpio_led_platform_data lager_leds_pdata = { .num_leds = ARRAY_SIZE(lager_leds), }; +/* GPIO KEY */ +#define GPIO_KEY(c, g, d, ...) \ + { .code = c, .gpio = g, .desc = d, .active_low = 1 } + +static struct gpio_keys_button gpio_buttons[] = { + GPIO_KEY(KEY_4, RCAR_GP_PIN(1, 28), "SW2-pin4"), + GPIO_KEY(KEY_3, RCAR_GP_PIN(1, 26), "SW2-pin3"), + GPIO_KEY(KEY_2, RCAR_GP_PIN(1, 24), "SW2-pin2"), + GPIO_KEY(KEY_1, RCAR_GP_PIN(1, 14), "SW2-pin1"), +}; + +static struct gpio_keys_platform_data lager_keys_pdata = { + .buttons = gpio_buttons, + .nbuttons = ARRAY_SIZE(gpio_buttons), +}; + static const struct pinctrl_map lager_pinctrl_map[] = { /* SCIF0 (CN19: DEBUG SERIAL0) */ PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.6", "pfc-r8a7790", @@ -73,6 +92,9 @@ static void __init lager_add_standard_devices(void) platform_device_register_data(&platform_bus, "leds-gpio", -1, &lager_leds_pdata, sizeof(lager_leds_pdata)); + platform_device_register_data(&platform_bus, "gpio-keys", -1, + &lager_keys_pdata, + sizeof(lager_keys_pdata)); } static const char *lager_boards_compat_dt[] __initdata = {