summaryrefslogtreecommitdiff
path: root/firmware/target/arm/as3525/ata_sd_as3525.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/as3525/ata_sd_as3525.c')
-rw-r--r--firmware/target/arm/as3525/ata_sd_as3525.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/firmware/target/arm/as3525/ata_sd_as3525.c b/firmware/target/arm/as3525/ata_sd_as3525.c
index 25052de826..6722e8e94a 100644
--- a/firmware/target/arm/as3525/ata_sd_as3525.c
+++ b/firmware/target/arm/as3525/ata_sd_as3525.c
@@ -616,6 +616,7 @@ sd_read_error:
616 } 616 }
617} 617}
618 618
619#ifndef BOOTLOADER
619void sd_sleep(void) 620void sd_sleep(void)
620{ 621{
621} 622}
@@ -628,3 +629,62 @@ void sd_spindown(int seconds)
628{ 629{
629 (void)seconds; 630 (void)seconds;
630} 631}
632
633long sd_last_disk_activity(void)
634{
635 return last_disk_activity;
636}
637
638void sd_enable(bool on)
639{
640 if(on)
641 {
642 CGU_PERI |= CGU_NAF_CLOCK_ENABLE;
643#ifdef HAVE_MULTIVOLUME
644 CGU_PERI |= CGU_MCI_CLOCK_ENABLE;
645#endif
646 CGU_IDE |= (1<<7) /* AHB interface enable */ |
647 (1<<6) /* interface enable */;
648 }
649 else
650 {
651 CGU_PERI &= ~CGU_NAF_CLOCK_ENABLE;
652#ifdef HAVE_MULTIVOLUME
653 CGU_PERI &= ~CGU_MCI_CLOCK_ENABLE;
654#endif
655 CGU_IDE &= ~((1<<7)|(1<<6));
656 }
657}
658
659/* move the sd-card info to mmc struct */
660tCardInfo *card_get_info_target(int card_no)
661{
662 int i, temp;
663 static tCardInfo card;
664 static const char mantissa[] = { /* *10 */
665 0, 10, 12, 13, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 70, 80 };
666 static const int exponent[] = { /* use varies */
667 1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000 };
668
669 card.initialized = card_info[card_no].initialized;
670 card.ocr = card_info[card_no].ocr;
671 for(i=0; i<4; i++) card.csd[i] = card_info[card_no].csd[i];
672 for(i=0; i<4; i++) card.cid[i] = card_info[card_no].cid[i];
673 card.numblocks = card_info[card_no].numblocks;
674 card.blocksize = card_info[card_no].block_size;
675 temp = card_extract_bits(card.csd, 29, 3);
676 card.speed = mantissa[card_extract_bits(card.csd, 25, 4)]
677 * exponent[temp > 2 ? 7 : temp + 4];
678 card.nsac = 100 * card_extract_bits(card.csd, 16, 8);
679 temp = card_extract_bits(card.csd, 13, 3);
680 card.tsac = mantissa[card_extract_bits(card.csd, 9, 4)]
681 * exponent[temp] / 10;
682 card.cid[0] = htobe32(card.cid[0]); /* ascii chars here */
683 card.cid[1] = htobe32(card.cid[1]); /* ascii chars here */
684 temp = *((char*)card.cid+13); /* adjust year<=>month, 1997 <=> 2000 */
685 *((char*)card.cid+13) = (unsigned char)((temp >> 4) | (temp << 4)) + 3;
686
687 return &card;
688}
689
690#endif /* BOOTLOADER */