drivers: flash: fix hw write protect before sw
This change sets write-protect pin disabled BEFORE SW write-protect disable and write-protect pin enabled AFTER SW write-protect enable. Signed-off-by: J.P. Hutchins <jp@intercreate.io>
This commit is contained in:
parent
b403fdee00
commit
d7313388c9
1 changed files with 8 additions and 2 deletions
|
@ -848,8 +848,8 @@ static int spi_nor_write_protection_set(const struct device *dev,
|
|||
int ret;
|
||||
|
||||
#if ANY_INST_HAS_WP_GPIOS
|
||||
if (DEV_CFG(dev)->wp) {
|
||||
gpio_pin_set_dt(DEV_CFG(dev)->wp, write_protect);
|
||||
if (DEV_CFG(dev)->wp && write_protect == false) {
|
||||
gpio_pin_set_dt(DEV_CFG(dev)->wp, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -862,6 +862,12 @@ static int spi_nor_write_protection_set(const struct device *dev,
|
|||
ret = spi_nor_cmd_write(dev, SPI_NOR_CMD_ULBPR);
|
||||
}
|
||||
|
||||
#if ANY_INST_HAS_WP_GPIOS
|
||||
if (DEV_CFG(dev)->wp && write_protect == true) {
|
||||
gpio_pin_set_dt(DEV_CFG(dev)->wp, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue