diff options
-rw-r--r-- | firmware/target/arm/as3525/sd-as3525v2.c | 48 |
1 files changed, 3 insertions, 45 deletions
diff --git a/firmware/target/arm/as3525/sd-as3525v2.c b/firmware/target/arm/as3525/sd-as3525v2.c index db1dbbb068..338a6d669f 100644 --- a/firmware/target/arm/as3525/sd-as3525v2.c +++ b/firmware/target/arm/as3525/sd-as3525v2.c | |||
@@ -43,24 +43,6 @@ | |||
43 | #include <stdarg.h> | 43 | #include <stdarg.h> |
44 | #include "sysfont.h" | 44 | #include "sysfont.h" |
45 | 45 | ||
46 | /* debug helper */ | ||
47 | static int line = 0; | ||
48 | static void printf(const char *format, ...) | ||
49 | { | ||
50 | char buf[50]; | ||
51 | int len; | ||
52 | va_list ap; | ||
53 | va_start(ap, format); | ||
54 | |||
55 | len = vsnprintf(buf, sizeof(buf), format, ap); | ||
56 | va_end(ap); | ||
57 | |||
58 | lcd_puts(0, line++, buf); | ||
59 | lcd_update(); | ||
60 | if(line >= LCD_HEIGHT/SYSFONT_HEIGHT) | ||
61 | line = 0; | ||
62 | } | ||
63 | |||
64 | /* command flags */ | 46 | /* command flags */ |
65 | #define MCI_NO_RESP (0<<0) | 47 | #define MCI_NO_RESP (0<<0) |
66 | #define MCI_RESP (1<<0) | 48 | #define MCI_RESP (1<<0) |
@@ -378,8 +360,6 @@ static int sd_init_card(void) | |||
378 | if(!send_cmd(SD_SET_BUS_WIDTH, card_info.rca | 2, MCI_NO_RESP, NULL)) | 360 | if(!send_cmd(SD_SET_BUS_WIDTH, card_info.rca | 2, MCI_NO_RESP, NULL)) |
379 | return -11; | 361 | return -11; |
380 | 362 | ||
381 | MCI_CTYPE = (1<<0); /* Bus width = 4 */ | ||
382 | |||
383 | if(!send_cmd(SD_SELECT_CARD, card_info.rca, MCI_NO_RESP, NULL)) | 363 | if(!send_cmd(SD_SELECT_CARD, card_info.rca, MCI_NO_RESP, NULL)) |
384 | return -9; | 364 | return -9; |
385 | 365 | ||
@@ -555,21 +535,6 @@ static int sd_wait_for_state(unsigned int state) | |||
555 | 535 | ||
556 | static int sd_transfer_sectors(unsigned long start, int count, void* buf, bool write) | 536 | static int sd_transfer_sectors(unsigned long start, int count, void* buf, bool write) |
557 | { | 537 | { |
558 | #if 1 | ||
559 | /* This is debug code, not functional yet */ | ||
560 | line = 0; | ||
561 | lcd_clear_display(); | ||
562 | printf("Entering SD transfer"); | ||
563 | printf("THIS IS DEBUG CODE !"); | ||
564 | printf(""); | ||
565 | printf("All your controllers"); | ||
566 | printf("are belong to us."); | ||
567 | volatile int delay = 0x500000; | ||
568 | while(delay--) ; | ||
569 | line = 0; | ||
570 | lcd_clear_display(); | ||
571 | #endif /* debug warning */ | ||
572 | |||
573 | int ret = 0; | 538 | int ret = 0; |
574 | 539 | ||
575 | if((int)buf & 3) | 540 | if((int)buf & 3) |
@@ -616,8 +581,8 @@ static int sd_transfer_sectors(unsigned long start, int count, void* buf, bool w | |||
616 | 581 | ||
617 | do | 582 | do |
618 | { | 583 | { |
619 | MCI_BLKSIZ = 512; | 584 | MCI_BLKSIZ = SD_BLOCK_SIZE; |
620 | MCI_BYTCNT = count * 512; | 585 | MCI_BYTCNT = count * SD_BLOCK_SIZE; |
621 | 586 | ||
622 | MCI_CTRL |= (FIFO_RESET|DMA_RESET); | 587 | MCI_CTRL |= (FIFO_RESET|DMA_RESET); |
623 | while(MCI_CTRL & (FIFO_RESET|DMA_RESET)) | 588 | while(MCI_CTRL & (FIFO_RESET|DMA_RESET)) |
@@ -625,7 +590,7 @@ static int sd_transfer_sectors(unsigned long start, int count, void* buf, bool w | |||
625 | 590 | ||
626 | MCI_CTRL |= DMA_ENABLE; | 591 | MCI_CTRL |= DMA_ENABLE; |
627 | MCI_MASK = MCI_INT_CD|MCI_INT_DTO|MCI_INT_DCRC|MCI_INT_DRTO| \ | 592 | MCI_MASK = MCI_INT_CD|MCI_INT_DTO|MCI_INT_DCRC|MCI_INT_DRTO| \ |
628 | MCI_INT_HTO|MCI_INT_FRUN|MCI_INT_HLE|MCI_INT_SBE|MCI_INT_EBE; | 593 | MCI_INT_HTO|MCI_INT_FRUN|/*MCI_INT_HLE|*/MCI_INT_SBE|MCI_INT_EBE; |
629 | 594 | ||
630 | MCI_FIFOTH &= MCI_FIFOTH_MASK; | 595 | MCI_FIFOTH &= MCI_FIFOTH_MASK; |
631 | MCI_FIFOTH |= 0x503f0080; | 596 | MCI_FIFOTH |= 0x503f0080; |
@@ -647,15 +612,8 @@ static int sd_transfer_sectors(unsigned long start, int count, void* buf, bool w | |||
647 | dma_enable_channel(0, MCI_FIFO, buf, DMA_PERI_SD, | 612 | dma_enable_channel(0, MCI_FIFO, buf, DMA_PERI_SD, |
648 | DMAC_FLOWCTRL_PERI_PERI_TO_MEM, false, true, 0, DMA_S8, NULL); | 613 | DMAC_FLOWCTRL_PERI_PERI_TO_MEM, false, true, 0, DMA_S8, NULL); |
649 | 614 | ||
650 | line = 0; | ||
651 | lcd_clear_display(); | ||
652 | printf("dma ->"); | ||
653 | |||
654 | wakeup_wait(&transfer_completion_signal, TIMEOUT_BLOCK); | 615 | wakeup_wait(&transfer_completion_signal, TIMEOUT_BLOCK); |
655 | 616 | ||
656 | printf("dma <-"); | ||
657 | int delay = 0x1000000; while(delay--) ; | ||
658 | |||
659 | last_disk_activity = current_tick; | 617 | last_disk_activity = current_tick; |
660 | 618 | ||
661 | if(!send_cmd(SD_STOP_TRANSMISSION, 0, MCI_NO_RESP, NULL)) | 619 | if(!send_cmd(SD_STOP_TRANSMISSION, 0, MCI_NO_RESP, NULL)) |