From: Frank Li <Frank.li@oss.nxp.com>
To: Jyothi Kumar Seerapu <jyothi.seerapu@oss.qualcomm.com>
Cc: Mark Brown <broonie@kernel.org>, Vinod Koul <vkoul@kernel.org>,
Frank Li <Frank.Li@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Andy Gross <agross@kernel.org>,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konradybcio@kernel.org>,
Abel Vesa <abelvesa@kernel.org>,
linux-arm-msm@vger.kernel.org, linux-spi@vger.kernel.org,
dmaengine@vger.kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v2 5/6] dmaengine: qcom: gpi: Add QSPI protocol support
Date: Thu, 3 Dec 2026 15:48:02 -0600 [thread overview]
Message-ID: <axHjkp-QKQvKCfX8@SMW015318> (raw)
In-Reply-To: <20261124-qspi_qup_upstream-v2-5-cd69894107c8@oss.qualcomm.com>
On Tue, Nov 24, 2026 at 05:45:26PM +0530, Jyothi Kumar Seerapu wrote:
> QSPI reuses the SPI TRE format but requires protocol-specific handling
> for GO TRE fragmentation, transfer mode selection and dummy cycles.
>
> Translate the QCOM_GPI_QSPI DT client identifier to hardware protocol
> encoding 9 when programming the channel's SCRATCH_0 register. Retain
> the DT identifier for protocol-specific driver operations and leave
> the existing SPI, UART and I2C hardware mappings unchanged.
>
> Add QSPI support to the SPI TRE generation path and extend
> gpi_spi_config with transfer mode and dummy-cycle parameters. Encode
> dummy cycles in CONFIG0 and select the QSPI GO format for single,
> dual and quad SDR transfers, preserving the existing SPI encoding.
>
> Add SPI_TX_RX to the shared DMA interface for sequential TX-then-RX
> transactions. Enable RX end-of-transfer events for QSPI TX-then-RX
> commands so clients can wait for both DMA completions.
>
> Signed-off-by: Jyothi Kumar Seerapu <jyothi.seerapu@oss.qualcomm.com>
> ---
> drivers/dma/qcom/gpi.c | 32 ++++++++++++++++++++++++++------
> drivers/spi/spi-geni-qcom.c | 1 -
> include/linux/dma/qcom-gpi-dma.h | 6 ++++++
> 3 files changed, 32 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/dma/qcom/gpi.c b/drivers/dma/qcom/gpi.c
> index f2a2f653cc0b..59d9a393120e 100644
> --- a/drivers/dma/qcom/gpi.c
> +++ b/drivers/dma/qcom/gpi.c
> @@ -36,6 +36,7 @@
> #define TRE_SPI_C0_CS BIT(11)
> #define TRE_SPI_C0_CPHA BIT(12)
> #define TRE_SPI_C0_CPOL BIT(13)
> +#define TRE_SPI_C0_DUMMY_CYCLES GENMASK(21, 14)
> #define TRE_SPI_C0_TX_PACK BIT(24)
> #define TRE_SPI_C0_RX_PACK BIT(25)
>
> @@ -48,6 +49,10 @@
> #define TRE_SPI_GO_CS GENMASK(10, 8)
> #define TRE_SPI_GO_FRAG BIT(26)
>
> +/* QSPI GO WD0 */
> +#define TRE_QSPI_GO_FRAG BIT(22)
> +#define TRE_QSPI_GO_MODE GENMASK(31, 28)
> +
> /* GO WD2 */
> #define TRE_RX_LEN GENMASK(23, 0)
>
> @@ -206,6 +211,7 @@ enum CNTXT_OFFS {
> #define GPII_n_CH_k_QOS_OFFS(n, k) (0x2005C + (0x4000 * (n)) + (0x80 * (k)))
>
> /* Scratch registers */
> +#define GPI_QSPI_PROTOCOL_ID 9
> #define GPII_n_CH_k_SCRATCH_0_OFFS(n, k) (0x20060 + (0x4000 * (n)) + (0x80 * (k)))
> #define GPII_n_CH_k_SCRATCH_0_SEID GENMASK(2, 0)
> #define GPII_n_CH_k_SCRATCH_0_PROTO GENMASK(7, 4)
> @@ -482,7 +488,7 @@ struct gchan {
> struct virt_dma_chan vc;
> u32 chid;
> u32 seid;
> - u32 protocol;
> + u32 protocol; /* DT client protocol identifier */
> struct gpii *gpii;
> enum gpi_ch_state ch_state;
> enum gpi_pm_state pm_state;
> @@ -1264,6 +1270,7 @@ static int gpi_alloc_chan(struct gchan *chan, bool send_alloc_cmd)
> u32 id = gpii->gpii_id;
> u32 chid = chan->chid;
> u32 pair_chid = !chid;
> + u32 protocol = chan->protocol;
>
> if (send_alloc_cmd) {
> ret = gpi_send_cmd(gpii, chan, GPI_CH_CMD_ALLOCATE);
> @@ -1274,6 +1281,10 @@ static int gpi_alloc_chan(struct gchan *chan, bool send_alloc_cmd)
> }
> }
>
> + /* Translate the DT client identifier to the hardware protocol encoding. */
> + if (protocol == QCOM_GPI_QSPI)
> + protocol = GPI_QSPI_PROTOCOL_ID;
> +
> gpi_write_reg(gpii, chan->ch_cntxt_base_reg + CNTXT_0_CONFIG,
> GPII_n_CH_k_CNTXT_0(ring->el_size, 0, chan->dir, GPI_CHTYPE_PROTO_GPI));
> gpi_write_reg(gpii, chan->ch_cntxt_base_reg + CNTXT_1_R_LENGTH, ring->len);
> @@ -1283,7 +1294,7 @@ static int gpi_alloc_chan(struct gchan *chan, bool send_alloc_cmd)
> gpi_write_reg(gpii, chan->ch_cntxt_db_reg + CNTXT_5_RING_RP_MSB - CNTXT_4_RING_RP_LSB,
> upper_32_bits(ring->phys_addr));
> gpi_write_reg(gpii, gpii->regs + GPII_n_CH_k_SCRATCH_0_OFFS(id, chid),
> - GPII_n_CH_k_SCRATCH_0(pair_chid, chan->protocol, chan->seid));
> + GPII_n_CH_k_SCRATCH_0(pair_chid, protocol, chan->seid));
> gpi_write_reg(gpii, gpii->regs + GPII_n_CH_k_SCRATCH_1_OFFS(id, chid), 0);
> gpi_write_reg(gpii, gpii->regs + GPII_n_CH_k_SCRATCH_2_OFFS(id, chid), 0);
> gpi_write_reg(gpii, gpii->regs + GPII_n_CH_k_SCRATCH_3_OFFS(id, chid), 0);
> @@ -1728,6 +1739,7 @@ static int gpi_create_spi_tre(struct gchan *chan, struct gpi_desc *desc,
> tre->dword[0] |= u32_encode_bits(spi->loopback_en, TRE_SPI_C0_LOOPBACK);
> tre->dword[0] |= u32_encode_bits(spi->clock_pol_high, TRE_SPI_C0_CPOL);
> tre->dword[0] |= u32_encode_bits(spi->data_pol_high, TRE_SPI_C0_CPHA);
> + tre->dword[0] |= u32_encode_bits(spi->dummy_cycles, TRE_SPI_C0_DUMMY_CYCLES);
> tre->dword[0] |= u32_encode_bits(spi->pack_en, TRE_SPI_C0_TX_PACK);
> tre->dword[0] |= u32_encode_bits(spi->pack_en, TRE_SPI_C0_RX_PACK);
I can't understand why need put these control dwords in dma engine drivers.
Suppose it should be prepare at slave side, then pass these information
at prep_sg or other dma APIs.
A similar case at drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c
These implement is also many years ago.
May use struct dma_slave_config's void *peripheral_config;
Then use new API dmaengine_prep_config_sg(), which combine config and prep.
Frank
>
> @@ -1745,7 +1757,12 @@ static int gpi_create_spi_tre(struct gchan *chan, struct gpi_desc *desc,
> tre = &desc->tre[tre_idx];
> tre_idx++;
>
> - tre->dword[0] = u32_encode_bits(spi->fragmentation, TRE_SPI_GO_FRAG);
> + if (chan->protocol == QCOM_GPI_QSPI) {
> + tre->dword[0] = u32_encode_bits(spi->fragmentation, TRE_QSPI_GO_FRAG);
> + tre->dword[0] |= u32_encode_bits(spi->qspi_mode, TRE_QSPI_GO_MODE);
> + } else {
> + tre->dword[0] = u32_encode_bits(spi->fragmentation, TRE_SPI_GO_FRAG);
> + }
> tre->dword[0] |= u32_encode_bits(spi->cs, TRE_SPI_GO_CS);
> tre->dword[0] |= u32_encode_bits(spi->cmd, TRE_SPI_GO_CMD);
>
> @@ -1759,7 +1776,7 @@ static int gpi_create_spi_tre(struct gchan *chan, struct gpi_desc *desc,
> tre->dword[3] |= u32_encode_bits(1, TRE_FLAGS_LINK);
> } else if (spi->cmd == SPI_TX) {
> tre->dword[3] |= u32_encode_bits(1, TRE_FLAGS_CHAIN);
> - } else { /* SPI_DUPLEX */
> + } else { /* SPI_DUPLEX or SPI_TX_RX */
> tre->dword[3] |= u32_encode_bits(1, TRE_FLAGS_CHAIN);
> tre->dword[3] |= u32_encode_bits(1, TRE_FLAGS_LINK);
> }
> @@ -1792,7 +1809,10 @@ static int gpi_create_spi_tre(struct gchan *chan, struct gpi_desc *desc,
> tre->dword[3] = u32_encode_bits(TRE_TYPE_DMA, TRE_FLAGS_TYPE);
> }
>
> - tre->dword[3] |= u32_encode_bits(direction == DMA_MEM_TO_DEV,
> + /* QSPI TX-then-RX commands need a separate RX completion event. */
> + tre->dword[3] |= u32_encode_bits(direction == DMA_MEM_TO_DEV ||
> + (chan->protocol == QCOM_GPI_QSPI &&
> + spi->cmd == SPI_TX_RX),
> TRE_FLAGS_IEOT);
>
> for (i = 0; i < tre_idx; i++)
> @@ -1850,7 +1870,7 @@ gpi_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
> return NULL;
>
> /* create TREs for xfer */
> - if (gchan->protocol == QCOM_GPI_SPI) {
> + if (gchan->protocol == QCOM_GPI_SPI || gchan->protocol == QCOM_GPI_QSPI) {
> i = gpi_create_spi_tre(gchan, gpi_desc, sgl, direction);
> } else if (gchan->protocol == QCOM_GPI_I2C) {
> i = gpi_create_i2c_tre(gchan, gpi_desc, sgl, direction, flags);
> diff --git a/drivers/spi/spi-geni-qcom.c b/drivers/spi/spi-geni-qcom.c
> index 0a15e75051d8..631908522957 100644
> --- a/drivers/spi/spi-geni-qcom.c
> +++ b/drivers/spi/spi-geni-qcom.c
> @@ -69,7 +69,6 @@
> /* M_CMD OP codes for SPI */
> #define SPI_TX_ONLY 1
> #define SPI_RX_ONLY 2
> -#define SPI_TX_RX 7
> #define SPI_CS_ASSERT 8
> #define SPI_CS_DEASSERT 9
> #define SPI_SCK_ONLY 10
> diff --git a/include/linux/dma/qcom-gpi-dma.h b/include/linux/dma/qcom-gpi-dma.h
> index 332be28427e4..d2d659a075f9 100644
> --- a/include/linux/dma/qcom-gpi-dma.h
> +++ b/include/linux/dma/qcom-gpi-dma.h
> @@ -11,11 +11,13 @@
> * @SPI_TX: SPI peripheral TX command
> * @SPI_RX: SPI peripheral RX command
> * @SPI_DUPLEX: SPI peripheral Duplex command
> + * @SPI_TX_RX: SPI peripheral Tx-then-Rx command (QSPI read transactions)
> */
> enum spi_transfer_cmd {
> SPI_TX = 1,
> SPI_RX,
> SPI_DUPLEX,
> + SPI_TX_RX = 7,
> };
>
> /**
> @@ -33,6 +35,8 @@ enum spi_transfer_cmd {
> * @cs: chip select toggle
> * @set_config: set peripheral config
> * @rx_len: receive length for buffer
> + * @dummy_cycles: number of dummy clock cycles for a QSPI transfer
> + * @qspi_mode: QSPI bus-width/SDR-DDR mode for the GO TRE
> */
> struct gpi_spi_config {
> u8 set_config;
> @@ -43,10 +47,12 @@ struct gpi_spi_config {
> u8 word_len;
> u8 fragmentation;
> u8 cs;
> + u8 dummy_cycles;
> u32 clk_div;
> u32 clk_src;
> enum spi_transfer_cmd cmd;
> u32 rx_len;
> + u16 qspi_mode;
> };
>
> enum i2c_op {
>
> --
> 2.34.1
>
next prev parent reply other threads:[~2026-12-03 21:48 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 12:15 [PATCH v2 0/6] spi: qcom-geni: Add QSPI support over GPI DMA Jyothi Kumar Seerapu
2026-11-24 12:15 ` [PATCH v2 1/6] spi: spi-geni-qcom: Add transfer_one_message() support Jyothi Kumar Seerapu
2026-11-24 12:30 ` sashiko-bot
2026-12-02 11:32 ` Praveen Talari
2026-11-24 12:15 ` [PATCH v2 2/6] dt-bindings: dma: qcom-gpi: Add QSPI protocol identifier Jyothi Kumar Seerapu
2026-11-24 12:15 ` [PATCH v2 3/6] dt-bindings: spi: qcom,spi-geni-qcom: Document QSPI support Jyothi Kumar Seerapu
2026-11-24 12:15 ` [PATCH v2 4/6] soc: qcom: geni-se: Define the QSPI firmware protocol Jyothi Kumar Seerapu
2026-11-24 12:15 ` [PATCH v2 5/6] dmaengine: qcom: gpi: Add QSPI protocol support Jyothi Kumar Seerapu
2026-12-03 21:48 ` Frank Li [this message]
2026-11-24 12:15 ` [PATCH v2 6/6] spi: spi-geni-qcom: Add QSPI support over GPI DMA Jyothi Kumar Seerapu
2026-11-24 12:41 ` sashiko-bot
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=axHjkp-QKQvKCfX8@SMW015318 \
--to=frank.li@oss.nxp.com \
--cc=Frank.Li@kernel.org \
--cc=abelvesa@kernel.org \
--cc=agross@kernel.org \
--cc=andersson@kernel.org \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=jyothi.seerapu@oss.qualcomm.com \
--cc=konradybcio@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=robh@kernel.org \
--cc=vkoul@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