Skip to content

Commit 44c9c1b

Browse files
committed
mtd: spinand: winbond: Convert W25N specific operation to SPINAND_OP()
Winbond W25N* chips require a vendor specific operation to select the target. 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 b347cdc commit 44c9c1b

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

drivers/mtd/nand/spi/winbond.c

Lines changed: 14 additions & 6 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_SELECT_TARGET_1S_0_1S(buf) \
91+
SPI_MEM_OP(SPI_MEM_OP_CMD(0xc2, 1), \
92+
SPI_MEM_OP_NO_ADDR, \
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_select_target_op(struct spinand_device *spinand, void *valptr)
98+
{
99+
return (struct spi_mem_op)SPINAND_WINBOND_SELECT_TARGET_1S_0_1S(valptr);
100+
}
101+
90102
static int w25m02gv_ooblayout_ecc(struct mtd_info *mtd, int section,
91103
struct mtd_oob_region *region)
92104
{
@@ -119,12 +131,8 @@ static const struct mtd_ooblayout_ops w25m02gv_ooblayout = {
119131
static int w25m02gv_select_target(struct spinand_device *spinand,
120132
unsigned int target)
121133
{
122-
struct spi_mem_op op = SPI_MEM_OP(SPI_MEM_OP_CMD(0xc2, 1),
123-
SPI_MEM_OP_NO_ADDR,
124-
SPI_MEM_OP_NO_DUMMY,
125-
SPI_MEM_OP_DATA_OUT(1,
126-
spinand->scratchbuf,
127-
1));
134+
struct spi_mem_op op = SPINAND_OP(spinand, winbond_select_target,
135+
spinand->scratchbuf);
128136

129137
*spinand->scratchbuf = target;
130138
return spi_mem_exec_op(spinand->spimem, &op);

0 commit comments

Comments
 (0)