Skip to content

Commit cba5bfc

Browse files
author
Veijo Pesonen
committed
QSPIFBlockDevice: Reads Sector Map Table by using a SFDP Reader cb
1 parent 4e1fb07 commit cba5bfc

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

components/storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ using namespace mbed;
5353

5454
/* Basic Parameters Table Parsing */
5555
/**********************************/
56-
#define SFDP_DEFAULT_BASIC_PARAMS_TABLE_SIZE_BYTES 64 /* 16 DWORDS */
5756
//READ Instruction support according to BUS Configuration
5857
#define QSPIF_BASIC_PARAM_TABLE_FAST_READ_SUPPORT_BYTE 2
5958
#define QSPIF_BASIC_PARAM_TABLE_QPI_READ_SUPPORT_BYTE 16
@@ -270,7 +269,8 @@ int QSPIFBlockDevice::init()
270269
if ((hdr_info.smtbl.addr != 0) && (0 != hdr_info.smtbl.size)) {
271270
tr_debug("Init - Parsing Sector Map Table - addr: 0x%lxh, Size: %d", hdr_info.smtbl.addr,
272271
hdr_info.smtbl.size);
273-
if (0 != _sfdp_parse_sector_map_table(hdr_info.smtbl.addr, hdr_info.smtbl.size)) {
272+
if (_sfdp_parse_sector_map_table(callback(this, &QSPIFBlockDevice::_qspi_send_read_sfdp_command),
273+
hdr_info.smtbl) < 0) {
274274
tr_error("Init - Parse Sector Map Table Failed");
275275
status = QSPIF_BD_ERROR_PARSING_FAILED;
276276
goto exit_point;
@@ -629,7 +629,7 @@ int QSPIFBlockDevice::remove_csel_instance(PinName csel)
629629
/*********************************************************/
630630
int QSPIFBlockDevice::_sfdp_parse_basic_param_table(uint32_t basic_table_addr, size_t basic_table_size)
631631
{
632-
uint8_t param_table[SFDP_DEFAULT_BASIC_PARAMS_TABLE_SIZE_BYTES]; /* Up To 16 DWORDS = 64 Bytes */
632+
uint8_t param_table[SFDP_BASIC_PARAMS_TBL_SIZE]; /* Up To 16 DWORDS = 64 Bytes */
633633

634634
int status = _qspi_send_read_sfdp_command(basic_table_addr, (char *)param_table, basic_table_size);
635635
if (status != QSPI_STATUS_OK) {
@@ -1103,17 +1103,18 @@ int QSPIFBlockDevice::_sfdp_detect_reset_protocol_and_reset(uint8_t *basic_param
11031103
return status;
11041104
}
11051105

1106-
int QSPIFBlockDevice::_sfdp_parse_sector_map_table(uint32_t sector_map_table_addr, size_t sector_map_table_size)
1106+
int QSPIFBlockDevice::_sfdp_parse_sector_map_table(Callback<int(bd_addr_t, void*, bd_size_t)> sfdp_reader,
1107+
sfdp_smtbl_info &smtbl)
11071108
{
1108-
uint8_t sector_map_table[SFDP_DEFAULT_BASIC_PARAMS_TABLE_SIZE_BYTES]; /* Up To 16 DWORDS = 64 Bytes */
1109+
uint8_t sector_map_table[SFDP_BASIC_PARAMS_TBL_SIZE]; /* Up To 16 DWORDS = 64 Bytes */
11091110
uint32_t tmp_region_size = 0;
11101111
int i_ind = 0;
11111112
int prev_boundary = 0;
11121113
// Default set to all type bits 1-4 are common
11131114
int min_common_erase_type_bits = ERASE_BITMASK_ALL;
11141115

1115-
int status = _qspi_send_read_sfdp_command(sector_map_table_addr, (char *)sector_map_table, sector_map_table_size);
1116-
if (status != QSPI_STATUS_OK) {
1116+
int status = sfdp_reader(smtbl.addr, sector_map_table, smtbl.size);
1117+
if (status < 0) {
11171118
tr_error("Init - Read SFDP First Table Failed");
11181119
return -1;
11191120
}

components/storage/blockdevice/COMPONENT_QSPIF/QSPIFBlockDevice.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,8 @@ class QSPIFBlockDevice : public mbed::BlockDevice {
322322
int _sfdp_parse_basic_param_table(uint32_t basic_table_addr, size_t basic_table_size);
323323

324324
// Parse and read information required by Regions Sector Map
325-
int _sfdp_parse_sector_map_table(uint32_t sector_map_table_addr, size_t sector_map_table_size);
325+
int _sfdp_parse_sector_map_table(mbed::Callback<int(mbed::bd_addr_t, void*, mbed::bd_size_t)> sfdp_reader,
326+
mbed::sfdp_smtbl_info &smtbl);
326327

327328
// Detect the soft reset protocol and reset - returns error if soft reset is not supported
328329
int _sfdp_detect_reset_protocol_and_reset(uint8_t *basic_param_table_ptr);

0 commit comments

Comments
 (0)