void omap3530_sdma_detach(omap3530_spi_t *omap3530) { rsrc_request_t req = { 0 }; if (omap3530->sdma_tx_chid != -1) { req.length = 1; req.start = omap3530->sdma_tx_chid; req.flags = RSRCDBMGR_DMA_CHANNEL; rsrcdbmgr_detach (&req, 1); } if (omap3530->sdma_rx_chid != -1) { memset (&req, 0, sizeof (req)); req.length = 1; req.start = omap3530->sdma_rx_chid; req.flags = RSRCDBMGR_DMA_CHANNEL; rsrcdbmgr_detach (&req, 1); } munmap_device_memory (omap3530->dma4, sizeof (dma4_t)); }
static void dmac_fini (dmac_dev_t * dmac_dev) { rsrc_request_t req; int timeout = 0; munmap (dmac_dev->lli, (MAX_LLI_NUM) * sizeof(at91sam9xx_dmac_bd_t) ); /* Disable channel */ dmac_dev->dmac->chdr |= (1 << dmac_dev->chid); while (dmac_dev->dmac->chsr & (1 <<dmac_dev->chid)) { delay (1); if (timeout++ > TIMEOUT_LOOPS) { slogf (_SLOGC_SIM_MMC, _SLOG_ERROR, "%s: release DMAC channel time out\n", __func__); break; } } /* release DMAC mmap resources */ munmap (dmac_dev->lli, (MAX_LLI_NUM) * sizeof(at91sam9xx_dmac_bd_t) ); /* Release DMAC channel */ memset(&req, 0, sizeof(req)); req.length = 1; req.flags = RSRCDBMGR_DMA_CHANNEL; req.start = dmac_dev->chid; req.end = dmac_dev->chid; /* Return the resource to the database: */ rsrcdbmgr_detach( &req, 1); if (dmac_dev != NULL) { if ( dmac_dev->dmac!= MAP_FAILED) munmap_device_memory((void *)dmac_dev->dmac, sizeof(at91sam9xx_dmac_t)); free (dmac_dev); } }