From patchwork Mon Dec 9 03:14:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Dave.Wang" X-Patchwork-Id: 11278377 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 91DF413B6 for ; Mon, 9 Dec 2019 03:14:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 65D60206E0 for ; Mon, 9 Dec 2019 03:14:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726823AbfLIDOc (ORCPT ); Sun, 8 Dec 2019 22:14:32 -0500 Received: from emcscan.emc.com.tw ([192.72.220.5]:12577 "EHLO emcscan.emc.com.tw" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726669AbfLIDOb (ORCPT ); Sun, 8 Dec 2019 22:14:31 -0500 X-IronPort-AV: E=Sophos;i="5.56,253,1539619200"; d="scan'208";a="33195812" Received: from unknown (HELO webmail.emc.com.tw) ([192.168.10.1]) by emcscan.emc.com.tw with ESMTP; 09 Dec 2019 11:14:29 +0800 Received: from 192.168.10.23 by webmail.emc.com.tw with MailAudit ESMTP Server V5.0(71508:0:AUTH_RELAY) (envelope-from ); Mon, 09 Dec 2019 11:14:31 +0800 (CST) Received: from 42.73.254.157 by webmail.emc.com.tw with Mail2000 ESMTPA Server V7.00(101171:0:AUTH_LOGIN) (envelope-from ); Mon, 09 Dec 2019 11:14:31 +0800 (CST) From: Dave Wang To: Linux-input@vger.kernel.org, Linux-kernel@vger.kernel.org, Dmitry.torokhov@gmail.com Cc: phoenix@emc.com.tw, josh.chen@emc.com.tw, jingle.wu@emc.com.tw, kai.heng.feng@canonical.com, "Dave.Wang" Subject: [PATCH 2/6] Input: elantech - Add the function to get more bytes from register Date: Sun, 8 Dec 2019 22:14:26 -0500 Message-Id: <20191209031426.30253-1-dave.wang@emc.com.tw> X-Mailer: git-send-email 2.17.1 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: "Dave.Wang" Send an Elantech style special command to read three bytes from register. Signed-off-by: Dave Wang --- drivers/input/mouse/elantech.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c index 1f0d914acd78..afb87122b766 100644 --- a/drivers/input/mouse/elantech.c +++ b/drivers/input/mouse/elantech.c @@ -89,6 +89,24 @@ static int elantech_ps2_command(struct psmouse *psmouse, return rc; } +/* + * Send an Elantech style special command to read 3 bytes from a register + */ +static int elantech_read_reg_params(struct psmouse *psmouse, unsigned char reg, + unsigned char *param) +{ + int rc = 0; + + if (elantech_ps2_command(psmouse, NULL, ETP_PS2_CUSTOM_COMMAND) || + elantech_ps2_command(psmouse, NULL, ETP_REGISTER_READWRITE) || + elantech_ps2_command(psmouse, NULL, ETP_PS2_CUSTOM_COMMAND) || + elantech_ps2_command(psmouse, NULL, reg) || + elantech_ps2_command(psmouse, param, PSMOUSE_CMD_GETINFO)) + rc = -1; + + return rc; +} + /* * Send an Elantech style special command to read a value from a register */ From patchwork Mon Dec 9 03:15:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Dave.Wang" X-Patchwork-Id: 11278379 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8DDD91593 for ; Mon, 9 Dec 2019 03:15:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7593E2071A for ; Mon, 9 Dec 2019 03:15:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726987AbfLIDPT (ORCPT ); Sun, 8 Dec 2019 22:15:19 -0500 Received: from emcscan.emc.com.tw ([192.72.220.5]:23966 "EHLO emcscan.emc.com.tw" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726669AbfLIDPT (ORCPT ); Sun, 8 Dec 2019 22:15:19 -0500 X-IronPort-AV: E=Sophos;i="5.56,253,1539619200"; d="scan'208";a="33195838" Received: from unknown (HELO webmail.emc.com.tw) ([192.168.10.1]) by emcscan.emc.com.tw with ESMTP; 09 Dec 2019 11:15:17 +0800 Received: from 192.168.10.23 by webmail.emc.com.tw with MailAudit ESMTP Server V5.0(71513:0:AUTH_RELAY) (envelope-from ); Mon, 09 Dec 2019 11:15:19 +0800 (CST) Received: from 42.73.254.157 by webmail.emc.com.tw with Mail2000 ESMTPA Server V7.00(101176:0:AUTH_LOGIN) (envelope-from ); Mon, 09 Dec 2019 11:15:16 +0800 (CST) From: Dave Wang To: Linux-input@vger.kernel.org, Linux-kernel@vger.kernel.org, Dmitry.torokhov@gmail.com Cc: phoenix@emc.com.tw, josh.chen@emc.com.tw, jingle.wu@emc.com.tw, kai.heng.feng@canonical.com, "Dave.Wang" Subject: [PATCH 3/6] Input: elantech - Increace and correct device information for pattern 0,1,2 Date: Sun, 8 Dec 2019 22:15:12 -0500 Message-Id: <20191209031512.30313-1-dave.wang@emc.com.tw> X-Mailer: git-send-email 2.17.1 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org From: "Dave.Wang" Get and correct the device informations including fw_checksum, iap_checksum, ic_body, iap_version from differnet pattern. Signed-off-by: Dave Wang --- drivers/input/mouse/elantech.c | 47 +++++++++++++++++++++++++++++++++- drivers/input/mouse/elantech.h | 8 ++++++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c index afb87122b766..322b181d00e9 100644 --- a/drivers/input/mouse/elantech.c +++ b/drivers/input/mouse/elantech.c @@ -857,7 +857,8 @@ static int elantech_packet_check_v4(struct psmouse *psmouse) */ if (etd->info.crc_enabled) sanity_check = ((packet[3] & 0x08) == 0x00); - else if (ic_version == 7 && etd->info.samples[1] == 0x2A) + else if (ic_version == 7 && etd->info.samples[1] == 0x2A && + etd->info.pattern == 0x00) sanity_check = ((packet[3] & 0x1c) == 0x10); else sanity_check = ((packet[0] & 0x08) == 0x00 && @@ -1669,6 +1670,50 @@ static int elantech_query_info(struct psmouse *psmouse, info->samples[2]); } + if (elantech_read_reg_params(psmouse, ETP_FW_CHECKSUM_QUERY, + info->fw_checksum)) { + psmouse_err(psmouse, "failed to get fw checksum\n"); + return -EINVAL; + } + psmouse_info(psmouse, + "Elan fw checksum result %02x, %02x, %02x\n", + info->fw_checksum[0], + info->fw_checksum[1], + info->fw_checksum[2]); + + if (elantech_read_reg_params(psmouse, ETP_IAP_CHECKSUM_QUERY, + info->iap_checksum)) { + psmouse_err(psmouse, "failed to get iap checksum\n"); + return -EINVAL; + } + psmouse_info(psmouse, + "Elan iap checksum result %02x, %02x, %02x\n", + info->iap_checksum[0], + info->iap_checksum[1], + info->iap_checksum[2]); + + if (info->pattern > 0x00) { + if (info->send_cmd(psmouse, ETP_ICBODY_QUERY, info->ic_body)) { + psmouse_err(psmouse, "failed to query ic body\n"); + return -EINVAL; + } + psmouse_info(psmouse, + "Elan ic body : %02x%02x, fw version : %02x\n", + info->ic_body[0], + info->ic_body[1], + info->ic_body[2]); + + if (info->send_cmd(psmouse, ETP_IAP_VERSION_QUERY, + info->iap_version)) { + psmouse_err(psmouse, "failed to query iap version\n"); + return -EINVAL; + } + psmouse_info(psmouse, + "Elan iap interface type : %02x, iap version : %02x\n", + info->iap_version[1], + info->iap_version[2]); + } + if (info->samples[1] == 0x74 && info->hw_version == 0x03) { /* * This module has a bug which makes absolute mode diff --git a/drivers/input/mouse/elantech.h b/drivers/input/mouse/elantech.h index 0aae6a9de8f0..a633ffa0eb07 100644 --- a/drivers/input/mouse/elantech.h +++ b/drivers/input/mouse/elantech.h @@ -18,6 +18,10 @@ #define ETP_CAPABILITIES_QUERY 0x02 #define ETP_SAMPLE_QUERY 0x03 #define ETP_RESOLUTION_QUERY 0x04 +#define ETP_ICBODY_QUERY 0x05 +#define ETP_IAP_VERSION_QUERY 0x06 +#define ETP_IAP_CHECKSUM_QUERY 0x0A +#define ETP_FW_CHECKSUM_QUERY 0xFE /* * Command values for register reading or writing @@ -138,6 +142,10 @@ struct finger_pos { struct elantech_device_info { unsigned char capabilities[3]; unsigned char samples[3]; + unsigned char fw_checksum[3]; + unsigned char iap_checksum[3]; + unsigned char ic_body[3]; + unsigned char iap_version[3]; unsigned char debug; unsigned char hw_version; unsigned char pattern;