drivers: spi_nor: support Microchip SPI flash global unblock
Microchip SPI flash require Global unblock command before writing is allowed. Signed-off-by: Timo Teräs <timo.teras@iki.fi>
This commit is contained in:
parent
bd8e241733
commit
52453082f8
2 changed files with 7 additions and 0 deletions
|
@ -290,6 +290,12 @@ static int spi_nor_write_protection_set(struct device *dev, bool write_protect)
|
|||
ret = spi_nor_cmd_write(dev, (write_protect) ?
|
||||
SPI_NOR_CMD_WRDI : SPI_NOR_CMD_WREN);
|
||||
|
||||
#if DT_INST_0_JEDEC_SPI_NOR_JEDEC_ID_0 == 0xbf && DT_INST_0_JEDEC_SPI_NOR_JEDEC_ID_1 == 0x26
|
||||
if (ret == 0 && !write_protect) {
|
||||
ret = spi_nor_cmd_write(dev, SPI_NOR_CMD_MCHP_UNLOCK);
|
||||
}
|
||||
#endif
|
||||
|
||||
SYNC_UNLOCK();
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -38,6 +38,7 @@ struct spi_nor_config {
|
|||
#define SPI_NOR_CMD_BE 0xD8 /* Block erase */
|
||||
#define SPI_NOR_CMD_CE 0xC7 /* Chip erase */
|
||||
#define SPI_NOR_CMD_RDID 0x9F /* Read JEDEC ID */
|
||||
#define SPI_NOR_CMD_MCHP_UNLOCK 0x98 /* Microchip: Global unblock */
|
||||
|
||||
/* Page, sector, and block size are standard, not configurable. */
|
||||
#define SPI_NOR_PAGE_SIZE 0x0100U
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue