Skip to content

Commit e515c41

Browse files
jerome-pouillerdkalowsk
authored andcommitted
drivers: spi: siwx91x: Fix compatibility with gpdma
Because of limitation of gpdma, DMA Rx won't run if user doesn't specify destination buffer. Thus, the DMA Rx may stop before the end of the full transaction. So, wait on DMA Tx instead. Then, the SPI data won't be consumed by the DMA. We need to properly reset the fifo before to start a new transaction (it is better to ensure we start with a clean state before every transaction). Signed-off-by: Jérôme Pouiller <[email protected]>
1 parent 42eff40 commit e515c41

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/spi/spi_silabs_siwx91x_gspi.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ static int gspi_siwx91x_config(const struct device *dev, const struct spi_config
192192
}
193193

194194
#ifdef CONFIG_SPI_SILABS_SIWX91X_GSPI_DMA
195-
static void gspi_siwx91x_dma_rx_callback(const struct device *dev, void *user_data,
195+
static void gspi_siwx91x_dma_tx_callback(const struct device *dev, void *user_data,
196196
uint32_t channel, int status)
197197
{
198198
const struct device *spi_dev = (const struct device *)user_data;
@@ -230,7 +230,7 @@ static int gspi_siwx91x_dma_config(const struct device *dev,
230230
.block_count = block_count,
231231
.head_block = channel->dma_descriptors,
232232
.dma_slot = channel->dma_slot,
233-
.dma_callback = !is_tx ? &gspi_siwx91x_dma_rx_callback : NULL,
233+
.dma_callback = is_tx ? &gspi_siwx91x_dma_tx_callback : NULL,
234234
.user_data = (void *)dev,
235235
};
236236

@@ -411,7 +411,8 @@ static int gspi_siwx91x_transceive_dma(const struct device *dev, const struct sp
411411
return -EINVAL;
412412
}
413413

414-
/* Reset the Rx and Tx FIFO register */
414+
cfg->reg->GSPI_FIFO_THRLD_b.RFIFO_RESET = 1;
415+
cfg->reg->GSPI_FIFO_THRLD_b.WFIFO_RESET = 1;
415416
cfg->reg->GSPI_FIFO_THRLD = 0;
416417

417418
ret = gspi_siwx91x_prepare_dma_transaction(dev, padded_transaction_size);

0 commit comments

Comments
 (0)