summaryrefslogtreecommitdiff
path: root/firmware/drivers/ata_mmc.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/ata_mmc.c')
-rw-r--r--firmware/drivers/ata_mmc.c80
1 files changed, 52 insertions, 28 deletions
diff --git a/firmware/drivers/ata_mmc.c b/firmware/drivers/ata_mmc.c
index 1040ab067f..953bb90bbc 100644
--- a/firmware/drivers/ata_mmc.c
+++ b/firmware/drivers/ata_mmc.c
@@ -19,7 +19,7 @@
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21#include <stdbool.h> 21#include <stdbool.h>
22#include "ata.h" 22#include "mmc.h"
23#include "ata_mmc.h" 23#include "ata_mmc.h"
24#include "ata_idle_notify.h" 24#include "ata_idle_notify.h"
25#include "kernel.h" 25#include "kernel.h"
@@ -36,6 +36,7 @@
36#include "adc.h" 36#include "adc.h"
37#include "bitswap.h" 37#include "bitswap.h"
38#include "disk.h" /* for mount/unmount */ 38#include "disk.h" /* for mount/unmount */
39#include "storage.h"
39 40
40#define BLOCK_SIZE 512 /* fixed */ 41#define BLOCK_SIZE 512 /* fixed */
41 42
@@ -84,8 +85,7 @@
84#define DT_STOP_TRAN 0xfd 85#define DT_STOP_TRAN 0xfd
85 86
86/* for compatibility */ 87/* for compatibility */
87int ata_spinup_time = 0; 88static long last_disk_activity = -1;
88long last_disk_activity = -1;
89 89
90/* private variables */ 90/* private variables */
91 91
@@ -601,7 +601,7 @@ static int send_block_send(unsigned char start_token, long timeout,
601 return rc; 601 return rc;
602} 602}
603 603
604int ata_read_sectors(IF_MV2(int drive,) 604int mmc_read_sectors(IF_MV2(int drive,)
605 unsigned long start, 605 unsigned long start,
606 int incount, 606 int incount,
607 void* inbuf) 607 void* inbuf)
@@ -687,7 +687,7 @@ int ata_read_sectors(IF_MV2(int drive,)
687 return rc; 687 return rc;
688} 688}
689 689
690int ata_write_sectors(IF_MV2(int drive,) 690int mmc_write_sectors(IF_MV2(int drive,)
691 unsigned long start, 691 unsigned long start,
692 int count, 692 int count,
693 const void* buf) 693 const void* buf)
@@ -755,25 +755,12 @@ int ata_write_sectors(IF_MV2(int drive,)
755 return rc; 755 return rc;
756} 756}
757 757
758void ata_spindown(int seconds) 758bool mmc_disk_is_active(void)
759{
760 (void)seconds;
761}
762
763bool ata_disk_is_active(void)
764{ 759{
765 /* this is correct unless early return from write gets implemented */ 760 /* this is correct unless early return from write gets implemented */
766 return mmc_mutex.locked; 761 return mmc_mutex.locked;
767} 762}
768 763
769void ata_sleep(void)
770{
771}
772
773void ata_spin(void)
774{
775}
776
777static void mmc_thread(void) 764static void mmc_thread(void)
778{ 765{
779 struct queue_event ev; 766 struct queue_event ev;
@@ -810,7 +797,7 @@ static void mmc_thread(void)
810 { 797 {
811 if (!idle_notified) 798 if (!idle_notified)
812 { 799 {
813 call_ata_idle_notifys(false); 800 call_storage_idle_notifys(false);
814 idle_notified = true; 801 idle_notified = true;
815 } 802 }
816 } 803 }
@@ -904,12 +891,7 @@ static void mmc_tick(void)
904 } 891 }
905} 892}
906 893
907int ata_soft_reset(void) 894void mmc_enable(bool on)
908{
909 return 0;
910}
911
912void ata_enable(bool on)
913{ 895{
914 PBCR1 &= ~0x0CF0; /* PB13, PB11 and PB10 become GPIO, 896 PBCR1 &= ~0x0CF0; /* PB13, PB11 and PB10 become GPIO,
915 * if not modified below */ 897 * if not modified below */
@@ -924,7 +906,7 @@ void ata_enable(bool on)
924 card_info[1].initialized = false; 906 card_info[1].initialized = false;
925} 907}
926 908
927int ata_init(void) 909int mmc_init(void)
928{ 910{
929 int rc = 0; 911 int rc = 0;
930 912
@@ -970,9 +952,51 @@ int ata_init(void)
970 tick_add_task(mmc_tick); 952 tick_add_task(mmc_tick);
971 initialized = true; 953 initialized = true;
972 } 954 }
973 ata_enable(true); 955 mmc_enable(true);
974 956
975 mutex_unlock(&mmc_mutex); 957 mutex_unlock(&mmc_mutex);
976 return rc; 958 return rc;
977} 959}
978 960
961long mmc_last_disk_activity(void)
962{
963 return last_disk_activity;
964}
965
966void mmc_get_info(IF_MV2(int drive,) struct storage_info *info)
967{
968#ifndef HAVE_MULTIVOLUME
969 const int drive=0;
970#endif
971 info->sector_size=card_info[drive].blocksize;
972 info->num_sectors=card_info[drive].numblocks;
973 info->vendor="Rockbox";
974 if(drive==0)
975 {
976 info->product="Internal Storage";
977 }
978 else
979 {
980 info->product="MMC Card Slot";
981 }
982 info->revision="0.00";
983}
984
985#ifdef HAVE_HOTSWAP
986bool mmc_removable(IF_MV_NONVOID(int drive))
987{
988#ifndef HAVE_MULTIVOLUME
989 const int drive=0;
990#endif
991 return (drive==1);
992}
993
994bool mmc_present(IF_MV_NONVOID(int drive))
995{
996#ifndef HAVE_MULTIVOLUME
997 const int drive=0;
998#endif
999 return (card_info[drive].initialized && card_info[drive].numblocks > 0);
1000}
1001#endif
1002