Skip to content

Commit 52aaa64

Browse files
miquelraynalgregkh
authored andcommitted
mtd: spinand: Give the bus interface to the configuration helper
[ Upstream commit 0a331a1 ] The chip configuration hook is the one responsible to actually switch the switch between bus interfaces. It is natural to give it the bus interface we expect with a new parameter. For now the only value we can give is SSDR, but this is subject to change in the future, so add a bit of extra logic in the implementations of this callback to make sure both the core and the chip driver are aligned on the request. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Stable-dep-of: 25a915f ("mtd: spinand: winbond: Clarify when to enable the HS bit") Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 6a5f5c2 commit 52aaa64

3 files changed

Lines changed: 26 additions & 10 deletions

File tree

drivers/mtd/nand/spi/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1499,7 +1499,7 @@ static int spinand_configure_chip(struct spinand_device *spinand)
14991499
return ret;
15001500

15011501
if (spinand->configure_chip) {
1502-
ret = spinand->configure_chip(spinand);
1502+
ret = spinand->configure_chip(spinand, SSDR);
15031503
if (ret)
15041504
return ret;
15051505
}

drivers/mtd/nand/spi/winbond.c

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -284,13 +284,17 @@ static int w25n02kv_ecc_get_status(struct spinand_device *spinand,
284284
return -EINVAL;
285285
}
286286

287-
static int w25n0xjw_hs_cfg(struct spinand_device *spinand)
287+
static int w25n0xjw_hs_cfg(struct spinand_device *spinand,
288+
enum spinand_bus_interface iface)
288289
{
289290
const struct spi_mem_op *op;
290291
bool hs;
291292
u8 sr4;
292293
int ret;
293294

295+
if (iface != SSDR)
296+
return -EOPNOTSUPP;
297+
294298
op = spinand->op_templates->read_cache;
295299
if (op->cmd.dtr || op->addr.dtr || op->dummy.dtr || op->data.dtr)
296300
hs = false;
@@ -347,17 +351,25 @@ static int w35n0xjw_write_vcr(struct spinand_device *spinand, u8 reg, u8 val)
347351
return 0;
348352
}
349353

350-
static int w35n0xjw_vcr_cfg(struct spinand_device *spinand)
354+
static int w35n0xjw_vcr_cfg(struct spinand_device *spinand,
355+
enum spinand_bus_interface iface)
351356
{
352-
const struct spi_mem_op *op;
357+
const struct spi_mem_op *ref_op;
353358
unsigned int dummy_cycles;
354359
bool dtr, single;
355360
u8 io_mode;
356361
int ret;
357362

358-
op = spinand->op_templates->read_cache;
363+
switch (iface) {
364+
case SSDR:
365+
ref_op = spinand->ssdr_op_templates.read_cache;
366+
break;
367+
default:
368+
return -EOPNOTSUPP;
369+
};
359370

360-
dummy_cycles = ((op->dummy.nbytes * 8) / op->dummy.buswidth) / (op->dummy.dtr ? 2 : 1);
371+
dummy_cycles = ((ref_op->dummy.nbytes * 8) / ref_op->dummy.buswidth) /
372+
(ref_op->dummy.dtr ? 2 : 1);
361373
switch (dummy_cycles) {
362374
case 8:
363375
case 12:
@@ -373,8 +385,10 @@ static int w35n0xjw_vcr_cfg(struct spinand_device *spinand)
373385
if (ret)
374386
return ret;
375387

376-
single = (op->cmd.buswidth == 1 && op->addr.buswidth == 1 && op->data.buswidth == 1);
377-
dtr = (op->cmd.dtr && op->addr.dtr && op->data.dtr);
388+
single = (ref_op->cmd.buswidth == 1 &&
389+
ref_op->addr.buswidth == 1 &&
390+
ref_op->data.buswidth == 1);
391+
dtr = (ref_op->cmd.dtr && ref_op->addr.dtr && ref_op->data.dtr);
378392
if (single && !dtr)
379393
io_mode = W35N01JW_VCR_IO_MODE_SINGLE_SDR;
380394
else if (!single && !dtr)

include/linux/mtd/spinand.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,8 @@ struct spinand_info {
532532
} op_variants;
533533
int (*select_target)(struct spinand_device *spinand,
534534
unsigned int target);
535-
int (*configure_chip)(struct spinand_device *spinand);
535+
int (*configure_chip)(struct spinand_device *spinand,
536+
enum spinand_bus_interface iface);
536537
int (*set_cont_read)(struct spinand_device *spinand,
537538
bool enable);
538539
struct spinand_fact_otp fact_otp;
@@ -704,7 +705,8 @@ struct spinand_device {
704705
const struct spinand_manufacturer *manufacturer;
705706
void *priv;
706707

707-
int (*configure_chip)(struct spinand_device *spinand);
708+
int (*configure_chip)(struct spinand_device *spinand,
709+
enum spinand_bus_interface iface);
708710
bool cont_read_possible;
709711
int (*set_cont_read)(struct spinand_device *spinand,
710712
bool enable);

0 commit comments

Comments
 (0)