Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e787296

Browse files
ananglkartben
authored andcommittedJun 23, 2025·
drivers: mspi_dw: Add support for RX dummy cycles in single line mode
Support for 8 dummy cycles in a single line RX transaction is required for the standard JEDEC Read SFDP command. The SSI controller does not support dummy cycles in Standard SPI mode, but the driver can simulate those by just sending a dummy data byte. Signed-off-by: Andrzej Głąbek <[email protected]>
1 parent 28dafe3 commit e787296

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed
 

‎drivers/mspi/mspi_dw.c

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -844,13 +844,16 @@ static int start_next_packet(const struct device *dev, k_timeout_t timeout)
844844
(dev_data->xfer.cmd_length != 0 ||
845845
dev_data->xfer.addr_length != 0)) {
846846
uint32_t rx_total_bytes;
847+
uint32_t dummy_cycles = dev_data->xfer.rx_dummy;
847848

848849
dev_data->bytes_to_discard = dev_data->xfer.cmd_length
849-
+ dev_data->xfer.addr_length;
850+
+ dev_data->xfer.addr_length
851+
+ dummy_cycles / 8;
850852
rx_total_bytes = dev_data->bytes_to_discard
851853
+ packet->num_bytes;
852854

853-
dev_data->dummy_bytes = packet->num_bytes;
855+
dev_data->dummy_bytes = dummy_cycles / 8
856+
+ packet->num_bytes;
854857

855858
imr = IMR_TXEIM_BIT | IMR_RXFIM_BIT;
856859
tmod = CTRLR0_TMOD_TX_RX;
@@ -862,11 +865,13 @@ static int start_next_packet(const struct device *dev, k_timeout_t timeout)
862865
tmod = CTRLR0_TMOD_RX;
863866
rx_fifo_threshold = MIN(packet_frames - 1,
864867
dev_config->rx_fifo_threshold);
868+
869+
dev_data->spi_ctrlr0 |=
870+
FIELD_PREP(SPI_CTRLR0_WAIT_CYCLES_MASK,
871+
dev_data->xfer.rx_dummy);
865872
}
866873

867874
dev_data->ctrlr0 |= FIELD_PREP(CTRLR0_TMOD_MASK, tmod);
868-
dev_data->spi_ctrlr0 |= FIELD_PREP(SPI_CTRLR0_WAIT_CYCLES_MASK,
869-
dev_data->xfer.rx_dummy);
870875

871876
write_rxftlr(dev, FIELD_PREP(RXFTLR_RFT_MASK,
872877
rx_fifo_threshold));
@@ -1039,10 +1044,15 @@ static int _api_transceive(const struct device *dev,
10391044
return -EINVAL;
10401045
}
10411046

1042-
if (dev_data->standard_spi &&
1043-
(req->rx_dummy != 0 || req->tx_dummy != 0)) {
1044-
LOG_ERR("Dummy cycles unsupported in single line mode");
1045-
return -EINVAL;
1047+
if (dev_data->standard_spi) {
1048+
if (req->tx_dummy) {
1049+
LOG_ERR("TX dummy cycles unsupported in single line mode");
1050+
return -EINVAL;
1051+
}
1052+
if (req->rx_dummy % 8) {
1053+
LOG_ERR("Unsupported RX (%u) dummy cycles", req->rx_dummy);
1054+
return -EINVAL;
1055+
}
10461056
} else if (req->rx_dummy > SPI_CTRLR0_WAIT_CYCLES_MAX ||
10471057
req->tx_dummy > SPI_CTRLR0_WAIT_CYCLES_MAX) {
10481058
LOG_ERR("Unsupported RX (%u) or TX (%u) dummy cycles",

0 commit comments

Comments
 (0)
Please sign in to comment.