summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/drivers/ata.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c
index 4dd858bca9..b80f615eb3 100644
--- a/firmware/drivers/ata.c
+++ b/firmware/drivers/ata.c
@@ -141,6 +141,10 @@ static void ata_lock_unlock(struct ata_lock *l)
141#define mutex_unlock ata_lock_unlock 141#define mutex_unlock ata_lock_unlock
142#endif /* MAX_PHYS_SECTOR_SIZE */ 142#endif /* MAX_PHYS_SECTOR_SIZE */
143 143
144#if defined(HAVE_USBSTACK) && defined(USE_ROCKBOX_USB) && !defined(BOOTLOADER)
145#define ALLOW_USB_SPINDOWN
146#endif
147
144static struct mutex ata_mtx SHAREDBSS_ATTR; 148static struct mutex ata_mtx SHAREDBSS_ATTR;
145static int ata_device; /* device 0 (master) or 1 (slave) */ 149static int ata_device; /* device 0 (master) or 1 (slave) */
146 150
@@ -884,7 +888,7 @@ static void ata_thread(void)
884 static long last_sleep = 0; 888 static long last_sleep = 0;
885 struct queue_event ev; 889 struct queue_event ev;
886 static long last_seen_mtx_unlock = 0; 890 static long last_seen_mtx_unlock = 0;
887#if defined(HAVE_USBSTACK) && defined(USE_ROCKBOX_USB) && !defined(BOOTLOADER) 891#ifdef ALLOW_USB_SPINDOWN
888 static bool usb_mode = false; 892 static bool usb_mode = false;
889#endif 893#endif
890 894
@@ -901,7 +905,7 @@ static void ata_thread(void)
901 last_seen_mtx_unlock = current_tick; 905 last_seen_mtx_unlock = current_tick;
902 if (TIME_AFTER(current_tick, last_seen_mtx_unlock+(HZ*2))) 906 if (TIME_AFTER(current_tick, last_seen_mtx_unlock+(HZ*2)))
903 { 907 {
904#if defined(HAVE_USBSTACK) && defined(USE_ROCKBOX_USB) && !defined(BOOTLOADER) 908#ifdef ALLOW_USB_SPINDOWN
905 if(!usb_mode) 909 if(!usb_mode)
906#endif 910#endif
907 call_ata_idle_notifys(false); 911 call_ata_idle_notifys(false);
@@ -914,7 +918,7 @@ static void ata_thread(void)
914 TIME_AFTER( current_tick, 918 TIME_AFTER( current_tick,
915 last_disk_activity + sleep_timeout ) ) 919 last_disk_activity + sleep_timeout ) )
916 { 920 {
917#if defined(HAVE_USBSTACK) && defined(USE_ROCKBOX_USB) && !defined(BOOTLOADER) 921#ifdef ALLOW_USB_SPINDOWN
918 if(!usb_mode) 922 if(!usb_mode)
919#endif 923#endif
920 call_ata_idle_notifys(true); 924 call_ata_idle_notifys(true);
@@ -949,7 +953,7 @@ static void ata_thread(void)
949 DEBUGF("ata_thread got SYS_USB_CONNECTED\n"); 953 DEBUGF("ata_thread got SYS_USB_CONNECTED\n");
950 usb_acknowledge(SYS_USB_CONNECTED_ACK); 954 usb_acknowledge(SYS_USB_CONNECTED_ACK);
951 955
952#if defined(HAVE_USBSTACK) && defined(USE_ROCKBOX_USB) && !defined(BOOTLOADER) 956#ifdef ALLOW_USB_SPINDOWN
953 usb_mode = true; 957 usb_mode = true;
954#else 958#else
955 /* Wait until the USB cable is extracted again */ 959 /* Wait until the USB cable is extracted again */
@@ -957,7 +961,7 @@ static void ata_thread(void)
957#endif 961#endif
958 break; 962 break;
959 963
960#if defined(HAVE_USBSTACK) && defined(USE_ROCKBOX_USB) && !defined(BOOTLOADER) 964#ifdef ALLOW_USB_SPINDOWN
961 case SYS_USB_DISCONNECTED: 965 case SYS_USB_DISCONNECTED:
962 /* Tell the USB thread that we are ready again */ 966 /* Tell the USB thread that we are ready again */
963 DEBUGF("ata_thread got SYS_USB_DISCONNECTED\n"); 967 DEBUGF("ata_thread got SYS_USB_DISCONNECTED\n");
@@ -967,7 +971,7 @@ static void ata_thread(void)
967#endif 971#endif
968#endif 972#endif
969 case Q_SLEEP: 973 case Q_SLEEP:
970#if defined(HAVE_USBSTACK) && defined(USE_ROCKBOX_USB) && !defined(BOOTLOADER) 974#ifdef ALLOW_USB_SPINDOWN
971 if(!usb_mode) 975 if(!usb_mode)
972#endif 976#endif
973 call_ata_idle_notifys(false); 977 call_ata_idle_notifys(false);