From patchwork Fri May 14 11:02:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dillon Min X-Patchwork-Id: 12257499 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=-13.8 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,USER_AGENT_GIT 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 7085AC433B4 for ; Fri, 14 May 2021 11:05:12 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 E6744611CA for ; Fri, 14 May 2021 11:05:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E6744611CA 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=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:MIME-Version:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:Cc:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=fK6ey4Gr5YUmZKvJW0MCx2BjbFp/iGOZbWYcWk7l0v4=; b=Dw64GA0honsHf+xobStbhGGs2x 3RAnELD4bkA5j739ELdoGUyVnGtnMmY2bDXuOkK21ySGyd9W8HNG+/qrNl3WowG88zwQj8AemJoFl eo0Y0ATZfATUokGpRdXt6Edc5CFLkpF/Fut3RZIEtprMf8MfeW/2OCSA52E4xuzlHPqQIisX8vDqB PGoeJrIlVqQMab2gVB23KAQnttgAGOVz4IVH9YFjuqXrRSi2TLN1EyyktLMUt9vt5nAkGSKvkacWt CFcGVuigq+rnbceL5HYEibELUT13i7QxwYhKS7ffqJirpHVhbnIfYNBxQ64xCRGbLpJCxTapPW6w7 XhP7qD2w==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lhVaz-007q2K-6O; Fri, 14 May 2021 11:03:05 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lhVal-007q09-5o for linux-arm-kernel@desiato.infradead.org; Fri, 14 May 2021 11:02:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description; bh=w2B2gYwn3MtKVjip2AWbrWG6iOvfQAn7f6GZqcZIKfs=; b=Ch6JbtEJ8x2Caks9HkBaIoOxkt jlsYpqxr1GLNt9mAaF1F3uWQ3V75UAozoUJGQOBw75GcoEaqB8gwIU/M8rt12wLNgP2boh6nw+Shp uWfCTPuvWx9peTgsysVPkSEVPeaZ4V0O1bxts4Txf0+I1FEYA21FFx4qwIi4Ng0D54lUP45bwjwq5 UFuC8ueR+4vFS8yY5FJhqyhA3EX8uFqrpMXDp7OIlXAlGP8Pg/I+glLfwM78YjR31oDGdwHXahuhx yYTnL5UNn5I9mmC3bZudO5uc0RX2BkHVEsEQBvq+V5QfyT+RPqoWW0YNVcslD7FJaKYiIR56pJfj/ EF1JmPAA==; Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lhVah-00Bv84-LM for linux-arm-kernel@lists.infradead.org; Fri, 14 May 2021 11:02:49 +0000 Received: by mail-pj1-x1035.google.com with SMTP id j6-20020a17090adc86b02900cbfe6f2c96so1453099pjv.1 for ; Fri, 14 May 2021 04:02:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=w2B2gYwn3MtKVjip2AWbrWG6iOvfQAn7f6GZqcZIKfs=; b=TgbI5fIWdbDixv8fZQJYly0iM+UMF4g0NP2bB7QvRKHOCtekFwFpdwqa2Smm0qieMR cQhkcuk6HrL9QzbMUwMKmQ/+iqX9qh8JtB3qI25fYIyVBCfZMjLjJev7LBwGYbLezRBA yqN5lgcHsnPgf+Yw7GP9KXRyjblIbqjopBrlYfvUl/XNB28FWqvU/JMeTYw2VEteBZBC CzMZrxWr/+sqkZ/SFR+u+tZoysRoNkJ1utyigrNwrPEQhj0Qgj7jycSJyyYgRkhzZhC6 2Ccz9+PDCY2IRMJNn08L+sLmXJaPYq/2kPBLvSfgbJZp4LzCaorgzrdUE5QdqxnmrUYE okbA== 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:in-reply-to :references; bh=w2B2gYwn3MtKVjip2AWbrWG6iOvfQAn7f6GZqcZIKfs=; b=TYanJA+eF9B/pM4EuZ6/v+uBjOaha3kmhjsJ2Yq/Xms7fhie7d/+oi+GbuQ3ZaC8P8 vDsgi2c2N5wc7TL7rBMpDBu2yrjcltv4rmQuKMXhvIPIO1HfU9BYM2y4C8PG3IaAklNg nl5YGGvGJsRJqlwtU+QczUFm5Q4dFsZWIm2KhDugKxmPYbzcZqXknHz5jULWiu9RLcII idcePzwuwpf6Ftkzg12Dpu3orCAUqW4rcKCBBWSDPjhAESveFmnKVBvj7V+ZoVMx41SJ n2PQLYoNiAUG/D/XpPYNONtoV/W8YTTJ9LSER/KKD1iJiJfQo60ftQz4xRzompVl1aSV cSUQ== X-Gm-Message-State: AOAM531PUmQEZ8xCnH4rJx29NbIjZFoyQIFmVNmVbCnPQ2odBZJOqJt+ OSUKbVvwBG42g1F4YQ8Il+0= X-Google-Smtp-Source: ABdhPJyKBOqrBQtdA21EkB22MKpeUJqnWyuTGt2+olXKI7Jp6Mm6RIl7J9Rgxmrr02pM//5pykqqyA== X-Received: by 2002:a17:90a:b945:: with SMTP id f5mr52371098pjw.233.1620990166436; Fri, 14 May 2021 04:02:46 -0700 (PDT) Received: from fmin-OptiPlex-7060.nreal.work ([137.59.103.165]) by smtp.gmail.com with ESMTPSA id 202sm4193402pgg.59.2021.05.14.04.02.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 May 2021 04:02:46 -0700 (PDT) From: dillon.minfei@gmail.com To: patrice.chotard@foss.st.com, pierre-yves.mordret@foss.st.com, alain.volmat@foss.st.com, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, sumit.semwal@linaro.org, christian.koenig@amd.com, mturquette@baylibre.com Cc: sboyd@kernel.org, linux-i2c@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-clk@vger.kernel.org, Dillon Min Subject: [PATCH 2/4] i2c: stm32f4: Fix stmpe811 get xyz data timeout issue Date: Fri, 14 May 2021 19:02:30 +0800 Message-Id: <1620990152-19255-3-git-send-email-dillon.minfei@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1620990152-19255-1-git-send-email-dillon.minfei@gmail.com> References: <1620990152-19255-1-git-send-email-dillon.minfei@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210514_040247_731265_A1F36436 X-CRM114-Status: GOOD ( 15.14 ) 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: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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