From patchwork Fri Nov 24 09:30:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 10073859 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 42C1B60375 for ; Fri, 24 Nov 2017 09:30:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36FFC2A31A for ; Fri, 24 Nov 2017 09:30:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2C14F2A354; Fri, 24 Nov 2017 09:30:58 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 BA9BC2A31A for ; Fri, 24 Nov 2017 09:30:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752935AbdKXJa4 (ORCPT ); Fri, 24 Nov 2017 04:30:56 -0500 Received: from mail-lf0-f66.google.com ([209.85.215.66]:39681 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752688AbdKXJa4 (ORCPT ); Fri, 24 Nov 2017 04:30:56 -0500 Received: by mail-lf0-f66.google.com with SMTP id x76so20102268lfb.6 for ; Fri, 24 Nov 2017 01:30:55 -0800 (PST) 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=xFL0cCmj3jzdG7ZmbOu+d9yCkniP2YUrU6RBdNJ2KiQ=; b=JcV7sicamyQxrl/Uwd6yEfwcUXHRb+Vx4KuJoNvm0zNyzxUR/UMv8VIx1jES1/C67O JKei4X2utT7TR1xp0zWyH1kidxYdfOvJnszHN7H5g0o8eFw+H7TQm6vGz+ZD9+1BoOXY TJilmDlND5/fA08CJOQiESIh02PGIC/oJO7Ww= 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=xFL0cCmj3jzdG7ZmbOu+d9yCkniP2YUrU6RBdNJ2KiQ=; b=QQKrlbyJO5hqisODl+LAQdD3CavCqvlvlXFhunWLKJ+9b7RarIgmdCyUExqZIZokyZ NInJzi/yQyItIt9zuPN4qn5V4lF6gvd3f6TanUc4dfRAG1h893Rqa0z94bRfBmC9HoOR 7An/H5K4q5zGbf/LJqA0zhv82CXsPMVxx761xUBFbeCpWsDpmZFOWvwRkEJqzCZbjNXu weyCayln/uTjaKFek1KBc2VTMSdE1nYD9UIEz33wELNth17FPAZe5EPyM8KzXux7zbfG WIFYKZbAP12CpLyd7f7Xd4HVfwB4tLhwHSHQaCPTLGq2sOqNey4Ma67GGC0DN3Cro3UY otkg== X-Gm-Message-State: AJaThX7aGKf9n6+IiJh5k5ITHvRJUmS308e9smaVISpCQgZZ9TVBrzYM jgeV/qFxXSyjuhwNWRXzbyNqHA== X-Google-Smtp-Source: AGs4zMbN+3Q30LTTGYSeTTRDV3TwFO7TjpT17ZQS8ukM+rL/Y0Vbuyr940Z1XAwY9fUkpeGFNOHjYA== X-Received: by 10.46.95.28 with SMTP id t28mr10007120ljb.110.1511515854357; Fri, 24 Nov 2017 01:30:54 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id 19sm4476608ljx.58.2017.11.24.01.30.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Nov 2017 01:30:53 -0800 (PST) From: Linus Walleij To: Dmitry Torokhov , linux-input@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Linus Walleij Subject: [PATCH 3/5] ARM: davinci: Switch DA850EVM to use GPIO descriptors Date: Fri, 24 Nov 2017 10:30:43 +0100 Message-Id: <20171124093045.5961-4-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171124093045.5961-1-linus.walleij@linaro.org> References: <20171124093045.5961-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 To get rid of the global GPIO numberspace we need to move to using descriptor tables with local offsets on the GPIO chip to reference the GPIO lines used by kernel drivers. This moves the DaVinci DA850EVM board over to using GPIO descriptors for passing GPIOs to the GPIO keys. Signed-off-by: Linus Walleij --- arch/arm/mach-davinci/board-da850-evm.c | 57 ++++++++++++++++++++++++++++----- 1 file changed, 49 insertions(+), 8 deletions(-) diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c index cbde0030c092..3792d760020f 100644 --- a/arch/arm/mach-davinci/board-da850-evm.c +++ b/arch/arm/mach-davinci/board-da850-evm.c @@ -404,11 +404,9 @@ static const char * const da850_evm_ui_exp[] = { static struct gpio_keys_button da850_evm_ui_keys[] = { [0 ... DA850_N_UI_PB - 1] = { .type = EV_KEY, - .active_low = 1, .wakeup = 0, .debounce_interval = DA850_KEYS_DEBOUNCE_MS, .code = -1, /* assigned at runtime */ - .gpio = -1, /* assigned at runtime */ .desc = NULL, /* assigned at runtime */ }, }; @@ -427,6 +425,29 @@ static struct platform_device da850_evm_ui_keys_device = { }, }; +static struct gpiod_lookup_table da850_evm_ui_keys_gpios_table = { + .dev_id = "gpio-keys-polled", + .table = { + GPIO_LOOKUP("tca6416-20", DA850_EVM_UI_EXP_PB8, + "pb8", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("tca6416-20", DA850_EVM_UI_EXP_PB7, + "pb7", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("tca6416-20", DA850_EVM_UI_EXP_PB6, + "pb6", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("tca6416-20", DA850_EVM_UI_EXP_PB5, + "pb5", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("tca6416-20", DA850_EVM_UI_EXP_PB4, + "pb4", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("tca6416-20", DA850_EVM_UI_EXP_PB3, + "pb3", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("tca6416-20", DA850_EVM_UI_EXP_PB2, + "pb2", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("tca6416-20", DA850_EVM_UI_EXP_PB1, + "pb1", GPIO_ACTIVE_LOW), + + }, +}; + static void da850_evm_ui_keys_init(unsigned gpio) { int i; @@ -436,8 +457,8 @@ static void da850_evm_ui_keys_init(unsigned gpio) button = &da850_evm_ui_keys[i]; button->code = KEY_F8 - i; button->desc = da850_evm_ui_exp[DA850_EVM_UI_EXP_PB8 + i]; - button->gpio = gpio + DA850_EVM_UI_EXP_PB8 + i; } + gpiod_add_lookup_table(&da850_evm_ui_keys_gpios_table); } #ifdef CONFIG_DA850_UI_SD_VIDEO_PORT @@ -572,21 +593,17 @@ static const char * const da850_evm_bb_exp[] = { static struct gpio_keys_button da850_evm_bb_keys[] = { [0] = { .type = EV_KEY, - .active_low = 1, .wakeup = 0, .debounce_interval = DA850_KEYS_DEBOUNCE_MS, .code = KEY_PROG1, .desc = NULL, /* assigned at runtime */ - .gpio = -1, /* assigned at runtime */ }, [1 ... DA850_N_BB_USER_SW] = { .type = EV_SW, - .active_low = 1, .wakeup = 0, .debounce_interval = DA850_KEYS_DEBOUNCE_MS, .code = -1, /* assigned at runtime */ .desc = NULL, /* assigned at runtime */ - .gpio = -1, /* assigned at runtime */ }, }; @@ -604,6 +621,30 @@ static struct platform_device da850_evm_bb_keys_device = { }, }; +static struct gpiod_lookup_table da850_evm_bb_keys_gpios_table = { + .dev_id = "gpio-keys-polled", + .table = { + GPIO_LOOKUP("tca6416-21", DA850_EVM_BB_EXP_USER_PB1, + "user_pb1", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("tca6416-21", DA850_EVM_BB_EXP_USER_SW1, + "user_sw1", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("tca6416-21", DA850_EVM_BB_EXP_USER_SW2, + "user_sw2", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("tca6416-21", DA850_EVM_BB_EXP_USER_SW3, + "user_sw3", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("tca6416-21", DA850_EVM_BB_EXP_USER_SW4, + "user_sw4", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("tca6416-21", DA850_EVM_BB_EXP_USER_SW5, + "user_sw5", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("tca6416-21", DA850_EVM_BB_EXP_USER_SW6, + "user_sw6", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("tca6416-21", DA850_EVM_BB_EXP_USER_SW7, + "user_sw7", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("tca6416-21", DA850_EVM_BB_EXP_USER_SW8, + "user_sw8", GPIO_ACTIVE_LOW), + }, +}; + static void da850_evm_bb_keys_init(unsigned gpio) { int i; @@ -617,8 +658,8 @@ static void da850_evm_bb_keys_init(unsigned gpio) button = &da850_evm_bb_keys[i + 1]; button->code = SW_LID + i; button->desc = da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_SW1 + i]; - button->gpio = gpio + DA850_EVM_BB_EXP_USER_SW1 + i; } + gpiod_add_lookup_table(&da850_evm_bb_keys_gpios_table); } #define DA850_N_BB_USER_LED 2