From patchwork Thu Jul 28 22:13:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 9251765 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 BA42B6077C for ; Thu, 28 Jul 2016 22:13:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A9DB427F10 for ; Thu, 28 Jul 2016 22:13:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9E74427F46; Thu, 28 Jul 2016 22:13:45 +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_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 87B1B27F10 for ; Thu, 28 Jul 2016 22:13:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751448AbcG1WNn (ORCPT ); Thu, 28 Jul 2016 18:13:43 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:35516 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751147AbcG1WNm (ORCPT ); Thu, 28 Jul 2016 18:13:42 -0400 Received: by mail-pf0-f193.google.com with SMTP id h186so4307751pfg.2; Thu, 28 Jul 2016 15:13:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:user-agent; bh=C57bEuj0BI8M8mlFvuyOGSpbNbCigWtCCQKpUSBzbwQ=; b=bEAS3WHiGkD/3aYg6NQQcj+rGCvO3pKN7jFRgbHZrhwNmNX0NUv86/CE+Iqy2+zItx XaeL4I1ne1eDkeI8OpN0RycmqCbhDn9CYbVfhPKKifCA2OGH6xwNc50+dL/UcJSzSm3f PCy1pkIoij1bsVQ4mL3JnQM3ENSAst89Z9BhL4Pr8BHXv+EVmcIKASvKTLxcz6Omso/b gnQxUkzPiQLssgB2Bi1UVWUwwyC2XyqvxxpARHeIYNYc3+n0Ei6rTLqYA+5Xoq4O1OPj iLk/CAK5WwYprLENI3CRgbHVVMEJhveQxwJjBqMmYrFu4zl6Mg1D+Gjc+CP35IVSmQMF nBqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:user-agent; bh=C57bEuj0BI8M8mlFvuyOGSpbNbCigWtCCQKpUSBzbwQ=; b=ZBwvH8vSIgSgkubNDWG3LjGv0+nsGwmVsjyuN7KZbysqllVKHq6NISdGt0ZxjXdD+t 03E5ZLdMMgJcdycb4unL/llfnc1n1LT+vi6G2c0PFzxh/hAXVWIpeahk/aA3PyCVqrfs /smGI918IHzjuf3ftmgY4AlO8F5rPB62eYlVtz33rrxcReu2frN8m7+OjuijAaLsX1ze qcfELsxPGI8s3KYMwdCy+ysCwWatJnXPNfEl/1x3Ok8tAzyPbvrUvxVzxTP2PWkXlZ/5 zE8QpIbit5BQv/RZw4fnrs4DmmdzSmvYojZ0Z9HM//YVDUWyiTCwT97vp4bPO/mim9w1 X/lw== X-Gm-Message-State: AEkooutFrVQmhRfLzahYisgnu7WQflDVAYI5Ds+rqRBpGmRLCwMVry1msw0v+Vz5YiWC/g== X-Received: by 10.98.68.148 with SMTP id m20mr59284773pfi.0.1469744021381; Thu, 28 Jul 2016 15:13:41 -0700 (PDT) Received: from dtor-ws ([2620:0:1000:1311:2998:3737:86f7:7c12]) by smtp.gmail.com with ESMTPSA id cp3sm19559825pad.12.2016.07.28.15.13.40 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 28 Jul 2016 15:13:40 -0700 (PDT) Date: Thu, 28 Jul 2016 15:13:38 -0700 From: Dmitry Torokhov To: Jonathan Gradstein , Chris Chiu , Vlad Glagolev Cc: linux-input@vger.kernel.org, KT Liao , linux-kernel@vger.kernel.org Subject: [PATCH] Input: elan_i2c - properly wake up touchpad on ASUS laptops Message-ID: <20160728221338.GA26740@dtor-ws> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) 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: KT Liao Some ASUS laptops were shipped with touchpads that require to be woken up first, before trying to switch them into absolute reporting mode, otherwise touchpad would fail to work while flooding the logs with: elan_i2c i2c-ELAN1000:00: invalid report id data (1) Among affected devices are Asus E202SA, N552VW, X456UF, UX305CA, and others. We detect such devices by checking the IC type and product ID numbers and adjusting order of operations accordingly. Signed-off-by: KT Liao Reported-by: Chris Chiu Reported-by: Vlad Glagolev Cc: stable@vger.kernel.org Signed-off-by: Dmitry Torokhov --- Vlad, Chris, Jonathan, could you please tell me if this version of the patch fixes your touchpad issue? Thanks! drivers/input/mouse/elan_i2c_core.c | 79 +++++++++++++++++++++++++++++-------- 1 file changed, 63 insertions(+), 16 deletions(-) diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c index 2f58985..d15b338 100644 --- a/drivers/input/mouse/elan_i2c_core.c +++ b/drivers/input/mouse/elan_i2c_core.c @@ -4,7 +4,8 @@ * Copyright (c) 2013 ELAN Microelectronics Corp. * * Author: 林政維 (Duson Lin) - * Version: 1.6.0 + * Author: KT Liao + * Version: 1.6.2 * * Based on cyapa driver: * copyright (c) 2011-2012 Cypress Semiconductor, Inc. @@ -40,7 +41,7 @@ #include "elan_i2c.h" #define DRIVER_NAME "elan_i2c" -#define ELAN_DRIVER_VERSION "1.6.1" +#define ELAN_DRIVER_VERSION "1.6.2" #define ELAN_VENDOR_ID 0x04f3 #define ETP_MAX_PRESSURE 255 #define ETP_FWIDTH_REDUCE 90 @@ -199,9 +200,41 @@ static int elan_sleep(struct elan_tp_data *data) return error; } +static int elan_query_product(struct elan_tp_data *data) +{ + int error; + + error = data->ops->get_product_id(data->client, &data->product_id); + if (error) + return error; + + error = data->ops->get_sm_version(data->client, &data->ic_type, + &data->sm_version); + if (error) + return error; + + return 0; +} + +static int elan_check_ASUS_special_fw(struct elan_tp_data *data) +{ + if (data->ic_type != 0x0E) + return false; + + switch (data->product_id) { + case 0x05 ... 0x07: + case 0x09: + case 0x13: + return true; + default: + return false; + } +} + static int __elan_initialize(struct elan_tp_data *data) { struct i2c_client *client = data->client; + bool woken_up = false; int error; error = data->ops->initialize(client); @@ -210,6 +243,27 @@ static int __elan_initialize(struct elan_tp_data *data) return error; } + error = elan_query_product(data); + if (error) + return error; + + /* + * Some ASUS devices were shipped with firmware that requires + * touchpads to be woken up first, before attempting to switch + * them into absolute reporting mode. + */ + if (elan_check_ASUS_special_fw(data)) { + error = data->ops->sleep_control(client, false); + if (error) { + dev_err(&client->dev, + "failed to wake device up: %d\n", error); + return error; + } + + msleep(200); + woken_up = true; + } + data->mode |= ETP_ENABLE_ABS; error = data->ops->set_mode(client, data->mode); if (error) { @@ -218,11 +272,13 @@ static int __elan_initialize(struct elan_tp_data *data) return error; } - error = data->ops->sleep_control(client, false); - if (error) { - dev_err(&client->dev, - "failed to wake device up: %d\n", error); - return error; + if (!woken_up) { + error = data->ops->sleep_control(client, false); + if (error) { + dev_err(&client->dev, + "failed to wake device up: %d\n", error); + return error; + } } return 0; @@ -248,10 +304,6 @@ static int elan_query_device_info(struct elan_tp_data *data) { int error; - error = data->ops->get_product_id(data->client, &data->product_id); - if (error) - return error; - error = data->ops->get_version(data->client, false, &data->fw_version); if (error) return error; @@ -261,11 +313,6 @@ static int elan_query_device_info(struct elan_tp_data *data) if (error) return error; - error = data->ops->get_sm_version(data->client, &data->ic_type, - &data->sm_version); - if (error) - return error; - error = data->ops->get_version(data->client, true, &data->iap_version); if (error) return error;