diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/target/arm/as3525/sd-as3525v2.c | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/firmware/target/arm/as3525/sd-as3525v2.c b/firmware/target/arm/as3525/sd-as3525v2.c index 3e370850d6..ee2a09ac0a 100644 --- a/firmware/target/arm/as3525/sd-as3525v2.c +++ b/firmware/target/arm/as3525/sd-as3525v2.c | |||
@@ -402,12 +402,6 @@ static bool send_cmd(const int drive, const int cmd, const int arg, const int fl | |||
402 | GPIOB_PIN(5) = (1-drive) << 5; | 402 | GPIOB_PIN(5) = (1-drive) << 5; |
403 | #endif | 403 | #endif |
404 | 404 | ||
405 | /* RCRC & RTO interrupts should be set together with the CD interrupt but | ||
406 | * in practice sometimes incorrectly precede the CD interrupt. If we leave | ||
407 | * them masked for now we can check them in the isr by reading raw status when | ||
408 | * the CD int is triggered. | ||
409 | */ | ||
410 | MCI_MASK |= MCI_INT_CD; | ||
411 | MCI_ARGUMENT = arg; | 405 | MCI_ARGUMENT = arg; |
412 | 406 | ||
413 | /* Construct MCI_COMMAND */ | 407 | /* Construct MCI_COMMAND */ |
@@ -438,8 +432,6 @@ static bool send_cmd(const int drive, const int cmd, const int arg, const int fl | |||
438 | #endif | 432 | #endif |
439 | wakeup_wait(&command_completion_signal, TIMEOUT_BLOCK); | 433 | wakeup_wait(&command_completion_signal, TIMEOUT_BLOCK); |
440 | 434 | ||
441 | MCI_MASK &= ~MCI_INT_CD; | ||
442 | |||
443 | /* Handle command responses & errors */ | 435 | /* Handle command responses & errors */ |
444 | if(flags & MCI_RESP) | 436 | if(flags & MCI_RESP) |
445 | { | 437 | { |
@@ -700,10 +692,16 @@ static void init_controller(void) | |||
700 | /* Rx watermark = 63(sd reads) Tx watermark = 128 (sd writes) */ | 692 | /* Rx watermark = 63(sd reads) Tx watermark = 128 (sd writes) */ |
701 | MCI_FIFOTH = (MCI_FIFOTH & MCI_FIFOTH_MASK) | 0x503f0080; | 693 | MCI_FIFOTH = (MCI_FIFOTH & MCI_FIFOTH_MASK) | 0x503f0080; |
702 | 694 | ||
703 | /* Mask all MCI Interrupts initially */ | 695 | /* RCRC & RTO interrupts should be set together with the CD interrupt but |
704 | MCI_MASK = 0; | 696 | * in practice sometimes incorrectly precede the CD interrupt. If we leave |
697 | * them masked for now we can check them in the isr by reading raw status when | ||
698 | * the CD int is triggered. | ||
699 | */ | ||
700 | MCI_MASK |= (MCI_DATA_ERROR | MCI_INT_DTO | MCI_INT_CD); | ||
705 | 701 | ||
706 | MCI_CTRL |= INT_ENABLE; | 702 | MCI_CTRL |= INT_ENABLE | DMA_ENABLE; |
703 | |||
704 | MCI_BLKSIZ = SD_BLOCK_SIZE; | ||
707 | } | 705 | } |
708 | 706 | ||
709 | int sd_init(void) | 707 | int sd_init(void) |
@@ -846,7 +844,6 @@ static int sd_transfer_sectors(IF_MD2(int drive,) unsigned long start, | |||
846 | /* Interrupt handler might set this to true during transfer */ | 844 | /* Interrupt handler might set this to true during transfer */ |
847 | retry = false; | 845 | retry = false; |
848 | 846 | ||
849 | MCI_BLKSIZ = SD_BLOCK_SIZE; | ||
850 | MCI_BYTCNT = transfer * SD_BLOCK_SIZE; | 847 | MCI_BYTCNT = transfer * SD_BLOCK_SIZE; |
851 | 848 | ||
852 | ret = sd_wait_for_state(drive, SD_TRAN); | 849 | ret = sd_wait_for_state(drive, SD_TRAN); |
@@ -874,17 +871,12 @@ static int sd_transfer_sectors(IF_MD2(int drive,) unsigned long start, | |||
874 | dma_enable_channel(0, MCI_FIFO, dma_buf, DMA_PERI_SD, | 871 | dma_enable_channel(0, MCI_FIFO, dma_buf, DMA_PERI_SD, |
875 | DMAC_FLOWCTRL_PERI_PERI_TO_MEM, false, true, 0, DMA_S8, NULL); | 872 | DMAC_FLOWCTRL_PERI_PERI_TO_MEM, false, true, 0, DMA_S8, NULL); |
876 | 873 | ||
877 | MCI_MASK |= (MCI_DATA_ERROR | MCI_INT_DTO); | ||
878 | MCI_CTRL |= DMA_ENABLE; | ||
879 | |||
880 | unsigned long dummy; /* if we don't ask for a response, writing fails */ | 874 | unsigned long dummy; /* if we don't ask for a response, writing fails */ |
881 | if(!send_cmd(drive, cmd, arg, MCI_RESP, &dummy)) | 875 | if(!send_cmd(drive, cmd, arg, MCI_RESP, &dummy)) |
882 | panicf("%s multiple blocks failed", write ? "write" : "read"); | 876 | panicf("%s multiple blocks failed", write ? "write" : "read"); |
883 | 877 | ||
884 | wakeup_wait(&transfer_completion_signal, TIMEOUT_BLOCK); | 878 | wakeup_wait(&transfer_completion_signal, TIMEOUT_BLOCK); |
885 | 879 | ||
886 | MCI_MASK &= ~(MCI_DATA_ERROR | MCI_INT_DTO); | ||
887 | |||
888 | last_disk_activity = current_tick; | 880 | last_disk_activity = current_tick; |
889 | 881 | ||
890 | if(!send_cmd(drive, SD_STOP_TRANSMISSION, 0, MCI_NO_RESP, NULL)) | 882 | if(!send_cmd(drive, SD_STOP_TRANSMISSION, 0, MCI_NO_RESP, NULL)) |