From patchwork Mon Sep 17 18:16:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 10603275 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 3926614DA for ; Mon, 17 Sep 2018 18:16:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1CD7328F76 for ; Mon, 17 Sep 2018 18:16:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0F2A028FCF; Mon, 17 Sep 2018 18:16:25 +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,FREEMAIL_FROM,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 94E9F28F76 for ; Mon, 17 Sep 2018 18:16:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727832AbeIQXor (ORCPT ); Mon, 17 Sep 2018 19:44:47 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:45388 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728486AbeIQXoq (ORCPT ); Mon, 17 Sep 2018 19:44:46 -0400 Received: by mail-pf1-f196.google.com with SMTP id i26-v6so7921986pfo.12; Mon, 17 Sep 2018 11:16:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HazVNGD9t6FfNvcp88ZRO3a2sLfWT0t9gqSYYowwjIc=; b=fHRCST8y8fiCjUuF8LMaFMwcxAnNCySikGe+6L1wyBsEQHsa0tjYmI0h789VRHGw7y 5/8aFQW9KRuX1L06zWZiFuNHqRMz9slhFuRqedmTQHcDNajrqxe7h9OQkubn6by/UVvo hp3FCZpmAZyCEqcHMx8q7gGoFcmygEFrigh1MAWZC+f5d+k6rrM9iLq/Cxd0QzJfg5ta zrRvZhwgXsBCRyhMRlYClEt/Rg79vrfa7SqP08OLQryA8RoGL1uEIObr0SicZ3jCURJe 0q5RVEkStEskHrxpRp50ShWnUywFw2OTnc+Ewr2ZCKTw1Zi8Dj1hzqJnF9yuey2xMpCt PzeA== 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:mime-version:content-transfer-encoding; bh=HazVNGD9t6FfNvcp88ZRO3a2sLfWT0t9gqSYYowwjIc=; b=njSBjWdlq1s+hAzQkM7OYeat4KUnKY4oi5EPspoHQxTffDQ/6Z5kriWYvS5qQ44t91 XucbgjXIrw1VbuTxEFw2Ag/5T4IKP/Auf1weMZkRAuDrl1e9UuEQsHPozo4PiSQ9MW9Q K6WB3ZQaXy3f/fYo3nn4cW3K6w2lpPx8Two/wN/5dlIRcR6bf2SF7sbAUpe34PxttEDv nUenC1xMtAd0Lnn2vaj53cuXbFlaazfuCIOFd1FI7pFsPopp5feUicBnsohOW+wG+0Yc cVzfUD1JxjJEfHlo+3aS53zfYXwnELrcmRn3IDOPEGA0GGeTId3cMAbKgwkfPIjyQxld vrQA== X-Gm-Message-State: APzg51B5MtbVrbyONOjyu8QEDdV7mHKjpNyuF2hBdWpSxZVnIUI54pAL qig0aPO8yU3nUzsV+/7sR1U= X-Google-Smtp-Source: ANB0VdaTmM5ZIMl0DBUv9NjUnOD4oXlKnFz8JTWC14Tijnm2wF4kc2rBUIw+nkUzHqrC2qVRu+4bzw== X-Received: by 2002:a63:d70e:: with SMTP id d14-v6mr24867555pgg.110.1537208176009; Mon, 17 Sep 2018 11:16:16 -0700 (PDT) Received: from dtor-ws.mtv.corp.google.com ([2620:15c:202:201:3adc:b08c:7acc:b325]) by smtp.gmail.com with ESMTPSA id 74-v6sm24076366pfv.33.2018.09.17.11.16.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Sep 2018 11:16:14 -0700 (PDT) From: Dmitry Torokhov To: Linus Walleij , "Rafael J . Wysocki" Cc: linux-input@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Andy Shevchenko Subject: [RFC/PATCH 5/5] RFC: ARM: simone: Hacked in keys Date: Mon, 17 Sep 2018 11:16:03 -0700 Message-Id: <20180917181603.125492-6-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.19.0.397.gdd90340f6a-goog In-Reply-To: <20180917181603.125492-1-dmitry.torokhov@gmail.com> References: <20180917181603.125492-1-dmitry.torokhov@gmail.com> MIME-Version: 1.0 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 From: Linus Walleij This serves as an illustration of how to use the gpio-keys in board files using static device properties and machine GPIO descriptor tables. It is a hack for the joystick connector on the entirely boardfile-based SIM.ONE. It will probably not be applied. Signed-off-by: Linus Walleij Signed-off-by: Dmitry Torokhov --- arch/arm/mach-ep93xx/simone.c | 60 +++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/arch/arm/mach-ep93xx/simone.c b/arch/arm/mach-ep93xx/simone.c index 41aa57581356..b998d6772158 100644 --- a/arch/arm/mach-ep93xx/simone.c +++ b/arch/arm/mach-ep93xx/simone.c @@ -24,7 +24,11 @@ #include #include #include +#include #include +#include +#include +#include #include #include @@ -34,6 +38,47 @@ #include "soc.h" +static const struct property_entry simone_key_enter_props[] __initconst = { + PROPERTY_ENTRY_U32("linux,code", KEY_ENTER), + PROPERTY_ENTRY_STRING("label", "enter"), + PROPERTY_ENTRY_STRING("gpios", "enter-gpios"), + { } +}; + +static const struct property_entry simone_key_up_props[] __initconst = { + PROPERTY_ENTRY_U32("linux,code", KEY_UP), + PROPERTY_ENTRY_STRING("label", "up"), + PROPERTY_ENTRY_STRING("gpios", "up-gpios"), + { } +}; + +static const struct property_entry simone_key_up_props[] __initconst = { + PROPERTY_ENTRY_U32("linux,code", KEY_LEFT), + PROPERTY_ENTRY_STRING("label", "left"), + PROPERTY_ENTRY_STRING("gpios", "left-gpios"), + { } +}; + +static const struct property_entry simone_key_props[] __initconst = { + /* There are no properties at device level on this device */ + { } +}; + +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, "enter-gpios", 0, GPIO_ACTIVE_LOW), + GPIO_LOOKUP_IDX("B", 1, "up-gpios", 1, GPIO_ACTIVE_LOW), + GPIO_LOOKUP_IDX("B", 2, "left-gpios", 2, GPIO_ACTIVE_LOW), + }, +}; + +static struct platform_device simone_keys_device = { + .name = "gpio-keys", + .id = -1, +}; + static struct ep93xx_eth_data __initdata simone_eth_data = { .phy_id = 1, }; @@ -107,6 +152,21 @@ 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); + device_add_properties(&simone_keys_device.dev, + simone_keys_device_props); + device_add_child_properties(&simone_keys_device.dev, + dev_fwnode(&simone_keys_device.dev), + simone_key_enter_props); + device_add_child_properties(&simone_keys_device.dev, + dev_fwnode(&simone_keys_device.dev), + simone_key_up_props); + device_add_child_properties(&simone_keys_device.dev, + dev_fwnode(&simone_keys_device.dev), + simone_key_left_props); + platform_device_register(&simone_keys_device); + simone_register_audio(); }