Devicetree
 help / color / mirror / Atom feed
From: Changhuang Liang <changhuang.liang@starfivetech.com>
To: Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Mark Brown <broonie@kernel.org>
Cc: Sudip Mukherjee <sudip.mukherjee@sifive.com>,
	Serge Semin <fancer.lancer@gmail.com>,
	linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org,
	devicetree@vger.kernel.org,
	Changhuang Liang <changhuang.liang@starfivetech.com>
Subject: [PATCH v2 05/11] spi: dw: update NDF while using enhanced spi mode
Date: Mon,  3 Aug 2026 05:40:38 -0700	[thread overview]
Message-ID: <20260803124044.156998-6-changhuang.liang@starfivetech.com> (raw)
In-Reply-To: <20260803124044.156998-1-changhuang.liang@starfivetech.com>

From: Sudip Mukherjee <sudip.mukherjee@sifive.com>

If the transfer of Transmit only mode is using enhanced SPI then
NDF needs to be updated with the number of data frames.
If the Transmit FIFO goes empty in-between, DWC_ssi masks the serial
clock and wait for rest of the data until the programmed amount of
frames are transferred successfully.
In receive mode, the number of data frames received is equal to this
register value plus 1.
In transmit mode, the number of data frames is equal this register
value.

Signed-off-by: Sudip Mukherjee <sudip.mukherjee@sifive.com>
Co-developed-by: Changhuang Liang <changhuang.liang@starfivetech.com>
Signed-off-by: Changhuang Liang <changhuang.liang@starfivetech.com>
---
 drivers/spi/spi-dw-core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/spi/spi-dw-core.c b/drivers/spi/spi-dw-core.c
index c7cd24337188..5f215e76a7ad 100644
--- a/drivers/spi/spi-dw-core.c
+++ b/drivers/spi/spi-dw-core.c
@@ -348,6 +348,9 @@ void dw_spi_update_config(struct dw_spi *dws, struct spi_device *spi,
 	if (cfg->tmode == DW_SPI_CTRLR0_TMOD_EPROMREAD ||
 	    cfg->tmode == DW_SPI_CTRLR0_TMOD_RO)
 		dw_writel(dws, DW_SPI_CTRLR1, cfg->ndf ? cfg->ndf - 1 : 0);
+	else if (cfg->tmode == DW_SPI_CTRLR0_TMOD_TO &&
+		 dws->caps & DW_SPI_CAP_EMODE)
+		dw_writel(dws, DW_SPI_CTRLR1, cfg->ndf);
 
 	/* Note DW APB SSI clock divider doesn't support odd numbers */
 	clk_div = (DIV_ROUND_UP(dws->max_freq, cfg->freq) + 1) & 0xfffe;
-- 
2.25.1


  parent reply	other threads:[~2026-08-03 12:41 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-03 12:40 [PATCH v2 00/11] Add support for StarFive JHB100 SFC Changhuang Liang
2026-08-03 12:40 ` [PATCH v2 01/11] spi: dw: Introduce spi_frf and STD_SPI Changhuang Liang
2026-08-03 12:40 ` [PATCH v2 02/11] spi: dw: update SPI_CTRLR0 register Changhuang Liang
2026-08-03 12:40 ` [PATCH v2 03/11] spi: dw: add check for support of enhanced spi Changhuang Liang
2026-08-03 12:53   ` sashiko-bot
2026-08-03 12:40 ` [PATCH v2 04/11] spi: dw: adjust size of mem_op Changhuang Liang
2026-08-03 12:40 ` Changhuang Liang [this message]
2026-08-03 13:02   ` [PATCH v2 05/11] spi: dw: update NDF while using enhanced spi mode sashiko-bot
2026-08-03 12:40 ` [PATCH v2 06/11] spi: dw: Introduce enhanced single/dual/quad/octal spi Changhuang Liang
2026-08-03 12:58   ` sashiko-bot
2026-08-03 12:40 ` [PATCH v2 07/11] spi: dw: send cmd and addr to start the spi transfer Changhuang Liang
2026-08-03 12:59   ` sashiko-bot
2026-08-03 12:40 ` [PATCH v2 08/11] spi: dw: use irq handler for enhanced spi Changhuang Liang
2026-08-03 12:59   ` sashiko-bot
2026-08-03 12:40 ` [PATCH v2 09/11] spi: dw: detect enhanced spi mode Changhuang Liang
2026-08-03 13:07   ` sashiko-bot
2026-08-03 12:40 ` [PATCH v2 10/11] spi: dt-bindings: snps,dw-apb-ssi: Add starfive,jhb100-sfc Changhuang Liang
2026-08-03 12:40 ` [PATCH v2 11/11] spi: dw: Add support for StarFive JHB100 SoC SFC Changhuang Liang
2026-08-03 13:07   ` sashiko-bot
2026-08-04 12:53 ` [PATCH v2 00/11] Add support for StarFive JHB100 SFC 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=20260803124044.156998-6-changhuang.liang@starfivetech.com \
    --to=changhuang.liang@starfivetech.com \
    --cc=broonie@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=fancer.lancer@gmail.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sudip.mukherjee@sifive.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