From patchwork Tue Apr 4 06:00:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaewon Kim X-Patchwork-Id: 13199174 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 88C2EC7618D for ; Tue, 4 Apr 2023 06:14:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233181AbjDDGOT (ORCPT ); Tue, 4 Apr 2023 02:14:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233675AbjDDGOS (ORCPT ); Tue, 4 Apr 2023 02:14:18 -0400 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9C4D1BCE for ; Mon, 3 Apr 2023 23:14:14 -0700 (PDT) Received: from epcas2p2.samsung.com (unknown [182.195.41.54]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20230404061411epoutp02aa441b98002cff83c3d77f8bd7f4990b~Spqf3ZH_C2905529055epoutp02r for ; Tue, 4 Apr 2023 06:14:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20230404061411epoutp02aa441b98002cff83c3d77f8bd7f4990b~Spqf3ZH_C2905529055epoutp02r DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1680588851; bh=YQOG1kLeNL9nH5IWx9ZXFg49ubwXjRePXvvk/rBA5sk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=moGK9aQ6rGZz68HV8SUkk1EZTj7Osu6VBDVZzlQLc/NVYnwxNvBmgZulN1ZDCwSAr Ac8ZMNwAM3ZEe/QI2I7GsZ6y/p9JwTVGl0QNv4Djk+tvehaViOqmWsX53fzr95lRw4 gVS7BsqUdS/fnjBP25LrHR54fm0RZCwev6fqxKIY= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas2p3.samsung.com (KnoxPortal) with ESMTP id 20230404061410epcas2p3ed4775b794f5044995c9189358693dcd~Spqe5UZWt2176821768epcas2p3V; Tue, 4 Apr 2023 06:14:10 +0000 (GMT) Received: from epsmges2p3.samsung.com (unknown [182.195.36.68]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4PrHXK667Gz4x9Ps; Tue, 4 Apr 2023 06:14:09 +0000 (GMT) Received: from epcas2p1.samsung.com ( [182.195.41.53]) by epsmges2p3.samsung.com (Symantec Messaging Gateway) with SMTP id 61.64.08750.130CB246; Tue, 4 Apr 2023 15:14:09 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas2p1.samsung.com (KnoxPortal) with ESMTPA id 20230404061409epcas2p15750d5844aa8d3655d1bfd094fac14a9~Spqd8hiBD1839518395epcas2p1z; Tue, 4 Apr 2023 06:14:09 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230404061409epsmtrp2c8139b86953002546b0ad0c67c0bb5d3~Spqd7oiwq2104021040epsmtrp2Q; Tue, 4 Apr 2023 06:14:09 +0000 (GMT) X-AuditID: b6c32a47-9f5fe7000000222e-48-642bc031f31b Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 69.8A.31821.130CB246; Tue, 4 Apr 2023 15:14:09 +0900 (KST) Received: from localhost.localdomain (unknown [10.229.9.51]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230404061409epsmtip1817a63890854b59df50249b212ce1c96~Spqdub5Uw3067630676epsmtip1F; Tue, 4 Apr 2023 06:14:09 +0000 (GMT) From: Jaewon Kim To: Krzysztof Kozlowski , Andi Shyti , Alim Akhtar , Mark Brown , Rob Herring Cc: linux-spi@vger.kernel.org, linux-samsung-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Chanho Park , Jaewon Kim Subject: [PATCH 1/3] spi: s3c64xx: support spi polling mode using devicetree Date: Tue, 4 Apr 2023 15:00:09 +0900 Message-Id: <20230404060011.108561-2-jaewon02.kim@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230404060011.108561-1-jaewon02.kim@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrJKsWRmVeSWpSXmKPExsWy7bCmqa7hAe0UgwnTdS0ezNvGZrH4x3Mm i6kPn7BZXN6vbTH/yDlWix0NR1gt9r7eym6x6fE1VovLu+awWcw4v4/JovHjTXaL1r1H2B14 PK4v+cTssWlVJ5vHnWt72Dw2L6n36NuyitHj8ya5ALaobJuM1MSU1CKF1Lzk/JTMvHRbJe/g eOd4UzMDQ11DSwtzJYW8xNxUWyUXnwBdt8wcoBOVFMoSc0qBQgGJxcVK+nY2RfmlJakKGfnF JbZKqQUpOQXmBXrFibnFpXnpenmpJVaGBgZGpkCFCdkZjzcsYSzYL12xa9VR1gbGx2JdjJwc EgImEnsX/mIBsYUEdjBKzFyV0sXIBWR/YpTY8O0GO4TzmVHi9eQeZpiO2xvnsUEkdjFKTLy3 lBXC+cgo0fCrFWwWm4C2xPf1i8ESIgJHGSW273wL5jALfGOUWHh0DhtIlbCAj8TU+fvBOlgE VCU+HXrOCGLzCthJPJvfxg6xT15i9YYDYLs5BewlvrbfYAEZJCHwlV3i6b0FjBBFLhKzzzxn gbCFJV4d3wLVLCXx+d1eNgg7W6J9+h9WCLtC4uKG2VBxY4lZz9qB5nAAXacpsX6XPogpIaAs ceQW2ERmAT6JjsN/2SHCvBIdbUIQjWoS96eegxoiIzHpyEomCNtD4ujPbUyQQJnEKNG8+BPz BEa5WQgLFjAyr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U5q8SFGaQ4WJXHeC10n44UE0hNLUrNTUwtSi2CyTBycUg1MB/9c0PnAtXjj BTc5xqPWz1fXhVjNiJY86+EzvYf9P8fee8u6fu29U+C4JtRu5TdVE70qNsl3epPEJs2YucpU ru3G/v3hrvVKNc8tuLjPV1VO+zK9tnztY3XGS0KPp098befgfVXr1XTnXRsPzZfmql0Xd8t/ 6iH2B5s7LZctOtjeXny5dYNpQedp01OOIiaTnv/g9PnU/U/0AntldP8Wrt1vxV1mBUvxrtb/ kPFd0jTww7ZFsXGu5zw6Xh8WkK0MWn8q/PtjcRvbI326fG3yGzgdHSfM4f5kp/5sa+qs88UC P5leKC7sy077vaivZpmDSdSO1UFWs0V+Pv1137Vx/6f7U8KYrjnuDVW7G66oo8RSnJFoqMVc VJwIAH5ggYTIAgAA X-CMS-MailID: 20230404061409epcas2p15750d5844aa8d3655d1bfd094fac14a9 X-Msg-Generator: CA X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230404061409epcas2p15750d5844aa8d3655d1bfd094fac14a9 References: <20230404060011.108561-1-jaewon02.kim@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org This patch adds new 'samsung,spi-polling' property to support polling mode. In some environments, polling mode is required even if DMA is supported. Changed it to support not only with quick but also optinally with devicetree. Signed-off-by: Jaewon Kim --- drivers/spi/spi-s3c64xx.c | 23 +++++++++++++++++------ include/linux/platform_data/spi-s3c64xx.h | 1 + 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index 71d324ec9a70..bf1f3dcca202 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -116,7 +116,6 @@ #define S3C64XX_SPI_TRAILCNT S3C64XX_SPI_MAX_TRAILCNT #define msecs_to_loops(t) (loops_per_jiffy / 1000 * HZ * t) -#define is_polling(x) (x->port_conf->quirks & S3C64XX_SPI_QUIRK_POLL) #define RXBUSY (1<<2) #define TXBUSY (1<<3) @@ -198,6 +197,17 @@ struct s3c64xx_spi_driver_data { unsigned int port_id; }; +static bool s3c64xx_is_polling(struct s3c64xx_spi_driver_data *sdd) +{ + if (sdd->port_conf->quirks & S3C64XX_SPI_QUIRK_POLL) + return true; + + if (sdd->cntrlr_info->polling) + return true; + + return false; +} + static void s3c64xx_flush_fifo(struct s3c64xx_spi_driver_data *sdd) { void __iomem *regs = sdd->regs; @@ -353,7 +363,7 @@ static int s3c64xx_spi_prepare_transfer(struct spi_master *spi) { struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(spi); - if (is_polling(sdd)) + if (s3c64xx_is_polling(sdd)) return 0; /* Requests DMA channels */ @@ -383,7 +393,7 @@ static int s3c64xx_spi_unprepare_transfer(struct spi_master *spi) { struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(spi); - if (is_polling(sdd)) + if (s3c64xx_is_polling(sdd)) return 0; /* Releases DMA channels if they are allocated */ @@ -749,7 +759,7 @@ static int s3c64xx_spi_transfer_one(struct spi_master *master, return status; } - if (!is_polling(sdd) && (xfer->len > fifo_len) && + if (!s3c64xx_is_polling(sdd) && (xfer->len > fifo_len) && sdd->rx_dma.ch && sdd->tx_dma.ch) { use_dma = 1; @@ -1067,6 +1077,7 @@ static struct s3c64xx_spi_info *s3c64xx_spi_parse_dt(struct device *dev) sci->num_cs = temp; } + sci->polling = of_property_read_bool(dev->of_node, "samsung,spi-polling"); sci->no_cs = of_property_read_bool(dev->of_node, "no-cs-readback"); return sci; @@ -1171,7 +1182,7 @@ static int s3c64xx_spi_probe(struct platform_device *pdev) if (sdd->port_conf->has_loopback) master->mode_bits |= SPI_LOOP; master->auto_runtime_pm = true; - if (!is_polling(sdd)) + if (!s3c64xx_is_polling(sdd)) master->can_dma = s3c64xx_spi_can_dma; sdd->regs = devm_ioremap_resource(&pdev->dev, mem_res); @@ -1295,7 +1306,7 @@ static int s3c64xx_spi_remove(struct platform_device *pdev) writel(0, sdd->regs + S3C64XX_SPI_INT_EN); - if (!is_polling(sdd)) { + if (!s3c64xx_is_polling(sdd)) { dma_release_channel(sdd->rx_dma.ch); dma_release_channel(sdd->tx_dma.ch); } diff --git a/include/linux/platform_data/spi-s3c64xx.h b/include/linux/platform_data/spi-s3c64xx.h index 5df1ace6d2c9..cb7b8ddc899f 100644 --- a/include/linux/platform_data/spi-s3c64xx.h +++ b/include/linux/platform_data/spi-s3c64xx.h @@ -35,6 +35,7 @@ struct s3c64xx_spi_info { int src_clk_nr; int num_cs; bool no_cs; + bool polling; int (*cfg_gpio)(void); }; From patchwork Tue Apr 4 06:00:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaewon Kim X-Patchwork-Id: 13199173 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 681C7C761A6 for ; Tue, 4 Apr 2023 06:14:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233027AbjDDGOU (ORCPT ); Tue, 4 Apr 2023 02:14:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233685AbjDDGOS (ORCPT ); Tue, 4 Apr 2023 02:14:18 -0400 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7B2E19BF for ; Mon, 3 Apr 2023 23:14:14 -0700 (PDT) Received: from epcas2p4.samsung.com (unknown [182.195.41.56]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20230404061410epoutp03dca70a7f5f78c8f44f6efb3ae35c977f~SpqfS40Vq3201732017epoutp03f for ; Tue, 4 Apr 2023 06:14:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20230404061410epoutp03dca70a7f5f78c8f44f6efb3ae35c977f~SpqfS40Vq3201732017epoutp03f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1680588850; bh=tRJgGYYznByDL7mxJ7EIBQGu/rJwJAmPezNaOZCA0hQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nxHNvNS9DsaMtwCJyKqDlRcnR4mJgVGh7emH8yhv7T+CHN7Iem0UjKUFzBuku9Ndp A2PM6DoclJpQoEdihPQpVZeQpad5+nGoF+DGJmTJ896/haeNw1R7pWHDpijosxEPHA 7OAnr4t/rtaxEHy6HkUc4e6Yn8XAOX9kYf8u76Vo= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas2p4.samsung.com (KnoxPortal) with ESMTP id 20230404061410epcas2p418b9cdf6e8c3dd1f6f38677261c47e14~SpqetJYYQ2325623256epcas2p4U; Tue, 4 Apr 2023 06:14:10 +0000 (GMT) Received: from epsmges2p4.samsung.com (unknown [182.195.36.97]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4PrHXK53yvz4x9Pp; Tue, 4 Apr 2023 06:14:09 +0000 (GMT) Received: from epcas2p3.samsung.com ( [182.195.41.55]) by epsmges2p4.samsung.com (Symantec Messaging Gateway) with SMTP id 15.26.35469.130CB246; Tue, 4 Apr 2023 15:14:09 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas2p3.samsung.com (KnoxPortal) with ESMTPA id 20230404061409epcas2p36402f7a84406ba9d831dcff0ddd994e9~SpqeBcm4b0777207772epcas2p36; Tue, 4 Apr 2023 06:14:09 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230404061409epsmtrp2be2358e26a8209311c48482d7bd33ea3~SpqeAmGtQ2104021040epsmtrp2R; Tue, 4 Apr 2023 06:14:09 +0000 (GMT) X-AuditID: b6c32a48-791ff70000008a8d-21-642bc03174b6 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 90.CD.18071.130CB246; Tue, 4 Apr 2023 15:14:09 +0900 (KST) Received: from localhost.localdomain (unknown [10.229.9.51]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230404061409epsmtip15e79fee3c5a715a623cbc8f82d9b8d4c~SpqdyxjUZ3067730677epsmtip1J; Tue, 4 Apr 2023 06:14:09 +0000 (GMT) From: Jaewon Kim To: Krzysztof Kozlowski , Andi Shyti , Alim Akhtar , Mark Brown , Rob Herring Cc: linux-spi@vger.kernel.org, linux-samsung-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Chanho Park , Jaewon Kim Subject: [PATCH 2/3] spi: dt-bindings: samsung: add samsung,spi-polling property Date: Tue, 4 Apr 2023 15:00:10 +0900 Message-Id: <20230404060011.108561-3-jaewon02.kim@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230404060011.108561-1-jaewon02.kim@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrGKsWRmVeSWpSXmKPExsWy7bCmua7hAe0Ugxdn1S0ezNvGZrH4x3Mm i6kPn7BZXN6vbTH/yDlWix0NR1gt9r7eym6x6fE1VovLu+awWcw4v4/JovHjTXaL1r1H2B14 PK4v+cTssWlVJ5vHnWt72Dw2L6n36NuyitHj8ya5ALaobJuM1MSU1CKF1Lzk/JTMvHRbJe/g eOd4UzMDQ11DSwtzJYW8xNxUWyUXnwBdt8wcoBOVFMoSc0qBQgGJxcVK+nY2RfmlJakKGfnF JbZKqQUpOQXmBXrFibnFpXnpenmpJVaGBgZGpkCFCdkZHefOsBRcYavY1D2DqYHxIGsXIyeH hIC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K4v+cTssWlVJ5vHnWt72Dw2L6n36NuyitHj8ya5ALYoLpuU1JzMstQifbsEroyOc2dYCq6w VWzqnsHUwHiQtYuRk0NCwETi/JKPjF2MXBxCArsZJX4t38IEkZCRWP6sjw3CFpa433IErEFI 4D2jxISXYSA2m4C2xPf1i1lBmkUETjJK/D7TxATiMAv8YZSYeuQ/2CRhgQCJ62uWsYPYLAKq EivOXweKc3DwCthJ7FjqD7FAXmL1hgPMIDangL3E1/YbLBDL7CR+/9vBPIGRbwEjwypGydSC 4tz03GLDAsO81HK94sTc4tK8dL3k/NxNjOBw1dLcwbh91Qe9Q4xMHIyHGCU4mJVEeFW7tFKE eFMSK6tSi/Lji0pzUosPMUpzsCiJ817oOhkvJJCeWJKanZpakFoEk2Xi4JRqYPITMD35zLPk qp/12+Q9EUqa1geePjaffWLRnNJaBs0NFe8fMJ3QievaG2IYn8229wLzU/2UHV/XSV9W1dM+ dSd7Qsv1rJ/tn7zeXm5rvPC8PlpzQubbTv1XE8JZlVsnXFvpmSXTVSWwPPXU/775pT6TJ4lu OvX2KePZm/sXsrs9Ubwtvfrvak5xrzsHUs65zO/x+Z3IK7j8gH0EA5swW5H8/xyBDbFJ6vU7 L1o8mbWaf+7u5SmpCQvq5WZULZUqnnhmsv+nreuteJo+8hoKPtcW1+bZdKBi/zfxnpBHVU02 55zZfhxScomY/vEr38kY4X0LIsz/N7Fy7fVZn8o/43nnpsJ9VxY/qzJf7xP2PEeJpTgj0VCL uag4EQAfy0aqxgIAAA== X-CMS-MailID: 20230404061409epcas2p36402f7a84406ba9d831dcff0ddd994e9 X-Msg-Generator: CA X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230404061409epcas2p36402f7a84406ba9d831dcff0ddd994e9 References: <20230404060011.108561-1-jaewon02.kim@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org This patch adds "samsung,spi-polling" property. It is method to check data trans by polling when DMA is not used. Signed-off-by: Jaewon Kim --- Documentation/devicetree/bindings/spi/samsung,spi.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/spi/samsung,spi.yaml b/Documentation/devicetree/bindings/spi/samsung,spi.yaml index e0a465d70b0a..b4942fe160f2 100644 --- a/Documentation/devicetree/bindings/spi/samsung,spi.yaml +++ b/Documentation/devicetree/bindings/spi/samsung,spi.yaml @@ -69,6 +69,12 @@ properties: $ref: /schemas/types.yaml#/definitions/uint32 default: 0 + samsung,spi-polling: + description: + Polling SPI data without DMA transfer. + type: boolean + default: 0 + reg: maxItems: 1 From patchwork Tue Apr 4 06:00:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaewon Kim X-Patchwork-Id: 13199172 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 1C206C6FD1D for ; Tue, 4 Apr 2023 06:14:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233678AbjDDGOS (ORCPT ); Tue, 4 Apr 2023 02:14:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233668AbjDDGOR (ORCPT ); Tue, 4 Apr 2023 02:14:17 -0400 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E75821B8 for ; Mon, 3 Apr 2023 23:14:14 -0700 (PDT) Received: from epcas2p1.samsung.com (unknown [182.195.41.53]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20230404061411epoutp039009679d095927187d1ea09ec511e4cc~Spqfp5zuZ3076830768epoutp03E for ; Tue, 4 Apr 2023 06:14:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20230404061411epoutp039009679d095927187d1ea09ec511e4cc~Spqfp5zuZ3076830768epoutp03E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1680588851; bh=yxk3LInfyfp4SqA7cJhgXDlEraKJNgFGdKmVnOtMA/g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FzeKSiSyaSV0fqX5IBCm+/O+Ch/FsjM2kRf2NTFZRTROpMjRIraUTBKzvfwvLvF5g Z5yMSor5P8SLgj6YVsCnoj/hFnFmFKtm0X2spg6hP5gJwXQrHjkxYElaTjXFoRqWQU waRfQZZ+kQkyZ3mFb1RBYVUOHBAnEUZV7/aJPb8Y= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas2p1.samsung.com (KnoxPortal) with ESMTP id 20230404061410epcas2p1ffd783739455327a78232e7a39fcc776~SpqfFMjrp1839918399epcas2p14; Tue, 4 Apr 2023 06:14:10 +0000 (GMT) Received: from epsmges2p1.samsung.com (unknown [182.195.36.70]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4PrHXL134Xz4x9QF; Tue, 4 Apr 2023 06:14:10 +0000 (GMT) Received: from epcas2p3.samsung.com ( [182.195.41.55]) by epsmges2p1.samsung.com (Symantec Messaging Gateway) with SMTP id C5.0D.61927.130CB246; Tue, 4 Apr 2023 15:14:10 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas2p2.samsung.com (KnoxPortal) with ESMTPA id 20230404061409epcas2p2b12a9cac014907e3930795cb67cb6040~SpqeEw5ss0906409064epcas2p2W; Tue, 4 Apr 2023 06:14:09 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20230404061409epsmtrp1d9839c642188df34f77c6026fd90d8b7~SpqeEBRS_0601006010epsmtrp1K; Tue, 4 Apr 2023 06:14:09 +0000 (GMT) X-AuditID: b6c32a45-671ff7000001f1e7-d2-642bc03137ec Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id A0.CD.18071.130CB246; Tue, 4 Apr 2023 15:14:09 +0900 (KST) Received: from localhost.localdomain (unknown [10.229.9.51]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20230404061409epsmtip13822c512614a3630e8784a3b1881b187~Spqd5kGE73056630566epsmtip1T; Tue, 4 Apr 2023 06:14:09 +0000 (GMT) From: Jaewon Kim To: Krzysztof Kozlowski , Andi Shyti , Alim Akhtar , Mark Brown , Rob Herring Cc: linux-spi@vger.kernel.org, linux-samsung-soc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Chanho Park , Jaewon Kim Subject: [PATCH 3/3] spi: s3c64xx: support interrupt based pio mode Date: Tue, 4 Apr 2023 15:00:11 +0900 Message-Id: <20230404060011.108561-4-jaewon02.kim@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230404060011.108561-1-jaewon02.kim@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrJKsWRmVeSWpSXmKPExsWy7bCmua7RAe0Ug40PGS0ezNvGZrH4x3Mm i6kPn7BZXN6vbTH/yDlWix0NR1gt9r7eym6x6fE1VovLu+awWcw4v4/JovHjTXaL1r1H2B14 PK4v+cTssWlVJ5vHnWt72Dw2L6n36NuyitHj8ya5ALaobJuM1MSU1CKF1Lzk/JTMvHRbJe/g eOd4UzMDQ11DSwtzJYW8xNxUWyUXnwBdt8wcoBOVFMoSc0qBQgGJxcVK+nY2RfmlJakKGfnF JbZKqQUpOQXmBXrFibnFpXnpenmpJVaGBgZGpkCFCdkZLec6mQr2yVccuvGYsYHxi0QXIyeH hICJxOuDGxm7GLk4hAR2MEq83jcLyvnEKPH9y212CO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yWc51MBfvk Kw7deMzYwPhFoouRk0NCwERiblcHYxcjF4eQwG5GiTv3tjBBJGQklj/rY4OwhSXutxxhhSh6 zyhxcdorZpAEm4C2xPf1i8ESIgInGSV+n2liAnGYBf4wSkw98h9slLCAs8SEaVvARrEIqEqc 7u4Bi/MK2EnseH4Pap28xOoNB8CmcgrYS3xtv8ECYgsB1fz+t4N5AiPfAkaGVYySqQXFuem5 xYYFhnmp5XrFibnFpXnpesn5uZsYwSGrpbmDcfuqD3qHGJk4GA8xSnAwK4nwqnZppQjxpiRW VqUW5ccXleakFh9ilOZgURLnvdB1Ml5IID2xJDU7NbUgtQgmy8TBKdXAtMp5WbA8W+OESgPN nrmFa/88KWE/nXXhxoyOiCYGPs8X5R16jUdeSk3iCfgfI1o1be6pewI32Fon8a5WdzHSYHn+ ff67J4e6HTx8thedUl5h4Myv7JD++upavxlu2UJvj0+59viCWPC73NjfKwQW/Fwnwlbh8z6Q 2z6z8oaDbZiOxAfV9tTdW02WHLnFcMrmyqtTYQX6r5IVU+Xvu2b35K5doifTxrdJ67c2X5SB /SdV4ZQ/0SJH7ui3dvX8lihknPBQLSZmz8J3EycZxzvbeK/R6zi6IEXUSGDPsh9//64+axj/ /8X/lWK+jWrlkvl3l63NL5/Pl/grTjcs0lzikmL3xhuPZJ/3hjFYXD6lxFKckWioxVxUnAgA i1UC1MgCAAA= X-CMS-MailID: 20230404061409epcas2p2b12a9cac014907e3930795cb67cb6040 X-Msg-Generator: CA X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20230404061409epcas2p2b12a9cac014907e3930795cb67cb6040 References: <20230404060011.108561-1-jaewon02.kim@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org This patch adds IRQ based PIO mode instead of cpu polling. By using the FIFO trigger level, interrupts are received. CPU consumption is reduced in PIO mode because registers are not constantly checked. Signed-off-by: Jaewon Kim --- drivers/spi/spi-s3c64xx.c | 54 ++++++++++++++++++++++++++++++++++----- 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index bf1f3dcca202..f8986b05309e 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -59,6 +59,8 @@ #define S3C64XX_SPI_MODE_BUS_TSZ_HALFWORD (1<<17) #define S3C64XX_SPI_MODE_BUS_TSZ_WORD (2<<17) #define S3C64XX_SPI_MODE_BUS_TSZ_MASK (3<<17) +#define S3C64XX_SPI_MODE_RX_RDY_LVL GENMASK(16, 11) +#define S3C64XX_SPI_MODE_RX_RDY_LVL_SHIFT 11 #define S3C64XX_SPI_MODE_SELF_LOOPBACK (1<<3) #define S3C64XX_SPI_MODE_RXDMA_ON (1<<2) #define S3C64XX_SPI_MODE_TXDMA_ON (1<<1) @@ -567,6 +569,7 @@ static int s3c64xx_wait_for_pio(struct s3c64xx_spi_driver_data *sdd, { void __iomem *regs = sdd->regs; unsigned long val; + unsigned long time; u32 status; int loops; u32 cpy_len; @@ -577,6 +580,11 @@ static int s3c64xx_wait_for_pio(struct s3c64xx_spi_driver_data *sdd, ms = xfer->len * 8 * 1000 / sdd->cur_speed; ms += 10; /* some tolerance */ + val = msecs_to_jiffies(ms); + time = wait_for_completion_timeout(&sdd->xfer_completion, val); + if (!time) + return -EIO; + val = msecs_to_loops(ms); do { status = readl(regs + S3C64XX_SPI_STATUS); @@ -743,6 +751,8 @@ static int s3c64xx_spi_transfer_one(struct spi_master *master, u32 speed; u8 bpw; unsigned long flags; + u32 rdy_lv; + u32 val; reinit_completion(&sdd->xfer_completion); @@ -763,17 +773,41 @@ static int s3c64xx_spi_transfer_one(struct spi_master *master, sdd->rx_dma.ch && sdd->tx_dma.ch) { use_dma = 1; - } else if (xfer->len > fifo_len) { + } else if (xfer->len >= fifo_len) { tx_buf = xfer->tx_buf; rx_buf = xfer->rx_buf; origin_len = xfer->len; - target_len = xfer->len; - if (xfer->len > fifo_len) - xfer->len = fifo_len; + xfer->len = fifo_len - 1; } do { + if (!use_dma) { + reinit_completion(&sdd->xfer_completion); + + rdy_lv = xfer->len; + /* Setup RDY_FIFO trigger Level + * RDY_LVL = + * fifo_lvl upto 64 byte -> N bytes + * 128 byte -> RDY_LVL * 2 bytes + * 256 byte -> RDY_LVL * 4 bytes + */ + if (fifo_len == 128) + rdy_lv /= 2; + else if (fifo_len == 256) + rdy_lv /= 4; + + val = readl(sdd->regs + S3C64XX_SPI_MODE_CFG); + val &= ~S3C64XX_SPI_MODE_RX_RDY_LVL; + val |= (rdy_lv << S3C64XX_SPI_MODE_RX_RDY_LVL_SHIFT); + writel(val, sdd->regs + S3C64XX_SPI_MODE_CFG); + + /* Enable FIFO_RDY_EN IRQ */ + val = readl(sdd->regs + S3C64XX_SPI_INT_EN); + writel((val | S3C64XX_SPI_INT_RX_FIFORDY_EN), + sdd->regs + S3C64XX_SPI_INT_EN); + + } spin_lock_irqsave(&sdd->lock, flags); /* Pending only which is to be done */ @@ -834,8 +868,8 @@ static int s3c64xx_spi_transfer_one(struct spi_master *master, if (xfer->rx_buf) xfer->rx_buf += xfer->len; - if (target_len > fifo_len) - xfer->len = fifo_len; + if (target_len >= fifo_len) + xfer->len = fifo_len - 1; else xfer->len = target_len; } @@ -1005,6 +1039,14 @@ static irqreturn_t s3c64xx_spi_irq(int irq, void *data) dev_err(&spi->dev, "TX underrun\n"); } + if (val & S3C64XX_SPI_ST_RX_FIFORDY) { + complete(&sdd->xfer_completion); + /* No pending clear irq, turn-off INT_EN_RX_FIFO_RDY */ + val = readl(sdd->regs + S3C64XX_SPI_INT_EN); + writel((val & ~S3C64XX_SPI_INT_RX_FIFORDY_EN), + sdd->regs + S3C64XX_SPI_INT_EN); + } + /* Clear the pending irq by setting and then clearing it */ writel(clr, sdd->regs + S3C64XX_SPI_PENDING_CLR); writel(0, sdd->regs + S3C64XX_SPI_PENDING_CLR);