From ce5194f2f8f07868bdbedc617df1b7a09c439710 Mon Sep 17 00:00:00 2001 From: offirko Date: Wed, 20 Mar 2019 14:27:49 +0200 Subject: [PATCH 1/4] Fix Bus mode mask and status register write size in some modes in quad enable --- .../blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/components/storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.cpp b/components/storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.cpp index ae0ca070ed..af29ad3c64 100644 --- a/components/storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.cpp +++ b/components/storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.cpp @@ -854,6 +854,7 @@ int QSPIFBlockDevice::_sfdp_set_quad_enabled(uint8_t *basic_param_table_ptr) case 1: case 4: status_reg_setup[1] = 0x02; //Bit 1 of Status Reg 2 + sr_write_size = 2; tr_debug("Setting QE Bit, Bit 1 of Status Reg 2"); break; @@ -874,6 +875,7 @@ int QSPIFBlockDevice::_sfdp_set_quad_enabled(uint8_t *basic_param_table_ptr) status_reg_setup[1] = 0x2; // Bit 1 of status Reg 2 _read_register_inst = 0x35; sr_read_size = 1; + sr_write_size = 2; tr_debug("Setting QE Bit, Bit 1 of Status Reg 2 -special read command"); break; default: @@ -1032,7 +1034,7 @@ int QSPIFBlockDevice::_sfdp_detect_best_bus_read_mode(uint8_t *basic_param_table } is_qpi_mode = false; examined_byte = basic_param_table_ptr[QSPIF_BASIC_PARAM_TABLE_FAST_READ_SUPPORT_BYTE]; - if (examined_byte & 0x40) { + if (examined_byte & 0x20) { // Fast Read 1-4-4 Supported read_inst = basic_param_table_ptr[QSPIF_BASIC_PARAM_TABLE_144_READ_INST_BYTE]; set_quad_enable = true; @@ -1045,7 +1047,7 @@ int QSPIFBlockDevice::_sfdp_detect_best_bus_read_mode(uint8_t *basic_param_table break; } - if (examined_byte & 0x80) { + if (examined_byte & 0x40) { // Fast Read 1-1-4 Supported read_inst = basic_param_table_ptr[QSPIF_BASIC_PARAM_TABLE_114_READ_INST_BYTE]; set_quad_enable = true; @@ -1068,7 +1070,7 @@ int QSPIFBlockDevice::_sfdp_detect_best_bus_read_mode(uint8_t *basic_param_table } examined_byte = basic_param_table_ptr[QSPIF_BASIC_PARAM_TABLE_FAST_READ_SUPPORT_BYTE]; - if (examined_byte & 0x20) { + if (examined_byte & 0x10) { // Fast Read 1-2-2 Supported read_inst = basic_param_table_ptr[QSPIF_BASIC_PARAM_TABLE_122_READ_INST_BYTE]; _dummy_and_mode_cycles = (basic_param_table_ptr[QSPIF_BASIC_PARAM_TABLE_122_READ_INST_BYTE - 1] >> 5) From 1a4c11e3b5e4a66e6fed9eecc7fbdd463857c7dd Mon Sep 17 00:00:00 2001 From: offirko Date: Wed, 20 Mar 2019 14:41:45 +0200 Subject: [PATCH 2/4] Fixed Bus Mode bit mask to select best mode. When setting Quad Enable, either SR1, SR2 or CR setup is required. Either way register size is up to 2 bytes. --- .../storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.cpp b/components/storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.cpp index af29ad3c64..bf39ff2dda 100644 --- a/components/storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.cpp +++ b/components/storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.cpp @@ -854,7 +854,7 @@ int QSPIFBlockDevice::_sfdp_set_quad_enabled(uint8_t *basic_param_table_ptr) case 1: case 4: status_reg_setup[1] = 0x02; //Bit 1 of Status Reg 2 - sr_write_size = 2; + sr_write_size = 2; tr_debug("Setting QE Bit, Bit 1 of Status Reg 2"); break; @@ -875,7 +875,7 @@ int QSPIFBlockDevice::_sfdp_set_quad_enabled(uint8_t *basic_param_table_ptr) status_reg_setup[1] = 0x2; // Bit 1 of status Reg 2 _read_register_inst = 0x35; sr_read_size = 1; - sr_write_size = 2; + sr_write_size = 2; tr_debug("Setting QE Bit, Bit 1 of Status Reg 2 -special read command"); break; default: From e8e0fb4fdf638eccaa7fa3064bf2298143a8cb04 Mon Sep 17 00:00:00 2001 From: offirko Date: Thu, 28 Mar 2019 10:18:16 +0200 Subject: [PATCH 3/4] If QER is undefined: do nothing but log warning and continue --- .../storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.cpp b/components/storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.cpp index bf39ff2dda..9cfd41f20d 100644 --- a/components/storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.cpp +++ b/components/storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.cpp @@ -879,8 +879,8 @@ int QSPIFBlockDevice::_sfdp_set_quad_enabled(uint8_t *basic_param_table_ptr) tr_debug("Setting QE Bit, Bit 1 of Status Reg 2 -special read command"); break; default: - tr_warning("_setQuadEnable - Unsuported QER configuration"); - break; + tr_warning("Unsuported QER configuration"); + return; } // Configure BUS Mode to 1_1_1 for all commands other than Read From 15fdb6ea7edba01e2cd814f03aa4a26c6d4b29d6 Mon Sep 17 00:00:00 2001 From: Offir Kochalsky Date: Fri, 29 Mar 2019 17:37:00 +0300 Subject: [PATCH 4/4] Update QSPIFBlockDevice.cpp --- .../storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.cpp b/components/storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.cpp index 9cfd41f20d..e37c4b275b 100644 --- a/components/storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.cpp +++ b/components/storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.cpp @@ -880,7 +880,7 @@ int QSPIFBlockDevice::_sfdp_set_quad_enabled(uint8_t *basic_param_table_ptr) break; default: tr_warning("Unsuported QER configuration"); - return; + return 0; } // Configure BUS Mode to 1_1_1 for all commands other than Read