Skip to content

Commit 61fd872

Browse files
committed
QSPIF: options to preset reset sequence for legacy SFDP
The first revision (1.0) of SFDP (ref: JESD216) does not include fields for software reset support. It's only been added in the second revision (1.5) (ref: JESD216A). Some Mbed OS targets such as DISCO_F746NG include flashes with legacy SFDP, thus we add an option to preset the reset mode.
1 parent d44fb29 commit 61fd872

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

storage/blockdevice/COMPONENT_QSPIF/mbed_lib.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
{
2-
"name": "qspif",
2+
"name": "qspif",
33
"config": {
4+
"enable-and-reset": {
5+
"help": "(Legacy SFDP 1.0 ONLY) Reset sequence is enable reset (0x66) then reset (0x99)",
6+
"value": false
7+
},
8+
"direct-reset": {
9+
"help": "(Legacy SFDP 1.0 ONLY) Reset involves a single command (0xF0)",
10+
"value": false
11+
},
412
"QSPI_IO0": "MBED_CONF_DRIVERS_QSPI_IO0",
513
"QSPI_IO1": "MBED_CONF_DRIVERS_QSPI_IO1",
614
"QSPI_IO2": "MBED_CONF_DRIVERS_QSPI_IO2",
@@ -23,7 +31,8 @@
2331
"QSPI_FREQ": "66000000"
2432
},
2533
"N25Q128A": {
26-
"QSPI_FREQ": "80000000"
34+
"QSPI_FREQ": "80000000",
35+
"enable-and-reset": true
2736
},
2837
"MCU_NRF52840": {
2938
"QSPI_FREQ": "32000000",

storage/blockdevice/COMPONENT_QSPIF/source/QSPIFBlockDevice.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -995,18 +995,35 @@ int QSPIFBlockDevice::_sfdp_detect_and_enable_4byte_addressing(uint8_t *basic_pa
995995
return status;
996996
}
997997

998+
#if MBED_CONF_QSPIF_ENABLE_AND_RESET && MBED_CONF_QSPIF_DIRECT_RESET
999+
#error "qspif.enable-and-reset and qspif.direct-reset cannot be both true!"
1000+
#endif
1001+
1002+
#define RESET_SEQUENCE_FROM_SFDP ( !MBED_CONF_QSPIF_ENABLE_AND_RESET && !MBED_CONF_QSPIF_DIRECT_RESET )
1003+
9981004
int QSPIFBlockDevice::_sfdp_detect_reset_protocol_and_reset(uint8_t *basic_param_table_ptr)
9991005
{
10001006
int status = QSPIF_BD_ERROR_OK;
1007+
1008+
#if RESET_SEQUENCE_FROM_SFDP
10011009
uint8_t examined_byte = basic_param_table_ptr[QSPIF_BASIC_PARAM_TABLE_SOFT_RESET_BYTE];
10021010

10031011
// Ignore bit indicating need to exit 0-4-4 mode - should not enter 0-4-4 mode from QSPIFBlockDevice
10041012
if (examined_byte & SOFT_RESET_RESET_INST_BITMASK) {
1013+
#endif
1014+
1015+
#if !MBED_CONF_QSPIF_ENABLE_AND_RESET // i.e. direct reset, or determined from SFDP
10051016
// Issue instruction 0xF0 to reset the device
10061017
qspi_status_t qspi_status = _qspi_send_general_command(0xF0, QSPI_NO_ADDRESS_COMMAND, // Send reset instruction
10071018
NULL, 0, NULL, 0);
10081019
status = (qspi_status == QSPI_STATUS_OK) ? QSPIF_BD_ERROR_OK : QSPIF_BD_ERROR_PARSING_FAILED;
1020+
#endif
1021+
1022+
#if RESET_SEQUENCE_FROM_SFDP
10091023
} else if (examined_byte & SOFT_RESET_ENABLE_AND_RESET_INST_BITMASK) {
1024+
#endif
1025+
1026+
#if !MBED_CONF_QSPIF_DIRECT_RESET // i.e. enable and reset, or determined from SFDP
10101027
// Issue instruction 66h to enable resets on the device
10111028
// Then issue instruction 99h to reset the device
10121029
qspi_status_t qspi_status = _qspi_send_general_command(0x66, QSPI_NO_ADDRESS_COMMAND, // Send reset enable instruction
@@ -1016,10 +1033,15 @@ int QSPIFBlockDevice::_sfdp_detect_reset_protocol_and_reset(uint8_t *basic_param
10161033
NULL, 0, NULL, 0);
10171034
}
10181035
status = (qspi_status == QSPI_STATUS_OK) ? QSPIF_BD_ERROR_OK : QSPIF_BD_ERROR_PARSING_FAILED;
1036+
#endif
1037+
1038+
#if RESET_SEQUENCE_FROM_SFDP
10191039
} else {
10201040
// Soft reset either is not supported or requires direct control over data lines
1041+
tr_error("Failed to determine soft reset sequence. If your device has a legacy SFDP table, please manually set enable-and-reset or direct-reset.");
10211042
status = QSPIF_BD_ERROR_PARSING_FAILED;
10221043
}
1044+
#endif
10231045

10241046
if (status == QSPIF_BD_ERROR_OK) {
10251047
if (false == _is_mem_ready()) {

0 commit comments

Comments
 (0)