From patchwork Wed Oct 25 12:17:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 738883 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 CD579C25B70 for ; Wed, 25 Oct 2023 12:17:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343821AbjJYMRu (ORCPT ); Wed, 25 Oct 2023 08:17:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343648AbjJYMRq (ORCPT ); Wed, 25 Oct 2023 08:17:46 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C679C191 for ; Wed, 25 Oct 2023 05:17:39 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20231025121738euoutp020fd4c2933b31e32d612d38591ef64403~RWOErfMUI2623326233euoutp02D for ; Wed, 25 Oct 2023 12:17:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20231025121738euoutp020fd4c2933b31e32d612d38591ef64403~RWOErfMUI2623326233euoutp02D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1698236258; bh=7i2kWxChpl+dJDdb02fIFXYVrXI2eBgain5wDSeEKPI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lXs5WA+j0QeQDf1CgaRBEloRb2CYT/4HmN56M6VRyV5l7OYNepWnbW3ryEZBXaXho jYi6Wu9NZa4aWwLOdcRGgZOgAWqjKlGZTMglVbQiMkCisJI7w69HMaYPnB3KXXdWht 4mDAv9r61Rr93ijNu7lmTy+iottXZ29J3SbpnFmA= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20231025121738eucas1p258ad23b4e246b76caf4c0b3a772fb419~RWOEdWxCQ0172001720eucas1p2u; Wed, 25 Oct 2023 12:17:38 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 5B.C0.11320.26709356; Wed, 25 Oct 2023 13:17:38 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20231025121737eucas1p1b5f0db709d99f8004f6177591cce0c8f~RWOD8ZUDM0317903179eucas1p1I; Wed, 25 Oct 2023 12:17:37 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20231025121737eusmtrp2f9faff147d35884baadd66d2df074a5b~RWOD7ukDI0245102451eusmtrp2F; Wed, 25 Oct 2023 12:17:37 +0000 (GMT) X-AuditID: cbfec7f4-993ff70000022c38-34-653907628296 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id DD.CA.10549.16709356; Wed, 25 Oct 2023 13:17:37 +0100 (BST) Received: from AMDC4653.digital.local (unknown [106.120.51.32]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20231025121737eusmtip2a777633719cde1288833fcc227dec25e~RWODbLYx13189431894eusmtip2g; Wed, 25 Oct 2023 12:17:37 +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 Subject: [PATCH v2 1/3] i2c: s3c24xx: fix read transfers in polling mode Date: Wed, 25 Oct 2023 14:17:23 +0200 Message-Id: <20231025121725.46028-2-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231025121725.46028-1-m.szyprowski@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupjleLIzCtJLcpLzFFi42LZduznOd0kdstUg6Z7ghYP5m1js7j/tYPR Yu/rrewWHX+/MFrMOL+PyWLtkbvsFnf3z2V0YPfYtKqTzePOtT1sHn1bVjF6fN4kF8ASxWWT kpqTWZZapG+XwJXROfMle8FPjoozz2awNDCuYO9i5OSQEDCRWPTxOHMXIxeHkMAKRomXD59A OV8YJRqbXrJCOJ8ZJZZ8XssI07L77A9GiMRyRonnf3axgiTAWh69FwKx2QQMJbredrGB2CIC DhLz1n5nB2lgFrjMKDFtzjYmkISwgIdE651ZzCA2i4CqxN+u9WBH8QrYSjS864Q6UF5i/8Gz YDWcAnYSX1d8Z4SoEZQ4OfMJC4jNDFTTvHU22N0SAms5JO63tkOd6iJxceF8qEHCEq+Ob4Gy ZST+75zPBNHQziix4Pd9KGcCo0TD81tQ3dYSd879AvqBA2iFpsT6XfoQYUeJddO3gIUlBPgk brwVhDiCT2LStunMEGFeiY42IYhqNYlZx9fBrT144RIzhO0hMXnjT9YJjIqzkLwzC8k7sxD2 LmBkXsUonlpanJueWmyUl1quV5yYW1yal66XnJ+7iRGYZE7/O/5lB+PyVx/1DjEycTAeYpTg YFYS4Y30sUgV4k1JrKxKLcqPLyrNSS0+xCjNwaIkzquaIp8qJJCeWJKanZpakFoEk2Xi4JRq YOpnV2vP+8Qn6VIU5bL779fHPM62jxVFu84e/2DG2r9hdsKb6ClVHO3v3l1dVZizcsHFuhbt exI+aYZC0dU6sraf/DRjYkX+mQTzVNlfc1dv1q0Ku7AjoP7bme7ljncP/vj6Y2HaqSnPVxeo brnxTXlS+6INT1V//s9iyys32xn1yeQ5z3YtDc3yPMPzjULfP9ibbpr+dtOZ+RNKyh+Vbz5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bgcpnbs9w2+P1B76MTXaJdNU1LVKW60q7k99jfj8ia8lpE9ZKs8N0T G2pCPpuFccxuKLocsK63Kb98u7WqW9K1dfsWzjC58OrVCyWW4oxEQy3mouJEAOOrisEPAwAA X-CMS-MailID: 20231025121737eucas1p1b5f0db709d99f8004f6177591cce0c8f X-Msg-Generator: CA X-RootMTR: 20231025121737eucas1p1b5f0db709d99f8004f6177591cce0c8f X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20231025121737eucas1p1b5f0db709d99f8004f6177591cce0c8f References: <20231025121725.46028-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 --- drivers/i2c/busses/i2c-s3c2410.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c index 127eb3805fac..f9dcb1112a61 100644 --- a/drivers/i2c/busses/i2c-s3c2410.c +++ b/drivers/i2c/busses/i2c-s3c2410.c @@ -216,8 +216,13 @@ 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)) { + usleep_range(100, 200); + return true; + } + if (tmp & S3C2410_IICCON_IRQPEND) { if (!(readl(i2c->regs + S3C2410_IICSTAT) & S3C2410_IICSTAT_LASTBIT)) return true; From patchwork Wed Oct 25 12:17:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 738130 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 205D1C25B6F for ; Wed, 25 Oct 2023 12:17:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234851AbjJYMRu (ORCPT ); Wed, 25 Oct 2023 08:17:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343773AbjJYMRq (ORCPT ); Wed, 25 Oct 2023 08:17:46 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B25B18C for ; Wed, 25 Oct 2023 05:17:41 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20231025121739euoutp01619a441d14bbc0b8982d4977e53d5972~RWOF7g5ba1299212992euoutp01f for ; Wed, 25 Oct 2023 12:17:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20231025121739euoutp01619a441d14bbc0b8982d4977e53d5972~RWOF7g5ba1299212992euoutp01f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1698236259; bh=EaxngnN5GPuk7N9hQGHXw/8N7rRnuHbLIX0yHopRP18=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QB34PelVVNndRMDWQtZ0Ro9Mxnkdrf5JcYTpuYC7OkVflDKjyEqJYdhwo1Qfu7vVL e/cRyrn991s2d179l0UxzglTALq9s1vqWMQuN83S3g6z1YIQQ0etuJ9bFruxj9QbMn nqBePJabDFlwjuKvtq0yl14EjYbHuP3v7zIHlzkg= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20231025121739eucas1p2bc0ec9c4828ca17177f534a268b82d2b~RWOFnbw1V1712917129eucas1p2G; Wed, 25 Oct 2023 12:17:39 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 7E.C0.11320.36709356; Wed, 25 Oct 2023 13:17:39 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20231025121739eucas1p26ce7f34cb63076626d40e08962497a0b~RWOFTaJvv1086510865eucas1p2Z; Wed, 25 Oct 2023 12:17:39 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20231025121739eusmtrp250f7e8c7f1cae10e6786c4039a6fb2a9~RWOFSrpmg0245102451eusmtrp2H; Wed, 25 Oct 2023 12:17:39 +0000 (GMT) X-AuditID: cbfec7f4-97dff70000022c38-39-6539076321e9 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 7F.CA.10549.36709356; Wed, 25 Oct 2023 13:17:39 +0100 (BST) Received: from AMDC4653.digital.local (unknown [106.120.51.32]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20231025121738eusmtip2b03099c0b30b3ae265b5595f06226191~RWOE1zQF_0359003590eusmtip2d; Wed, 25 Oct 2023 12:17:38 +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 Subject: [PATCH v2 2/3] i2c: s3c24xx: fix transferring more than one message in polling mode Date: Wed, 25 Oct 2023 14:17:24 +0200 Message-Id: <20231025121725.46028-3-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231025121725.46028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NRiLipOBAAC ZygwDgMAAA== X-CMS-MailID: 20231025121739eucas1p26ce7f34cb63076626d40e08962497a0b X-Msg-Generator: CA X-RootMTR: 20231025121739eucas1p26ce7f34cb63076626d40e08962497a0b X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20231025121739eucas1p26ce7f34cb63076626d40e08962497a0b References: <20231025121725.46028-1-m.szyprowski@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org To properly handle ACK on the bus when transferring more than one message in polling mode, move the polling handling loop from s3c24xx_i2c_message_start() to s3c24xx_i2c_doxfer(). This way i2c_s3c_irq_nextbyte() is always executed till the end, properly acknowledging the IRQ bits and no recursive calls to i2c_s3c_irq_nextbyte() are made. While touching this, also fix finishing transfers in polling mode by using common code path and always waiting for the bus to become idle and disabled. Fixes: 117053f77a5a ("i2c: s3c2410: Add polling mode support") Signed-off-by: Marek Szyprowski Reviewed-by: Chanho Park --- drivers/i2c/busses/i2c-s3c2410.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c index f9dcb1112a61..8da85cb42980 100644 --- a/drivers/i2c/busses/i2c-s3c2410.c +++ b/drivers/i2c/busses/i2c-s3c2410.c @@ -275,16 +275,6 @@ static void s3c24xx_i2c_message_start(struct s3c24xx_i2c *i2c, stat |= S3C2410_IICSTAT_START; writel(stat, i2c->regs + S3C2410_IICSTAT); - - if (i2c->quirks & QUIRK_POLL) { - while ((i2c->msg_num != 0) && is_ack(i2c)) { - i2c_s3c_irq_nextbyte(i2c, stat); - stat = readl(i2c->regs + S3C2410_IICSTAT); - - if (stat & S3C2410_IICSTAT_ARBITR) - dev_err(i2c->dev, "deal with arbitration loss\n"); - } - } } static inline void s3c24xx_i2c_stop(struct s3c24xx_i2c *i2c, int ret) @@ -691,7 +681,7 @@ static void s3c24xx_i2c_wait_idle(struct s3c24xx_i2c *i2c) static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c, struct i2c_msg *msgs, int num) { - unsigned long timeout; + unsigned long timeout = 0; int ret; ret = s3c24xx_i2c_set_master(i2c); @@ -711,16 +701,21 @@ static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c, s3c24xx_i2c_message_start(i2c, msgs); if (i2c->quirks & QUIRK_POLL) { - ret = i2c->msg_idx; + while ((i2c->msg_num != 0) && is_ack(i2c)) { + unsigned long stat = readl(i2c->regs + S3C2410_IICSTAT); - if (ret != num) - dev_dbg(i2c->dev, "incomplete xfer (%d)\n", ret); + i2c_s3c_irq_nextbyte(i2c, stat); - goto out; + stat = readl(i2c->regs + S3C2410_IICSTAT); + if (stat & S3C2410_IICSTAT_ARBITR) + dev_err(i2c->dev, "deal with arbitration loss\n"); + } + goto skip_waiting; } timeout = wait_event_timeout(i2c->wait, i2c->msg_num == 0, HZ * 5); + skip_waiting: ret = i2c->msg_idx; /* From patchwork Wed Oct 25 12:17:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 738129 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 474C5C25B71 for ; Wed, 25 Oct 2023 12:17:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343851AbjJYMRw (ORCPT ); Wed, 25 Oct 2023 08:17:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343840AbjJYMRq (ORCPT ); Wed, 25 Oct 2023 08:17:46 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 136281AD for ; Wed, 25 Oct 2023 05:17:43 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20231025121741euoutp01338478a58689fcb95408edc8ef75ecb5~RWOHOwKqH1352713527euoutp01F for ; Wed, 25 Oct 2023 12:17:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20231025121741euoutp01338478a58689fcb95408edc8ef75ecb5~RWOHOwKqH1352713527euoutp01F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1698236261; bh=BpdV7f9VR8u/BvRs3fCZwzxWnpXyLciTLMxLr/lmKWs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sik4vA+CcbX6Y3haTf5Njyf3CjEOryGsPW4cb5jb2lfZ0wJuiW85VfJlbQ/itDgQw DS9sfiT87NQkTlWZ7PWZyjlu4v/b2DX9E+rcCeW5td30qYri2XfC9EwAB1wW4QCQHA nDDmZta9U5vjDYK2rwsUc7q56/9BgdOR2Bv31btE= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20231025121741eucas1p296c6b198607e86f1ace7b09a4e35a53d~RWOG-OaV00868708687eucas1p2J; Wed, 25 Oct 2023 12:17:41 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 00.D0.11320.46709356; Wed, 25 Oct 2023 13:17:40 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20231025121740eucas1p2db798a12d80580af321c75edf5d59663~RWOGkCSOW0941409414eucas1p2D; Wed, 25 Oct 2023 12:17:40 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20231025121740eusmtrp21f8bfe7fa64a842afad87ff76cd1e9cf~RWOGjcyd20245102451eusmtrp2K; Wed, 25 Oct 2023 12:17:40 +0000 (GMT) X-AuditID: cbfec7f4-993ff70000022c38-40-65390764ed9a Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 41.DA.10549.46709356; Wed, 25 Oct 2023 13:17:40 +0100 (BST) Received: from AMDC4653.digital.local (unknown [106.120.51.32]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20231025121740eusmtip20cf96bf644ee975258f6ae98c4a482d0~RWOGGz8oW0383403834eusmtip2e; Wed, 25 Oct 2023 12:17:40 +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 Subject: [PATCH v2 3/3] i2c: s3c24xx: add support for atomic transfers Date: Wed, 25 Oct 2023 14:17:25 +0200 Message-Id: <20231025121725.46028-4-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231025121725.46028-1-m.szyprowski@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuplleLIzCtJLcpLzFFi42LZduznOd1UdstUg1ZhiwfztrFZ3P/awWix 9/VWdouOv18YLWac38dksfbIXXaLu/vnMjqwe2xa1cnmcefaHjaPvi2rGD0+b5ILYInisklJ zcksSy3St0vgyrhx7jhjwQuhikOPljI2MO7m72Lk5JAQMJH4P+sccxcjF4eQwApGiTO7njNB OF8YJTb8X8MMUiUk8JlR4sAnbpiOpT//MkIULWeU+PZnGRtcx91n81lAqtgEDCW63naxgdgi Ag4S89Z+ZwcpYha4zCgxbc42JpCEsICbxPW+drAiFgFViWnf/4M18wrYSmz93cEOsU5eYv/B s2BncArYSXxd8Z0RokZQ4uTMJ2D1zEA1zVtngz0hIbCFQ+LZsrO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CthKbP3dwQ6xQV5i/8GzzCA2p4CdxNcV38F6hYBqdh/vZIeoF5Q4OfMJWC8zUH3z 1tnMExgFZiFJzUKSWsDItIpRJLW0ODc9t9hQrzgxt7g0L10vOT93EyMwGrYd+7l5B+O8Vx/1 DjEycTAeYpTgYFYS4Y30sUgV4k1JrKxKLcqPLyrNSS0+xGgKdPdEZinR5HxgPOaVxBuaGZga mphZGphamhkrifN6FnQkCgmkJ5akZqemFqQWwfQxcXBKNTAFnRNiCTnXx9MslL71wI3e9juR 05QPHlwdV2kc+1PvokTEUQvbmclpu12yiuPfOphNPJp26M9MroMHtZyaJ7x/vmvxeZMAFuZ+ 9mdbTl6763yiTOicgUDZ/7JWOzWn6CW3axwuHdNZ1bPi18FnU8JsD/c//JIWL35u19pUld4j LJ8t1NlXbp+6gvVNUcUZq/cbC78bZcTs27/Mb7HFKkFWv6CMJR+jGZaJ/lqW7lkxX9A5Mce9 0prrSeRydp70Wye2zLR9zB60a9tjHltxu8MZ02dVc4Zdkw5gyuTbk6k5nSNPUj/15m/HMKlp l6uD0tYt0xLP7pj2WM9Nu8Ne9syMfQYZUf9mMKTuYb6w2kWJpTgj0VCLuag4EQCzrFSbDwMA AA== X-CMS-MailID: 20231025121740eucas1p2db798a12d80580af321c75edf5d59663 X-Msg-Generator: CA X-RootMTR: 20231025121740eucas1p2db798a12d80580af321c75edf5d59663 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20231025121740eucas1p2db798a12d80580af321c75edf5d59663 References: <20231025121725.46028-1-m.szyprowski@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org Add support for atomic transfers using polling mode with interrupts intentionally disabled to get rid of the warning introduced by commit 63b96983a5dd ("i2c: core: introduce callbacks for atomic transfers") during system reboot and power-off. Signed-off-by: Marek Szyprowski Reviewed-by: Chanho Park --- drivers/i2c/busses/i2c-s3c2410.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c index 8da85cb42980..586b82b30bdf 100644 --- a/drivers/i2c/busses/i2c-s3c2410.c +++ b/drivers/i2c/busses/i2c-s3c2410.c @@ -76,6 +76,7 @@ #define QUIRK_HDMIPHY (1 << 1) #define QUIRK_NO_GPIO (1 << 2) #define QUIRK_POLL (1 << 3) +#define QUIRK_ATOMIC (1 << 4) /* Max time to wait for bus to become idle after a xfer (in us) */ #define S3C2410_IDLE_TIMEOUT 5000 @@ -174,7 +175,7 @@ static inline void s3c24xx_i2c_master_complete(struct s3c24xx_i2c *i2c, int ret) if (ret) i2c->msg_idx = ret; - if (!(i2c->quirks & QUIRK_POLL)) + if (!(i2c->quirks & (QUIRK_POLL | QUIRK_ATOMIC))) wake_up(&i2c->wait); } @@ -700,7 +701,7 @@ static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c, s3c24xx_i2c_enable_irq(i2c); s3c24xx_i2c_message_start(i2c, msgs); - if (i2c->quirks & QUIRK_POLL) { + if (i2c->quirks & (QUIRK_POLL | QUIRK_ATOMIC)) { while ((i2c->msg_num != 0) && is_ack(i2c)) { unsigned long stat = readl(i2c->regs + S3C2410_IICSTAT); @@ -774,6 +775,21 @@ static int s3c24xx_i2c_xfer(struct i2c_adapter *adap, return -EREMOTEIO; } +static int s3c24xx_i2c_xfer_atomic(struct i2c_adapter *adap, + struct i2c_msg *msgs, int num) +{ + struct s3c24xx_i2c *i2c = (struct s3c24xx_i2c *)adap->algo_data; + int ret; + + disable_irq(i2c->irq); + i2c->quirks |= QUIRK_ATOMIC; + ret = s3c24xx_i2c_xfer(adap, msgs, num); + i2c->quirks &= ~QUIRK_ATOMIC; + enable_irq(i2c->irq); + + return ret; +} + /* declare our i2c functionality */ static u32 s3c24xx_i2c_func(struct i2c_adapter *adap) { @@ -784,6 +800,7 @@ static u32 s3c24xx_i2c_func(struct i2c_adapter *adap) /* i2c bus registration info */ static const struct i2c_algorithm s3c24xx_i2c_algorithm = { .master_xfer = s3c24xx_i2c_xfer, + .master_xfer_atomic = s3c24xx_i2c_xfer_atomic, .functionality = s3c24xx_i2c_func, };