mtd: spinand: Only touch the QE bit on chips that have one
Subsystems (2)
PATCH 1/1 mtd: spinand: Only touch the QE bit on chips that have one
Since commit be0b86c648bf ("mtd: spinand: Gather all the bus interface steps in one single function") spinand_init_quad_enable() is called unconditionally and clears bit 0 of the configuration register even on chips without SPINAND_HAS_QE_BIT. On such chips that bit can have another
meaning: on the Winbond W25N02KV it is H-DIS (Hold Disable, default 1), and clearing it enables the /HOLD function, after which erase and program operations silently stop taking effect on MT7986 boards.
Only program the QE bit when the chip declares SPINAND_HAS_QE_BIT, as before.
--- drivers/mtd/nand/spi/core.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/mtd/nand/spi/core.c +10 -5
@@ -1781,7 +1781,7 @@ static int spinand_detect(struct spinand_device *spinand)static int spinand_configure_chip (struct spinand_device *spinand) {bool odtr = false, quad_enable = false; -int ret; +int ret =0 ; if (spinand->odtr_op_templates.read_cache && spinand->odtr_op_templates.write_cache &&
@@ -1808,16 +1808,21 @@ static int spinand_configure_chip(struct spinand_device *spinand) } try_ssdr: +/* +* Only touch the QE bit on chips that actually have one. On other +* chips bit 0 of the configuration register may have a different +* meaning (e.g. H-DIS on the Winbond W25N02KV). +*/ if (spinand->flags &SPINAND_HAS_QE_BIT ) {if (spinand->ssdr_op_templates.read_cache->data.buswidth ==4 || spinand->ssdr_op_templates.write_cache->data.buswidth ==4 || spinand->ssdr_op_templates.update_cache->data.buswidth ==4 ) quad_enable = true; - } - ret =spinand_init_quad_enable (spinand, quad_enable); -if (ret) -return ret; + ret =spinand_init_quad_enable (spinand, quad_enable); +if (ret) +return ret; + }if (spinand->configure_chip) { ret = spinand->configure_chip (spinand,SSDR );
base-commit: 21f027016b1290d13c30b198ae7a00e6b3d1d5a5
Signature · 1 line
2.34.1
Miquel Raynal
maintainerHi Ahmed,
Quoted 10 lines · Ahmed Naseef
Since commit
be0b86c648bf("mtd: spinand: Gather all the bus interface steps in one single function")spinand_init_quad_enable()is called unconditionally and clears bit 0 of the configuration register even on chips withoutSPINAND_HAS_QE_BIT. On such chips that bit can have another
meaning: on the Winbond W25N02KV it is H-DIS (Hold Disable, default 1), and clearing it enables the /HOLD function, after which erase and program operations silently stop taking effect on MT7986 boards.Only program the QE bit when the chip declares
SPINAND_HAS_QE_BIT, as before.
Sorry for the breakage and thanks for the fix, unfortunately it arrived just after another commit -which I am about to apply now-, therefore I must take the first patch sent visible there:
Is is very close to your proposal.
Thanks,
Miquèl