Skip to content

Commit b347cdc

Browse files
committed
mtd: spinand: macronix: Convert vendor specific operation to SPINAND_OP()
Macronix chips require a vendor specific operation to read the ECC status register. 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 88b0e35 commit b347cdc

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

drivers/mtd/nand/spi/macronix.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ static SPINAND_OP_VARIANTS(update_cache_variants,
4141
SPINAND_PROG_LOAD_1S_1S_4S_OP(false, 0, NULL, 0),
4242
SPINAND_PROG_LOAD_1S_1S_1S_OP(false, 0, NULL, 0));
4343

44+
#define SPINAND_MACRONIX_READ_ECCSR_1S_0_1S(buf) \
45+
SPI_MEM_OP(SPI_MEM_OP_CMD(0x7c, 1), \
46+
SPI_MEM_OP_NO_ADDR, \
47+
SPI_MEM_OP_DUMMY(1, 1), \
48+
SPI_MEM_OP_DATA_IN(1, buf, 1))
49+
50+
static struct spi_mem_op
51+
spinand_fill_macronix_read_eccsr_op(struct spinand_device *spinand, void *valptr)
52+
{
53+
return (struct spi_mem_op)SPINAND_MACRONIX_READ_ECCSR_1S_0_1S(valptr);
54+
}
55+
4456
static int mx35lfxge4ab_ooblayout_ecc(struct mtd_info *mtd, int section,
4557
struct mtd_oob_region *region)
4658
{
@@ -67,12 +79,10 @@ static const struct mtd_ooblayout_ops mx35lfxge4ab_ooblayout = {
6779
static int macronix_get_eccsr(struct spinand_device *spinand, u8 *eccsr)
6880
{
6981
struct macronix_priv *priv = spinand->priv;
70-
struct spi_mem_op op = SPI_MEM_OP(SPI_MEM_OP_CMD(0x7c, 1),
71-
SPI_MEM_OP_NO_ADDR,
72-
SPI_MEM_OP_DUMMY(1, 1),
73-
SPI_MEM_OP_DATA_IN(1, eccsr, 1));
82+
struct spi_mem_op op = SPINAND_OP(spinand, macronix_read_eccsr, eccsr);
83+
int ret;
7484

75-
int ret = spi_mem_exec_op(spinand->spimem, &op);
85+
ret = spi_mem_exec_op(spinand->spimem, &op);
7686
if (ret)
7787
return ret;
7888

0 commit comments

Comments
 (0)