From patchwork Wed Nov 29 08:33:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masaki Ota <012nexus@gmail.com> X-Patchwork-Id: 10081557 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 9E8A560353 for ; Wed, 29 Nov 2017 08:34:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8C5CC28C3E for ; Wed, 29 Nov 2017 08:34:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 80D3329096; Wed, 29 Nov 2017 08:34:08 +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.0 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,FROM_STARTS_WITH_NUMS,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 0BF6A28C3E for ; Wed, 29 Nov 2017 08:34:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753168AbdK2IeH (ORCPT ); Wed, 29 Nov 2017 03:34:07 -0500 Received: from mail-pf0-f194.google.com ([209.85.192.194]:39129 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753166AbdK2IeG (ORCPT ); Wed, 29 Nov 2017 03:34:06 -0500 Received: by mail-pf0-f194.google.com with SMTP id l24so1238572pfj.6; Wed, 29 Nov 2017 00:34:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=G6fXbNpHmVO9g2ph+dnzlXzS//tTDKydLUSIUcAr4f0=; b=Qz41XJt//0IA7bLOvA242F5IDUId+F+m/+YR28HCwZdP3k62Z0YH8A+OJO/Tk6VzxX An2WREVCEiYCI8DED1PzPgzwAWmXDntNP7y6QeTUjqHrmeYYsLHusyQGkquJXZjTsiWe udzHh+Y0B6sKXrvR6/LXI98Tr6ixW6j4zFqXfEfygP7TfxYxle9qKawW0S0KNW8TDaGR bPxFQrFbIGrpoNimezN8CefJQRed6PIQqLd7o9aXmvxuCFPO66/nFIlb5mHXTc632Xxd gKCkmNEqA0z+3yw/YHlc4vesWuur9dMbZ5M7fdThWozO4/fp2unElUCl/tNhRsny9C7b Coqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=G6fXbNpHmVO9g2ph+dnzlXzS//tTDKydLUSIUcAr4f0=; b=d/2RDT/nh0QU0S34QhFVFwu4drabh1iFDN5o0vNz1QMVNrk8Vxeh/MCXvjiJ8Pi/Wq e9Ud45ev8zBqmB489b6OqVf8aSjp/s0rwAVKJ9XkqtFYpfB+3FUNNvs0gr09AMD0+Iuv MR4i71DrL4Hvu0dwyvZvuESqo67at4faeFpXIAJ6MwKQrWgZLXPmg7Qs25owPq3G3mEd /atJKxpGy2mfuBGqhCOqkuXBrTQxJ9QEz31myeLeC13QMPwrOvnhpJvGACeovCbMbtCt 6IezVnRZupA3exkLNH/SBIGkNNJsS7R2dolWJEIjaxR+meEXHsrH51ABOJZHHBPeIsbD 2/xQ== X-Gm-Message-State: AJaThX5BjmLx7lg3tuixYuUSK6TTCAzKMu4DVC6qt6b1Yi1yF/JdLT4E vIhYYzJWC68l70plC3+d8Dg= X-Google-Smtp-Source: AGs4zMbLM305Li4Y5ghVxF21HwC2pjT06DV+vc5LttHvFSwBSO9wIJECcFrx4oChHP+tbnWlzq+2cw== X-Received: by 10.99.133.200 with SMTP id u191mr2033775pgd.327.1511944445547; Wed, 29 Nov 2017 00:34:05 -0800 (PST) Received: from localhost (p2218-ipad303aobadori.miyagi.ocn.ne.jp. [123.216.73.218]) by smtp.gmail.com with ESMTPSA id m87sm2359344pfi.88.2017.11.29.00.34.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 29 Nov 2017 00:34:04 -0800 (PST) From: Masaki Ota <012nexus@gmail.com> X-Google-Original-From: Masaki Ota To: dmitry.torokhov@gmail.com, benjamin.tissoires@redhat.com, pali.rohar@gmail.com, aaron.ma@canonical.com, jaak@ristioja.ee, masaki.ota@jp.alps.com Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] Support TrackStick of Thinkpad L570 Date: Wed, 29 Nov 2017 17:33:58 +0900 Message-Id: <20171129083358.5063-1-masaki.ota@jp.alps.com> X-Mailer: git-send-email 2.14.1 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: Masaki Ota - The issue is that Thinkpad L570 TrackStick does not work. Because the main interface of Thinkpad L570 device is SMBus, so ALPS overlooked PS2 interface Firmware setting of TrackStick. The detail is that TrackStick otp bit is disabled. - Add the code that checks 0xD7 address value. This value is device number information, so we can identify the device by checking this value. - If we check 0xD7 value, we need to enable Command mode and after check the value we need to disable Command mode, then we have to enable the device(0xF4 command). - Thinkpad L570 device number is 0x0C or 0x1D. If it is TRUE, enable ALPS_DUALPOINT flag. Signed-off-by: Masaki Ota Tested-by: Aaron Ma Tested-by: Jonathan Liu --- drivers/input/mouse/alps.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c index 850b00e3ad8e..6f092bdd9fc5 100644 --- a/drivers/input/mouse/alps.c +++ b/drivers/input/mouse/alps.c @@ -2541,13 +2541,31 @@ static int alps_update_btn_info_ss4_v2(unsigned char otp[][4], } static int alps_update_dual_info_ss4_v2(unsigned char otp[][4], - struct alps_data *priv) + struct alps_data *priv, + struct psmouse *psmouse) { bool is_dual = false; + int reg_val = 0; + struct ps2dev *ps2dev = &psmouse->ps2dev; - if (IS_SS4PLUS_DEV(priv->dev_id)) + if (IS_SS4PLUS_DEV(priv->dev_id)) { is_dual = (otp[0][0] >> 4) & 0x01; + if (!is_dual) { + /* For support TrackStick of Thinkpad L/E series */ + if (alps_exit_command_mode(psmouse) == 0 && + alps_enter_command_mode(psmouse) == 0) { + reg_val = alps_command_mode_read_reg(psmouse, + 0xD7); + } + alps_exit_command_mode(psmouse); + ps2_command(ps2dev, NULL, PSMOUSE_CMD_ENABLE); + + if (reg_val == 0x0C || reg_val == 0x1D) + is_dual = true; + } + } + if (is_dual) priv->flags |= ALPS_DUALPOINT | ALPS_DUALPOINT_WITH_PRESSURE; @@ -2570,7 +2588,7 @@ static int alps_set_defaults_ss4_v2(struct psmouse *psmouse, alps_update_btn_info_ss4_v2(otp, priv); - alps_update_dual_info_ss4_v2(otp, priv); + alps_update_dual_info_ss4_v2(otp, priv, psmouse); return 0; }