From patchwork Thu Sep 6 07:59:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 10589981 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DA7E36CB for ; Thu, 6 Sep 2018 07:59:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BEEB92A3A5 for ; Thu, 6 Sep 2018 07:59:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B2C6E2A4E9; Thu, 6 Sep 2018 07:59:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5224D2A3A5 for ; Thu, 6 Sep 2018 07:59:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728134AbeIFMdf (ORCPT ); Thu, 6 Sep 2018 08:33:35 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:45897 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728132AbeIFMdf (ORCPT ); Thu, 6 Sep 2018 08:33:35 -0400 Received: by mail-lj1-f194.google.com with SMTP id u83-v6so8480321lje.12 for ; Thu, 06 Sep 2018 00:59:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4rWgSaidxSf3WayfOVM6Uc0/KOIGkkaRLG+kNBpbt+8=; b=BTWiyIAVLKPz7OOytYqjIwPROlzbZI43HX9lN1kjn12lclV+kHCegmq7IQ21dZs7u8 fWwARusR9XbosMav4pQjOtglLVd78u/ny06q9u+nXkXhZo86sc9i10EUEs63gpV8dZeT uFisOE8Db9ngAl6FWs+pbX5g9k2C/npi+B7KQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4rWgSaidxSf3WayfOVM6Uc0/KOIGkkaRLG+kNBpbt+8=; b=Y0IJq34RfONiZ+ztRaBDpTpSiCfmhOPKeIJMDYsJ+sMWgSAWz+MfKYObAxMcZ4Dccz TdtTLLhbXYE22qOOhcH7I1lQzz+OZ/O7GoXtFxF4o0JsRlnUa9DllzRj+NgBAVHDCGow BEPxe9rDVY5caSuc9UAO83+c56RLKODePytil9K7gXw/KsW3CNz3RTYLW8gtO4pWXnK3 SCU/e/bbYi908LoXHzvTD9/XN1XS2VQVlRkHtQ4c6GYfOYDSOgNnurZHnXPU9QO51gJt 6dDuV7SIXMAa8vdYmJ76zGjSaU1c66GXqTTZlOQqk5Z3+eL5qFzD/o64eDjjAYjih6MD 0auQ== X-Gm-Message-State: APzg51CGgroPpLEEINIEsffah1vobTldpuWIIB47a8s4JayM/bA1GFGy R3yuxyO1TZH/HmsTwEM5ctA+/A== X-Google-Smtp-Source: ANB0VdbecuqwMcmTpS7IqvbnHw4lKCCp4QKgVqK46qQDxymO4O1jdxjFyINnZ1SpWasyFu0P5/daqQ== X-Received: by 2002:a2e:54b:: with SMTP id 72-v6mr1094050ljf.152.1536220762153; Thu, 06 Sep 2018 00:59:22 -0700 (PDT) Received: from localhost.bredbandsbolaget (c-ae7b71d5.014-348-6c756e10.bbcust.telenor.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id f129-v6sm690869lff.37.2018.09.06.00.59.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Sep 2018 00:59:20 -0700 (PDT) From: Linus Walleij To: Dmitry Torokhov , linux-input@vger.kernel.org, linux-gpio@vger.kernel.org Cc: Andy Shevchenko , "Rafael J . Wysocki" , Sakari Ailus , Linus Walleij Subject: [PATCH 3/3] RFC: ARM: simone: Hacked in keys Date: Thu, 6 Sep 2018 09:59:02 +0200 Message-Id: <20180906075902.31240-4-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180906075902.31240-1-linus.walleij@linaro.org> References: <20180906075902.31240-1-linus.walleij@linaro.org> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This serves as an illustration of how to use the gpio-keys in boardfiles with just a machine GPIO descriptor table. It is a hack for the joystick connector on the entirely boardfile-based SIM.ONE. It will probably not be applied. Cc: Dmitry Torokhov Cc: Andy Shevchenko Cc: Rafael J. Wysocki Cc: Sakari Ailus Signed-off-by: Linus Walleij --- arch/arm/mach-ep93xx/simone.c | 50 +++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/arch/arm/mach-ep93xx/simone.c b/arch/arm/mach-ep93xx/simone.c index 41aa57581356..a3c3020da850 100644 --- a/arch/arm/mach-ep93xx/simone.c +++ b/arch/arm/mach-ep93xx/simone.c @@ -24,7 +24,10 @@ #include #include #include +#include #include +#include +#include #include #include @@ -34,6 +37,51 @@ #include "soc.h" +static struct gpio_keys_button simone_buttons[] = { + { + .code = KEY_ENTER, + .type = EV_KEY, + .active_low = 1, + .desc = "enter", + }, + { + .code = KEY_UP, + .type = EV_KEY, + .active_low = 1, + .desc = "up", + }, + { + .code = KEY_LEFT, + .type = EV_KEY, + .active_low = 1, + .desc = "left", + }, +}; + +static struct gpio_keys_platform_data simone_keys_pdata = { + .buttons = simone_buttons, + .nbuttons = ARRAY_SIZE(simone_buttons), + .rep = 0, +}; + +static struct gpiod_lookup_table simone_keys_gpiod_table = { + .dev_id = "gpio-keys", + .table = { + /* Use local offsets on gpiochip/port "B" */ + GPIO_LOOKUP_IDX("B", 0, "gpios", 0, GPIO_ACTIVE_LOW), + GPIO_LOOKUP_IDX("B", 1, "gpios", 1, GPIO_ACTIVE_LOW), + GPIO_LOOKUP_IDX("B", 2, "gpios", 2, GPIO_ACTIVE_LOW), + }, +}; + +static struct platform_device simone_keys_device = { + .name = "gpio-keys", + .id = -1, + .dev = { + .platform_data = &simone_keys_pdata, + }, +}; + static struct ep93xx_eth_data __initdata simone_eth_data = { .phy_id = 1, }; @@ -107,6 +155,8 @@ static void __init simone_init_machine(void) ARRAY_SIZE(simone_i2c_board_info)); ep93xx_register_spi(&simone_spi_info, simone_spi_devices, ARRAY_SIZE(simone_spi_devices)); + gpiod_add_lookup_table(&simone_keys_gpiod_table); + platform_device_register(&simone_keys_device); simone_register_audio(); }