CFG_ERASESEC_TOGGLE_32BIT_ADDR);
}
- /* For QUAD mode, set 'QE' STATUS bit */
+ /* Check status of 'QE' bit */
+ stfsm_read_status(fsm, FLASH_CMD_RDSR, &sta);
data_pads = ((fsm->stfsm_seq_read.seq_cfg >> 16) & 0x3) + 1;
if (data_pads == 4) {
- stfsm_read_status(fsm, FLASH_CMD_RDSR, &sta);
- sta |= MX25_STATUS_QE;
- stfsm_write_status(fsm, sta, 1);
+ if (!(sta & MX25_STATUS_QE)) {
+ /* Set 'QE' */
+ sta |= MX25_STATUS_QE;
+
+ stfsm_write_status(fsm, sta, 1);
+
+ stfsm_wait_busy(fsm);
+ }
+ } else {
+ if (sta & MX25_STATUS_QE) {
+ /* Clear 'QE' */
+ sta &= ~MX25_STATUS_QE;
+
+ stfsm_write_status(fsm, sta, 1);
+
+ stfsm_wait_busy(fsm);
+ }
}
return 0;