drivers: spi: mcux_flexcomm: fix DMA bug for 2-byte transfers
The MCUX DMA controller only supports a single data_size for a DMA transfer, not separate ones for source and dest. An older version of the DMA driver used dest_data_size as the DMA transfer size, but the current one uses MIN(dest/source) as the trasnfer size, which breaks case when SPI wants to do 2-byte transfers. Signed-off-by: Mike J. Chen <mjchen@google.com>
This commit is contained in:
parent
f882d31ea7
commit
04f488accf
1 changed files with 6 additions and 5 deletions
|
@ -590,6 +590,7 @@ static int transceive_dma(const struct device *dev,
|
|||
SPI_Type *base = config->base;
|
||||
int ret;
|
||||
uint32_t word_size;
|
||||
uint16_t data_size;
|
||||
|
||||
spi_context_lock(&data->ctx, asynchronous, cb, userdata, spi_cfg);
|
||||
|
||||
|
@ -604,9 +605,11 @@ static int transceive_dma(const struct device *dev,
|
|||
|
||||
word_size = SPI_WORD_SIZE_GET(spi_cfg->operation);
|
||||
|
||||
data->dma_rx.dma_cfg.dest_data_size = (word_size > 8) ?
|
||||
(sizeof(uint16_t)) : (sizeof(uint8_t));
|
||||
data->dma_tx.dma_cfg.dest_data_size = data->dma_rx.dma_cfg.dest_data_size;
|
||||
data_size = (word_size > 8) ? (sizeof(uint16_t)) : (sizeof(uint8_t));
|
||||
data->dma_rx.dma_cfg.source_data_size = data_size;
|
||||
data->dma_rx.dma_cfg.dest_data_size = data_size;
|
||||
data->dma_tx.dma_cfg.source_data_size = data_size;
|
||||
data->dma_tx.dma_cfg.dest_data_size = data_size;
|
||||
|
||||
while (data->ctx.rx_len > 0 || data->ctx.tx_len > 0) {
|
||||
size_t dma_len;
|
||||
|
@ -830,7 +833,6 @@ static void spi_mcux_config_func_##id(const struct device *dev) \
|
|||
.dma_cfg = { \
|
||||
.channel_direction = MEMORY_TO_PERIPHERAL, \
|
||||
.dma_callback = spi_mcux_dma_callback, \
|
||||
.source_data_size = 1, \
|
||||
.block_count = 2, \
|
||||
} \
|
||||
}, \
|
||||
|
@ -841,7 +843,6 @@ static void spi_mcux_config_func_##id(const struct device *dev) \
|
|||
.dma_cfg = { \
|
||||
.channel_direction = PERIPHERAL_TO_MEMORY, \
|
||||
.dma_callback = spi_mcux_dma_callback, \
|
||||
.source_data_size = 1, \
|
||||
.block_count = 1, \
|
||||
} \
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue