summaryrefslogtreecommitdiffstats
path: root/firmware/target/arm
diff options
context:
space:
mode:
authorRafaël Carré <rafael.carre@gmail.com>2009-06-29 11:56:49 +0000
committerRafaël Carré <rafael.carre@gmail.com>2009-06-29 11:56:49 +0000
commit529855e79b7d95eebc6035b12ca6091f227e3c8c (patch)
treeb872d93eb749a304cf2f7c243ddb0a797e345e3b /firmware/target/arm
parente84a98ba675fd479ce7ec208d9bed7a6ba9e46f6 (diff)
downloadrockbox-529855e79b7d95eebc6035b12ca6091f227e3c8c.tar.gz
rockbox-529855e79b7d95eebc6035b12ca6091f227e3c8c.zip
Sansa AMS: correct sd_select_bank() in SD driver
Put the card data sent by DMA aligned on cache line size, and in uncached memory Since sd_select_bank() is not used very often, still allocate the DMA buffer on the stack. If you still experience any problems with this commit please report them after having formatted your player and reinstalled rockbox git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21550 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm')
-rw-r--r--firmware/target/arm/as3525/ata_sd_as3525.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/firmware/target/arm/as3525/ata_sd_as3525.c b/firmware/target/arm/as3525/ata_sd_as3525.c
index 0556cc0eb4..9ef8226019 100644
--- a/firmware/target/arm/as3525/ata_sd_as3525.c
+++ b/firmware/target/arm/as3525/ata_sd_as3525.c
@@ -571,7 +571,11 @@ static int sd_wait_for_state(const int drive, unsigned int state)
static int sd_select_bank(signed char bank)
{
- unsigned char card_data[512];
+ /* allocate card data buffer on the stack */
+ unsigned char card_data[512 + 31];
+ /* align it on cache line size */
+ unsigned char *aligned_card_data = (void*)(((int)&card_data[0] + 31) & ~31);
+ unsigned char *uncached_card_data = UNCACHED_ADDR(aligned_card_data);
int ret;
do {
@@ -592,19 +596,22 @@ static int sd_select_bank(signed char bank)
mci_delay();
- memset(card_data, 0, 512);
+ memset(uncached_card_data, 0, 512);
if(bank == -1)
{ /* enable bank switching */
- card_data[0] = 16;
- card_data[1] = 1;
- card_data[2] = 10;
+ uncached_card_data[0] = 16;
+ uncached_card_data[1] = 1;
+ uncached_card_data[2] = 10;
}
else
- card_data[0] = bank;
+ uncached_card_data[0] = bank;
dma_retain();
- dma_enable_channel(0, card_data, MCI_FIFO(INTERNAL_AS3525), DMA_PERI_SD,
- DMAC_FLOWCTRL_PERI_MEM_TO_PERI, true, false, 0, DMA_S8, NULL);
+ /* we don't use the uncached card data for DMA, because we need the
+ * physical memory address for DMA transfers */
+ dma_enable_channel(0, aligned_card_data, MCI_FIFO(INTERNAL_AS3525),
+ DMA_PERI_SD, DMAC_FLOWCTRL_PERI_MEM_TO_PERI, true, false, 0, DMA_S8,
+ NULL);
MCI_DATA_TIMER(INTERNAL_AS3525) = SD_MAX_WRITE_TIMEOUT;
MCI_DATA_LENGTH(INTERNAL_AS3525) = 512;