@@ -646,6 +646,15 @@ qspi_status_t SPINANDBlockDevice::_qspi_send_read_command(qspi_inst_t read_inst,
646646
647647 size_t buf_len = size;
648648
649+ qspi_bus_width_t data_width;
650+ if (read_inst == SPINAND_INST_READ_CACHE) {
651+ data_width = QSPI_CFG_BUS_SINGLE;
652+ } else if (read_inst == SPINAND_INST_READ_CACHE2) {
653+ data_width = QSPI_CFG_BUS_DUAL;
654+ } else if (read_inst == SPINAND_INST_READ_CACHE4) {
655+ data_width = QSPI_CFG_BUS_QUAD;
656+ }
657+
649658 // Send read command to device driver
650659 // Read commands use the best bus mode supported by the part
651660 qspi_status_t status = _qspi.configure_format (_inst_width, _address_width, SPI_NAND_COLUMN_ADDR_SIZE, // Alt width should be the same as address width
@@ -668,11 +677,11 @@ qspi_status_t SPINANDBlockDevice::_qspi_send_read_command(qspi_inst_t read_inst,
668677
669678 if (false == _is_mem_ready ()) {
670679 tr_error (" Device not ready, clearing block protection failed" );
671- return - 1 ;
680+ return QSPI_STATUS_ERROR ;
672681 }
673682
674683 status = _qspi.configure_format (_inst_width, _address_width, SPI_NAND_ROW_ADDR_SIZE, _address_width, // Alt width should be the same as address width
675- _alt_size, QSPI_CFG_BUS_QUAD , _dummy_cycles);
684+ _alt_size, data_width , _dummy_cycles);
676685 if (QSPI_STATUS_OK != status) {
677686 tr_error (" _qspi_configure_format failed" );
678687 return status;
@@ -702,9 +711,17 @@ qspi_status_t SPINANDBlockDevice::_qspi_send_program_command(qspi_inst_t prog_in
702711{
703712 tr_debug (" Inst: 0x%xh, addr: %llu, size: %llu" , prog_inst, addr, *size);
704713
714+ qspi_bus_width_t data_width;
715+
716+ if (prog_inst == SPINAND_INST_PP_LOAD) {
717+ data_width = QSPI_CFG_BUS_SINGLE;
718+ } else if (prog_inst == SPINAND_INST_4PP_LOAD) {
719+ data_width = QSPI_CFG_BUS_QUAD;
720+ }
721+
705722 // Program load commands need 16 bit row address
706723 qspi_status_t status = _qspi.configure_format (_inst_width, _address_width, SPI_NAND_ROW_ADDR_SIZE, // Alt width should be the same as address width
707- _address_width, _alt_size, QSPI_CFG_BUS_QUAD , 0 );
724+ _address_width, _alt_size, data_width , 0 );
708725 if (QSPI_STATUS_OK != status) {
709726 tr_error (" _qspi_configure_format failed" );
710727 return status;
@@ -795,3 +812,4 @@ qspi_status_t SPINANDBlockDevice::_qspi_send_general_command(qspi_inst_t instruc
795812 return QSPI_STATUS_OK;
796813}
797814
815+
0 commit comments