summaryrefslogtreecommitdiff
path: root/firmware/powermgmt.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/powermgmt.c')
-rw-r--r--firmware/powermgmt.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c
index 519785f9c6..fdc77f680b 100644
--- a/firmware/powermgmt.c
+++ b/firmware/powermgmt.c
@@ -44,6 +44,7 @@
44#ifdef HAVE_UDA1380 44#ifdef HAVE_UDA1380
45#include "uda1380.h" 45#include "uda1380.h"
46#endif 46#endif
47#include "logf.h"
47 48
48/* 49/*
49 * Define DEBUG_FILE to create a csv (spreadsheet) with battery information 50 * Define DEBUG_FILE to create a csv (spreadsheet) with battery information
@@ -389,7 +390,7 @@ static void handle_auto_poweroff(void)
389 if(TIME_AFTER(current_tick, last_event_tick + timeout) && 390 if(TIME_AFTER(current_tick, last_event_tick + timeout) &&
390 TIME_AFTER(current_tick, last_disk_activity + timeout)) 391 TIME_AFTER(current_tick, last_disk_activity + timeout))
391 { 392 {
392 shutdown_hw(); 393 sys_poweroff(true);
393 } 394 }
394 } 395 }
395 else 396 else
@@ -412,11 +413,7 @@ static void handle_auto_poweroff(void)
412#endif 413#endif
413 { 414 {
414 DEBUGF("Sleep timer timeout. Shutting off...\n"); 415 DEBUGF("Sleep timer timeout. Shutting off...\n");
415 /* Make sure that the disk isn't spinning when 416 sys_poweroff(true);
416 we cut the power */
417 while(ata_disk_is_active())
418 sleep(HZ);
419 shutdown_hw();
420 } 417 }
421 } 418 }
422 } 419 }
@@ -877,6 +874,14 @@ void powermgmt_init(void)
877 874
878#endif /* SIMULATOR */ 875#endif /* SIMULATOR */
879 876
877void sys_poweroff(bool halt)
878{
879 logf("sys_poweroff(%d)", halt);
880 queue_post(&button_queue, SYS_POWEROFF, NULL);
881 while(halt)
882 yield();
883}
884
880/* Various hardware housekeeping tasks relating to shutting down the jukebox */ 885/* Various hardware housekeeping tasks relating to shutting down the jukebox */
881void shutdown_hw(void) 886void shutdown_hw(void)
882{ 887{