[PATCH RFC v2 09/35] spi: amlogic-spifc-a4: Consume dummy cycles directly
From: Miquel Raynal
Date: Fri Nov 27 2026 - 09:26:51 EST
The controller programs the dummy phase in clock cycles, but the driver
converts the legacy dummy byte count into cycles. Advertise the
dummy_cycles capability and use op->dummy.ncycles directly.
Signed-off-by: Miquel Raynal <miquel.raynal@xxxxxxxxxxx>
---
drivers/spi/spi-amlogic-spifc-a4.c | 29 +++++------------------------
1 file changed, 5 insertions(+), 24 deletions(-)
diff --git a/drivers/spi/spi-amlogic-spifc-a4.c b/drivers/spi/spi-amlogic-spifc-a4.c
index 16346f50c7d9..9b658ed1a580 100644
--- a/drivers/spi/spi-amlogic-spifc-a4.c
+++ b/drivers/spi/spi-amlogic-spifc-a4.c
@@ -148,7 +148,6 @@
#define SFC_MAX_CS_NUM 2
/* SPI-FLASH R/W operation cmd */
-#define SPIFLASH_RD_OCTALIO 0xcb
#define SPIFLASH_RD_OCTAL 0x8b
#define SPIFLASH_RD_QUADIO 0xeb
#define SPIFLASH_RD_QUAD 0x6b
@@ -334,23 +333,9 @@ static int aml_sfc_send_addr(struct aml_sfc *sfc, const struct spi_mem_op *op)
return 0;
}
-static bool aml_sfc_is_xio_op(const struct spi_mem_op *op)
-{
- switch (op->cmd.opcode) {
- case SPIFLASH_RD_OCTALIO:
- case SPIFLASH_RD_QUADIO:
- case SPIFLASH_RD_DUALIO:
- return true;
- default:
- break;
- }
-
- return false;
-}
-
static int aml_sfc_send_cmd_addr_dummy(struct aml_sfc *sfc, const struct spi_mem_op *op)
{
- u32 dummy_cycle, cmd;
+ u32 cmd;
int ret;
ret = aml_sfc_send_cmd(sfc, op);
@@ -361,13 +346,8 @@ static int aml_sfc_send_cmd_addr_dummy(struct aml_sfc *sfc, const struct spi_mem
if (ret)
return ret;
- if (op->dummy.nbytes) {
- /* Dummy buswidth configuration is not supported */
- if (aml_sfc_is_xio_op(op))
- dummy_cycle = op->dummy.nbytes * 8 / op->data.buswidth;
- else
- dummy_cycle = op->dummy.nbytes * 8;
- cmd = CMD_DUMMY(sfc->cs_sel, dummy_cycle - 1);
+ if (op->dummy.ncycles) {
+ cmd = CMD_DUMMY(sfc->cs_sel, op->dummy.ncycles - 1);
return regmap_write(sfc->regmap_base, SFC_CMD, cmd);
}
@@ -803,7 +783,7 @@ static int aml_sfc_exec_op(struct spi_mem *mem, const struct spi_mem_op *op)
dev_dbg(sfc->dev, "cmd:0x%02x - addr:%08llX@%d:%u - dummy:%d:%u - data:%d:%u",
op->cmd.opcode, op->addr.val, op->addr.buswidth, op->addr.nbytes,
- op->dummy.buswidth, op->dummy.nbytes, op->data.buswidth, op->data.nbytes);
+ op->dummy.buswidth, op->dummy.ncycles, op->data.buswidth, op->data.nbytes);
ret = aml_sfc_pre_transfer(sfc, DEFAULT_PULLUP_CYCLE, CS_SETUP_CYCLE);
if (ret)
@@ -1057,6 +1037,7 @@ static int aml_sfc_ecc_finish_io_req(struct nand_device *nand,
static const struct spi_controller_mem_caps aml_sfc_mem_caps = {
.ecc = true,
+ .dummy_cycles = true,
};
static const struct nand_ecc_engine_ops aml_sfc_ecc_engine_ops = {
--
2.56.0