/* Sflash enable RCV mode to recovery for erase while power drop need lock.  */
__WEAK int ATTR_TCM_SECTION bflb_xip_sflash_rcv_enable_need_lock(spi_flash_cfg_type *p_flash_cfg, uint8_t r_cmd, uint8_t w_cmd, uint8_t bit_pos, uint8_t group, uint8_t bank)
/* Sflash enable RCV mode to recovery for erase while power drop need lock.  */
__WEAK int ATTR_TCM_SECTION bflb_xip_sflash_rcv_enable_need_lock(spi_flash_cfg_type *p_flash_cfg, uint8_t r_cmd, uint8_t w_cmd, uint8_t bit_pos, uint8_t group, uint8_t bank)
{
    int stat = -1;
    uint32_t offset;
    uint8_t io_mode = p_flash_cfg->io_mode & 0xf;
    stat = bflb_xip_sflash_state_save(p_flash_cfg, &offset, group, bank);
    if (stat != 0) {
        bflb_sflash_set_xip_cfg(p_flash_cfg, io_mode, 1, 0, 32 , bank);
    } else {
        stat = bflb_sflash_rcv_enable(p_flash_cfg, r_cmd, w_cmd, bit_pos);
        bflb_xip_sflash_state_restore_ext(p_flash_cfg, offset, group, bank);
    }
    return stat;
}