Skip to content

Commit db1ed25

Browse files
tswaehncfriedt
authored andcommitted
drivers: sam dma xdmac: implemented dma device get_status()
the sam xdmac driver does not yet implement the get_status() function. with this commit the function will be implemented. Fixes #62003 Signed-off-by: Sven Ginka <[email protected]> (cherry picked from commit bc695c6)
1 parent e6f70e9 commit db1ed25

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

drivers/dma/dma_sam_xdmac.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,11 +354,36 @@ static int sam_xdmac_initialize(const struct device *dev)
354354
return 0;
355355
}
356356

357+
static int sam_xdmac_get_status(const struct device *dev, uint32_t channel,
358+
struct dma_status *status)
359+
{
360+
const struct sam_xdmac_dev_cfg *const dev_cfg = dev->config;
361+
362+
Xdmac * const xdmac = dev_cfg->regs;
363+
uint32_t chan_cfg = xdmac->XDMAC_CHID[channel].XDMAC_CC;
364+
uint32_t ublen = xdmac->XDMAC_CHID[channel].XDMAC_CUBC;
365+
366+
/* we need to check some of the XDMAC_CC registers to determine the DMA direction */
367+
if ((chan_cfg & XDMAC_CC_TYPE_Msk) == 0) {
368+
status->dir = MEMORY_TO_MEMORY;
369+
} else if ((chan_cfg & XDMAC_CC_DSYNC_Msk) == XDMAC_CC_DSYNC_MEM2PER) {
370+
status->dir = MEMORY_TO_PERIPHERAL;
371+
} else {
372+
status->dir = PERIPHERAL_TO_MEMORY;
373+
}
374+
375+
status->busy = ((chan_cfg & XDMAC_CC_INITD_Msk) != 0) || (ublen > 0);
376+
status->pending_length = ublen;
377+
378+
return 0;
379+
}
380+
357381
static const struct dma_driver_api sam_xdmac_driver_api = {
358382
.config = sam_xdmac_config,
359383
.reload = sam_xdmac_transfer_reload,
360384
.start = sam_xdmac_transfer_start,
361385
.stop = sam_xdmac_transfer_stop,
386+
.get_status = sam_xdmac_get_status,
362387
};
363388

364389
/* DMA0 */

0 commit comments

Comments
 (0)