]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mtd: spinand: winbond: Convert W35N specific operation to SPINAND_OP()
authorMiquel Raynal <miquel.raynal@bootlin.com>
Fri, 9 Jan 2026 17:18:11 +0000 (18:18 +0100)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Thu, 29 Jan 2026 19:21:41 +0000 (20:21 +0100)
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>
drivers/mtd/nand/spi/winbond.c

index dde59f8f63f511a298a43a5b43fe07c1d726f179..3003ad7e83ee8f553ec82a0326422916c0ed794c 100644 (file)
@@ -87,6 +87,18 @@ static SPINAND_OP_VARIANTS(update_cache_variants,
                SPINAND_PROG_LOAD_1S_1S_4S_OP(false, 0, NULL, 0),
                SPINAND_PROG_LOAD_1S_1S_1S_OP(false, 0, NULL, 0));
 
+#define SPINAND_WINBOND_WRITE_VCR_1S_1S_1S(reg, buf)                   \
+       SPI_MEM_OP(SPI_MEM_OP_CMD(0x81, 1),                             \
+                  SPI_MEM_OP_ADDR(3, reg, 1),                          \
+                  SPI_MEM_OP_NO_DUMMY,                                 \
+                  SPI_MEM_OP_DATA_OUT(1, buf, 1))
+
+static struct spi_mem_op
+spinand_fill_winbond_write_vcr_op(struct spinand_device *spinand, u8 reg, void *valptr)
+{
+       return (struct spi_mem_op)SPINAND_WINBOND_WRITE_VCR_1S_1S_1S(reg, valptr);
+}
+
 #define SPINAND_WINBOND_SELECT_TARGET_1S_0_1S(buf)                     \
        SPI_MEM_OP(SPI_MEM_OP_CMD(0xc2, 1),                             \
                   SPI_MEM_OP_NO_ADDR,                                  \
@@ -329,11 +341,8 @@ static int w25n0xjw_hs_cfg(struct spinand_device *spinand)
 
 static int w35n0xjw_write_vcr(struct spinand_device *spinand, u8 reg, u8 val)
 {
-       struct spi_mem_op op =
-               SPI_MEM_OP(SPI_MEM_OP_CMD(0x81, 1),
-                          SPI_MEM_OP_ADDR(3, reg, 1),
-                          SPI_MEM_OP_NO_DUMMY,
-                          SPI_MEM_OP_DATA_OUT(1, spinand->scratchbuf, 1));
+       struct spi_mem_op op = SPINAND_OP(spinand, winbond_write_vcr,
+                                         reg, spinand->scratchbuf);
        int ret;
 
        *spinand->scratchbuf = val;