summaryrefslogtreecommitdiff
path: root/firmware/target/arm
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/target/arm
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/target/arm')
-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);
98 98
99static tSDCardInfo card_info[NUM_VOLUMES]; 99static tSDCardInfo card_info[NUM_VOLUMES];
100 100
101/* maximum timeouts recommanded in the SD Specification v2.00 */
102#define SD_MAX_READ_TIMEOUT ((AS3525_PCLK_FREQ) / 1000 * 100) /* 100 ms */
103#define SD_MAX_WRITE_TIMEOUT ((AS3525_PCLK_FREQ) / 1000 * 250) /* 250 ms */
104
101/* for compatibility */ 105/* for compatibility */
102static long last_disk_activity = -1; 106static long last_disk_activity = -1;
103 107
@@ -595,7 +599,7 @@ static int sd_select_bank(signed char bank)
595 dma_enable_channel(0, card_data, MCI_FIFO(INTERNAL_AS3525), DMA_PERI_SD, 599 dma_enable_channel(0, card_data, MCI_FIFO(INTERNAL_AS3525), DMA_PERI_SD,
596 DMAC_FLOWCTRL_PERI_MEM_TO_PERI, true, false, 0, DMA_S8, NULL); 600 DMAC_FLOWCTRL_PERI_MEM_TO_PERI, true, false, 0, DMA_S8, NULL);
597 601
598 MCI_DATA_TIMER(INTERNAL_AS3525) = 0xffffffff;/* FIXME: arbitrary */ 602 MCI_DATA_TIMER(INTERNAL_AS3525) = SD_MAX_WRITE_TIMEOUT;
599 MCI_DATA_LENGTH(INTERNAL_AS3525) = 512; 603 MCI_DATA_LENGTH(INTERNAL_AS3525) = 512;
600 MCI_DATA_CTRL(INTERNAL_AS3525) = (1<<0) /* enable */ | 604 MCI_DATA_CTRL(INTERNAL_AS3525) = (1<<0) /* enable */ |
601 (0<<1) /* transfer direction */ | 605 (0<<1) /* transfer direction */ |
@@ -718,7 +722,11 @@ static int sd_transfer_sectors(IF_MV2(int drive,) unsigned long start,
718 (drive == INTERNAL_AS3525) ? DMA_PERI_SD : DMA_PERI_SD_SLOT, 722 (drive == INTERNAL_AS3525) ? DMA_PERI_SD : DMA_PERI_SD_SLOT,
719 DMAC_FLOWCTRL_PERI_PERI_TO_MEM, false, true, 0, DMA_S8, NULL); 723 DMAC_FLOWCTRL_PERI_PERI_TO_MEM, false, true, 0, DMA_S8, NULL);
720 724
721 MCI_DATA_TIMER(drive) = 0x1000000; /* FIXME: arbitrary */ 725 /* FIXME : we should check if the timeouts calculated from the card's
726 * CSD are lower, and use them if it is the case
727 * Note : the OF doesn't seem to use them anyway */
728 MCI_DATA_TIMER(drive) = write ?
729 SD_MAX_WRITE_TIMEOUT : SD_MAX_READ_TIMEOUT;
722 MCI_DATA_LENGTH(drive) = transfer * card_info[drive].block_size; 730 MCI_DATA_LENGTH(drive) = transfer * card_info[drive].block_size;
723 MCI_DATA_CTRL(drive) = (1<<0) /* enable */ | 731 MCI_DATA_CTRL(drive) = (1<<0) /* enable */ |
724 (!write<<1) /* transfer direction */ | 732 (!write<<1) /* transfer direction */ |