From 7572141d42008ce6acd0c2907e4f548cf05fe108 Mon Sep 17 00:00:00 2001 From: Rafaël Carré Date: Thu, 11 Jun 2009 17:17:12 +0000 Subject: FS#10309 : Sets reasonable timeouts for data access in the SD driver MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Those are the recommended maximal timeouts in §4.6.2 Despite that, some people still experiment problems with the SD driver since MMU and data cache were enabled git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21247 a1c6a512-1295-4272-9138-f99709370657 --- firmware/target/arm/as3525/ata_sd_as3525.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'firmware/target/arm') diff --git a/firmware/target/arm/as3525/ata_sd_as3525.c b/firmware/target/arm/as3525/ata_sd_as3525.c index 488988d430..919cd50e9d 100644 --- a/firmware/target/arm/as3525/ata_sd_as3525.c +++ b/firmware/target/arm/as3525/ata_sd_as3525.c @@ -98,6 +98,10 @@ static void init_pl180_controller(const int drive); static tSDCardInfo card_info[NUM_VOLUMES]; +/* maximum timeouts recommanded in the SD Specification v2.00 */ +#define SD_MAX_READ_TIMEOUT ((AS3525_PCLK_FREQ) / 1000 * 100) /* 100 ms */ +#define SD_MAX_WRITE_TIMEOUT ((AS3525_PCLK_FREQ) / 1000 * 250) /* 250 ms */ + /* for compatibility */ static long last_disk_activity = -1; @@ -595,7 +599,7 @@ static int sd_select_bank(signed char bank) 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); - MCI_DATA_TIMER(INTERNAL_AS3525) = 0xffffffff;/* FIXME: arbitrary */ + MCI_DATA_TIMER(INTERNAL_AS3525) = SD_MAX_WRITE_TIMEOUT; MCI_DATA_LENGTH(INTERNAL_AS3525) = 512; MCI_DATA_CTRL(INTERNAL_AS3525) = (1<<0) /* enable */ | (0<<1) /* transfer direction */ | @@ -718,7 +722,11 @@ static int sd_transfer_sectors(IF_MV2(int drive,) unsigned long start, (drive == INTERNAL_AS3525) ? DMA_PERI_SD : DMA_PERI_SD_SLOT, DMAC_FLOWCTRL_PERI_PERI_TO_MEM, false, true, 0, DMA_S8, NULL); - MCI_DATA_TIMER(drive) = 0x1000000; /* FIXME: arbitrary */ + /* FIXME : we should check if the timeouts calculated from the card's + * CSD are lower, and use them if it is the case + * Note : the OF doesn't seem to use them anyway */ + MCI_DATA_TIMER(drive) = write ? + SD_MAX_WRITE_TIMEOUT : SD_MAX_READ_TIMEOUT; MCI_DATA_LENGTH(drive) = transfer * card_info[drive].block_size; MCI_DATA_CTRL(drive) = (1<<0) /* enable */ | (!write<<1) /* transfer direction */ | -- cgit v1.2.3