linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: James Clark <james.clark@linaro.org>
To: Vladimir Oltean <olteanv@gmail.com>,
	Mark Brown <broonie@kernel.org>,  Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	 Matti Vaittinen <mazziesaccount@gmail.com>
Cc: Conor Dooley <conor+dt@kernel.org>, Frank Li <Frank.Li@nxp.com>,
	 Chester Lin <chester62515@gmail.com>,
	Matthias Brugger <mbrugger@suse.com>,
	 Ghennadi Procopciuc <ghennadi.procopciuc@oss.nxp.com>,
	 NXP S32 Linux Team <s32@nxp.com>,
	Shawn Guo <shawnguo@kernel.org>,
	 Sascha Hauer <s.hauer@pengutronix.de>,
	 Pengutronix Kernel Team <kernel@pengutronix.de>,
	 Fabio Estevam <festevam@gmail.com>,
	Chao Fu <B44548@freescale.com>,
	 Xiubo Li <Li.Xiubo@freescale.com>,
	Lukasz Majewski <lukma@denx.de>,
	 linux-spi@vger.kernel.org, imx@lists.linux.dev,
	 linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	 linux-arm-kernel@lists.infradead.org,
	 Vladimir Oltean <vladimir.oltean@nxp.com>,
	 Dan Carpenter <dan.carpenter@linaro.org>,
	 Larisa Grigore <larisa.grigore@nxp.com>,
	 Ciprian Marian Costea <ciprianmarian.costea@nxp.com>,
	 James Clark <james.clark@linaro.org>
Subject: [PATCH v2 09/14] spi: spi-fsl-dspi: Use DMA for S32G controller in target mode
Date: Thu, 22 May 2025 15:51:38 +0100	[thread overview]
Message-ID: <20250522-james-nxp-spi-v2-9-bea884630cfb@linaro.org> (raw)
In-Reply-To: <20250522-james-nxp-spi-v2-0-bea884630cfb@linaro.org>

From: Larisa Grigore <larisa.grigore@nxp.com>

Switch to DMA for target mode otherwise the controller is too slow to
feed TX FIFO and UNDERFLOW occurs frequently. DMA can work only with 8
and 16 bits per word. 32bits per word is not supported, this is a
hardware limitation, so we keep the controller mode in TCFQ mode.

Signed-off-by: Larisa Grigore <larisa.grigore@nxp.com>
Signed-off-by: Ciprian Marian Costea <ciprianmarian.costea@nxp.com>
Signed-off-by: James Clark <james.clark@linaro.org>
---
 drivers/spi/spi-fsl-dspi.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c
