From 96666a39aed47c8c643dc7c6a6e15e314e63f42b Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sun, 8 Apr 2012 17:34:46 +0000 Subject: DMA: Split the APBH DMA init into block and channel init This fixes the issue where mxs_dma_init() was called either twice or never, without introducing any new init hooks. The idea is to allow each and every device using the APBH DMA block to configure and request only the channels it uses, instead of making it call init for all the channels as is now. The common DMA block init part, which only configures the block, is then called from CPUs arch_cpu_init() call. NOTE: This patch depends on: http://patchwork.ozlabs.org/patch/150957/ Signed-off-by: Marek Vasut Cc: Stefano Babic Cc: Wolfgang Denk Cc: Detlev Zundel Cc: Fabio Estevam Tested-by: Fabio Estevam --- drivers/dma/apbh_dma.c | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) (limited to 'drivers/dma') diff --git a/drivers/dma/apbh_dma.c b/drivers/dma/apbh_dma.c index c086629b0a..cb2193ec55 100644 --- a/drivers/dma/apbh_dma.c +++ b/drivers/dma/apbh_dma.c @@ -316,7 +316,7 @@ static int mxs_dma_request(int channel) * The channel will NOT be released if it's marked "busy" (see * mxs_dma_enable()). */ -static int mxs_dma_release(int channel) +int mxs_dma_release(int channel) { struct mxs_dma_chan *pchan; int ret; @@ -552,12 +552,10 @@ int mxs_dma_go(int chan) /* * Initialize the DMA hardware */ -int mxs_dma_init(void) +void mxs_dma_init(void) { struct mx28_apbh_regs *apbh_regs = (struct mx28_apbh_regs *)MXS_APBH_BASE; - struct mxs_dma_chan *pchan; - int ret, channel; mx28_reset_block(&apbh_regs->hw_apbh_ctrl0_reg); @@ -576,28 +574,26 @@ int mxs_dma_init(void) writel(APBH_CTRL0_APB_BURST_EN, &apbh_regs->hw_apbh_ctrl0_clr); #endif +} - for (channel = 0; channel < MXS_MAX_DMA_CHANNELS; channel++) { - pchan = mxs_dma_channels + channel; - pchan->flags = MXS_DMA_FLAGS_VALID; - - ret = mxs_dma_request(channel); +int mxs_dma_init_channel(int channel) +{ + struct mxs_dma_chan *pchan; + int ret; - if (ret) { - printf("MXS DMA: Can't acquire DMA channel %i\n", - channel); + pchan = mxs_dma_channels + channel; + pchan->flags = MXS_DMA_FLAGS_VALID; - goto err; - } + ret = mxs_dma_request(channel); - mxs_dma_reset(channel); - mxs_dma_ack_irq(channel); + if (ret) { + printf("MXS DMA: Can't acquire DMA channel %i\n", + channel); + return ret; } - return 0; + mxs_dma_reset(channel); + mxs_dma_ack_irq(channel); -err: - while (--channel >= 0) - mxs_dma_release(channel); - return ret; + return 0; } -- cgit v1.2.1