Skip to content

Commit 93e398c

Browse files
committed
[nrf fromtree] drivers: nrf_qspi_nor: Prevent reading status before sending RDPD
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 <[email protected]> (cherry picked from commit 1727bbc)
1 parent 7d3f7bb commit 93e398c

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

drivers/flash/nrf_qspi_nor.c

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,15 +1339,34 @@ static int enter_dpd(const struct device *const dev)
13391339
static int exit_dpd(const struct device *const dev)
13401340
{
13411341
if (IS_ENABLED(DT_INST_PROP(0, has_dpd))) {
1342+
nrf_qspi_pins_t pins;
1343+
nrf_qspi_pins_t disconnected_pins = {
1344+
.sck_pin = NRF_QSPI_PIN_NOT_CONNECTED,
1345+
.csn_pin = NRF_QSPI_PIN_NOT_CONNECTED,
1346+
.io0_pin = NRF_QSPI_PIN_NOT_CONNECTED,
1347+
.io1_pin = NRF_QSPI_PIN_NOT_CONNECTED,
1348+
.io2_pin = NRF_QSPI_PIN_NOT_CONNECTED,
1349+
.io3_pin = NRF_QSPI_PIN_NOT_CONNECTED,
1350+
};
13421351
struct qspi_cmd cmd = {
13431352
.op_code = SPI_NOR_CMD_RDPD,
13441353
};
13451354
uint32_t t_exit_dpd = DT_INST_PROP_OR(0, t_exit_dpd, 0);
1346-
int ret;
1355+
nrfx_err_t res;
1356+
int rc;
13471357

1348-
ret = qspi_send_cmd(dev, &cmd, false);
1349-
if (ret < 0) {
1350-
return ret;
1358+
nrf_qspi_pins_get(NRF_QSPI, &pins);
1359+
nrf_qspi_pins_set(NRF_QSPI, &disconnected_pins);
1360+
res = nrfx_qspi_activate(true);
1361+
nrf_qspi_pins_set(NRF_QSPI, &pins);
1362+
1363+
if (res != NRFX_SUCCESS) {
1364+
return -EIO;
1365+
}
1366+
1367+
rc = qspi_send_cmd(dev, &cmd, false);
1368+
if (rc < 0) {
1369+
return rc;
13511370
}
13521371

13531372
if (t_exit_dpd) {

0 commit comments

Comments
 (0)