index 24a51267cb4d..db5a2ed66f68 100644
--- a/drivers/spi/spi-fsl-dspi.c
+++ b/drivers/spi/spi-fsl-dspi.c
@@ -139,6 +139,7 @@ enum {
 	MCF5441X,
 	VF610,
 	S32G,
+	S32G_TARGET,
 };
 
 static const struct regmap_range dspi_yes_ranges[] = {
@@ -183,6 +184,7 @@ static const struct regmap_access_table dspi_volatile_table = {
 
 enum {
 	DSPI_REGMAP,
+	S32G_DSPI_REGMAP,
 	DSPI_XSPI_REGMAP,
 	S32G_DSPI_XSPI_REGMAP,
 	DSPI_PUSHR,
@@ -198,6 +200,15 @@ static const struct regmap_config dspi_regmap_config[] = {
 		.rd_table	= &dspi_access_table,
 		.wr_table	= &dspi_access_table,
 	},
+	[S32G_DSPI_REGMAP] = {
+		.reg_bits	= 32,
+		.val_bits	= 32,
+		.reg_stride	= 4,
+		.max_register	= SPI_RXFR4,
+		.volatile_table	= &dspi_volatile_table,
+		.wr_table	= &s32g_dspi_access_table,
+		.rd_table	= &s32g_dspi_access_table,
+	},
 	[DSPI_XSPI_REGMAP] = {
 		.reg_bits	= 32,
 		.val_bits	= 32,
@@ -296,6 +307,12 @@ static const struct fsl_dspi_devtype_data devtype_data[] = {
 		.fifo_size	  = 5,
 		.regmap		  = &dspi_regmap_config[S32G_DSPI_XSPI_REGMAP],
 	},
+	[S32G_TARGET] = {
+		.trans_mode	  = DSPI_DMA_MODE,
+		.max_clock_factor = 1,
+		.fifo_size	  = 5,
+		.regmap		  = &dspi_regmap_config[S32G_DSPI_REGMAP],
+	},
 };
 
 struct fsl_dspi_dma {
@@ -351,6 +368,12 @@ struct fsl_dspi {
 	void (*dev_to_host)(struct fsl_dspi *dspi, u32 rxdata);
 };
 
+static bool is_s32g_dspi(struct fsl_dspi *data)
+{
+	return data->devtype_data == &devtype_data[S32G] ||
+	       data->devtype_data == &devtype_data[S32G_TARGET];
+}
+
 static void dspi_native_host_to_dev(struct fsl_dspi *dspi, u32 *txdata)
 {
 	switch (dspi->oper_word_size) {
@@ -1426,6 +1449,9 @@ static int dspi_probe(struct platform_device *pdev)
 		dspi->pushr_tx = 0;
 	}
 
+	if (spi_controller_is_target(ctlr) && is_s32g_dspi(dspi))
+		dspi->devtype_data = &devtype_data[S32G_TARGET];
+
 	if (dspi->devtype_data->trans_mode == DSPI_XSPI_MODE)
 		ctlr->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 32);
 	else

-- 
2.34.1


  parent reply	other threads:[~2025-05-22 14:52 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-22 14:51 [PATCH v2 00/14] spi: spi-fsl-dspi: DSPI support for NXP S32G platforms James Clark
2025-05-22 14:51 ` [PATCH v2 01/14] spi: spi-fsl-dspi: restrict register range for regmap access James Clark
2025-05-22 14:51 ` [PATCH v2 02/14] spi: spi-fsl-dspi: Halt the module after a new message transfer James Clark
2025-05-22 14:51 ` [PATCH v2 03/14] spi: spi-fsl-dspi: Reset SR flags before sending a new message James Clark
2025-05-22 14:51 ` [PATCH v2 04/14] spi: spi-fsl-dspi: Re-use one volatile regmap for both device types James Clark
2025-05-22 14:51 ` [PATCH v2 05/14] spi: spi-fsl-dspi: Define regmaps per device James Clark
2025-05-22 14:51 ` [PATCH v2 06/14] spi: spi-fsl-dspi: Add config and regmaps for S32G platforms James Clark
2025-05-22 14:51 ` [PATCH v2 07/14] spi: spi-fsl-dspi: Use spi_alloc_target for target James Clark
2025-05-22 14:51 ` [PATCH v2 08/14] spi: spi-fsl-dspi: Avoid setup_accel logic for DMA transfers James Clark
2025-05-22 14:51 ` James Clark [this message]
2025-05-22 14:51 ` [PATCH v2 10/14] spi: spi-fsl-dspi: Reinitialize DSPI regs after resuming for S32G James Clark
2025-05-22 14:51 ` [PATCH v2 11/14] spi: spi-fsl-dspi: Enable modified transfer protocol on S32G James Clark
2025-05-22 14:51 ` [PATCH v2 12/14] dt-bindings: spi: dspi: Add S32G support James Clark
2025-05-22 14:51 ` [PATCH v2 13/14] spi: spi-fsl-dspi: Enable support for S32G platforms James Clark
2025-05-22 14:51 ` [PATCH v2 14/14] arm64: dts: Add DSPI entries " James Clark
2025-06-19  7:38   ` Shawn Guo
2025-05-22 17:17 ` (subset) [PATCH v2 00/14] spi: spi-fsl-dspi: DSPI support for NXP " Mark Brown
2025-06-09 19: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=20250522-james-nxp-spi-v2-9-bea884630cfb@linaro.org \
    --to=james.clark@linaro.org \
    --cc=B44548@freescale.com \
    --cc=Frank.Li@nxp.com \
    --cc=Li.Xiubo@freescale.com \
    --cc=broonie@kernel.org \
    --cc=chester62515@gmail.com \
    --cc=ciprianmarian.costea@nxp.com \
    --cc=conor+dt@kernel.org \
    --cc=dan.carpenter@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=festevam@gmail.com \
    --cc=ghennadi.procopciuc@oss.nxp.com \
    --cc=imx@lists.linux.dev \
    --cc=kernel@pengutronix.de \
    --cc=krzk+dt@kernel.org \
    --cc=larisa.grigore@nxp.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=lukma@denx.de \
    --cc=mazziesaccount@gmail.com \
    --cc=mbrugger@suse.com \
    --cc=olteanv@gmail.com \
    --cc=robh@kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=s32@nxp.com \
    --cc=shawnguo@kernel.org \
    --cc=vladimir.oltean@nxp.com \
    /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;
as well as URLs for NNTP newsgroup(s).