summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorRafaël Carré <rafael.carre@gmail.com>2009-06-11 17:17:12 +0000
committerRafaël Carré <rafael.carre@gmail.com>2009-06-11 17:17:12 +0000
commit7572141d42008ce6acd0c2907e4f548cf05fe108 (patch)
treef68b62ef693b5d1dda5905082b2d2f19f1859ba9 /firmware
parent85dbf3fe182b52ef9be9875f0766c14efb294848 (diff)
downloadrockbox-7572141d42008ce6acd0c2907e4f548cf05fe108.tar.gz
rockbox-7572141d42008ce6acd0c2907e4f548cf05fe108.zip
FS#10309 : Sets reasonable timeouts for data access in the SD driver
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
Diffstat (limited to 'firmware')
-rw-r--r--firmware/target/arm/as3525/ata_sd_as3525.c12
1 files changed, 10 insertions, 2 deletions
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 */ |