diff --git a/drivers/mspi/mspi_dw.c b/drivers/mspi/mspi_dw.c index d4700a99261aa..49bab8df6f612 100644 --- a/drivers/mspi/mspi_dw.c +++ b/drivers/mspi/mspi_dw.c @@ -59,7 +59,7 @@ struct mspi_dw_data { enum mspi_cpp_mode xip_cpp; #endif - uint16_t dummy_bytes; + uint32_t dummy_bytes; uint8_t bytes_to_discard; uint8_t bytes_per_frame_exp; bool standard_spi; @@ -317,7 +317,7 @@ static bool tx_dummy_bytes(const struct device *dev, bool *repeat) uint8_t fifo_room = dev_config->max_queued_dummy_bytes - FIELD_GET(TXFLR_TXTFL_MASK, read_txflr(dev)); uint8_t rx_fifo_items = FIELD_GET(RXFLR_RXTFL_MASK, read_rxflr(dev)); - uint16_t dummy_bytes = dev_data->dummy_bytes; + uint32_t dummy_bytes = dev_data->dummy_bytes; const uint8_t dummy_val = 0; /* Subtract the number of items that are already stored in the RX diff --git a/tests/drivers/flash/common/boards/mx25uw63_low_freq.overlay b/tests/drivers/flash/common/boards/mx25uw63_low_freq.overlay index 950005eaf5c22..8dacdb15ff558 100644 --- a/tests/drivers/flash/common/boards/mx25uw63_low_freq.overlay +++ b/tests/drivers/flash/common/boards/mx25uw63_low_freq.overlay @@ -7,4 +7,5 @@ &mx25uw63 { status = "okay"; mspi-max-frequency = ; + transfer-timeout = <500>; }; diff --git a/tests/drivers/flash/common/boards/mx25uw63_single_io.overlay b/tests/drivers/flash/common/boards/mx25uw63_single_io.overlay index 062020aea3533..766c0279ae55d 100644 --- a/tests/drivers/flash/common/boards/mx25uw63_single_io.overlay +++ b/tests/drivers/flash/common/boards/mx25uw63_single_io.overlay @@ -58,4 +58,5 @@ status = "okay"; mspi-max-frequency = ; mspi-io-mode = "MSPI_IO_MODE_SINGLE"; + transfer-timeout = <5000>; }; diff --git a/tests/drivers/flash/common/boards/mx25uw63_single_io_4B_addr_sreset.overlay b/tests/drivers/flash/common/boards/mx25uw63_single_io_4B_addr_sreset.overlay index 587d685465613..d8ebe4435d167 100644 --- a/tests/drivers/flash/common/boards/mx25uw63_single_io_4B_addr_sreset.overlay +++ b/tests/drivers/flash/common/boards/mx25uw63_single_io_4B_addr_sreset.overlay @@ -61,4 +61,5 @@ mspi-io-mode = "MSPI_IO_MODE_SINGLE"; use-4byte-addressing; initial-soft-reset; + transfer-timeout = <5000>; }; diff --git a/tests/drivers/flash/common/src/main.c b/tests/drivers/flash/common/src/main.c index 8d9265d0bf361..0bc7a7adda365 100644 --- a/tests/drivers/flash/common/src/main.c +++ b/tests/drivers/flash/common/src/main.c @@ -71,6 +71,11 @@ #error There is no flash device enabled or it is missing Kconfig options #endif +#if DT_NODE_HAS_PROP(DT_BUS(TEST_AREA_DEV_NODE), packet_data_limit) +#define CONTROLLER_PACKET_DATA_LIMIT DT_PROP(DT_BUS(TEST_AREA_DEV_NODE), packet_data_limit) +#define BUFFER_SIZE_OVER_PACKET_LIMIT CONTROLLER_PACKET_DATA_LIMIT + 1 +#endif + static const struct device *const flash_dev = TEST_AREA_DEVICE; static struct flash_pages_info page_info; static uint8_t __aligned(4) expected[EXPECTED_SIZE]; @@ -334,6 +339,39 @@ ZTEST(flash_driver, test_flash_erase) zassert_not_equal(expected[0], erase_value, "These values shall be different"); } +ZTEST(flash_driver, test_flash_write_read_over_the_packet_limit) +{ + +#if !defined(CONTROLLER_PACKET_DATA_LIMIT) + TC_PRINT("Given bus controller does not have 'packet_data_limit' property\n"); + ztest_test_skip(); +#else + int rc; + const uint8_t pattern = 0xA1; + static uint8_t large_data_buf[BUFFER_SIZE_OVER_PACKET_LIMIT]; + + /* Flatten area corresponding to the size of two packets */ + rc = flash_flatten(flash_dev, page_info.start_offset, 2 * CONTROLLER_PACKET_DATA_LIMIT); + zassert_equal(rc, 0, "Flash flatten failed: %d", rc); + + /* Fill flash area with buffer size over the configured packet limit */ + rc = flash_fill(flash_dev, pattern, page_info.start_offset, BUFFER_SIZE_OVER_PACKET_LIMIT); + zassert_equal(rc, 0, "Flash fill failed"); + + /* Read flash area with buffer size over the MSPI packet limit */ + rc = flash_read(flash_dev, page_info.start_offset, large_data_buf, + BUFFER_SIZE_OVER_PACKET_LIMIT); + zassert_equal(rc, 0, "Flash read failed"); + + /* Compare read data to the pre-defined pattern */ + for (int i = 0; i < BUFFER_SIZE_OVER_PACKET_LIMIT; i++) { + zassert_equal(large_data_buf[i], pattern, + "large_data_buf[%u]=%x read, does not match written pattern %x", i, + large_data_buf[i], pattern); + } +#endif +} + ZTEST(flash_driver, test_supply_gpios_control) { if (!DT_NODE_HAS_PROP(TEST_AREA_DEV_NODE, supply_gpios)) {