From patchwork Wed Jul 13 19:22:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 9228407 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 CD9EF60572 for ; Wed, 13 Jul 2016 19:23:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B160F27FB7 for ; Wed, 13 Jul 2016 19:23:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A585628047; Wed, 13 Jul 2016 19:23:30 +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 5D35727FB7 for ; Wed, 13 Jul 2016 19:23:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750987AbcGMTXI (ORCPT ); Wed, 13 Jul 2016 15:23:08 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:33780 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750912AbcGMTXH (ORCPT ); Wed, 13 Jul 2016 15:23:07 -0400 Received: by mail-pf0-f193.google.com with SMTP id i6so3263044pfe.0; Wed, 13 Jul 2016 12:22:56 -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:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=t9f+wPjjD8olzHUspetQWr9MfJ1wm3LWZSG9bFsGNIc=; b=rpRVigI8gh4L/D+B1h42oEmXBgTyN92YlkZsTvtVfVPbJ8OPKjGMNSTiMDV4MToAlO B4LDt0kSmjjRWEhr/f59VcjAHrZ/3MbqHXqwZh1LQwZx5EQbOFKrNKLTcHvDQfxI+pf9 Wg+JLUZlcQ+3rYyNTF3l2AoCc4n6tQyQaEeRcvXVPXDdWagUU+pIEVmy2PSBXWRkwC8z UEly+Ln5Z/Rc4gtf6NUPpKGEFAaZ5IHp5ft3zAOGoY3ObVt5lQcgOFuWbRX8rUSHTVRm fX14PY2/hR6UZ3kuneT49CJ1uRPds32h6mFXHNIbNmwv/ZhPegmNn/8fRXRTU+Dn3PJc TVZg== 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:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=t9f+wPjjD8olzHUspetQWr9MfJ1wm3LWZSG9bFsGNIc=; b=QzB+jciVy9YDmc2+su614YZmrE1JJLmNnkJO20koctrvjRpsD6duVy6Y6reR4mx6D6 am7sT1bAI5d72ftQfAGfK7uGJ7wQAArSqv/UcJfoh5pBZWNw8JcTJ5cFCJQndOgSB0Fk EZ/1G2s95m/NVofoHeYkv8ouA31X1Gq08ld99iNzrAtrLSZvWWUjAw72LDn7NcKNsAtB PnL3INlXGp6Rv7GOm6c5P8WeUKo5NXo2l6f3xWxcjUi2FiYpe1yIX7Spvw6iA7OrhJpK dqeYOrN23PA+JYhJbJOwAjbDVWzhhu0uQJ56CseBcE3HrJZlQKpaKF8xmovZ6qSNbKLq 3YAA== X-Gm-Message-State: ALyK8tKW9tPJW3VzWVMD623IPRk4EDtv7zyCxS4DoMetmr4NTjwiB3z66EHNAPVUoEbgiQ== X-Received: by 10.98.216.199 with SMTP id e190mr6146926pfg.123.1468437770563; Wed, 13 Jul 2016 12:22:50 -0700 (PDT) Received: from dtor-ws ([2620:0:1000:1311:d161:f27b:b6b7:e602]) by smtp.gmail.com with ESMTPSA id 75sm6481940pfw.92.2016.07.13.12.22.49 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Wed, 13 Jul 2016 12:22:49 -0700 (PDT) Date: Wed, 13 Jul 2016 12:22:47 -0700 From: Dmitry Torokhov To: KT Liao Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, phoenix@emc.com.tw, kt.liao@emc.com.tw, Benjamin Tissoires , Jonathan Gradstein , Chris Chiu , Vlad Glagolev Subject: Re: Fix tuchpad wakeup on ASUS laptops (was [PATCH] Input: /input/mouse/elan_i2c_core.c) Message-ID: <20160713192247.GB10821@dtor-ws> References: <1468416629-4615-1-git-send-email-kt.liao@emc.com.tw> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1468416629-4615-1-git-send-email-kt.liao@emc.com.tw> 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 [ Resending to actually CC people I asked to try the patch ] On Wed, Jul 13, 2016 at 09:30:29PM +0800, KT Liao wrote: > Fix some Asus touchapod which casue TP no funciton sometimes, the patch detect some specific touchpad and run a special initialize > > Signed-off-by: KT Liao > --- > drivers/input/mouse/elan_i2c_core.c | 93 ++++++++++++++++++++++++++++--------- > 1 file changed, 71 insertions(+), 22 deletions(-) > > diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c > index 2f58985..36a69d2 100644 > --- a/drivers/input/mouse/elan_i2c_core.c > +++ b/drivers/input/mouse/elan_i2c_core.c > @@ -3,8 +3,8 @@ > * > * Copyright (c) 2013 ELAN Microelectronics Corp. > * > - * Author: 林政維 (Duson Lin) Let's not remove Duson's name, he did quite a bit of work on the driver. > - * Version: 1.6.0 > + * Author: KT Liao > + * Version: 1.6.2 > * > * Based on cyapa driver: > * copyright (c) 2011-2012 Cypress Semiconductor, Inc. > @@ -40,7 +40,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 > @@ -95,6 +95,8 @@ struct elan_tp_data { > bool baseline_ready; > }; > > +static int check_ASUS_special_fw(struct elan_tp_data *data); > + > static int elan_get_fwinfo(u8 iap_version, u16 *validpage_count, > u16 *signature_address) > { > @@ -210,21 +212,40 @@ static int __elan_initialize(struct elan_tp_data *data) > return error; > } > > - data->mode |= ETP_ENABLE_ABS; > - error = data->ops->set_mode(client, data->mode); > - if (error) { > - dev_err(&client->dev, > - "failed to switch to absolute mode: %d\n", error); > - return error; > - } > + /* If it's the special FW, it need a different flow for mode change.*/ > + if (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; > + } > > - 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); > > + data->mode |= ETP_ENABLE_ABS; > + error = data->ops->set_mode(client, data->mode); > + if (error) { > + dev_err(&client->dev, > + "failed to switch to absolute mode: %d\n", error); > + return error; > + } > + } else { > + data->mode |= ETP_ENABLE_ABS; > + error = data->ops->set_mode(client, data->mode); > + if (error) { > + dev_err(&client->dev, > + "failed to switch to absolute mode: %d\n", error); > + 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; > + } > + } > return 0; > } > > @@ -244,7 +265,7 @@ static int elan_initialize(struct elan_tp_data *data) > return error; > } > > -static int elan_query_device_info(struct elan_tp_data *data) > +static int elan_query_device_pid_smver(struct elan_tp_data *data) > { > int error; > > @@ -252,17 +273,24 @@ static int elan_query_device_info(struct elan_tp_data *data) > if (error) > return error; > > - error = data->ops->get_version(data->client, false, &data->fw_version); > + error = data->ops->get_sm_version(data->client, &data->ic_type, > + &data->sm_version); > if (error) > return error; > > - error = data->ops->get_checksum(data->client, false, > - &data->fw_checksum); > + return 0; > +} > + > +static int elan_query_device_info(struct elan_tp_data *data) > +{ > + int error; > + > + error = data->ops->get_version(data->client, false, &data->fw_version); > if (error) > return error; > > - error = data->ops->get_sm_version(data->client, &data->ic_type, > - &data->sm_version); > + error = data->ops->get_checksum(data->client, false, > + &data->fw_checksum); > if (error) > return error; > > @@ -419,6 +447,7 @@ static int elan_update_firmware(struct elan_tp_data *data, > data->ops->iap_reset(client); > } else { > /* Reinitialize TP after fw is updated */ > + elan_query_device_pid_smver(data); > elan_initialize(data); > elan_query_device_info(data); > } > @@ -757,6 +786,22 @@ out: > return retval; > } > > +static int check_ASUS_special_fw(struct elan_tp_data *data) > +{ > + if (data->ic_type != 0x0E) > + return false; > + > + switch (data->product_id) { > + case 0x05: > + case 0x06: > + case 0x07: > + case 0x09: > + case 0x013: > + return true; > + default: > + return false; > + } > +} > > static DEVICE_ATTR_WO(acquire); > static DEVICE_ATTR_RO(min); > @@ -1033,6 +1078,10 @@ static int elan_probe(struct i2c_client *client, > return error; > } > > + error = elan_query_device_pid_smver(data); > + if (error) > + return error; The original code was fetching product ID and IC type after calling the transport "initialize" function; I'd prefer if we kept this order. Could you tell me if the following version of the patch looks OK to you? Vlad, Chris, Jonathan, could you please tell me if this version of the patch fixes your touchpad issue? Thanks! 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;