Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp577508imu; Thu, 20 Dec 2018 01:43:18 -0800 (PST) X-Google-Smtp-Source: AFSGD/V+TMzPF8Ln6oMva4yrMQLXUKWa4cDqfA3AljP5ozgdSNJY3fJXJTGWUBaxSnIZKKejr96t X-Received: by 2002:a63:8d44:: with SMTP id z65mr22562534pgd.57.1545298998017; Thu, 20 Dec 2018 01:43:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545298997; cv=none; d=google.com; s=arc-20160816; b=tCfXNyNk+DQaTRHhw7ZdTwmhhfzTF60r9D/DVLv/o8kmoDyvKJdQSDUby88kXN1MBa ldaBTCgqTIchS0LrByzCAjg4mARH2bDEnkF2WsFzlbkbhlTDfx1zfRrAno87a/1KE1eB zBSxg1JNHicNudFTlg5mqqLTnQZoWeiRapvb82Mi+ViWBcZ2cOyMaCzDEJfAv0GDr0Mj YHmgWzFlx0zPqbLTJG0fX/9YglZPJ0NUXLPUP2zmDODs/JOQqSRVbM1kAvUxxUIbhuXV oqnpkiapcLhOwrZmhix6Cm+wJ4GwVYbeJNEO4raub4ezQgEz6T3wpor+5CgwSjJljEXU Zbpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qljVMCfY58W+Tuqiv2f63KWt/RCeN+1VBgOF9urVDE8=; b=X6+E5rz83XQCxfdYW901CR2LW1PsCyRbCvnTjU91cIkNsyPH7qSF5XcMu9S9XiSvwj V90aIRYXHuh3vZp1T62PZtNLFU0Q3PEs0njglkzXHUFTrtxlcmstUlX17831p9BbeBip 0q/eGuuyiQvSzrhYIL8ThbVXkyMK4ZA6WCuhkFPbfIhN2ooBysvlOVyaF6EdwNwa+cgJ oA/F8fnnzeGUARe2ZbRXq9tCMRpmXwnnNx466tlb1U4+5JHEKirAsrA0aUbOM/CB5Bkj uuI3QlYOgLRdMzsPVmeInn/zHk/s5cChQZH0fkGOautRHcDWsGh2bYBKXo2RanDTE/Aa YWOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=amxUfJt2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t3si18259631pgo.585.2018.12.20.01.43.02; Thu, 20 Dec 2018 01:43:17 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@kernel.org header.s=default header.b=amxUfJt2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732297AbeLTJki (ORCPT + 99 others); Thu, 20 Dec 2018 04:40:38 -0500 Received: from mail.kernel.org ([198.145.29.99]:35666 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731802AbeLTJYa (ORCPT ); Thu, 20 Dec 2018 04:24:30 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 98F6220656; Thu, 20 Dec 2018 09:24:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1545297869; bh=xrEhSD7c5TkBFeev9XBTfgDntn5pbpeqlOjikEAVYBw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=amxUfJt24RRiAglXWA/8W2LEjue5LvBJ9bBBEmFjp141EQH8cJJIxQZ0wI02HQzwk 3t92HrOUzQghrG3Rsj4qwHUF9PC7/iLn6iHj5/fwDXb1VAUaTBH39ZB94+xS8pibPv Pu92Jjy/LrC0KVO42omnNYAVtw8lwE8rpHTYzjUw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Machek , Tony Lindgren , Dmitry Torokhov , Sasha Levin Subject: [PATCH 4.9 46/61] Input: omap-keypad - fix keyboard debounce configuration Date: Thu, 20 Dec 2018 10:18:46 +0100 Message-Id: <20181220085845.622350283@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20181220085843.743900603@linuxfoundation.org> References: <20181220085843.743900603@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 6c3516fed7b61a3527459ccfa67fab130d910610 ] I noticed that the Android v3.0.8 kernel on droid4 is using different keypad values from the mainline kernel and does not have issues with keys occasionally being stuck until pressed again. Turns out there was an earlier patch posted to fix this as "Input: omap-keypad: errata i689: Correct debounce time", but it was never reposted to fix use macros for timing calculations. This updated version is using macros, and also fixes the use of the input clock rate to use 32768KiHz instead of 32000KiHz. And we want to use the known good Android kernel values of 3 and 6 instead of 2 and 6 in the earlier patch. Reported-by: Pavel Machek Signed-off-by: Tony Lindgren Signed-off-by: Dmitry Torokhov Signed-off-by: Sasha Levin --- drivers/input/keyboard/omap4-keypad.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c index 6639b2b8528a..f78c464899db 100644 --- a/drivers/input/keyboard/omap4-keypad.c +++ b/drivers/input/keyboard/omap4-keypad.c @@ -60,8 +60,18 @@ /* OMAP4 values */ #define OMAP4_VAL_IRQDISABLE 0x0 -#define OMAP4_VAL_DEBOUNCINGTIME 0x7 -#define OMAP4_VAL_PVT 0x7 + +/* + * Errata i689: If a key is released for a time shorter than debounce time, + * the keyboard will idle and never detect the key release. The workaround + * is to use at least a 12ms debounce time. See omap5432 TRM chapter + * "26.4.6.2 Keyboard Controller Timer" for more information. + */ +#define OMAP4_KEYPAD_PTV_DIV_128 0x6 +#define OMAP4_KEYPAD_DEBOUNCINGTIME_MS(dbms, ptv) \ + ((((dbms) * 1000) / ((1 << ((ptv) + 1)) * (1000000 / 32768))) - 1) +#define OMAP4_VAL_DEBOUNCINGTIME_16MS \ + OMAP4_KEYPAD_DEBOUNCINGTIME_MS(16, OMAP4_KEYPAD_PTV_DIV_128) enum { KBD_REVISION_OMAP4 = 0, @@ -181,9 +191,9 @@ static int omap4_keypad_open(struct input_dev *input) kbd_writel(keypad_data, OMAP4_KBD_CTRL, OMAP4_DEF_CTRL_NOSOFTMODE | - (OMAP4_VAL_PVT << OMAP4_DEF_CTRL_PTV_SHIFT)); + (OMAP4_KEYPAD_PTV_DIV_128 << OMAP4_DEF_CTRL_PTV_SHIFT)); kbd_writel(keypad_data, OMAP4_KBD_DEBOUNCINGTIME, - OMAP4_VAL_DEBOUNCINGTIME); + OMAP4_VAL_DEBOUNCINGTIME_16MS); /* clear pending interrupts */ kbd_write_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS, kbd_read_irqreg(keypad_data, OMAP4_KBD_IRQSTATUS)); -- 2.19.1