From: Jaewon Kim <jaewon02.kim@samsung.com>
To: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
Andi Shyti <andi@etezian.org>,
Alim Akhtar <alim.akhtar@samsung.com>,
Mark Brown <broonie@kernel.org>, Rob Herring <robh+dt@kernel.org>
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 <chanho61.park@samsung.com>,
Jaewon Kim <jaewon02.kim@samsung.com>
Subject: [PATCH 1/3] spi: s3c64xx: support spi polling mode using devicetree
Date: Tue, 4 Apr 2023 15:00:09 +0900 [thread overview]
Message-ID: <20230404060011.108561-2-jaewon02.kim@samsung.com> (raw)
In-Reply-To: <20230404060011.108561-1-jaewon02.kim@samsung.com>
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 <jaewon02.kim@samsung.com>
---
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);
};
--
2.17.1
next prev parent reply other threads:[~2023-04-04 6:14 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20230404061409epcas2p2e97fff5459b405db0d5a206e2ad38f82@epcas2p2.samsung.com>
2023-04-04 6:00 ` [PATCH 0/3] spi: s3c64xx: improve SPI polling mode Jaewon Kim
[not found] ` <CGME20230404061409epcas2p15750d5844aa8d3655d1bfd094fac14a9@epcas2p1.samsung.com>
2023-04-04 6:00 ` Jaewon Kim [this message]
2023-04-04 10:54 ` [PATCH 1/3] spi: s3c64xx: support spi polling mode using devicetree Mark Brown
2023-04-04 11:17 ` Jaewon Kim
2023-04-04 11:41 ` Mark Brown
2023-04-04 12:22 ` Jaewon Kim
2023-04-04 12:41 ` Mark Brown
2023-04-05 5:42 ` Krzysztof Kozlowski
2023-04-05 11:42 ` Jaewon Kim
[not found] ` <CGME20230404061409epcas2p36402f7a84406ba9d831dcff0ddd994e9@epcas2p3.samsung.com>
2023-04-04 6:00 ` [PATCH 2/3] spi: dt-bindings: samsung: add samsung,spi-polling property Jaewon Kim
2023-04-04 12:36 ` Rob Herring
[not found] ` <CGME20230404061409epcas2p2b12a9cac014907e3930795cb67cb6040@epcas2p2.samsung.com>
2023-04-04 6:00 ` [PATCH 3/3] spi: s3c64xx: support interrupt based pio mode Jaewon Kim
2023-04-04 12:58 ` Mark Brown
2023-04-04 13:15 ` Jaewon Kim
2023-04-04 13:33 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230404060011.108561-2-jaewon02.kim@samsung.com \
--to=jaewon02.kim@samsung.com \
--cc=alim.akhtar@samsung.com \
--cc=andi@etezian.org \
--cc=broonie@kernel.org \
--cc=chanho61.park@samsung.com \
--cc=devicetree@vger.kernel.org \
--cc=krzysztof.kozlowski@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=robh+dt@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®