From patchwork Fri Jan 6 21:01:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brendan McGrath X-Patchwork-Id: 9501849 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 A975F6021C for ; Fri, 6 Jan 2017 21:08:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9C8D0269A3 for ; Fri, 6 Jan 2017 21:08:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 90FE128540; Fri, 6 Jan 2017 21:08: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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 15D5927BE5 for ; Fri, 6 Jan 2017 21:08:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751588AbdAFVIG (ORCPT ); Fri, 6 Jan 2017 16:08:06 -0500 Received: from ipmail06.adl6.internode.on.net ([150.101.137.145]:13633 "EHLO ipmail06.adl6.internode.on.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751018AbdAFVIG (ORCPT ); Fri, 6 Jan 2017 16:08:06 -0500 Received: from ppp118-209-20-12.lns20.mel4.internode.on.net (HELO mail.hermana.com.au) ([118.209.20.12]) by ipmail06.adl6.internode.on.net with ESMTP; 07 Jan 2017 07:31:59 +1030 Received: from localhost.localdomain (2001-44b8-412c-1c00-4c47-09ea-393a-2fc6.static.ipv6.internode.on.net [IPv6:2001:44b8:412c:1c00:4c47:9ea:393a:2fc6]) by mail.hermana.com.au (Postfix) with ESMTPSA id 2E1BF4FF; Sat, 7 Jan 2017 08:01:58 +1100 (AEDT) From: Brendan McGrath To: Jiri Kosina , Benjamin Tissoires , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Victor Vlasenko , Frederik Wenigwieser , Brendan McGrath Subject: [PATCHv3] HID: i2c-hid: Add sleep between POWER ON and RESET Date: Sat, 7 Jan 2017 08:01:38 +1100 Message-Id: <1483736498-7805-1-git-send-email-redmcg@redmandi.dyndns.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <20170106081144.GE15702@mail.corp.redhat.com> References: <20170106081144.GE15702@mail.corp.redhat.com> 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 Support for the Asus Touchpad was recently added. It turns out this device can fail initialisation (and become unusable) when the RESET command is sent too soon after the POWER ON command. Unfortunately the i2c-hid specification does not specify the need for a delay between these two commands. But it was discovered the Windows driver has a 1ms delay. As a result, this patch modifies the i2c-hid module to add a sleep inbetween the POWER ON and RESET commands which lasts between 1ms and 5ms. See https://github.com/vlasenko/hid-asus-dkms/issues/24 for further details. Signed-off-by: Brendan McGrath Reviewed-by: Benjamin Tissoires --- Changes since v2: - added comments to explain the reason for the sleep drivers/hid/i2c-hid/i2c-hid.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c index 844662c..d5288f3 100644 --- a/drivers/hid/i2c-hid/i2c-hid.c +++ b/drivers/hid/i2c-hid/i2c-hid.c @@ -426,6 +426,15 @@ static int i2c_hid_hwreset(struct i2c_client *client) if (ret) goto out_unlock; + /* + * The HID over I2C specification states that if a DEVICE needs time + * after the PWR_ON request, it should utilise CLOCK stretching. + * However, it has been observered that the Windows driver provides a + * 1ms sleep between the PWR_ON and RESET requests and that some devices + * rely on this. + */ + usleep_range(1000, 5000); + i2c_hid_dbg(ihid, "resetting...\n"); ret = i2c_hid_command(client, &hid_reset_cmd, NULL, 0);