diff options
-rw-r--r-- | firmware/drivers/pcf50606.c | 7 | ||||
-rw-r--r-- | firmware/export/pcf50606.h | 2 | ||||
-rw-r--r-- | firmware/powermgmt.c | 9 | ||||
-rw-r--r-- | firmware/target/arm/tcc780x/cowond2/power-cowond2.c | 22 |
4 files changed, 28 insertions, 12 deletions
diff --git a/firmware/drivers/pcf50606.c b/firmware/drivers/pcf50606.c index 6fb2840bca..6a98b0d021 100644 --- a/firmware/drivers/pcf50606.c +++ b/firmware/drivers/pcf50606.c | |||
@@ -55,3 +55,10 @@ void pcf50606_init(void) | |||
55 | { | 55 | { |
56 | // TODO | 56 | // TODO |
57 | } | 57 | } |
58 | |||
59 | void pcf50606_reset_timeout(void) | ||
60 | { | ||
61 | int level = disable_irq_save(); | ||
62 | pcf50606_write(PCF5060X_OOCC1, pcf50606_read(PCF5060X_OOCC1) | TOTRST); | ||
63 | restore_irq(level); | ||
64 | } | ||
diff --git a/firmware/export/pcf50606.h b/firmware/export/pcf50606.h index 88b7d67a13..8e01346028 100644 --- a/firmware/export/pcf50606.h +++ b/firmware/export/pcf50606.h | |||
@@ -48,7 +48,7 @@ void pcf50606_i2c_outb(unsigned char byte); | |||
48 | unsigned char pcf50606_i2c_inb(bool ack); | 48 | unsigned char pcf50606_i2c_inb(bool ack); |
49 | #endif | 49 | #endif |
50 | 50 | ||
51 | #if (defined(IAUDIO_X5) || defined(IAUDIO_M5)) && !defined (SIMULATOR) | 51 | #if (defined(IAUDIO_X5) || defined(IAUDIO_M5) || defined(COWON_D2)) && !defined (SIMULATOR) |
52 | void pcf50606_reset_timeout(void); | 52 | void pcf50606_reset_timeout(void); |
53 | #endif | 53 | #endif |
54 | 54 | ||
diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c index 64aa5c0637..6ec0307ae5 100644 --- a/firmware/powermgmt.c +++ b/firmware/powermgmt.c | |||
@@ -49,9 +49,12 @@ | |||
49 | #endif | 49 | #endif |
50 | 50 | ||
51 | #if (defined(IAUDIO_X5) || defined(IAUDIO_M5)) && !defined (SIMULATOR) | 51 | #if (defined(IAUDIO_X5) || defined(IAUDIO_M5)) && !defined (SIMULATOR) |
52 | #include "pcf50606.h" | ||
53 | #include "lcd-remote-target.h" | 52 | #include "lcd-remote-target.h" |
54 | #endif | 53 | #endif |
54 | #if (defined(IAUDIO_X5) || defined(IAUDIO_M5) || defined(COWON_D2)) \ | ||
55 | && !defined (SIMULATOR) | ||
56 | #include "pcf50606.h" | ||
57 | #endif | ||
55 | 58 | ||
56 | /** Shared by sim **/ | 59 | /** Shared by sim **/ |
57 | int last_sent_battery_level = 100; | 60 | int last_sent_battery_level = 100; |
@@ -788,7 +791,7 @@ void sys_poweroff(void) | |||
788 | /* If the main thread fails to shut down the system, we will force a | 791 | /* If the main thread fails to shut down the system, we will force a |
789 | power off after an 20 second timeout - 28 seconds if recording */ | 792 | power off after an 20 second timeout - 28 seconds if recording */ |
790 | if (shutdown_timeout == 0) { | 793 | if (shutdown_timeout == 0) { |
791 | #if defined(IAUDIO_X5) || defined(IAUDIO_M5) | 794 | #if defined(IAUDIO_X5) || defined(IAUDIO_M5) || defined(COWON_D2) |
792 | pcf50606_reset_timeout(); /* Reset timer on first attempt only */ | 795 | pcf50606_reset_timeout(); /* Reset timer on first attempt only */ |
793 | #endif | 796 | #endif |
794 | #ifdef HAVE_RECORDING | 797 | #ifdef HAVE_RECORDING |
@@ -806,7 +809,7 @@ void cancel_shutdown(void) | |||
806 | { | 809 | { |
807 | logf("cancel_shutdown()"); | 810 | logf("cancel_shutdown()"); |
808 | 811 | ||
809 | #if defined(IAUDIO_X5) || defined(IAUDIO_M5) | 812 | #if defined(IAUDIO_X5) || defined(IAUDIO_M5) || defined(COWON_D2) |
810 | /* TODO: Move some things to target/ tree */ | 813 | /* TODO: Move some things to target/ tree */ |
811 | if (shutdown_timeout) | 814 | if (shutdown_timeout) |
812 | pcf50606_reset_timeout(); | 815 | pcf50606_reset_timeout(); |
diff --git a/firmware/target/arm/tcc780x/cowond2/power-cowond2.c b/firmware/target/arm/tcc780x/cowond2/power-cowond2.c index aed6a1911b..5897370735 100644 --- a/firmware/target/arm/tcc780x/cowond2/power-cowond2.c +++ b/firmware/target/arm/tcc780x/cowond2/power-cowond2.c | |||
@@ -25,6 +25,8 @@ | |||
25 | #include "pcf50606.h" | 25 | #include "pcf50606.h" |
26 | #include "button-target.h" | 26 | #include "button-target.h" |
27 | #include "tuner.h" | 27 | #include "tuner.h" |
28 | #include "backlight-target.h" | ||
29 | #include "powermgmt.h" | ||
28 | 30 | ||
29 | void power_init(void) | 31 | void power_init(void) |
30 | { | 32 | { |
@@ -50,8 +52,13 @@ void power_init(void) | |||
50 | 52 | ||
51 | void power_off(void) | 53 | void power_off(void) |
52 | { | 54 | { |
53 | /* Forcibly cut power to SoC & peripherals by putting the PCF to sleep */ | 55 | /* Turn the backlight off first to avoid a bright stripe on power-off */ |
54 | pcf50606_write(PCF5060X_OOCC1, GOSTDBY | CHGWAK | EXTONWAK); | 56 | _backlight_off(); |
57 | sleep(HZ/10); | ||
58 | |||
59 | /* Power off the player using the same mechanism as the OF */ | ||
60 | GPIOA_CLEAR = (1<<7); | ||
61 | while(true); | ||
55 | } | 62 | } |
56 | 63 | ||
57 | #ifndef BOOTLOADER | 64 | #ifndef BOOTLOADER |
@@ -64,12 +71,11 @@ void EXT3(void) | |||
64 | 71 | ||
65 | if (data[0] & 0x04) | 72 | if (data[0] & 0x04) |
66 | { | 73 | { |
67 | /* ONKEY1S: don't reset the timeout, because we want a way to power off | 74 | /* ONKEY1S */ |
68 | the player in the event of a crashed plugin or UIE/panic, etc. */ | 75 | if (!charger_inserted()) |
69 | #if 0 | 76 | sys_poweroff(); |
70 | /* ONKEY1S: reset timeout as we're using SW poweroff */ | 77 | else |
71 | pcf50606_write(0x08, pcf50606_read(0x08) | 0x02); /* OOCC1: TOTRST=1 */ | 78 | pcf50606_reset_timeout(); |
72 | #endif | ||
73 | } | 79 | } |
74 | 80 | ||
75 | if (data[2] & 0x08) | 81 | if (data[2] & 0x08) |