From patchwork Thu Sep 28 19:24:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 727438 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 477B5CE7B1E for ; Thu, 28 Sep 2023 19:24:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230390AbjI1TYd (ORCPT ); Thu, 28 Sep 2023 15:24:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229478AbjI1TYb (ORCPT ); Thu, 28 Sep 2023 15:24:31 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B11E1A2 for ; Thu, 28 Sep 2023 12:24:29 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230928192427euoutp026045c6a0e8bae29c5aa0161c76a15344~JJoBrNWz90642006420euoutp02V for ; Thu, 28 Sep 2023 19:24:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230928192427euoutp026045c6a0e8bae29c5aa0161c76a15344~JJoBrNWz90642006420euoutp02V DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1695929067; bh=GFOyU81B/Zw0ASGJNMLnJcw4VVGvy7QuYTXBvsRx+xQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A8k+eG2amUBfRrEN/nSRgUUQeLsrCAc/VPgQf8jAMD0Xngi9t1Q/8eeVwFhTFFyJ7 i5LHredwrBnakxBO4cY7V6A01A0ra0qC1I1/pgx57uOYS43H7bC8GlzJCpHSkCcVb4 ycjhBcHGrUm+dgHTXNJhv/y1YlPOcT0q4ez79OtE= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20230928192426eucas1p104af8583aedfa059f6ee7bad21573821~JJoAm_1Nm1181211812eucas1p17; Thu, 28 Sep 2023 19:24:26 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id DC.60.11320.AE2D5156; Thu, 28 Sep 2023 20:24:26 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230928192426eucas1p2b1763303daefc3fe1ac9354c17432572~JJoAOlcjT0047000470eucas1p2p; Thu, 28 Sep 2023 19:24:26 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230928192426eusmtrp2fd6c1a553186f69c82c415e7fda1585a~JJoAOFyXz2794927949eusmtrp2l; Thu, 28 Sep 2023 19:24:26 +0000 (GMT) X-AuditID: cbfec7f4-993ff70000022c38-9c-6515d2eafc61 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 02.F9.25043.AE2D5156; Thu, 28 Sep 2023 20:24:26 +0100 (BST) Received: from AMDC4653.digital.local (unknown [106.120.51.32]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230928192425eusmtip22b152eb299f6856c83994bbbac2651ce~JJn-y2dj12447124471eusmtip2P; Thu, 28 Sep 2023 19:24:25 +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 1/3] i2c: s3c24xx: fix read transfers in polled mode Date: Thu, 28 Sep 2023 21:24:12 +0200 Message-Id: <20230928192414.258169-2-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928192414.258169-1-m.szyprowski@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupmleLIzCtJLcpLzFFi42LZduznOd1Xl0RTDbbOkLF4MG8bm8X9rx2M Fntfb2W36Pj7hdFixvl9TBZrj9xlt7i7fy6jA7vHplWdbB53ru1h8+jbsorR4/MmuQCWKC6b lNSczLLUIn27BK6MCf9fsBfc5ai43MXdwDiJvYuRk0NCwESi89RFpi5GLg4hgRWMErsu3mKE cL4wSuybdpMZwvnMKLG98wtcy7/VU6CqljNKLJ39mhkkAdYybZcriM0mYCjR9baLDcQWEXCQ mLf2OztIA7PAZaCaOduYQBLCAi4SW/+9ZwWxWQRUJSa1NANN5eDgFbCT+HRSB2KZvMT+g2eZ QcKcAvYSFz5LgoR5BQQlTs58wgJiMwOVNG+dDXaohMAWDombrX+ZIXpdJKZ1rYeyhSVeHd8C 9YCMxP+d85kgGtoZJRb8vg/lTGCUaHgOCgCQKmuJO+d+sYFsZhbQlFi/Sx8i7Chx9M8LsLCE AJ/EjbeCEEfwSUzaNp0ZIswr0dEmBFGtJjHr+Dq4tQcvXII6x0Pi1ZNTzBMYFWcheWcWkndm IexdwMi8ilE8tbQ4Nz212CgvtVyvODG3uDQvXS85P3cTIzC9nP53/MsOxuWvPuodYmTiYDzE KMHBrCTC+/C2UKoQb0piZVVqUX58UWlOavEhRmkOFiVxXm3bk8lCAumJJanZqakFqUUwWSYO TqkGphB7A4mb30VfpLGzhAZNPJOybNmBjtvTV93Uf3Qk8Y992vOnHd0sUuufeN0+93ZNiv+J Ttu8qf19pt7JR89cm1/x7Z6X/7Wt52+Lrjj/XXN/lds2+W3XopN/7e2fZla9yT3o4urob8aC zHbNhnOn/90i++nGvWmOU5zeV7oknl3iv+P+KQ2bV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x0t20jj/G0R+5K3+Mm C994FxXzVf5CHL/Y3Md5G+Mmsc3oVPWZHPGx/rug8s/Df67suN5Z/UotNVjf9lOzyo7bATLP jNo9np6a8bQx/4eadv/MxyWL0wuivgfMf6zO15B5ikXjsK2nEktxRqKhFnNRcSIASC0KqQsD AAA= X-CMS-MailID: 20230928192426eucas1p2b1763303daefc3fe1ac9354c17432572 X-Msg-Generator: CA X-RootMTR: 20230928192426eucas1p2b1763303daefc3fe1ac9354c17432572 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230928192426eucas1p2b1763303daefc3fe1ac9354c17432572 References: <20230928192414.258169-1-m.szyprowski@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org To properly handle read transfers in polled mode, no waiting for the ACK state is needed. Just wait a bit to ensure start state is on the bus and continue processing 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 Thu Sep 28 19:24:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 728290 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 CD103E80A98 for ; Thu, 28 Sep 2023 19:24:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229478AbjI1TYd (ORCPT ); Thu, 28 Sep 2023 15:24:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231191AbjI1TYc (ORCPT ); Thu, 28 Sep 2023 15:24:32 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3347F1A5 for ; Thu, 28 Sep 2023 12:24:29 -0700 (PDT) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230928192427euoutp0130f454ec09e9819e0e549fc4382c4d58~JJoB8lQln0400004000euoutp01u for ; Thu, 28 Sep 2023 19:24:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230928192427euoutp0130f454ec09e9819e0e549fc4382c4d58~JJoB8lQln0400004000euoutp01u DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1695929068; bh=QFAsA2i7L3s/e//v7+GdgOSFKhScvcK0wqEuRE0fPmA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NNt/L1+d5UWDAdoih7Zngsl9Izg467zETXxfTqh1Ld/+dcvu+41yQd07E1iMYkEMm /45ljCPdFAGMoVXd1lj65IHgVKATumu0V8hJtfts3xt/y9dWv5dZJBPP6E1JQs3J5T kpi1aUbx7iggndetXvOZiS3q18K3GjWxxR+cMhgs= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230928192427eucas1p2adaa7aef3d812da843ea4f1946f367fa~JJoBwqASb2293522935eucas1p2C; Thu, 28 Sep 2023 19:24:27 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id A0.9A.37758.BE2D5156; Thu, 28 Sep 2023 20:24:27 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230928192426eucas1p19f03ce636f843fcbaeecde038c24f983~JJoArK53_1600016000eucas1p14; Thu, 28 Sep 2023 19:24:26 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230928192426eusmtrp1af5bc6497f37586178fd06fb500c7267~JJoAqrgqe2223422234eusmtrp1C; Thu, 28 Sep 2023 19:24:26 +0000 (GMT) X-AuditID: cbfec7f5-815ff7000002937e-83-6515d2eb8bc6 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 40.DC.10549.AE2D5156; Thu, 28 Sep 2023 20:24:26 +0100 (BST) Received: from AMDC4653.digital.local (unknown [106.120.51.32]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230928192426eusmtip26d3bedef21d4b6a9b64c1fb3b9006901~JJoAMpCIR1722017220eusmtip2n; Thu, 28 Sep 2023 19:24:26 +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 2/3] i2c: s3c24xx: fix transferring more than one message in polled mode Date: Thu, 28 Sep 2023 21:24:13 +0200 Message-Id: <20230928192414.258169-3-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928192414.258169-1-m.szyprowski@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuplleLIzCtJLcpLzFFi42LZduznOd3Xl0RTDba16Vg8mLeNzeL+1w5G i72vt7JbdPz9wmgx4/w+Jou1R+6yW9zdP5fRgd1j06pONo871/awefRtWcXo8XmTXABLFJdN SmpOZllqkb5dAlfG80vHWAqOCld82v+LrYHxO38XIyeHhICJRNfuQyxdjFwcQgIrGCXWH3vO BOF8YZSY2dPLCuF8ZpS4sH8lkMMB1nL7mw5EfDmjROetTla4jn0nDjOCzGUTMJToetvFBmKL CDhIzFv7nR2kiFngMqPEtDnbmEASwgJREk8mLGAFsVkEVCUmTf8K1swrYCdxcepmJogD5SX2 HzzLDLKZU8Be4sJnSYgSQYmTM5+wgNjMQCXNW2czg8yXENjBIfFjwSlmiF4XiSWT+tghbGGJ V8e3QNkyEqcn97BANLQzSiz4fZ8JwpnAKNHw/BYjRJW1xJ1zv9hANjMLaEqs36UPEXaUaDj8 hwUSFHwSN94KQhzBJzFp23RmiDCvREebEES1msSs4+vg1h68cAnqNA+JyUca2SYwKs5C8s4s JO/MQti7gJF5FaN4amlxbnpqsXFearlecWJucWleul5yfu4mRmCKOf3v+NcdjCtefdQ7xMjE wXiIUYKDWUmE9+FtoVQh3pTEyqrUovz4otKc1OJDjNIcLErivNq2J5OFBNITS1KzU1MLUotg skwcnFINTKYpp1uKuNonTOF6vjyznlHF/9qahWLc3f9v1h1cazPJxjaN+7eYjOiqTsH974wC /8xYY9y+oWOeVJfB5dU/zn5ldhfIPjipZY5f7hveTBb9pzeXP1Dti206VZ35sXqmFFdvntF7 Pb2jWk07I6cozxT7s89Z7cyPHWEdJ3ZOr9JrXnB0e8GDQ+9Xdd6o8V30uGDT+uoFjaZ/dgXa BczMesjfzXZX5NVH5yMVHvM71tsnmNged7syd8XGySE7Uya87S3eWJXu2q1dveLOhlt9XH4O j6KmvlB//NJJ8/Wl7MDtfwP+TzVO/X9PMG5uouXeAJl/Zcab27J+Mc7p75+wTkO7Ofnv/all NT03mGqqVyuxFGckGmoxFxUnAgARHP+CoAMAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrJLMWRmVeSWpSXmKPExsVy+t/xe7qvLommGnR9kbV4MG8bm8X9rx2M Fntfb2W36Pj7hdFixvl9TBZrj9xlt7i7fy6jA7vHplWdbB53ru1h8+jbsorR4/MmuQCWKD2b ovzSklSFjPziElulaEMLIz1DSws9IxNLPUNj81grI1MlfTublNSczLLUIn27BL2M55eOsRQc Fa74tP8XWwPjd/4uRg4OCQETidvfdLoYuTiEBJYySqw7do2xi5ETKC4jcXJaAyuELSzx51oX G0TRJ0aJa88ugiXYBAwlut6CJDg5RAScJG4vmsUKUsQscJ1R4vuBf2CThAUiJPq33mICsVkE VCUmTf8KFucVsJO4OHUzE8QGeYn9B88yg1zEKWAvceGzJIgpBFQy57gKRLWgxMmZT1hAbGag 6uats5knMArMQpKahSS1gJFpFaNIamlxbnpusaFecWJucWleul5yfu4mRmAcbDv2c/MOxnmv PuodYmTiYDzEKMHBrCTC+/C2UKoQb0piZVVqUX58UWlOavEhRlOgqycyS4km5wMjMa8k3tDM wNTQxMzSwNTSzFhJnNezoCNRSCA9sSQ1OzW1ILUIpo+Jg1OqgWmK07EXavOiaxIdtyyyXH2n Moj32Z87nZFrLwQest3BcuRCwswvCh08xjeuOK19eucgi1Lys9pd17yYa9bfY+t89He6TcOR LJaHW4uLYmZuEXzw0eL2gpeNSft8a6amK6zeEnwpJHjdngjHf/ZlHOcmzrXu4S817D+rMCEx rv2S1dsyw9WSka+lGPyXP73lHcOVLfJwmsfzRu+//8J44hY5WuvqyTppmHm2PZnNnfNjzsaO FX8nxr97Kvq859KbA3vPp/Q/KdniKft+TsKETxVpiu9PTfhrGxn4e1mP5obiUxt9Jqrd19jS 2d3mIRRlJfN7PceEiMSNx4QzylhEl+6w8WPjY7Wyazz+bQ6fzC8lluKMREMt5qLiRADTO0vn DAMAAA== X-CMS-MailID: 20230928192426eucas1p19f03ce636f843fcbaeecde038c24f983 X-Msg-Generator: CA X-RootMTR: 20230928192426eucas1p19f03ce636f843fcbaeecde038c24f983 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230928192426eucas1p19f03ce636f843fcbaeecde038c24f983 References: <20230928192414.258169-1-m.szyprowski@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org To properly handle ACK on the bus when transferring more than one message in polled 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. Also fix finishing transfers in polled 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 --- 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 Thu Sep 28 19:24:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 727437 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 31F12E80ABC for ; Thu, 28 Sep 2023 19:24:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231191AbjI1TYe (ORCPT ); Thu, 28 Sep 2023 15:24:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231556AbjI1TYc (ORCPT ); Thu, 28 Sep 2023 15:24:32 -0400 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB9EB1A1 for ; Thu, 28 Sep 2023 12:24:29 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20230928192428euoutp01cc87d9f088c969d6f0193d1a6609159f~JJoCtKSus3233332333euoutp01J for ; Thu, 28 Sep 2023 19:24:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20230928192428euoutp01cc87d9f088c969d6f0193d1a6609159f~JJoCtKSus3233332333euoutp01J DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1695929068; bh=oBDmmJRwhJ39d2l7by/nE4QIBDkcbt4eJaaAte6Fm54=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CaPkqy+Vjg0wjru2aDsvfif63n2hT9A9cs28aQSkVHyQ8Qa4ZrCR5Q3gna8v2Uhuh gGgUpnXmfZyK1hoeYArohC3gfI55+YPwF42XXHYhW2Mj5Ul9aQ9qoFRr8PZEKc77ZD K5ScyhbKVluQInChyZ2xPYWZhJuEyv7CeKKiJDl8= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230928192427eucas1p25f4bb1a4c32ff9bd8384d4df11653828~JJoB6L9hh2293122931eucas1p2F; Thu, 28 Sep 2023 19:24:27 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id E1.03.42423.BE2D5156; Thu, 28 Sep 2023 20:24:27 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20230928192427eucas1p2e9e7147af816c288e3fec365467ca357~JJoBDNgNP2294322943eucas1p2E; Thu, 28 Sep 2023 19:24:27 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230928192426eusmtrp19854def43ee1f91c36d45f6143a3197b~JJoBCmcU62223422234eusmtrp1D; Thu, 28 Sep 2023 19:24:26 +0000 (GMT) X-AuditID: cbfec7f2-a51ff7000002a5b7-8d-6515d2eb92ca Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id C0.DC.10549.AE2D5156; Thu, 28 Sep 2023 20:24:26 +0100 (BST) Received: from AMDC4653.digital.local (unknown [106.120.51.32]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230928192426eusmtip2d264c5d5577478fd49a61b7a60e8260b~JJoAnAffY1592515925eusmtip2m; Thu, 28 Sep 2023 19:24:26 +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 3/3] i2c: s3c24xx: add support for atomic transfers Date: Thu, 28 Sep 2023 21:24:14 +0200 Message-Id: <20230928192414.258169-4-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230928192414.258169-1-m.szyprowski@samsung.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupkleLIzCtJLcpLzFFi42LZduzned3Xl0RTDV49NbZ4MG8bm8X9rx2M Fntfb2W36Pj7hdFixvl9TBZrj9xlt7i7fy6jA7vHplWdbB53ru1h8+jbsorR4/MmuQCWKC6b lNSczLLUIn27BK6Mw99bmQuuCVXcmHmWpYFxA38XIyeHhICJxLxvK1lAbCGBFYwSB+dYdDFy AdlfGCU6pj1lhUh8ZpT4v9MJpuHZ6VdAcQ6g+HJGiZ9SECVA9XsuJIDYbAKGEl1vu9hAbBEB B4l5a7+zg8xkFrjMKDFtzjYmkISwgLPE7t0TwGwWAVWJvqXLmEFsXgE7iaYrjcwQu+Ql9h88 ywyyi1PAXuLCZ0mIEkGJkzOfgN3MDFTSvHU2M8h8CYEtHBK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dxgxi8wrYSTRdaWSG2CAvsf/gWSCbg4NTwF7iwmdJEFMIqGTOcRWIakGJkzOfgN3GDFTd vHU28wRGgVlIUrOQpBYwMq1iFEktLc5Nzy021CtOzC0uzUvXS87P3cQIjIRtx35u3sE479VH vUOMTByMhxglOJiVRHgf3hZKFeJNSaysSi3Kjy8qzUktPsRoCnT1RGYp0eR8YCzmlcQbmhmY GpqYWRqYWpoZK4nzehZ0JAoJpCeWpGanphakFsH0MXFwSjUwtU70YdR1vDz1ePMb67WZtxQ+ X34Qc+0t4+eNux7kfH4jtfL6X6Wunkds8b8fb9ScHnZdJbYp8EbqaY1mZmbWe771Zg9zdXkn XOxLkP3zeXXQ4Rmsm6878eVXOO9bM8H4iqjBL3Hvxo2xf3YzTXuWY9Bszv97alhDg6qqtMq7 2Ofqf0ye1H+ed/Bn1la7isC5DoybJDeon13twnPrfDzv5ecXZcxZIssTd12Rt4wsNv4a25zG m6t8/KHVqWIuLfvPfb+FP5706T8cM8d9QnPLjFq7LccfpS2KO5IS/k90q3u4Ruuin1OTDn4/ ecS5oLJtRxIjy+/tidOnfdN+mq0hu6Lh95QNa9/NW69scPnjDiWW4oxEQy3mouJEAOQAnx0N AwAA X-CMS-MailID: 20230928192427eucas1p2e9e7147af816c288e3fec365467ca357 X-Msg-Generator: CA X-RootMTR: 20230928192427eucas1p2e9e7147af816c288e3fec365467ca357 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230928192427eucas1p2e9e7147af816c288e3fec365467ca357 References: <20230928192414.258169-1-m.szyprowski@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Add support for atomic transfers using polled mode with interrupts intentionally disabled to get rid of the warning introduced by commit 63b96983a5dd ("i2c: core: introduce callbacks for atomic transfers"). Signed-off-by: Marek Szyprowski --- 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_FORCE_POLL (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_FORCE_POLL))) 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_FORCE_POLL)) { 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_FORCE_POLL; + ret = s3c24xx_i2c_xfer(adap, msgs, num); + i2c->quirks &= ~QUIRK_FORCE_POLL; + 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, };