From patchwork Fri Jul 8 12:12:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: KT Liao X-Patchwork-Id: 9220717 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 D01EE6044F for ; Fri, 8 Jul 2016 12:12:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C0BD92873C for ; Fri, 8 Jul 2016 12:12:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B54442873E; Fri, 8 Jul 2016 12:12:46 +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=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 8D8692873C for ; Fri, 8 Jul 2016 12:12:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754936AbcGHMMc (ORCPT ); Fri, 8 Jul 2016 08:12:32 -0400 Received: from mail-pa0-f65.google.com ([209.85.220.65]:33596 "EHLO mail-pa0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755023AbcGHMMX (ORCPT ); Fri, 8 Jul 2016 08:12:23 -0400 Received: by mail-pa0-f65.google.com with SMTP id ts6so6272576pac.0; Fri, 08 Jul 2016 05:12:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2he/opwaZoDdp+TUZWFtimbqG03ZEOD/xLcDys6F1TU=; b=qXQlkRvsdIivRXO7zbgNmosPsOgeJhiGcC7znTmB0wQelrG8SWx3TMwMzu2jQZdXNG c7554xOhycdi51Nt5/XTyAnVy8PNvsgToz+xMTu9h4pkbkBmK826lD1tTN+P1twudLKD /F56QFDlNAh48amdUIjr+w/U+vvdVGOZqGC0yaATPK0B5zkjt1HfRJ8KaZmAn35MSR07 Keci/aXGM0NXRy2zw0+K9uoKMyH7UAnb4dGgPV9P+LLLVflIsfQG6ES7PEFzzleeFlWq 1jgqLqM7eKcMx8f7c+36o+r19PnMXGOLm+mdqr5aKb/gZE7PkQKECyju4srC3BMhToix LWLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2he/opwaZoDdp+TUZWFtimbqG03ZEOD/xLcDys6F1TU=; b=WnbMHUF52QPPZkG8+8nObBDmB+q3so7zlJkGwEmX8JmOwYqZdFyDwjcpLAGoQuo9S5 kR40SfZdJ03tudZp3n3D8rmjzl1yJFE8cX9kFBZwJNDeFVX4qEiuZtDvcRWeZ7bJwqkP 7GKiLBDsUmtelLyv4k4bLCUTE0a/cpH660Re3cqXbTjaaTsAzAPDYJhPnu19Fmf20NQn x8AZtyqEAqk8KXS8jweCBlwifI6W/pChlgBXhxiJptBeYUsbu3jMlzRte5QXdroGFDLY KIl32E6U3maLze1ZQaAEO+S8D4Dhj24yuClwRjHTyA7pix1a0iCUkjQKj02MPx4aosv/ N5oQ== X-Gm-Message-State: ALyK8tJgFZOOx19NZuLXlrMzd1v3DHTIaiqBuEG56wp4gzOnansqyKMpUH1s7Q3fIPMx4A== X-Received: by 10.66.79.2 with SMTP id f2mr9394619pax.14.1467979937684; Fri, 08 Jul 2016 05:12:17 -0700 (PDT) Received: from localhost.localdomain (42-73-75-186.EMOME-IP.hinet.net. [42.73.75.186]) by smtp.gmail.com with ESMTPSA id m8sm4158188pfi.27.2016.07.08.05.12.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 08 Jul 2016 05:12:16 -0700 (PDT) From: KT Liao X-Google-Original-From: KT Liao To: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, dmitry.torokhov@gmail.com Cc: phoenix@emc.com.tw, kt.liao@emc.com.tw Subject: [PATCH] Input: /input/mouse/elan_i2c_core.c Fix some Asus touchapod which casue TP no funciton sometimes, the patch detect some specific touchpad and run a special initialize Date: Fri, 8 Jul 2016 20:12:09 +0800 Message-Id: <1467979929-3409-1-git-send-email-kt.liao@emc.com.tw> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 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 Signed-off-by: KT Liao --- drivers/input/mouse/elan_i2c_core.c | 81 +++++++++++++++++++++++++++++-------- 1 file changed, 65 insertions(+), 16 deletions(-) diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c index 2f58985..1c200fb 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) - * 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; } @@ -757,6 +778,34 @@ out: return retval; } +static int check_ASUS_special_fw(struct elan_tp_data *data) +{ + struct i2c_client *client = data->client; + int error; + + error = data->ops->get_product_id(client, &data->product_id); + if (error) + return false; + + error = data->ops->get_sm_version(client, &data->ic_type, + &data->sm_version); + if (error) + return false; + + if (data->ic_type == 0x0E) { + switch (data->product_id) { + case 0x05: + case 0x06: + case 0x07: + case 0x09: + case 0x13: + return true; + default: + return false; + } + } + return false; +} static DEVICE_ATTR_WO(acquire); static DEVICE_ATTR_RO(min);