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:
J.P. Hutchins 2023-08-07 11:40:48 -07:00 committed by Carles Cufí
commit d7313388c9

View file

@ -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;
}