Skip to content

Commit ef1ed29

Browse files
committed
mtd: spinand: winbond: Configure the IO mode after the dummy cycles
When we will change the bus interface, the action that actually performs the transition is the IO mode register write. This means after the IO mode register write, we should use the new bus interface. But the ->configure_chip() hook itself is not responsible of making this change official, it is the caller that must act according to the return value. Reorganize this helper to first configure the dummy cycles before possibly switching to another bus interface. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
1 parent 57e1015 commit ef1ed29

1 file changed

Lines changed: 15 additions & 15 deletions

File tree

drivers/mtd/nand/spi/winbond.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -381,21 +381,6 @@ static int w35n0xjw_vcr_cfg(struct spinand_device *spinand)
381381

382382
op = spinand->op_templates->read_cache;
383383

384-
single = (op->cmd.buswidth == 1 && op->addr.buswidth == 1 && op->data.buswidth == 1);
385-
dtr = (op->cmd.dtr || op->addr.dtr || op->data.dtr);
386-
if (single && !dtr)
387-
io_mode = W35N01JW_VCR_IO_MODE_SINGLE_SDR;
388-
else if (!single && !dtr)
389-
io_mode = W35N01JW_VCR_IO_MODE_OCTAL_SDR;
390-
else if (!single && dtr)
391-
io_mode = W35N01JW_VCR_IO_MODE_OCTAL_DDR;
392-
else
393-
return -EINVAL;
394-
395-
ret = w35n0xjw_write_vcr(spinand, W35N01JW_VCR_IO_MODE_REG, io_mode);
396-
if (ret)
397-
return ret;
398-
399384
dummy_cycles = ((op->dummy.nbytes * 8) / op->dummy.buswidth) / (op->dummy.dtr ? 2 : 1);
400385
switch (dummy_cycles) {
401386
case 8:
@@ -413,6 +398,21 @@ static int w35n0xjw_vcr_cfg(struct spinand_device *spinand)
413398
if (ret)
414399
return ret;
415400

401+
single = (op->cmd.buswidth == 1 && op->addr.buswidth == 1 && op->data.buswidth == 1);
402+
dtr = (op->cmd.dtr && op->addr.dtr && op->data.dtr);
403+
if (single && !dtr)
404+
io_mode = W35N01JW_VCR_IO_MODE_SINGLE_SDR;
405+
else if (!single && !dtr)
406+
io_mode = W35N01JW_VCR_IO_MODE_OCTAL_SDR;
407+
else if (!single && dtr)
408+
io_mode = W35N01JW_VCR_IO_MODE_OCTAL_DDR;
409+
else
410+
return -EINVAL;
411+
412+
ret = w35n0xjw_write_vcr(spinand, W35N01JW_VCR_IO_MODE_REG, io_mode);
413+
if (ret)
414+
return ret;
415+
416416
return 0;
417417
}
418418

0 commit comments

Comments
 (0)