Skip to content

Commit dea8cd3

Browse files
yclistanfordkartben
authored andcommitted
dma_mcux_lpc: Fix descriptor address conversion when used by DSP
The SDK FSL DMA driver converts descriptor addresses to DMA's address space when linking descriptors. The Zephyr dma_mcux_lpc driver is missing the inverse conversion when dereferencing the linked next descriptor pointer. This isn't a problem when this driver is used on the M33 core of the MIMXRT595S because the M33 can access the address space of the DMA (0x20000000+). But when the Fusion F1 DSP core uses this driver, the DSP cannot access the DMA's address space so the inverse conversion is needed. Signed-off-by: Yicheng Li <yichengli@google.com>
1 parent a2d230b commit dea8cd3

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

drivers/dma/dma_mcux_lpc.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
#include <zephyr/drivers/dma.h>
1414
#include <fsl_dma.h>
1515
#include <fsl_inputmux.h>
16+
#if defined(FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET) && (FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET == 1)
17+
#include "fsl_memory.h"
18+
#endif
1619
#include <zephyr/logging/log.h>
1720
#include <zephyr/irq.h>
1821
#include <zephyr/sys/barrier.h>
@@ -206,6 +209,14 @@ static int dma_mcux_lpc_queue_descriptors(struct channel_data *data,
206209
* is called from a reload function
207210
*/
208211
next_descriptor = data->curr_descriptor->linkToNextDesc;
212+
/* The SDK converts next descriptor addresses to DMA's
213+
* address space when linking the descriptors, so
214+
* convert it back.
215+
*/
216+
#if defined(FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET) && (FSL_FEATURE_MEMORY_HAS_ADDRESS_OFFSET == 1)
217+
next_descriptor = (void *)MEMORY_ConvertMemoryMapAddress(
218+
(uint32_t)next_descriptor, kMEMORY_DMA2Local);
219+
#endif
209220
}
210221

211222
/* SPI TX transfers need to queue a DMA descriptor to

0 commit comments

Comments
 (0)