1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
diff --git a/firmware/target/arm/as3525/sd-as3525.c b/firmware/target/arm/as3525/sd-as3525.c
index 19914ab..ff604d9 100644
--- a/firmware/target/arm/as3525/sd-as3525.c
+++ b/firmware/target/arm/as3525/sd-as3525.c
@@ -866,6 +866,27 @@ long sd_last_disk_activity(void)

 void sd_enable(bool on)
 {
+    if(on == sd_enabled)
+        return;
+
+    if(on)
+    {
+        MCI_CLOCK(INTERNAL_AS3525) &= ~MCI_CLOCK_POWERSAVE;
+#ifdef HAVE_MULTIDRIVE
+        MCI_CLOCK(SD_SLOT_AS3525) &= ~MCI_CLOCK_POWERSAVE;
+#endif
+    }
+    else
+    {
+        MCI_CLOCK(INTERNAL_AS3525) |= MCI_CLOCK_POWERSAVE;
+#ifdef HAVE_MULTIDRIVE
+        MCI_CLOCK(SD_SLOT_AS3525) |= MCI_CLOCK_POWERSAVE;
+#endif
+    }
+
+    sd_enabled = on;
+    return;
+
 #if defined(HAVE_BUTTON_LIGHT) && defined(HAVE_MULTIDRIVE)
     extern int buttonlight_is_on;
 #endif