summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiika Pekkarinen <miipekk@ihme.org>2006-11-29 12:17:26 +0000
committerMiika Pekkarinen <miipekk@ihme.org>2006-11-29 12:17:26 +0000
commit077ed4925ef6954eb7f4626e153f89dda5df0731 (patch)
tree7c3f3ee64055ace3ee1d3806a7f62be0f383e510
parent2b545c3104af6c1c8150d55831c8d9eea1478471 (diff)
downloadrockbox-077ed4925ef6954eb7f4626e153f89dda5df0731.tar.gz
rockbox-077ed4925ef6954eb7f4626e153f89dda5df0731.zip
Prevent the click of death when connecting an ipod to usb.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11622 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/drivers/ata.c10
-rw-r--r--firmware/export/ata.h1
-rw-r--r--firmware/target/arm/ipod/usb-ipod.c3
3 files changed, 13 insertions, 1 deletions
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c
index 0de2eb1804..d0cca2e148 100644
--- a/firmware/drivers/ata.c
+++ b/firmware/drivers/ata.c
@@ -1215,6 +1215,15 @@ void ata_sleep(void)
1215 queue_post(&ata_queue, Q_SLEEP, NULL); 1215 queue_post(&ata_queue, Q_SLEEP, NULL);
1216} 1216}
1217 1217
1218void ata_sleepnow(void)
1219{
1220 if (!spinup && !sleeping && !ata_mtx.locked)
1221 {
1222 call_ata_idle_notifys(false);
1223 ata_perform_sleep();
1224 }
1225}
1226
1218void ata_spin(void) 1227void ata_spin(void)
1219{ 1228{
1220 last_user_activity = current_tick; 1229 last_user_activity = current_tick;
@@ -1288,7 +1297,6 @@ static void ata_thread(void)
1288 call_ata_idle_notifys(false); 1297 call_ata_idle_notifys(false);
1289 last_disk_activity = current_tick - sleep_timeout + (HZ/2); 1298 last_disk_activity = current_tick - sleep_timeout + (HZ/2);
1290 break; 1299 break;
1291
1292 } 1300 }
1293 } 1301 }
1294} 1302}
diff --git a/firmware/export/ata.h b/firmware/export/ata.h
index c2ba974544..a2cb8ab975 100644
--- a/firmware/export/ata.h
+++ b/firmware/export/ata.h
@@ -40,6 +40,7 @@ extern void ata_enable(bool on);
40extern void ata_spindown(int seconds); 40extern void ata_spindown(int seconds);
41extern void ata_poweroff(bool enable); 41extern void ata_poweroff(bool enable);
42extern void ata_sleep(void); 42extern void ata_sleep(void);
43extern void ata_sleepnow(void);
43extern bool ata_disk_is_active(void); 44extern bool ata_disk_is_active(void);
44extern int ata_hard_reset(void); 45extern int ata_hard_reset(void);
45extern int ata_soft_reset(void); 46extern int ata_soft_reset(void);
diff --git a/firmware/target/arm/ipod/usb-ipod.c b/firmware/target/arm/ipod/usb-ipod.c
index c481355768..9298d65ff7 100644
--- a/firmware/target/arm/ipod/usb-ipod.c
+++ b/firmware/target/arm/ipod/usb-ipod.c
@@ -94,6 +94,9 @@ void usb_enable(bool on)
94#elif defined(IPOD_NANO) || defined(IPOD_VIDEO) || defined(IPOD_MINI2G) 94#elif defined(IPOD_NANO) || defined(IPOD_VIDEO) || defined(IPOD_MINI2G)
95 unsigned char* storage_ptr = (unsigned char *)0x4001FF00; 95 unsigned char* storage_ptr = (unsigned char *)0x4001FF00;
96#endif 96#endif
97
98 ata_sleepnow(); /* Immediately spindown the disk. */
99 sleep(HZ*2);
97 memcpy(storage_ptr, "diskmode\0\0hotstuff\0\0\1", 21); 100 memcpy(storage_ptr, "diskmode\0\0hotstuff\0\0\1", 21);
98 DEV_RS |= 4; /* Reboot */ 101 DEV_RS |= 4; /* Reboot */
99 } 102 }