@@ -646,6 +646,15 @@ qspi_status_t SPINANDBlockDevice::_qspi_send_read_command(qspi_inst_t read_inst,
646
646
647
647
size_t buf_len = size;
648
648
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
+
649
658
// Send read command to device driver
650
659
// Read commands use the best bus mode supported by the part
651
660
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,
668
677
669
678
if (false == _is_mem_ready ()) {
670
679
tr_error (" Device not ready, clearing block protection failed" );
671
- return - 1 ;
680
+ return QSPI_STATUS_ERROR ;
672
681
}
673
682
674
683
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);
676
685
if (QSPI_STATUS_OK != status) {
677
686
tr_error (" _qspi_configure_format failed" );
678
687
return status;
@@ -702,9 +711,17 @@ qspi_status_t SPINANDBlockDevice::_qspi_send_program_command(qspi_inst_t prog_in
702
711
{
703
712
tr_debug (" Inst: 0x%xh, addr: %llu, size: %llu" , prog_inst, addr, *size);
704
713
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
+
705
722
// Program load commands need 16 bit row address
706
723
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 );
708
725
if (QSPI_STATUS_OK != status) {
709
726
tr_error (" _qspi_configure_format failed" );
710
727
return status;
@@ -795,3 +812,4 @@ qspi_status_t SPINANDBlockDevice::_qspi_send_general_command(qspi_inst_t instruc
795
812
return QSPI_STATUS_OK;
796
813
}
797
814
815
+
0 commit comments