From patchwork Sat Oct 18 12:56:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 39020 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4A1A3202DB for ; Sat, 18 Oct 2014 12:57:10 +0000 (UTC) Received: by mail-lb0-f198.google.com with SMTP id 10sf1245610lbg.9 for ; Sat, 18 Oct 2014 05:57:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=8WGD4gDK2PyR6XWkFtawvpHjdAyiu2lBRWtRAr4s5/M=; b=eJtxeRpyUhalemcJaMND0SgFPJ276GgKBc2z0YhaJWIulUR1qLkTX3/0g6g/L7h/eM yzSuZtCP8PeqgqUe14oAR9Wo4UOJuVB2fEdVbMEJqelMjaWaZxUsoEuPZVAPdS8ksDqk veBLufp8BhkC9Cvw/F7ckrde0rOV/OaABmGskltdUIEtYcB2xlPlLVBfNuFwEEbaQKWb yC71ErCC7ivWF7Xngf6Z3u64t9UK1JKoBuRI59pEVqdfv7aKlYQrOlCPCdoMEE3JY5/Y m01AIyfX6XPQvp0QvnL0NvmtVR3Si64YglNmy8V+Yngw5wEbZHMk+/13iYRYSuQCxwsP vJ2Q== X-Gm-Message-State: ALoCoQnuzu086tVdiSrYbah0wK/FOr5ibyYtwBVQhcBYTLIAMI8COlOsFJ4njTKo7HiZ3MCLgf9o X-Received: by 10.152.25.202 with SMTP id e10mr2331309lag.2.1413637028670; Sat, 18 Oct 2014 05:57:08 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.26.72 with SMTP id j8ls272419lag.105.gmail; Sat, 18 Oct 2014 05:57:08 -0700 (PDT) X-Received: by 10.152.120.73 with SMTP id la9mr15072186lab.23.1413637028028; Sat, 18 Oct 2014 05:57:08 -0700 (PDT) Received: from mail-lb0-f176.google.com (mail-lb0-f176.google.com. [209.85.217.176]) by mx.google.com with ESMTPS id ls3si6079236lac.126.2014.10.18.05.57.08 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 18 Oct 2014 05:57:08 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.176 as permitted sender) client-ip=209.85.217.176; Received: by mail-lb0-f176.google.com with SMTP id p9so1873587lbv.7 for ; Sat, 18 Oct 2014 05:57:07 -0700 (PDT) X-Received: by 10.112.130.41 with SMTP id ob9mr14797469lbb.74.1413637027916; Sat, 18 Oct 2014 05:57:07 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.84.229 with SMTP id c5csp43841lbz; Sat, 18 Oct 2014 05:57:07 -0700 (PDT) X-Received: by 10.68.143.226 with SMTP id sh2mr15207314pbb.62.1413637026212; Sat, 18 Oct 2014 05:57:06 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gt8si3500233pbc.42.2014.10.18.05.57.05 for ; Sat, 18 Oct 2014 05:57:06 -0700 (PDT) Received-SPF: none (google.com: linux-input-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751549AbaJRM4s (ORCPT ); Sat, 18 Oct 2014 08:56:48 -0400 Received: from mail-lb0-f181.google.com ([209.85.217.181]:51201 "EHLO mail-lb0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751425AbaJRM4q (ORCPT ); Sat, 18 Oct 2014 08:56:46 -0400 Received: by mail-lb0-f181.google.com with SMTP id l4so1863258lbv.40 for ; Sat, 18 Oct 2014 05:56:44 -0700 (PDT) X-Received: by 10.112.189.10 with SMTP id ge10mr14903224lbc.23.1413637003931; Sat, 18 Oct 2014 05:56:43 -0700 (PDT) Received: from localhost.localdomain (c83-254-157-117.bredband.comhem.se. [83.254.157.117]) by mx.google.com with ESMTPSA id kw10sm1317968lbc.17.2014.10.18.05.56.42 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Oct 2014 05:56:42 -0700 (PDT) From: Linus Walleij To: Samuel Ortiz , Lee Jones , Dmitry Torokhov , linux-kernel@vger.kernel.org, linux-input@vger.kernel.org Cc: Linus Walleij Subject: [PATCH 3/3] input: stmpe: bias keypad columns properly Date: Sat, 18 Oct 2014 14:56:39 +0200 Message-Id: <1413636999-3326-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 1.9.3 Sender: linux-input-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: linus.walleij@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.176 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , All keypad column pins used as inputs should be pulled up on the STMPE24xx, but this is not done by the current driver. Add some logic that will do this properly. The STMPE1601 also has a keypad controller, but explicitly does *NOT* require you to set up any pull-ups. Signed-off-by: Linus Walleij --- drivers/input/keyboard/stmpe-keypad.c | 37 +++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/drivers/input/keyboard/stmpe-keypad.c b/drivers/input/keyboard/stmpe-keypad.c index d46391f48310..fe6e3f22eed7 100644 --- a/drivers/input/keyboard/stmpe-keypad.c +++ b/drivers/input/keyboard/stmpe-keypad.c @@ -52,6 +52,7 @@ * struct stmpe_keypad_variant - model-specific attributes * @auto_increment: whether the KPC_DATA_BYTE register address * auto-increments on multiple read + * @set_pullup: whether the pins need to have their pull-ups set * @num_data: number of data bytes * @num_normal_data: number of normal keys' data bytes * @max_cols: maximum number of columns supported @@ -61,6 +62,7 @@ */ struct stmpe_keypad_variant { bool auto_increment; + bool set_pullup; int num_data; int num_normal_data; int max_cols; @@ -81,6 +83,7 @@ static const struct stmpe_keypad_variant stmpe_keypad_variants[] = { }, [STMPE2401] = { .auto_increment = false, + .set_pullup = true, .num_data = 3, .num_normal_data = 2, .max_cols = 8, @@ -90,6 +93,7 @@ static const struct stmpe_keypad_variant stmpe_keypad_variants[] = { }, [STMPE2403] = { .auto_increment = true, + .set_pullup = true, .num_data = 5, .num_normal_data = 3, .max_cols = 8, @@ -185,7 +189,10 @@ static int stmpe_keypad_altfunc_init(struct stmpe_keypad *keypad) unsigned int col_gpios = variant->col_gpios; unsigned int row_gpios = variant->row_gpios; struct stmpe *stmpe = keypad->stmpe; + u8 pureg = stmpe->regs[STMPE_IDX_GPPUR_LSB]; unsigned int pins = 0; + unsigned int pu_pins = 0; + int ret; int i; /* @@ -202,8 +209,10 @@ static int stmpe_keypad_altfunc_init(struct stmpe_keypad *keypad) for (i = 0; i < variant->max_cols; i++) { int num = __ffs(col_gpios); - if (keypad->cols & (1 << i)) + if (keypad->cols & (1 << i)) { pins |= 1 << num; + pu_pins |= 1 << num; + } col_gpios &= ~(1 << num); } @@ -217,7 +226,31 @@ static int stmpe_keypad_altfunc_init(struct stmpe_keypad *keypad) row_gpios &= ~(1 << num); } - return stmpe_set_altfunc(stmpe, pins, STMPE_BLOCK_KEYPAD); + ret = stmpe_set_altfunc(stmpe, pins, STMPE_BLOCK_KEYPAD); + if (ret) + return ret; + + /* + * On STMPE24xx, set pin bias to pull-up on all keypad input + * pins (columns), this incidentally happen to be maximum 8 pins + * and placed at GPIO0-7 so only the LSB of the pull up register + * ever needs to be written. + */ + if (variant->set_pullup) { + u8 val; + + ret = stmpe_reg_read(stmpe, pureg); + if (ret) + return ret; + + /* Do not touch unused pins, may be used for GPIO */ + val = ret & ~pu_pins; + val |= pu_pins; + + ret = stmpe_reg_write(stmpe, pureg, val); + } + + return 0; } static int stmpe_keypad_chip_init(struct stmpe_keypad *keypad)