From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03C8CC47080 for ; Tue, 1 Jun 2021 12:01:02 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B552C613BD for ; Tue, 1 Jun 2021 12:01:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B552C613BD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hw+qTSwc+EDPPM3KvQkvy7fkyfYf1pV50hZJcXJngIM=; b=DyDmdcrTs+j6AQ /W68fYPIC5VmRO6CyF7vCRQIE40ZuWpEbcpHKeIyvX2XKUshAp7TMSzK0WlCD+imwLC3iZj6gHcrX U7N47uHlriP5IfQrmYa8gfOgmkD1SFyjeT8KVPvYkxD20K52tGGr4Sc0enA7ovr/0hSs40dGXBBWb LbX6vU+XHJZXPxSv69XPGIi+iTPFx0fPvZMLWZu42j2/td5ylJlQQmFvFnPLkSah4xfSTfDAYH5ne c9PNdheKqbhIVbmfO0f/izgUTSsLuNI+eOAzGJMdGf2/bfaZrWMvrrefjp0Y40R3vfEigE274Q7CT BOp12/XX5kTIFNWNQOZA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lo33N-00GG4v-62; Tue, 01 Jun 2021 11:59:25 +0000 Received: from mail-il1-x130.google.com ([2607:f8b0:4864:20::130]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lo33J-00GG4O-Kr for linux-arm-kernel@lists.infradead.org; Tue, 01 Jun 2021 11:59:23 +0000 Received: by mail-il1-x130.google.com with SMTP id b9so4955575ilr.2 for ; Tue, 01 Jun 2021 04:59:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=7h+A8aEDUOIPJ0mvlv22w1DuGIkLT4pGU/4T1UhDmms=; b=j8OR4Sn96SBx/RobEUIz9aB1+A6WnyGyB/Nq9pQVaWc2TGT3igc9cVZ+6RCDiG/1Vt 91J+WmrmrdtltcMDhPWPILb7dlfZbG9O+aP9c+Ex4LSQ7aOq4Zgy9/KjMEDiH+JviTUz RtxQu/DrawhynBcoCvnB61AguKMnM6UbFgQ02FxqgF8I4EwELZp6XdlPBxOnP6Wg8PnG UfHsMrmsJE4M482D3FI+fxogHtZQ9LnCApgrZSs+6hzfp8bsw/5jdeXzDFcqddcXVnvn dPuxBoMvNelA28r+iqN6V23EBTb2nroadn5t3qfUy5mxqAmNGqZPvx7r/hf/6PUWmzOG moRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=7h+A8aEDUOIPJ0mvlv22w1DuGIkLT4pGU/4T1UhDmms=; b=Qw+S9tu2lCDgkOExbzA2LaKA4NGfJAeGOAQMSKcLLZ8a9InMTyjAT1dEvcyQGXK9AZ 0yyRAmsMYSX1wOUTgC21x/hc7koD+9+3WwsytFUE2MLWz7ySz4Uh5ZpOqPwvye9RNsPD kYOabdq6/e5+WI/+RRDfnhwoMYa6ijhDWPvryuupxmd28l0q6QRz7LZKqbE9Vj72afai ZraXyCaw4jRe/weuIQzGXHnExwYGObiEknqOPaEh3zbip56y2Q7t2mxCyBBZrpx7GC6G d60VGdC5Lc5XjJAHIegiRaV0DkAbcJYd4It6N410OzV/ibuYnxDmkv/aTGfu+MsfUjy/ b7FA== X-Gm-Message-State: AOAM531YB/rYvrLC2P4L4gpXoDme8M/hioJ0j7+qGDjbYEBOHnHyyrKQ bPKisiVV3zzkug6d32/qtRlORSMTcAneGdDgWdg= X-Google-Smtp-Source: ABdhPJyVH+Rz58jeThjRqbHxM68F5xsZlanLSn0RHHf58g9eo4S828VK2JlD7ENXVa+FmPR8K/Dy/SG+qLvsgPGZN4I= X-Received: by 2002:a05:6e02:1561:: with SMTP id k1mr21593650ilu.218.1622548760336; Tue, 01 Jun 2021 04:59:20 -0700 (PDT) MIME-Version: 1.0 References: <1620990152-19255-1-git-send-email-dillon.minfei@gmail.com> <1620990152-19255-3-git-send-email-dillon.minfei@gmail.com> In-Reply-To: From: Dillon Min Date: Tue, 1 Jun 2021 19:58:44 +0800 Message-ID: Subject: Re: [PATCH 2/4] i2c: stm32f4: Fix stmpe811 get xyz data timeout issue To: Patrice CHOTARD Cc: pierre-yves.mordret@foss.st.com, alain.volmat@foss.st.com, Maxime Coquelin , Alexandre TORGUE , Sumit Semwal , christian.koenig@amd.com, Michael Turquette , Stephen Boyd , linux-i2c@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, Linux ARM , Linux Kernel Mailing List , linux-media , "open list:DRM PANEL DRIVERS" , linaro-mm-sig@lists.linaro.org, linux-clk X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210601_045921_725536_CB215070 X-CRM114-Status: GOOD ( 34.32 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Patrice, Pierre-Yves, Alain On Tue, Jun 1, 2021 at 7:43 PM Patrice CHOTARD wrote: > > Hi Dillon > > On 5/14/21 1:02 PM, dillon.minfei@gmail.com wrote: > > From: Dillon Min > > > > As stm32f429's internal flash is 2Mbytes and compiled kernel > > image bigger than 2Mbytes, so we have to load kernel image > > to sdram on stm32f429-disco board which has 8Mbytes sdram space. > > > > based on above context, as you knows kernel running on external > > sdram is more slower than internal flash. besides, we need read 4 > > bytes to get touch screen xyz(x, y, pressure) coordinate data in > > stmpe811 interrupt. > > > > so, in stm32f4_i2c_handle_rx_done, as i2c read slower than running > > in xip mode, have to adjust 'STOP/START bit set position' from last > > two bytes to last one bytes. else, will get i2c timeout in reading > > touch screen coordinate. > > > > to not bring in side effect, introduce IIC_LAST_BYTE_POS to support xip > > kernel or zImage. > > > > Fixes: 62817fc8d282 ("i2c: stm32f4: add driver") > > Link: https://lore.kernel.org/lkml/1591709203-12106-5-git-send-email-dillon.minfei@gmail.com/ > > Signed-off-by: Dillon Min > > --- > > drivers/i2c/busses/i2c-stm32f4.c | 12 +++++++++--- > > 1 file changed, 9 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/i2c/busses/i2c-stm32f4.c b/drivers/i2c/busses/i2c-stm32f4.c > > index 4933fc8ce3fd..2e41231b9037 100644 > > --- a/drivers/i2c/busses/i2c-stm32f4.c > > +++ b/drivers/i2c/busses/i2c-stm32f4.c > > @@ -93,6 +93,12 @@ > > #define STM32F4_I2C_MAX_FREQ 46U > > #define HZ_TO_MHZ 1000000 > > > > +#if !defined(CONFIG_MMU) && !defined(CONFIG_XIP_KERNEL) > > +#define IIC_LAST_BYTE_POS 1 > > +#else > > +#define IIC_LAST_BYTE_POS 2 > > +#endif > > + > > /** > > * struct stm32f4_i2c_msg - client specific data > > * @addr: 8-bit slave addr, including r/w bit > > @@ -439,7 +445,7 @@ static void stm32f4_i2c_handle_rx_done(struct stm32f4_i2c_dev *i2c_dev) > > int i; > > > > switch (msg->count) { > > - case 2: > > + case IIC_LAST_BYTE_POS: > > /* > > * In order to correctly send the Stop or Repeated Start > > * condition on the I2C bus, the STOP/START bit has to be set > > @@ -454,7 +460,7 @@ static void stm32f4_i2c_handle_rx_done(struct stm32f4_i2c_dev *i2c_dev) > > else > > stm32f4_i2c_set_bits(reg, STM32F4_I2C_CR1_START); > > > > - for (i = 2; i > 0; i--) > > + for (i = IIC_LAST_BYTE_POS; i > 0; i--) > > stm32f4_i2c_read_msg(i2c_dev); > > > > reg = i2c_dev->base + STM32F4_I2C_CR2; > > @@ -463,7 +469,7 @@ static void stm32f4_i2c_handle_rx_done(struct stm32f4_i2c_dev *i2c_dev) > > > > complete(&i2c_dev->complete); > > break; > > - case 3: > > + case (IIC_LAST_BYTE_POS+1): > > /* > > * In order to correctly generate the NACK pulse after the last > > * received data byte, we have to enable NACK before reading N-2 > > > > I tested this patch on STM32F429-Disco, it fixes the issue described by Dillon. > But i think it's not a good idea to make usage of #if !defined(CONFIG_MMU) && !defined(CONFIG_XIP_KERNEL) > inside the driver code. Hi Patrice, Thanks for your time. How about introducing a dts node for this purpose. like stm32-i2c,last-byte-pos = <1>; or stm32-i2c,last-byte-pos = <2>; if not set, the default value is 2 Best Regards Dillon > > Pierre-Yves, Alain, as i am not I2C expert, can you have a look at this patch and propose another solution > to fix the original issue described by Dillon ? > > Thanks > Patrice _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel