-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NXP drivers: spi: spi_mcux_lpspi: enable CONFIG_SPI_ASYNC mode with DMA #78194
Conversation
35119cb
to
703d3c3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in Kconfig.mcux_lpspi can you please add something like depends on DMA
if SPI_ASYNC
to the LPSPI driver kconfig
@@ -532,6 +532,12 @@ static int dma_mcux_edma_reload(const struct device *dev, uint32_t channel, | |||
ret = -EFAULT; | |||
} | |||
|
|||
if (data->edma_handle.tcdPool == NULL) { | |||
/* Not using scatter/gather mode, re-enable the hardware request */ | |||
EDMA_EnableChannelRequest(DEV_EDMA_HANDLE(dev, channel)->base, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you give an explanation of "why" in the commit message at least, maybe also in the comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added details in comment and commit message
drivers/spi/spi_mcux_lpspi.c
Outdated
dma_size = MIN(data->ctx.tx_len, data->ctx.rx_len); | ||
|
||
if (dma_size == 0) { | ||
dma_size = MAX(data->ctx.tx_len, data->ctx.rx_len); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is it not always max?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @decsny ,
Making this change (always MAX) here in spi_mcux_dma_callback()
, the spi_loopback
test passes. However, if I make this same change in spi_mcux_dma_rxtx_load()
, the "half start" test fails. I believe this existing code is keeping the RX and TX transfers equal size until one completes, and then it finishes the other.
With some compiler optimizations, compiler error occurs when trying to test tx_buf_size in BUILD_ASSERT. Signed-off-by: Derek Snell <[email protected]>
If not using scatter/gather mode, re-enable the hardware channel requests. The fsl_edma driver uses the eDMA DREQ bit to automatically disable the hardware DMA request at the end of the major loop. Signed-off-by: Derek Snell <[email protected]>
DMA scatter/gather mode was unused in this driver. Signed-off-by: Derek Snell <[email protected]>
If CONFIG_SPI_ASYNC, select the DMA feature Signed-off-by: Derek Snell <[email protected]>
add DMA async support. Signed-off-by: Derek Snell <[email protected]>
…ards Enable testing async mode on all the NXP boards with the LPSPI peripherals. Signed-off-by: Derek Snell <[email protected]>
703d3c3
to
cd2b208
Compare
} | ||
|
||
/* Restart the TX DMA */ | ||
ret = dma_reload(dev, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have we verified this works correctly when the SPI is only sending or only receiving data? If memory serves, we usually configure the TX DMA or RX DMA with a step size of zero and a dummy buffer in these cases, so that DMA will run on both channels. My concern is that if we (for example) are sending TX data and not receiving anything, the LPSPI RX FIFO will overflow since the DMA will not be reading from it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, @danieldegrasse .
No, that has not been tested here. the spi_loopback
test does not enable RX without TX.
Adding DNM label until we test further.
Thanks
Hello, I'm testing with mimxrt1060_evk. The tests are passing, but the functionality is incorrect. I am getting chip select for every byte when I should only get chip select for one block. |
what do you mean by this, are you saying that PR breaks it? because if so, that's not my observations. |
I'm using main branch of zephyr, and executing
If I remove the
I think the flag is correct because otherwise, you could only send one byte commands. The documentation says that to use this function, you need to send extra command to deselect chip-select.
|
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
Updates LPSPI driver to support async mode with DMA. Enables
spi_loopback
testing async mode on all the NXP boards with the LPSPI peripherals. Resolves #74907.spi_loopback test with
CONFIG_SPI_ASYNC
passes on the following boards. The test failed on 1 board which needs more investigation, a separate issue created for that board at #78238.