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.c52
1 files changed, 32 insertions, 20 deletions
diff --git a/firmware/drivers/ata_mmc.c b/firmware/drivers/ata_mmc.c
index 5afb6ca8a1..aa333dba32 100644
--- a/firmware/drivers/ata_mmc.c
+++ b/firmware/drivers/ata_mmc.c
@@ -94,6 +94,7 @@ static struct mutex mmc_mutex;
94static long mmc_stack[(DEFAULT_STACK_SIZE + 0x800)/sizeof(long)]; 94static long mmc_stack[(DEFAULT_STACK_SIZE + 0x800)/sizeof(long)];
95static const char mmc_thread_name[] = "mmc"; 95static const char mmc_thread_name[] = "mmc";
96static struct event_queue mmc_queue; 96static struct event_queue mmc_queue;
97static bool mmc_monitor_enabled = false;
97#endif 98#endif
98static bool initialized = false; 99static bool initialized = false;
99static bool new_mmc_circuit; 100static bool new_mmc_circuit;
@@ -1033,6 +1034,11 @@ static void mmc_thread(void)
1033 } 1034 }
1034 } 1035 }
1035} 1036}
1037
1038void mmc_enable_monitoring(bool on)
1039{
1040 mmc_monitor_enabled = on;
1041}
1036#endif /* #ifdef HAVE_HOTSWAP */ 1042#endif /* #ifdef HAVE_HOTSWAP */
1037 1043
1038bool mmc_detect(void) 1044bool mmc_detect(void)
@@ -1050,6 +1056,9 @@ bool mmc_usb_active(int delayticks)
1050static void mmc_tick(void) 1056static void mmc_tick(void)
1051{ 1057{
1052 bool current_status; 1058 bool current_status;
1059#ifndef HAVE_HOTSWAP
1060 const bool mmc_monitor_enabled = true;
1061#endif
1053 1062
1054 if (new_mmc_circuit) 1063 if (new_mmc_circuit)
1055 /* USB bridge activity is 0 on idle, ~527 on active */ 1064 /* USB bridge activity is 0 on idle, ~527 on active */
@@ -1061,29 +1070,32 @@ static void mmc_tick(void)
1061 last_usb_activity = current_tick; 1070 last_usb_activity = current_tick;
1062 usb_activity = current_status; 1071 usb_activity = current_status;
1063 1072
1064 current_status = mmc_detect(); 1073 if (mmc_monitor_enabled)
1065 /* Only report when the status has changed */
1066 if (current_status != last_mmc_status)
1067 {
1068 last_mmc_status = current_status;
1069 countdown = 30;
1070 }
1071 else
1072 { 1074 {
1073 /* Count down until it gets negative */ 1075 current_status = mmc_detect();
1074 if (countdown >= 0) 1076 /* Only report when the status has changed */
1075 countdown--; 1077 if (current_status != last_mmc_status)
1076
1077 if (countdown == 0)
1078 { 1078 {
1079 if (current_status) 1079 last_mmc_status = current_status;
1080 { 1080 countdown = 30;
1081 queue_broadcast(SYS_MMC_INSERTED, NULL); 1081 }
1082 } 1082 else
1083 else 1083 {
1084 /* Count down until it gets negative */
1085 if (countdown >= 0)
1086 countdown--;
1087
1088 if (countdown == 0)
1084 { 1089 {
1085 queue_broadcast(SYS_MMC_EXTRACTED, NULL); 1090 if (current_status)
1086 card_info[1].initialized = false; 1091 {
1092 queue_broadcast(SYS_MMC_INSERTED, NULL);
1093 }
1094 else
1095 {
1096 queue_broadcast(SYS_MMC_EXTRACTED, NULL);
1097 card_info[1].initialized = false;
1098 }
1087 } 1099 }
1088 } 1100 }
1089 } 1101 }