From patchwork Wed Mar 22 20:16:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Rivshin X-Patchwork-Id: 9639975 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 8640E60328 for ; Wed, 22 Mar 2017 20:17:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D92628482 for ; Wed, 22 Mar 2017 20:17:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7252528488; Wed, 22 Mar 2017 20:17:56 +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 C10C228485 for ; Wed, 22 Mar 2017 20:17:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751327AbdCVURi (ORCPT ); Wed, 22 Mar 2017 16:17:38 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:40608 "EHLO out1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752709AbdCVURR (ORCPT ); Wed, 22 Mar 2017 16:17:17 -0400 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 161C320DCC; Wed, 22 Mar 2017 16:17:10 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute7.internal (MEProxy); Wed, 22 Mar 2017 16:17:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=awxrd.com; h=cc :date:from:message-id:subject:to:x-me-sender:x-me-sender :x-sasl-enc:x-sasl-enc; s=fm1; bh=1lCfuWxP9+QhVVUO3DfhnF1Am4lxR3 /Z4V9kkeG+3tU=; b=OkNoWH++4Ce9sB0MMyYjzVE5/79AIBQiIuvkJuyNOif8MI araoJUyiehR3uL8JdsT7GuuqTk8uAcCh6WtwSI0hE0CrSKrBMi7HtRSKSFASZYuD EKSsg+yOBDx0gV9WkaiDgeM+5ag5KTbahF1nrYQj9i25Qq5qRpMWRMvez8W5Gf2q O7/LrIo/FmHfnTBv2J41Av58ZfpfXQmwCi7RUHIVoSjmJ20uoZdCx5dMtVImAXuV E78yOHaJ8suvvVDQt8DzznWrBG37T++U2FS365L3d6J0spRnSIKIUq39DgIV0vSV Kbll0gepV9pVPXKn4Ez/M4qsfJbI5mhqGd6LTpDg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:message-id:subject:to :x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s=fm1; bh=1lCfuW xP9+QhVVUO3DfhnF1Am4lxR3/Z4V9kkeG+3tU=; b=TT21wFwGMIK+anDmi25rKa bxEKOw5uce1X36QBkRzjoSeC8Kl+b+r4AvJY48uXYOXPjuMRK7v2S+ohEXC7bppk OOdAw8ESgm1k6N0/taXNAqj8FTJsBiRkah3vBd3vmYmWKmfauqW9lCjEtFOr51/x mzstlCdoG7+HINPA0yXYCjNtBDQ+kSIu7AxTrl/DMEi0Oi3brEoG5g3tQm9cOqto NRyxKfC7nKS1N3Los+6GEn7/M5BPnckQf6SCi26swcDcLQzwkC7FKuG3hdcPgZuS XYTXM3CoKdq7SxhQ6mZLP5f2/N8jGtq9z925sr4yUIEJcqBhZEBxX78rmYqwTFWg == X-ME-Sender: X-Sasl-enc: 4rQZxzvlXWrLLvE176U4Qy+UmMKH5NGLaallAYyWYSq+ 1490213829 Received: from drivshin-linux.crosskeys.inscitek.com (unknown [24.213.148.66]) by mail.messagingengine.com (Postfix) with ESMTPA id 7E8EF7E669; Wed, 22 Mar 2017 16:17:09 -0400 (EDT) From: David Rivshin To: Dmitry Torokhov , Rob Herring , Mark Rutland Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] input: matrix_keypad: add option to drive inactive columns Date: Wed, 22 Mar 2017 16:16:50 -0400 Message-Id: <20170322201650.9072-1-drivshin@awxrd.com> X-Mailer: git-send-email 2.9.3 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: David Rivshin The gpio-matrix-keypad driver normally sets inactive columns as inputs while scanning. This does not work for all hardware, which may require the inactive columns to be actively driven in order to overcome any pull-ups/downs on the columns. Signed-off-by: David Rivshin Acked-by: Rob Herring --- .../devicetree/bindings/input/gpio-matrix-keypad.txt | 2 ++ drivers/input/keyboard/matrix_keypad.c | 13 +++++++++---- include/linux/input/matrix_keypad.h | 3 +++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Documentation/devicetree/bindings/input/gpio-matrix-keypad.txt b/Documentation/devicetree/bindings/input/gpio-matrix-keypad.txt index d0ea09b..570dc10 100644 --- a/Documentation/devicetree/bindings/input/gpio-matrix-keypad.txt +++ b/Documentation/devicetree/bindings/input/gpio-matrix-keypad.txt @@ -24,6 +24,8 @@ Optional Properties: - debounce-delay-ms: debounce interval in milliseconds - col-scan-delay-us: delay, measured in microseconds, that is needed before we can scan keypad after activating column gpio +- drive-inactive-cols: drive inactive columns during scan, + default is to turn inactive columns into inputs. Example: matrix-keypad { diff --git a/drivers/input/keyboard/matrix_keypad.c b/drivers/input/keyboard/matrix_keypad.c index 18839cd..1f316d6 100644 --- a/drivers/input/keyboard/matrix_keypad.c +++ b/drivers/input/keyboard/matrix_keypad.c @@ -42,9 +42,10 @@ struct matrix_keypad { }; /* - * NOTE: normally the GPIO has to be put into HiZ when de-activated to cause - * minmal side effect when scanning other columns, here it is configured to - * be input, and it should work on most platforms. + * NOTE: If drive_inactive_cols is false, then the GPIO has to be put into + * HiZ when de-activated to cause minmal side effect when scanning other + * columns. In that case it is configured here to be input, otherwise it is + * driven with the inactive value. */ static void __activate_col(const struct matrix_keypad_platform_data *pdata, int col, bool on) @@ -55,7 +56,8 @@ static void __activate_col(const struct matrix_keypad_platform_data *pdata, gpio_direction_output(pdata->col_gpios[col], level_on); } else { gpio_set_value_cansleep(pdata->col_gpios[col], !level_on); - gpio_direction_input(pdata->col_gpios[col]); + if (!pdata->drive_inactive_cols) + gpio_direction_input(pdata->col_gpios[col]); } } @@ -432,6 +434,9 @@ matrix_keypad_parse_dt(struct device *dev) if (of_get_property(np, "gpio-activelow", NULL)) pdata->active_low = true; + pdata->drive_inactive_cols = + of_property_read_bool(np, "drive-inactive-cols"); + of_property_read_u32(np, "debounce-delay-ms", &pdata->debounce_ms); of_property_read_u32(np, "col-scan-delay-us", &pdata->col_scan_delay_us); diff --git a/include/linux/input/matrix_keypad.h b/include/linux/input/matrix_keypad.h index 37b04a0..6174733 100644 --- a/include/linux/input/matrix_keypad.h +++ b/include/linux/input/matrix_keypad.h @@ -49,6 +49,8 @@ struct matrix_keymap_data { * @wakeup: controls whether the device should be set up as wakeup * source * @no_autorepeat: disable key autorepeat + * @drive_inactive_cols: drive inactive columns during scan, rather than + * making them inputs. * * This structure represents platform-specific data that use used by * matrix_keypad driver to perform proper initialization. @@ -73,6 +75,7 @@ struct matrix_keypad_platform_data { bool active_low; bool wakeup; bool no_autorepeat; + bool drive_inactive_cols; }; int matrix_keypad_build_keymap(const struct matrix_keymap_data *keymap_data,