From f72874b1a5e949b40d42c52022de63085649fcaf Mon Sep 17 00:00:00 2001 From: Apurva Nandan Date: Fri, 26 May 2023 14:42:31 +0530 Subject: [PATCH] spi: spi-mem: Add DTR templates for cmd, address, dummy and data phase Setting dtr field of spi_mem_op is used when creating templates for DTR ops in spinand.h. Also, 2 bytes cmd phases are required when operating in Octal DTR SPI mode. Create new templates for dtr mode cmd, address, dummy and data phase in spi_mem_op, to set the dtr field to 1 and also allow passing the nbytes for the cmd phase. Signed-off-by: Apurva Nandan --- include/spi-mem.h | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/include/spi-mem.h b/include/spi-mem.h index f55361d628..6b969919b6 100644 --- a/include/spi-mem.h +++ b/include/spi-mem.h @@ -13,44 +13,59 @@ struct udevice; -#define SPI_MEM_OP_CMD(__opcode, __buswidth) \ +#define SPI_MEM_OP_DTR .dtr = 1 + +#define SPI_MEM_OP_CMD(__opcode, __buswidth, ...) \ { \ .buswidth = __buswidth, \ .opcode = __opcode, \ .nbytes = 1, \ + __VA_ARGS__ \ } -#define SPI_MEM_OP_ADDR(__nbytes, __val, __buswidth) \ +#define SPI_MEM_OP_EXT_CMD(__nbytes, __opcode, __buswidth, ...) \ + { \ + .buswidth = __buswidth, \ + .opcode = __opcode, \ + .nbytes = __nbytes, \ + __VA_ARGS__ \ + } + +#define SPI_MEM_OP_ADDR(__nbytes, __val, __buswidth, ...) \ { \ .nbytes = __nbytes, \ .val = __val, \ .buswidth = __buswidth, \ + __VA_ARGS__ \ } #define SPI_MEM_OP_NO_ADDR { } -#define SPI_MEM_OP_DUMMY(__nbytes, __buswidth) \ +#define SPI_MEM_OP_DUMMY(__nbytes, __buswidth, ...) \ { \ .nbytes = __nbytes, \ .buswidth = __buswidth, \ + __VA_ARGS__ \ } #define SPI_MEM_OP_NO_DUMMY { } -#define SPI_MEM_OP_DATA_IN(__nbytes, __buf, __buswidth) \ +#define SPI_MEM_OP_DATA_IN(__nbytes, __buf, __buswidth, ...) \ { \ .dir = SPI_MEM_DATA_IN, \ .nbytes = __nbytes, \ .buf.in = __buf, \ .buswidth = __buswidth, \ + __VA_ARGS__ \ } -#define SPI_MEM_OP_DATA_OUT(__nbytes, __buf, __buswidth) \ +#define SPI_MEM_OP_DATA_OUT(__nbytes, __buf, __buswidth, ...) \ { \ .dir = SPI_MEM_DATA_OUT, \ .nbytes = __nbytes, \ .buf.out = __buf, \ .buswidth = __buswidth, \ + __VA_ARGS__ \ } #define SPI_MEM_OP_NO_DATA { }