Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp1028974pxa; Fri, 28 Aug 2020 01:23:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx7vWwJBtxMMZyJrYgylSpFTMHHxh8Yj8QGl3KtOYgdqhklu6OyVSkULSsuR8Q/phCvJXNx X-Received: by 2002:a17:906:4a99:: with SMTP id x25mr630723eju.439.1598603021596; Fri, 28 Aug 2020 01:23:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598603021; cv=none; d=google.com; s=arc-20160816; b=pnuBOxziU4hVdv4c3gsTAPNU7oU5u8lTxIk1npxLCGY3x7Ies/cdh9Vi0vNoXClHFy Dxa2RFRUPoqJyoIpbQMCcDA99sbP3G7kNAE+TZH6sLNIj7FrWZ9uNswv6rze4fW3MGZO H5SKEsfZ4O+k8St/fc0Vl5yE14ONwi4SyI1o2ZABBW7iPn3pri41wC3KfTcV4oXDeTns i0O3Yh/r29DnnCvZtP8dfw7orXPVz9fIoW31NtL/oKi5AaAs7PijfG2LMYf6OIW6mOJr KrTM4K6dmCsaF+wi/TdxRrknER7zTFTMmXGx51ASbSfmhmsXZVcSblJ+dVBCsfGmsevL +l4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=emgRC1O/XN0oKlbZwUrLkuHyx1g+CfGZ4VZjo4v2TFA=; b=G2V16rAcJPAU/S66ZTkd0JOOC0MNu1r3+YvZkV+KipgrVzVm8F87HT3w5eBB84qPb0 ToG/K9RNboEUVk2rjS5iY4KyPUWQGDuytNdGK7jgig6uqEHhc1rEYaDN2dBWN7/sr9zl ltVpNkMuqtVvMpVa+ielqdBbGRcn5WINPGLar3AmpSTnWSnsaikoVFSCFqfYzc3PeKG5 mMZUGe5Lh/S2lWCnjDxIFEGuMPUivCGJ8ScDbKV6ygPagUH3gA34JmjOydA6vOlKP+Gu +rsRfQeuZEKYYNuZx4HU+gOAXLuYTHGJR7fCrAW4ZOFf6a8nkNHv+kOCnOck3c7EpBEn QmmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="a6JKM/Xm"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d10si108191edu.284.2020.08.28.01.23.18; Fri, 28 Aug 2020 01:23:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="a6JKM/Xm"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728670AbgH1ITz (ORCPT + 99 others); Fri, 28 Aug 2020 04:19:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726834AbgH1ITw (ORCPT ); Fri, 28 Aug 2020 04:19:52 -0400 Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A2D3C061264; Fri, 28 Aug 2020 01:19:52 -0700 (PDT) Received: by mail-lj1-x241.google.com with SMTP id y2so371934ljc.1; Fri, 28 Aug 2020 01:19:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=emgRC1O/XN0oKlbZwUrLkuHyx1g+CfGZ4VZjo4v2TFA=; b=a6JKM/XmL6dUFdomj9HWPyx+/NYG5Kv95t0T/VyRByN0rjTLkCnaICTaipLziHlU0M PUD+nYM3vIfGxUu6NSKbl/edJRMCWvlAIYLBAmYGhipTS64wK0bJiotq+uXf/2oYgbC+ HHnyDCCeiUPDviJBfdYGWYx1QnKJ0lrgnw06L/NOjqSCmbJrBzFz3Kuxogfwq00aQKcR 6HVjK8stQUZussRhe859K0Vns9cS7XKYs4fH/kXEHZc28G2GECrLIiAMBHt8soZFDmCv g/4n0l4CFxzqZ+aardNjeNjF6utmkrfs4p8rK6tUNaEPME8NzDLMNPnMPMH/5MAxixmn 0ttQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=emgRC1O/XN0oKlbZwUrLkuHyx1g+CfGZ4VZjo4v2TFA=; b=EX7XTQn5+P9fNHlA26MFte3YfmKRERVWiKJmWDM6+uHnSO1YtfwhUqoHJY5KyyXT86 lNKTgdMNWBbZbnoZ+EcEpyCFm3TRejmhdWaV/0m8F2+g0lV5FJGyhHQ+Opsv/Q0qb3h5 UMM7dcCmixUQic3CPn+l6Hk9Rb6KXQoBkBYhTZmQ9NWJb0grMeYOQVUVeN1m4y/DbAot 6kNlLKbyQYj84lnXtxnsexjyA+Rr43pPbimM9+Q6sb6ssxPO39tFXwZ8p3+tOsBrh6Cd R+XI8HDK9Sc4zDW7jL6WAV/11FC8AwK9ULEdp8HW8RiBCt68aD36mkhEqCZGS81oQXgm 34Ig== X-Gm-Message-State: AOAM533fD3yVYA6/dMfdy6ponoXjndWSun1NzvLk+EUZKjH16HoFxeFu +M/Yiu5QmC/QF7SIj2Je/vE= X-Received: by 2002:a05:651c:23a:: with SMTP id z26mr323559ljn.257.1598602790712; Fri, 28 Aug 2020 01:19:50 -0700 (PDT) Received: from [192.168.2.145] (109-252-170-211.dynamic.spd-mgts.ru. [109.252.170.211]) by smtp.googlemail.com with ESMTPSA id a2sm56719ljp.26.2020.08.28.01.19.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 28 Aug 2020 01:19:50 -0700 (PDT) Subject: Re: [PATCH 1/1] Input: atmel_mxt_ts - implement I2C retries To: Jiada Wang , nick@shmanahar.org, dmitry.torokhov@gmail.com Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, erosca@de.adit-jv.com, Andrew_Gabbasov@mentor.com References: <20200821082254.16661-1-jiada_wang@mentor.com> From: Dmitry Osipenko Message-ID: <64c77ff9-6d20-abcf-f549-7d5c85fba28d@gmail.com> Date: Fri, 28 Aug 2020 11:19:49 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200821082254.16661-1-jiada_wang@mentor.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 21.08.2020 11:22, Jiada Wang пишет: > From: Nick Dyer > > Some maXTouch chips (eg mXT1386) will not respond on the first I2C request > when they are in a sleep state. It must be retried after a delay for the > chip to wake up. > > Signed-off-by: Nick Dyer > Acked-by: Yufeng Shen > (cherry picked from ndyer/linux/for-upstream commit 63fd7a2cd03c3a572a5db39c52f4856819e1835d) > [gdavis: Forward port and fix conflicts.] > Signed-off-by: George G. Davis > Signed-off-by: Jiada Wang > --- > drivers/input/touchscreen/atmel_mxt_ts.c | 45 ++++++++++++++++-------- > 1 file changed, 30 insertions(+), 15 deletions(-) Hello, Jiada! I tested this patch on Acer A500 that has mXT1386 controller which requires the I2C retrying and everything working good, no problems spotted! Touchscreen doesn't work without this patch! Tested-by: Dmitry Osipenko I have one minor comment, please see it below! > diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c > index a2189739e30f..e93eda1f3d59 100644 > --- a/drivers/input/touchscreen/atmel_mxt_ts.c > +++ b/drivers/input/touchscreen/atmel_mxt_ts.c > @@ -196,6 +196,7 @@ enum t100_type { > #define MXT_CRC_TIMEOUT 1000 /* msec */ > #define MXT_FW_RESET_TIME 3000 /* msec */ > #define MXT_FW_CHG_TIMEOUT 300 /* msec */ > +#define MXT_WAKEUP_TIME 25 /* msec */ > > /* Command to unlock bootloader */ > #define MXT_UNLOCK_CMD_MSB 0xaa > @@ -626,6 +627,7 @@ static int __mxt_read_reg(struct i2c_client *client, > struct i2c_msg xfer[2]; > u8 buf[2]; > int ret; > + bool retry = false; > > buf[0] = reg & 0xff; > buf[1] = (reg >> 8) & 0xff; > @@ -642,17 +644,22 @@ static int __mxt_read_reg(struct i2c_client *client, > xfer[1].len = len; > xfer[1].buf = val; > > - ret = i2c_transfer(client->adapter, xfer, 2); > - if (ret == 2) { > - ret = 0; > - } else { > - if (ret >= 0) > - ret = -EIO; > - dev_err(&client->dev, "%s: i2c transfer failed (%d)\n", > - __func__, ret); > +retry_read: > + ret = i2c_transfer(client->adapter, xfer, ARRAY_SIZE(xfer)); > + if (ret != ARRAY_SIZE(xfer)) { Is it really possible to get a positive ret != 2 from i2c_transfer()? Maybe it's better to keep the old code behaviour by returning the "ret" value directly if it's not equal to ARRAY_SIZE(xfer)?