[PATCH v1 3/7] SST26* locking: need to enable write

Bernhard Kirchen schlimmchen at gmail.com
Thu Jan 28 17:28:22 CET 2021


prior to using the WBPR (write block protection register) command to
write new block protection register values, the WREN command must be
sent. otherwise the new values are not applied.

Signed-off-by: Bernhard Kirchen <bernhard.kirchen at mbconnectline.com>
---

 drivers/mtd/spi/spi-nor-core.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
index e16b0e1462..050aeac3fa 100644
--- a/drivers/mtd/spi/spi-nor-core.c
+++ b/drivers/mtd/spi/spi-nor-core.c
@@ -1091,12 +1091,20 @@ static int sst26_lock_ctl(struct spi_nor *nor, loff_t ofs, uint64_t len, enum lo
 	if (ctl == SST26_CTL_CHECK)
 		return 0;
 
+	ret = write_enable(nor);
+	if (ret < 0)
+		return ret;
+
 	ret = nor->write_reg(nor, SPINOR_OP_WRITE_BPR, bpr_buff, bpr_size);
 	if (ret < 0) {
 		dev_err(nor->dev, "fail to write block-protection register\n");
 		return ret;
 	}
 
+	// ignore return value. even if write disable failed, the actual task
+	// (write block protecton register) was completed successfully.
+	write_disable(nor);
+
 	return 0;
 }
 
-- 
2.29.2



More information about the U-Boot mailing list