Skip to content

Commit

Permalink
drivers: nrf_qspi_nor: Prevent reading status before sending RDPD
Browse files Browse the repository at this point in the history
After entering the Deep Power-down mode, some flash chips ignore all
commands except from the one that releases the chip from the DP mode
and it is not possible to successfully read their Status Register then.
Since the QSPI peripheral tries to read this register when it is being
activated, it consequently fails to send the actual command that would
release the flash chip from the DP mode if that is to be done right
after QSPI initialization.
Prevent this problem by performing the QSPI activation with all pins
disconnected. This causes that the Status Register value is read as
all zeros and allows the activation to always finish successfully,
and the RDPD command to be properly sent.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
  • Loading branch information
anangl authored and carlescufi committed Nov 21, 2023
1 parent 23cf389 commit 1727bbc
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions drivers/flash/nrf_qspi_nor.c
Original file line number Diff line number Diff line change
Expand Up @@ -1339,15 +1339,34 @@ static int enter_dpd(const struct device *const dev)
static int exit_dpd(const struct device *const dev)
{
if (IS_ENABLED(DT_INST_PROP(0, has_dpd))) {
nrf_qspi_pins_t pins;
nrf_qspi_pins_t disconnected_pins = {
.sck_pin = NRF_QSPI_PIN_NOT_CONNECTED,
.csn_pin = NRF_QSPI_PIN_NOT_CONNECTED,
.io0_pin = NRF_QSPI_PIN_NOT_CONNECTED,
.io1_pin = NRF_QSPI_PIN_NOT_CONNECTED,
.io2_pin = NRF_QSPI_PIN_NOT_CONNECTED,
.io3_pin = NRF_QSPI_PIN_NOT_CONNECTED,
};
struct qspi_cmd cmd = {
.op_code = SPI_NOR_CMD_RDPD,
};
uint32_t t_exit_dpd = DT_INST_PROP_OR(0, t_exit_dpd, 0);
int ret;
nrfx_err_t res;
int rc;

ret = qspi_send_cmd(dev, &cmd, false);
if (ret < 0) {
return ret;
nrf_qspi_pins_get(NRF_QSPI, &pins);
nrf_qspi_pins_set(NRF_QSPI, &disconnected_pins);
res = nrfx_qspi_activate(true);
nrf_qspi_pins_set(NRF_QSPI, &pins);

if (res != NRFX_SUCCESS) {
return -EIO;
}

rc = qspi_send_cmd(dev, &cmd, false);
if (rc < 0) {
return rc;
}

if (t_exit_dpd) {
Expand Down

0 comments on commit 1727bbc

Please sign in to comment.