Skip to content

Commit 6ec7ace

Browse files
committed
mtd: spinand: winbond: Convert W35N specific operation to SPINAND_OP()
Winbond W35N* chips require a vendor specific operation to write their VCR register (a configuration register, typically used for tuning the number of dummy cycles and switching to a different bus interface). Instead of defining this op only in the function that needs it, hiding it from the core, make it a proper define like all other spi-mem operations, and implement the necessary spinand_fill_*_op() helper to make the SPINAND_OP() macro work. This way we can use it from any function without any extra handling outside of this helper when we will convert the core to support octal DDR busses. Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
1 parent 44c9c1b commit 6ec7ace

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

drivers/mtd/nand/spi/winbond.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,18 @@ static SPINAND_OP_VARIANTS(update_cache_variants,
8787
SPINAND_PROG_LOAD_1S_1S_4S_OP(false, 0, NULL, 0),
8888
SPINAND_PROG_LOAD_1S_1S_1S_OP(false, 0, NULL, 0));
8989

90+
#define SPINAND_WINBOND_WRITE_VCR_1S_1S_1S(reg, buf) \
91+
SPI_MEM_OP(SPI_MEM_OP_CMD(0x81, 1), \
92+
SPI_MEM_OP_ADDR(3, reg, 1), \
93+
SPI_MEM_OP_NO_DUMMY, \
94+
SPI_MEM_OP_DATA_OUT(1, buf, 1))
95+
96+
static struct spi_mem_op
97+
spinand_fill_winbond_write_vcr_op(struct spinand_device *spinand, u8 reg, void *valptr)
98+
{
99+
return (struct spi_mem_op)SPINAND_WINBOND_WRITE_VCR_1S_1S_1S(reg, valptr);
100+
}
101+
90102
#define SPINAND_WINBOND_SELECT_TARGET_1S_0_1S(buf) \
91103
SPI_MEM_OP(SPI_MEM_OP_CMD(0xc2, 1), \
92104
SPI_MEM_OP_NO_ADDR, \
@@ -329,11 +341,8 @@ static int w25n0xjw_hs_cfg(struct spinand_device *spinand)
329341

330342
static int w35n0xjw_write_vcr(struct spinand_device *spinand, u8 reg, u8 val)
331343
{
332-
struct spi_mem_op op =
333-
SPI_MEM_OP(SPI_MEM_OP_CMD(0x81, 1),
334-
SPI_MEM_OP_ADDR(3, reg, 1),
335-
SPI_MEM_OP_NO_DUMMY,
336-
SPI_MEM_OP_DATA_OUT(1, spinand->scratchbuf, 1));
344+
struct spi_mem_op op = SPINAND_OP(spinand, winbond_write_vcr,
345+
reg, spinand->scratchbuf);
337346
int ret;
338347

339348
*spinand->scratchbuf = val;

0 commit comments

Comments
 (0)