mtd: spi-nor: implement OTP erase for Winbond and similar flashes
Subsystems (2)
PATCH 1/1 mtd: spi-nor: implement OTP erase for Winbond and similar flashes
Winbond flashes with OTP support provide a command to erase the OTP data. This might come in handy during development.
This was tested with a Winbond W25Q32JW on a LS1028A SoC with the NXP FSPI controller.
Signed-off-by Michael Walle <[email protected]>
--- drivers/mtd/spi-nor/core.c | 4 +- drivers/mtd/spi-nor/core.h | 4 ++ drivers/mtd/spi-nor/otp.c | 75 ++++++++++++++++++++++++++++++++++- drivers/mtd/spi-nor/winbond.c | 1 + 4 files changed, 80 insertions(+), 4 deletions(-)
drivers/mtd/spi-nor/core.c +2 -2
@@ -166,8 +166,8 @@ static int spi_nor_controller_ops_read_reg(struct spi_nor *nor, u8 opcode,return nor->controller_ops->read_reg (nor, opcode, buf, len); } -static int spi_nor_controller_ops_write_reg (struct spi_nor *nor,u8 opcode, -const u8 *buf,size_t len) +int spi_nor_controller_ops_write_reg (struct spi_nor *nor,u8 opcode, +const u8 *buf,size_t len) {if (spi_nor_protocol_is_dtr (nor->reg_proto))return -EOPNOTSUPP ;
drivers/mtd/spi-nor/core.h +4 -0
@@ -213,6 +213,7 @@ struct spi_nor_otp_ops {int (*read)(struct spi_nor *nor,loff_t addr,size_t len,u8 *buf);int (*write)(struct spi_nor *nor,loff_t addr,size_t len,u8 *buf);int (*lock)(struct spi_nor *nor,unsigned int region); +int (*erase)(struct spi_nor *nor,loff_t addr);int (*is_locked)(struct spi_nor *nor,unsigned int region); };
@@ -480,6 +481,8 @@ extern const struct spi_nor_manufacturer spi_nor_xmc;void spi_nor_spimem_setup_op (const struct spi_nor *nor,struct spi_mem_op *op,const enum spi_nor_protocol proto); +int spi_nor_controller_ops_write_reg (struct spi_nor *nor,u8 opcode, +const u8 *buf,size_t len);int spi_nor_write_enable (struct spi_nor *nor);int spi_nor_write_disable (struct spi_nor *nor);int spi_nor_set_4byte_addr_mode (struct spi_nor *nor,bool enable);
@@ -505,6 +508,7 @@ ssize_t spi_nor_write_data(struct spi_nor *nor, loff_t to, size_t len,int spi_nor_otp_read_secr (struct spi_nor *nor,loff_t addr,size_t len,u8 *buf);int spi_nor_otp_write_secr (struct spi_nor *nor,loff_t addr,size_t len,u8 *buf); +int spi_nor_otp_erase_secr (struct spi_nor *nor,loff_t addr);int spi_nor_otp_lock_sr2 (struct spi_nor *nor,unsigned int region);int spi_nor_otp_is_locked_sr2 (struct spi_nor *nor,unsigned int region);
drivers/mtd/spi-nor/otp.c +73 -2
114 lines not on this page · raw message
drivers/mtd/spi-nor/winbond.c +1 -0
@@ -139,6 +139,7 @@ static int winbond_set_4byte_addr_mode(struct spi_nor *nor, bool enable)static const struct spi_nor_otp_ops winbond_otp_ops = { .read = spi_nor_otp_read_secr, .write = spi_nor_otp_write_secr, + .erase = spi_nor_otp_erase_secr, .lock = spi_nor_otp_lock_sr2, .is_locked = spi_nor_otp_is_locked_sr2, };
Signature · 1 line
2.20.1