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: 146070 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp194842ljw; Thu, 6 Sep 2018 00:59:26 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaNpRJTQWTxgah1V4ojR7sWsFnXqVSTkkEnp8iDVleSkTdYA9VjeD3BazAlhgLLSRz+RUZW X-Received: by 2002:a63:df04:: with SMTP id u4-v6mr1560661pgg.434.1536220766195; Thu, 06 Sep 2018 00:59:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536220766; cv=none; d=google.com; s=arc-20160816; b=WR3RbB1rQ9Rux6Kt/UpuyFpiRDKRlfxxEq3dRBeE+2yF79Nh2dv1p97pVTefav+dpi mMN6fMEkpdrJAxzx09KXJijBHkUNVsQ69k7LiCaqw2zapb7xWjgqbX+q8Edkv8c4MfmJ GNT9Ev+RhtBmdeRo1EI7zRvnq1jg/3ddT1936bOEHhtlqFfNIRGDG+C2fyoIFRSD7YjG je3akYTellW88cixgrSb+K78ZbaUqaFhRDfgGmMjD7A6mEVmk6joj+H9tKj3SDm5da6H dEqrNMfCfIqOqoPd3ZakmA9lchdd2c5pnJnaRr7i2e3Ya1RLmImY7eucFd/PHpugvNJr 5pwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=4rWgSaidxSf3WayfOVM6Uc0/KOIGkkaRLG+kNBpbt+8=; b=J3A63c9/pQ4LNCaFn3fEvuQ8FAcPvuet2RHkNnrJ7TVDb0NXig4DMNs0H/kWBCf1CW Zzb6+xOYujYnpkjoCT9UYD7MNdwpwohPyrxsH98YFntUFStec+rDBSflag+L3Tg0SGnP lYwvj4N3tktdMQzTfkkS1+XnbYDCAzHkYYdwdalaL4TnvGmkIlBwpNf43XCGdclgud7f Ze4P0uBwmXkx1ScJm2ZN+6QN3Z5p6HMTmtuUYtS2w3nW12MWNnoTtaAmpIeR6pmpz8L+ 9Cd1pIyGBtfQQ4wN3SUNOynyt6LITOFXEQ1Rt4X4jDJIKQ9EwFtERK7E5IXRq9nX4GI3 xXeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BTWiyIAV; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d20-v6si4596262pgj.535.2018.09.06.00.59.25; Thu, 06 Sep 2018 00:59:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BTWiyIAV; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728133AbeIFMdf (ORCPT + 5 others); Thu, 6 Sep 2018 08:33:35 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:43660 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728099AbeIFMdf (ORCPT ); Thu, 6 Sep 2018 08:33:35 -0400 Received: by mail-lj1-f193.google.com with SMTP id m84-v6so8481124lje.10 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=rGceKQPCW7GDGB0oKoCxX2iUcTJ1gG/VCxd4zj+UbPezdsL8b2NCBMZxPiqmM88i6J A++LQXhoebPNv/JrTtQRsCICTwPU+I97BMqTYKWa9SBFS8H34jp8rKQ2vz2fVNogV83g GoSx6ijnWiZKtuCI0dJaVGQwKlpv8LNL7Bl4GnnDmLGqQF10Lixr3vUFHOCB533EB11U rsU8Y84wDRooZiKjq5EMI/MnsaaOX98GFIUak97KlYuCyUi1oqj52SP2XrFnOvQq040a kHgZLGagaF9ZtRrHIkUArZ3a8bdKSrSuqSAKz9a9YJs01HJmLak1lGGPPJ+Xr9mbrRKo WBCw== X-Gm-Message-State: APzg51BRERc3fhWU0+ncyFnEFgQtc7bzIkVL4MiLzVDuGaokEKaURKt0 FkNnjQ6RhbLJcYouEbqKI3SPcw== 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-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org 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(+) -- 2.17.1 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(); }