1
0
Fork 0
forked from len0rd/rockbox

Sansa AMS: use non-busy wakeup to signal end of DMA transfer

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19233 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Rafaël Carré 2008-11-26 16:02:00 +00:00
parent aaaf609996
commit a39e4e9962
4 changed files with 16 additions and 10 deletions

View file

@ -434,7 +434,7 @@
#endif /* BOOTLOADER */ #endif /* BOOTLOADER */
#if defined(HAVE_USBSTACK) || (CONFIG_CPU == JZ4732) #if defined(HAVE_USBSTACK) || (CONFIG_CPU == JZ4732) || (CONFIG_CPU == AS3525)
#define HAVE_WAKEUP_OBJECTS #define HAVE_WAKEUP_OBJECTS
#endif #endif

View file

@ -553,8 +553,7 @@ static int sd_transfer_sectors(IF_MV2(int drive,) unsigned long start,
(1<<3) /* DMA */ | (1<<3) /* DMA */ |
(9<<4) /* 2^9 = 512 */ ; (9<<4) /* 2^9 = 512 */ ;
while(!dma_finished) dma_wait_transfer(0);
yield();
buf += transfer * SECTOR_SIZE; buf += transfer * SECTOR_SIZE;
start += transfer; start += transfer;

View file

@ -19,21 +19,30 @@
* *
****************************************************************************/ ****************************************************************************/
#include <stdbool.h>
#include "as3525.h" #include "as3525.h"
#include "pl081.h" #include "pl081.h"
#include "dma-target.h" #include "dma-target.h"
#include <stdbool.h>
#include "panic.h" #include "panic.h"
#include "kernel.h"
volatile bool dma_finished; static struct wakeup transfer_completion_signal[2]; /* 2 channels */
inline void dma_wait_transfer(int channel)
{
wakeup_wait(&transfer_completion_signal[channel], TIMEOUT_BLOCK);
}
void dma_init(void) void dma_init(void)
{ {
/* Enable DMA controller */ /* Enable DMA controller */
CGU_PERI |= CGU_DMA_CLOCK_ENABLE; CGU_PERI |= CGU_DMA_CLOCK_ENABLE;
DMAC_CONFIGURATION |= (1<<0); DMAC_CONFIGURATION |= (1<<0); /* TODO: disable controller when not used */
DMAC_SYNC = 0; DMAC_SYNC = 0;
VIC_INT_ENABLE |= INTERRUPT_DMAC; VIC_INT_ENABLE |= INTERRUPT_DMAC;
wakeup_init(&transfer_completion_signal[0]);
wakeup_init(&transfer_completion_signal[1]);
} }
void dma_enable_channel(int channel, void *src, void *dst, int peri, void dma_enable_channel(int channel, void *src, void *dst, int peri,
@ -65,8 +74,6 @@ void dma_enable_channel(int channel, void *src, void *dst, int peri,
DMAC_CH_CONTROL(channel) = control; DMAC_CH_CONTROL(channel) = control;
dma_finished = false;
/* only needed if DMAC and Peripheral do not run at the same clock speed */ /* only needed if DMAC and Peripheral do not run at the same clock speed */
DMAC_SYNC |= (1<<peri); DMAC_SYNC |= (1<<peri);
@ -92,5 +99,5 @@ void INT_DMAC(void)
DMAC_INT_TC_CLEAR |= (1<<channel); /* clear terminal count interrupt */ DMAC_INT_TC_CLEAR |= (1<<channel); /* clear terminal count interrupt */
dma_finished = true; /* TODO : use struct wakeup ? */ wakeup_signal(&transfer_completion_signal[channel]);
} }

View file

@ -36,4 +36,4 @@ void dma_enable_channel(int channel, void *src, void *dst, int peri,
int flow_controller, bool src_inc, bool dst_inc, int flow_controller, bool src_inc, bool dst_inc,
size_t size, int nwords); size_t size, int nwords);
extern volatile bool dma_finished; inline void dma_wait_transfer(int channel);