From patchwork Thu Apr 5 13:25:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Tissoires X-Patchwork-Id: 10324629 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 5B9D66032A for ; Thu, 5 Apr 2018 13:26:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C82428B09 for ; Thu, 5 Apr 2018 13:26:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 40FF028BDF; Thu, 5 Apr 2018 13:26:48 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable 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 EAC0828B09 for ; Thu, 5 Apr 2018 13:26:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751900AbeDEN0c (ORCPT ); Thu, 5 Apr 2018 09:26:32 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:49600 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751519AbeDENZ5 (ORCPT ); Thu, 5 Apr 2018 09:25:57 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D77EDEBFEC; Thu, 5 Apr 2018 13:25:56 +0000 (UTC) Received: from plouf.banquise.eu.com (ovpn-117-43.ams2.redhat.com [10.36.117.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9915F2023235; Thu, 5 Apr 2018 13:25:55 +0000 (UTC) From: Benjamin Tissoires To: Dmitry Torokhov Cc: kt.liao@emc.com.tw, Oliver Haessler , Benjamin Berg , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Benjamin Tissoires Subject: [PATCH 7/8] Input: elantech - detect new ICs and setup Host Notify for them Date: Thu, 5 Apr 2018 15:25:36 +0200 Message-Id: <20180405132537.3218-8-benjamin.tissoires@redhat.com> In-Reply-To: <20180405132537.3218-1-benjamin.tissoires@redhat.com> References: <20180405132537.3218-1-benjamin.tissoires@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Thu, 05 Apr 2018 13:25:56 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Thu, 05 Apr 2018 13:25:56 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'benjamin.tissoires@redhat.com' RCPT:'' 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 New ICs are using a different scheme for the alternate bus parameter. Given that they are new and are only using either PS2 only or PS2 + SMBus Host Notify, we force those new ICs to use the SMBus solution for enhanced reporting. This allows the touchpad found on the Lenovo T480s to report 5 fingers every 8 ms, instead of having a limit of 2 every 8 ms. Signed-off-by: Benjamin Tissoires --- drivers/input/mouse/elantech.c | 11 +++++++---- drivers/input/mouse/elantech.h | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c index a61fbddd6b92..29f55e8e07e9 100644 --- a/drivers/input/mouse/elantech.c +++ b/drivers/input/mouse/elantech.c @@ -1789,11 +1789,11 @@ static int elantech_setup_smbus(struct psmouse *psmouse, if (elantech_smbus == ELANTECH_SMBUS_NOT_SET) { /* - * FIXME: - * constraint the I2C capable devices by using FW version, - * board version, or by using DMI matching + * New ICs are enabled by default. + * Old ICs are up to the user to decide. */ - return -ENXIO; + if (!ETP_NEW_IC_SMBUS_HOST_NOTIFY(info->fw_version)) + return -ENXIO; } psmouse_info(psmouse, "Trying to set up SMBus access\n"); @@ -1814,6 +1814,9 @@ static int elantech_setup_smbus(struct psmouse *psmouse, static bool elantech_use_host_notify(struct psmouse *psmouse, struct elantech_device_info *info) { + if (ETP_NEW_IC_SMBUS_HOST_NOTIFY(info->fw_version)) + return true; + switch (info->bus) { case ETP_BUS_PS2_ONLY: /* expected case */ diff --git a/drivers/input/mouse/elantech.h b/drivers/input/mouse/elantech.h index f9b1c485e8d9..119727085a60 100644 --- a/drivers/input/mouse/elantech.h +++ b/drivers/input/mouse/elantech.h @@ -115,6 +115,21 @@ #define ETP_BUS_PS2_SMB_ALERT 3 #define ETP_BUS_PS2_SMB_HST_NTFY 4 +/* + * New ICs are either using SMBus Host Notify or just plain PS2. + * + * ETP_FW_VERSION_QUERY is: + * Byte 1: + * - bit 0..3: IC BODY + * Byte 2: + * - bit 4: HiddenButton + * - bit 5: PS2_SMBUS_NOTIFY + * - bit 6: PS2CRCCheck + */ +#define ETP_NEW_IC_SMBUS_HOST_NOTIFY(fw_version) \ + ((((fw_version) & 0x0f2000) == 0x0f2000) && \ + ((fw_version) & 0x0000ff) > 0) + /* * The base position for one finger, v4 hardware */