Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2412218pxk; Mon, 14 Sep 2020 12:37:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxikdVitwfqxqodscD8lHVz0U8UIOgkp7lYdudgfKwjVAB6nk3pFGvGDFsvcQ4GxZBM5qy4 X-Received: by 2002:a17:906:bc52:: with SMTP id s18mr15530281ejv.398.1600112223159; Mon, 14 Sep 2020 12:37:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600112223; cv=none; d=google.com; s=arc-20160816; b=XozLdthV/PV7e0MupvLx0KkugI4+RYvWefbXVniLhdrxrpU1YoON98s1XDlug3YhXj uicpiXYPdPHMegzdPdBAmz4NVnc/rLx8yjqT6ana4xWCk8uGZBIx8WdTCy0giAtopyUY 6tuBt+OOZyZVxY48RJjtnquvg6M1McuFe9djMZGHLgQ5/lWeiWQpaUGMhXp4Egc2cZ+K 5Rw3Bf5JTXsLoPY2uVJ2sOrZAfkGf45nOFT8WgaSP6l3ArfOb66f2pwk30GBw6Hkx522 CHk3e2c13M+LgEnz6qVl97IQm6I9KiV/AdTy2u01WyIbHqMz26K2B8Sb2VxGVefRM7Eb bXXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=KkqW6KbGxh/KSzD5Wn3+KsznoNndYdFD3MoHDu0yS4o=; b=sw1Sl8yDBbml/D1uozzeH6EvWYRJk+gPmAn2BoLkicmI3e1bXuGX29koStFbBCBFvE 4I36XBNk9j2f/TAzr4bQ/kjjK8LpByFUJSLX+MwMSelVlw9O2q+eOJzcpZ0oP9eKnhd4 WgNYpudfTnP2q/1ixjdCERCWIoAyTuFB2qc8HZH7hIQxw4RbMoVSDP98MXV6sZrAiuqa 7ZWu+9x9LRb9obkw+A3DHGzi0m53GkdwM0PePGsqY3dN/YCROuSPJf1sBkpetnBm4WiO V9rhJKgkrUVk07ER9/tm3HXXYW3e/chdRJdt+cP+qUvQcvv6GUTgSlc270EDd5zvmCfx 97QQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HfYCcZI9; 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 ce12si7580248ejb.719.2020.09.14.12.36.40; Mon, 14 Sep 2020 12:37:03 -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=HfYCcZI9; 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 S1726009AbgINTdr (ORCPT + 99 others); Mon, 14 Sep 2020 15:33:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725951AbgINTdo (ORCPT ); Mon, 14 Sep 2020 15:33:44 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACB3FC06174A; Mon, 14 Sep 2020 12:33:43 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id t14so614033pgl.10; Mon, 14 Sep 2020 12:33:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=KkqW6KbGxh/KSzD5Wn3+KsznoNndYdFD3MoHDu0yS4o=; b=HfYCcZI99+eKdPn+gu+0tW1l9EDS6ETq2rWjaKfMje5mzce1L5EtvJ5iBfwX3DyrkZ z4WOxdPJNDR/MPnkHostr5TaHikU5kDP/tZxpn0McXQJOb/VmdYYBJvvNrfKToknN5MA EkunW0nK5eLh3doETfKpGaco1W+8jQWnXHQL8nNLdF6ElipJIn7BeQOcj0jzUDTQKkas mQmQ023eo8lEkg20TmX0dEyj10LZbv8MalsiT+3pBcJTNFg35OEAGcV+Oaxc5Qtc2oVl NnsmTbV3nVO6Yx1eghtKDnIEPWSjt870ra9wlkD8X7W4Gps5XmUgIgHR/az3mdyEgr8f SnWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=KkqW6KbGxh/KSzD5Wn3+KsznoNndYdFD3MoHDu0yS4o=; b=IRn5JQA2O+jNk0X5gxcoWNJG7UfkQWx2IoSAVGs2G9Ez4MMv85M1Lgv8C6NAZfq7od dbzV/IfD1P7QlJxf2RYsKVx9YbjXZ9tP+RSKCMPVjHlhFtxTPBP74g3Ii8yseBnwCYxx SBZ6z6tLJcvKSOUQStINDL6L9ilp1i342Xyx/q2CdTnKxuhGIoSt59BkeX8cy4mmFGNQ HRBZjzClFTwwCpJ+t7ec+17icuEdCoS3qz3yH5zIWmbtBtKqV8Dqd3Jatx1NYzpT9VaU JcIm5bVsd68Znra3W97j+y17Pvbikqgsq9lkAMjmWjvkJCcHr/WISxcGlJ92GRrAD41k KDIQ== X-Gm-Message-State: AOAM532AOrs+fWpM49WwOqmhL03x38zMA39QXJfv7vlIwvvb/sJRbHOO ptzWJtJS15sGWo7qVx0NE+w= X-Received: by 2002:a63:7f50:: with SMTP id p16mr11972543pgn.451.1600112023115; Mon, 14 Sep 2020 12:33:43 -0700 (PDT) Received: from dtor-ws ([2620:15c:202:201:a6ae:11ff:fe11:fcc3]) by smtp.gmail.com with ESMTPSA id a2sm10835024pfr.104.2020.09.14.12.33.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Sep 2020 12:33:42 -0700 (PDT) Date: Mon, 14 Sep 2020 12:33:40 -0700 From: Dmitry Torokhov To: Dmitry Osipenko Cc: Jiada Wang , nick@shmanahar.org, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, andy.shevchenko@gmail.com, erosca@de.adit-jv.com, Andrew_Gabbasov@mentor.com Subject: Re: [PATCH v4 1/1] Input: atmel_mxt_ts - implement I2C retries Message-ID: <20200914193340.GV1665100@dtor-ws> References: <20200912005521.26319-1-jiada_wang@mentor.com> <20200913165644.GF1665100@dtor-ws> <65d1b9f2-a8e3-6398-712d-41d8067d06a1@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <65d1b9f2-a8e3-6398-712d-41d8067d06a1@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 14, 2020 at 08:29:44PM +0300, Dmitry Osipenko wrote: > 13.09.2020 19:56, Dmitry Torokhov пишет: > > Hi Jiada, > > > > On Sat, Sep 12, 2020 at 09:55:21AM +0900, Jiada Wang wrote: > >> 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. > > > > Do we know when the chip is in sleep state? Can we do a quick I2C > > transaction in this case instead of adding retry logic to everything? Or > > there is another benefit for having such retry logic? > > Hello! > > Please take a look at page 29 of: > > https://ww1.microchip.com/downloads/en/DeviceDoc/mXT1386_1vx_Datasheet_LX.pdf > > It says that the retry is needed after waking up from a deep-sleep mode. > > There are at least two examples when it's needed: > > 1. Driver probe. Controller could be in a deep-sleep mode at the probe > time, and then first __mxt_read_reg() returns I2C NACK on reading out TS > hardware info. > > 2. Touchscreen input device is opened. The touchscreen is in a > deep-sleep mode at the time when input device is opened, hence first > __mxt_write_reg() invoked from mxt_start() returns I2C NACK. > > I think placing the retries within __mxt_read() / write_reg() should be > the most universal option. > > Perhaps it should be possible to add mxt_wake() that will read out some > generic register I do not think we need to read a particular register, just doing a quick read: i2c_smbus_xfer(client->adapter, client->addr, 0, I2C_SMBUS_READ, 0, I2C_SMBUS_BYTE, &dummy) should suffice. > and then this helper should be invoked after HW > resetting (before mxt_read_info_block()) and from mxt_start() (before > mxt_set_t7_power_cfg()). But this approach feels a bit fragile to me. > Actually, reading the spec, it all depends on how the WAKE pin is wired up on a given board. In certain setups retrying transaction is the right approach, while in others explicit control is needed. So indeed, we need a "wake" helper that we should call in probe and resume paths. Thanks. -- Dmitry