diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/drivers/ata_mmc.c | 52 | ||||
-rw-r--r-- | firmware/export/ata_mmc.h | 3 | ||||
-rw-r--r-- | firmware/usb.c | 6 |
3 files changed, 41 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; | |||
94 | static long mmc_stack[(DEFAULT_STACK_SIZE + 0x800)/sizeof(long)]; | 94 | static long mmc_stack[(DEFAULT_STACK_SIZE + 0x800)/sizeof(long)]; |
95 | static const char mmc_thread_name[] = "mmc"; | 95 | static const char mmc_thread_name[] = "mmc"; |
96 | static struct event_queue mmc_queue; | 96 | static struct event_queue mmc_queue; |
97 | static bool mmc_monitor_enabled = false; | ||
97 | #endif | 98 | #endif |
98 | static bool initialized = false; | 99 | static bool initialized = false; |
99 | static bool new_mmc_circuit; | 100 | static bool new_mmc_circuit; |
@@ -1033,6 +1034,11 @@ static void mmc_thread(void) | |||
1033 | } | 1034 | } |
1034 | } | 1035 | } |
1035 | } | 1036 | } |
1037 | |||
1038 | void mmc_enable_monitoring(bool on) | ||
1039 | { | ||
1040 | mmc_monitor_enabled = on; | ||
1041 | } | ||
1036 | #endif /* #ifdef HAVE_HOTSWAP */ | 1042 | #endif /* #ifdef HAVE_HOTSWAP */ |
1037 | 1043 | ||
1038 | bool mmc_detect(void) | 1044 | bool mmc_detect(void) |
@@ -1050,6 +1056,9 @@ bool mmc_usb_active(int delayticks) | |||
1050 | static void mmc_tick(void) | 1056 | static 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 | } |
diff --git a/firmware/export/ata_mmc.h b/firmware/export/ata_mmc.h index 8b5056bbd8..6f7fb2bdb5 100644 --- a/firmware/export/ata_mmc.h +++ b/firmware/export/ata_mmc.h | |||
@@ -45,5 +45,8 @@ unsigned long mmc_extract_bits(const unsigned long *p, unsigned int start, | |||
45 | unsigned int size); | 45 | unsigned int size); |
46 | tCardInfo *mmc_card_info(int card_no); | 46 | tCardInfo *mmc_card_info(int card_no); |
47 | bool mmc_usb_active(int delayticks); | 47 | bool mmc_usb_active(int delayticks); |
48 | #ifdef HAVE_HOTSWAP | ||
49 | void mmc_enable_monitoring(bool on); | ||
50 | #endif | ||
48 | 51 | ||
49 | #endif | 52 | #endif |
diff --git a/firmware/usb.c b/firmware/usb.c index 6095bcd65e..4b76fe60be 100644 --- a/firmware/usb.c +++ b/firmware/usb.c | |||
@@ -194,7 +194,13 @@ static void usb_slave_mode(bool on) | |||
194 | panicf("ata: %d",rc); | 194 | panicf("ata: %d",rc); |
195 | } | 195 | } |
196 | 196 | ||
197 | #if defined(HAVE_MMC) && defined(HAVE_HOTSWAP) | ||
198 | mmc_enable_monitoring(false); | ||
197 | rc = disk_mount_all(); | 199 | rc = disk_mount_all(); |
200 | mmc_enable_monitoring(true); | ||
201 | #else | ||
202 | rc = disk_mount_all(); | ||
203 | #endif | ||
198 | if (rc <= 0) /* no partition */ | 204 | if (rc <= 0) /* no partition */ |
199 | panicf("mount: %d",rc); | 205 | panicf("mount: %d",rc); |
200 | 206 | ||