Skip to content

Commit

Permalink
QSPIFBlockDevice: Handle CR3NV[1] quirk on S25FS512S
Browse files Browse the repository at this point in the history
Cypress S25FS512S's SFDP table suggests checking bit-1 of the register
25FS512S as part of configuration detection. This bit should equal 1
in order for configuration to be correctly determined, but it is 0 on
actual hardware. We add a quirk to work around this.

Note: In Mbed OS, vendor-specific quirks are handled in block devices,
and the SFDP class is agnostic of any quirks. So when the SFDP class
requests the value of CR3NV, we let QSPIFBlockDevice's SFDP reader
callback to set bit-1 of the output to 1 to allow the SFDP class to
work correctly.
  • Loading branch information
LDong-Arm committed Aug 10, 2021
1 parent c6e838e commit 05d60b1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ class QSPIFBlockDevice : public mbed::BlockDevice {
int _quad_enable_bit;

bool _needs_fast_mode;
bool _CR3NV_quirk;

// Clear block protection
qspif_clear_protection_method_t _clear_protection_method;
Expand Down
20 changes: 20 additions & 0 deletions storage/blockdevice/COMPONENT_QSPIF/source/QSPIFBlockDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ QSPIFBlockDevice::QSPIFBlockDevice(PinName io0, PinName io1, PinName io2, PinNam
// Set default 4-byte addressing extension register write instruction
_attempt_4_byte_addressing = true;
_4byte_msb_reg_write_inst = QSPIF_INST_4BYTE_REG_WRITE_DEFAULT;

// Quirk for CR3NV[1] on Cypress S25FS512S
_CR3NV_quirk = false;
}

int QSPIFBlockDevice::init()
Expand Down Expand Up @@ -1099,6 +1102,15 @@ int QSPIFBlockDevice::_handle_vendor_quirks()
tr_debug("Applying quirks for ISSI");
_num_status_registers = 1;
break;
case 0x01:
if (vendor_device_ids[1] == 0x02 && vendor_device_ids[2] == 0x20) {
// On a Cypress S25FS512S flash chip, bit-1 of the register CR3NV is
// expected to be 1 but its actual value is 0 on manufactured hardware.
// In order for configuration detection to work, this chip needs to be
// specially handled.
_CR3NV_quirk = true;
}
break;
}

return 0;
Expand Down Expand Up @@ -1469,6 +1481,14 @@ int QSPIFBlockDevice::_qspi_send_read_sfdp_command(mbed::bd_addr_t addr, mbed::s
return status;
}

// Handle CR3NV[1] quirk.
const mbed::bd_addr_t register_CR3NV = 0x000004;
if (_CR3NV_quirk && (addr == register_CR3NV)) {
// If we reach here, rx_buffer is guaranteed to be non-null
// because it's been checked by _qspi.read() above.
static_cast<uint8_t *>(rx_buffer)[0] |= 0x01;
}

return QSPI_STATUS_OK;
}

Expand Down

0 comments on commit 05d60b1

Please sign in to comment.