/*************************************************************************** * __________ __ ___. * Open \______ \ ____ ____ | | _\_ |__ _______ ___ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * \/ \/ \/ \/ \/ * $Id$ * * Copyright © 2008 Rafaël Carré * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * KIND, either express or implied. * ****************************************************************************/ #include "config.h" #include "system.h" #include "pl081.h" #include "dma-target.h" #include "panic.h" static int dma_used = 0; static void (*dma_callback[2])(void); /* 2 channels */ void dma_retain(void) { if(++dma_used == 1) { bitset32(&CGU_PERI, CGU_DMA_CLOCK_ENABLE); bitset32(&DMAC_CONFIGURATION, 1<<0); } } void dma_release(void) { if(--dma_used == 0) { bitclr32(&DMAC_CONFIGURATION, 1<<0); bitclr32(&CGU_PERI, CGU_DMA_CLOCK_ENABLE); } if (dma_used < 0) panicf("dma_used < 0!"); } void dma_init(void) { #if CONFIG_CPU == AS3525 DMAC_SYNC = 0xffff; /* disable synchronisation logic */ #endif VIC_INT_ENABLE = INTERRUPT_DMAC; } void dma_pause_channel(int channel) { /* Disable the channel - clears the FIFO after sending last word */ bitclr32(&DMAC_CH_CONFIGURATION(channel), 1<<0); /* Wait for it to go inactive */ while (DMAC_CH_CONFIGURATION(channel) & (1<<17)); } void dma_resume_channel(int channel) { /* Resume - must reinit to where it left off (so the docs say) */ unsigned long control = DMAC_CH_CONTROL(channel); if ((control & 0x7ff) == 0) return; /* empty */ DMAC_INT_TC_CLEAR = (1<