summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/target/arm/as3525/sd-as3525v2.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/firmware/target/arm/as3525/sd-as3525v2.c b/firmware/target/arm/as3525/sd-as3525v2.c
index 1546bcbd30..5db63eef10 100644
--- a/firmware/target/arm/as3525/sd-as3525v2.c
+++ b/firmware/target/arm/as3525/sd-as3525v2.c
@@ -758,7 +758,6 @@ static int sd_transfer_sectors(IF_MD2(int drive,) unsigned long start,
758 758
759 const int cmd = write ? SD_WRITE_MULTIPLE_BLOCK : SD_READ_MULTIPLE_BLOCK; 759 const int cmd = write ? SD_WRITE_MULTIPLE_BLOCK : SD_READ_MULTIPLE_BLOCK;
760 760
761 /* Interrupt handler might set this to true during transfer */
762 do 761 do
763 { 762 {
764 void *dma_buf = aligned_buffer; 763 void *dma_buf = aligned_buffer;
@@ -769,15 +768,12 @@ static int sd_transfer_sectors(IF_MD2(int drive,) unsigned long start,
769 if(write) 768 if(write)
770 memcpy(uncached_buffer, buf, transfer * SD_BLOCK_SIZE); 769 memcpy(uncached_buffer, buf, transfer * SD_BLOCK_SIZE);
771 770
771 /* Interrupt handler might set this to true during transfer */
772 retry = false; 772 retry = false;
773 773
774 MCI_BLKSIZ = SD_BLOCK_SIZE; 774 MCI_BLKSIZ = SD_BLOCK_SIZE;
775 MCI_BYTCNT = transfer * SD_BLOCK_SIZE; 775 MCI_BYTCNT = transfer * SD_BLOCK_SIZE;
776 776
777 MCI_CTRL |= (FIFO_RESET|DMA_RESET);
778 while(MCI_CTRL & (FIFO_RESET|DMA_RESET))
779 ;
780
781 ret = sd_wait_for_state(drive, SD_TRAN); 777 ret = sd_wait_for_state(drive, SD_TRAN);
782 if (ret < 0) 778 if (ret < 0)
783 { 779 {
@@ -833,6 +829,13 @@ static int sd_transfer_sectors(IF_MD2(int drive,) unsigned long start,
833 start += transfer; 829 start += transfer;
834 count -= transfer; 830 count -= transfer;
835 } 831 }
832 else /* reset controller if we had an error */
833 {
834 MCI_CTRL |= (FIFO_RESET|DMA_RESET);
835 while(MCI_CTRL & (FIFO_RESET|DMA_RESET))
836 ;
837 }
838
836 } while(retry || count); 839 } while(retry || count);
837 840
838 dma_release(); 841 dma_release();