From patchwork Wed Nov 8 16:43:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 13450318 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18B62C4167D for ; Wed, 8 Nov 2023 16:44:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229816AbjKHQoJ (ORCPT ); Wed, 8 Nov 2023 11:44:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230501AbjKHQoI (ORCPT ); Wed, 8 Nov 2023 11:44:08 -0500 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E1BB1FE8 for ; Wed, 8 Nov 2023 08:44:06 -0800 (PST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20231108164404euoutp01aa1b271fc067a12e25d9c8f5e81a20d1~Vs4szgKrs1558815588euoutp01u for ; Wed, 8 Nov 2023 16:44:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20231108164404euoutp01aa1b271fc067a12e25d9c8f5e81a20d1~Vs4szgKrs1558815588euoutp01u DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1699461844; bh=+fxGh0F2jh5WLjDPhQfaN5Ox2KF8VceXdmWAUqrEtYA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=urKWOBNrmNI1A2mqlb9XnjRKasfR8IL8VzkA7pS1+WqudOynRrVnPGUvdPqpuuIxc I0opGqJMu7RX0G4lkfbYVMgxrc2oj982KovlBOlYnkD1FYGnvHz40H5gTp/5x8GQrr ppPqxT4wzee1cJJaRzGkG3cE1yKLyTXQukdclFbM= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20231108164404eucas1p10c37b7f63fcda0e722054080041dd191~Vs4sV61-P0870608706eucas1p1u; Wed, 8 Nov 2023 16:44:04 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 95.D2.42423.4DABB456; Wed, 8 Nov 2023 16:44:04 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20231108164404eucas1p2fab093d286ef3c118f63bdc375964776~Vs4sBgv0G0157401574eucas1p2s; Wed, 8 Nov 2023 16:44:04 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20231108164403eusmtrp2c372e8b21f0aea4efba9a59f62810d04~Vs4sA3DFp2869728697eusmtrp2E; Wed, 8 Nov 2023 16:44:03 +0000 (GMT) X-AuditID: cbfec7f2-a3bff7000002a5b7-1e-654bbad4429f Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 79.12.25043.3DABB456; Wed, 8 Nov 2023 16:44:03 +0000 (GMT) Received: from AMDC4653.digital.local (unknown [106.120.51.32]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20231108164403eusmtip28a7163c316b152ef92196a14a2a86518~Vs4rdcjUL1025410254eusmtip2E; Wed, 8 Nov 2023 16:44:03 +0000 (GMT) From: Marek Szyprowski To: linux-samsung-soc@vger.kernel.org, linux-i2c@vger.kernel.org Cc: Marek Szyprowski , Krzysztof Kozlowski , Alim Akhtar , Andi Shyti , Wolfram Sang , Chanho Park Subject: [PATCH v4 1/3] i2c: s3c24xx: fix read transfers in polling mode Date: Wed, 8 Nov 2023 17:43:52 +0100 Message-Id: <20231108164354.712406-2-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231108164354.712406-1-m.szyprowski@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupjleLIzCtJLcpLzFFi42LZduzned0ru7xTDS7PF7R4MG8bm8X9rx2M Fpf3a1vsfb2V3aLj7xdGixnn9zFZrD1yl93i7v65jA4cHptWdbJ53Lm2h82jb8sqRo/Pm+QC WKK4bFJSczLLUov07RK4Mh4d/M9UcIarYtnPLqYGxvMcXYycHBICJhL3D2xk72Lk4hASWMEo sWvOYTaQhJDAF0aJPeskIezPjBJH3wfCNEy61M8K0bCcUeLT8euMEA5Qw5wvk9lBqtgEDCW6 3naBTRIRcJCYt/Y7WJxZ4B+jxPcveiC2sICHxMcp88DiLAKqErd+gkzl5OAVsJNY39TGDLFN XmL/wbNgNqeAvUT3hNnsEDWCEidnPmGBmCkv0bx1NjPIERICOzgkvkxdBVTEAeS4SDQvK4eY Iyzx6vgWdghbRuL/zvlMEPXtjBILft+HciYwSjQ8v8UIUWUtcefcLzaQQcwCmhLrd+lDzHSU +PmNC8Lkk7jxVhDiBD6JSdumM0OEeSU62oQgZqhJzDq+Dm7rwQuXoL7ykLj6cDvjBEbFWUie mYXkmVkIaxcwMq9iFE8tLc5NTy02zEst1ytOzC0uzUvXS87P3cQITDKn/x3/tINx7quPeocY mTgYDzFKcDArifD+tfdIFeJNSaysSi3Kjy8qzUktPsQozcGiJM6rmiKfKiSQnliSmp2aWpBa BJNl4uCUamCa8kHIJd6p33eV6Y0rW+dEMV6xLLWS7Cjbn7D+orLgyzUN80pY1L/zdeo45VqH rnHXyFhfaaQQN1fN8eDJXee0HaZENe/sdfmkaHL07on0g1/qH6935rR44vdljffVUzdq9hbx NvKccjk0rTDIVmbFmUyXpDT5B7Nf+1gYXpo5VUz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g8N0da z51h76OjKvT9qFBJtNHEd1dmnT56/Pryb8Wqyp/6gviecgsYsHQbzFxbv+64yNt59pZe/Qy7 XS/UHE/0kPW+FLFxTv76+XURSx/cZ7wQOk3Wpe3x+qLHKa9XPVViKc5INNRiLipOBACvzYGf EgMAAA== X-CMS-MailID: 20231108164404eucas1p2fab093d286ef3c118f63bdc375964776 X-Msg-Generator: CA X-RootMTR: 20231108164404eucas1p2fab093d286ef3c118f63bdc375964776 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20231108164404eucas1p2fab093d286ef3c118f63bdc375964776 References: <20231108164354.712406-1-m.szyprowski@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org To properly handle read transfers in polling mode, no waiting for the ACK state is needed as it will never come. Just wait a bit to ensure start state is on the bus and continue processing next bytes. Fixes: 117053f77a5a ("i2c: s3c2410: Add polling mode support") Signed-off-by: Marek Szyprowski Reviewed-by: Chanho Park Reviewed-by: Andi Shyti --- drivers/i2c/busses/i2c-s3c2410.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c index c56886af724e..bf9a5670ef33 100644 --- a/drivers/i2c/busses/i2c-s3c2410.c +++ b/drivers/i2c/busses/i2c-s3c2410.c @@ -216,8 +216,17 @@ static bool is_ack(struct s3c24xx_i2c *i2c) int tries; for (tries = 50; tries; --tries) { - if (readl(i2c->regs + S3C2410_IICCON) - & S3C2410_IICCON_IRQPEND) { + unsigned long tmp = readl(i2c->regs + S3C2410_IICCON); + + if (!(tmp & S3C2410_IICCON_ACKEN)) { + /* + * Wait a bit for the bus to stabilize, + * delay estimated experimentally. + */ + usleep_range(100, 200); + return true; + } + if (tmp & S3C2410_IICCON_IRQPEND) { if (!(readl(i2c->regs + S3C2410_IICSTAT) & S3C2410_IICSTAT_LASTBIT)) return true;