summaryrefslogtreecommitdiff
path: root/firmware/target/arm/as3525/dma-pl081.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/as3525/dma-pl081.c')
-rw-r--r--firmware/target/arm/as3525/dma-pl081.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/firmware/target/arm/as3525/dma-pl081.c b/firmware/target/arm/as3525/dma-pl081.c
index 3de4e73c12..8ec2919714 100644
--- a/firmware/target/arm/as3525/dma-pl081.c
+++ b/firmware/target/arm/as3525/dma-pl081.c
@@ -26,6 +26,7 @@
26#include "panic.h" 26#include "panic.h"
27#include "kernel.h" 27#include "kernel.h"
28 28
29static int dma_used = 0;
29static struct wakeup transfer_completion_signal[2]; /* 2 channels */ 30static struct wakeup transfer_completion_signal[2]; /* 2 channels */
30static void (*dma_callback[2])(void); /* 2 channels */ 31static void (*dma_callback[2])(void); /* 2 channels */
31 32
@@ -34,11 +35,26 @@ inline void dma_wait_transfer(int channel)
34 wakeup_wait(&transfer_completion_signal[channel], TIMEOUT_BLOCK); 35 wakeup_wait(&transfer_completion_signal[channel], TIMEOUT_BLOCK);
35} 36}
36 37
38void dma_retain(void)
39{
40 if(++dma_used == 1)
41 {
42 CGU_PERI |= CGU_DMA_CLOCK_ENABLE;
43 DMAC_CONFIGURATION |= (1<<0);
44 }
45}
46
47void dma_release(void)
48{
49 if(--dma_used == 0)
50 {
51 DMAC_CONFIGURATION &= ~(1<<0);
52 CGU_PERI &= ~CGU_DMA_CLOCK_ENABLE;
53 }
54}
55
37void dma_init(void) 56void dma_init(void)
38{ 57{
39 /* Enable DMA controller */
40 CGU_PERI |= CGU_DMA_CLOCK_ENABLE;
41 DMAC_CONFIGURATION |= (1<<0); /* TODO: disable controller when not used */
42 DMAC_SYNC = 0; 58 DMAC_SYNC = 0;
43 VIC_INT_ENABLE |= INTERRUPT_DMAC; 59 VIC_INT_ENABLE |= INTERRUPT_DMAC;
44 60