[PATCH v1 06/11] spi: dw: send cmd and addr to start the spi transfer
From: Changhuang Liang
Date: Thu Jul 09 2026 - 02:10:56 EST
From: Sudip Mukherjee <sudip.mukherjee@xxxxxxxxxx>
In enhanced spi mode, read or write will start by sending the cmd
and address (if present).
Signed-off-by: Sudip Mukherjee <sudip.mukherjee@xxxxxxxxxx>
Co-developed-by: Changhuang Liang <changhuang.liang@xxxxxxxxxxxxxxxx>
Signed-off-by: Changhuang Liang <changhuang.liang@xxxxxxxxxxxxxxxx>
---
drivers/spi/spi-dw-core.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/drivers/spi/spi-dw-core.c b/drivers/spi/spi-dw-core.c
index 9f3ee1d78c05..9f0f7e0b93a1 100644
--- a/drivers/spi/spi-dw-core.c
+++ b/drivers/spi/spi-dw-core.c
@@ -836,6 +836,19 @@ static void dw_spi_init_enh_mem_buf(struct dw_spi *dws, const struct spi_mem_op
}
}
+static void dw_spi_enh_write_cmd_addr(struct dw_spi *dws, const struct spi_mem_op *op)
+{
+ /* Send cmd as 32 bit value */
+ dw_write_io_reg(dws, DW_SPI_DR, op->cmd.opcode);
+ if (op->addr.nbytes) {
+ dw_write_io_reg(dws, DW_SPI_DR, lower_32_bits(op->addr.val));
+ if (op->addr.nbytes > 4) {
+ /* address more than 32bit */
+ dw_write_io_reg(dws, DW_SPI_DR, upper_32_bits(op->addr.val));
+ }
+ }
+}
+
static int dw_spi_exec_enh_mem_op(struct spi_mem *mem, const struct spi_mem_op *op)
{
struct spi_controller *ctlr = mem->spi->controller;
@@ -895,6 +908,8 @@ static int dw_spi_exec_enh_mem_op(struct spi_mem *mem, const struct spi_mem_op *
dw_spi_enable_chip(dws, 1);
+ dw_spi_enh_write_cmd_addr(dws, op);
+
return 0;
}
--
2.25.1