summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2006-09-12 14:20:29 +0000
committerMichael Sevakis <jethead71@rockbox.org>2006-09-12 14:20:29 +0000
commit3bee89ed44680c0abeffe4f1c6e69f9928b00e89 (patch)
treefc2760e29bc595a0a00f03174909adcde6bf4350 /firmware
parentbc0943e922fde5c13ba4e01b9e372db6ee598765 (diff)
Improved handling of the ONKEY1S interrupt. Off for the remote must be explicitly mapped now.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10932 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/powermgmt.c11
-rw-r--r--firmware/target/coldfire/iaudio/x5/pcf50606-x5.c40
2 files changed, 36 insertions, 15 deletions
diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c
index 44e43f0ea5..6a52beb272 100644
--- a/firmware/powermgmt.c
+++ b/firmware/powermgmt.c
@@ -59,6 +59,10 @@
#include <time.h>
#endif
+#ifdef IAUDIO_X5
+extern void pcf50606_reset_timeout(void);
+#endif
+
/*
* Define DEBUG_FILE to create a csv (spreadsheet) with battery information
* in it (one sample per minute). This is only for very low level debug.
@@ -1010,6 +1014,13 @@ void sys_poweroff(void)
void cancel_shutdown(void)
{
logf("sys_cancel_shutdown()");
+
+#ifdef IAUDIO_X5
+ /* TODO: Move some things to target/ tree */
+ if (shutdown_timeout)
+ pcf50606_reset_timeout();
+#endif
+
shutdown_timeout = 0;
}
diff --git a/firmware/target/coldfire/iaudio/x5/pcf50606-x5.c b/firmware/target/coldfire/iaudio/x5/pcf50606-x5.c
index f0e11f088d..eaecc5bef6 100644
--- a/firmware/target/coldfire/iaudio/x5/pcf50606-x5.c
+++ b/firmware/target/coldfire/iaudio/x5/pcf50606-x5.c
@@ -26,6 +26,7 @@
#include "debug.h"
#include "string.h"
#include "generic_i2c.h"
+#include "powermgmt.h"
void pcf50606_sda_output(void)
{
@@ -154,7 +155,13 @@ static void set_voltages(void)
void pcf50606_init(void)
{
- unsigned char read[3];
+ /* inital data is interrupt masks */
+ unsigned char data[3] =
+ {
+ ~0x04, /* unmask ONKEY1S */
+ ~0x00,
+ ~0x00
+ };
/* Bit banged I2C */
or_l(0x00001000, &GPIO1_OUT);
@@ -169,10 +176,10 @@ void pcf50606_init(void)
/* make sure GPI0 interrupt is off before unmasking anything */
and_l(~0xF, &INTPRI5); /* INT32 - Priority 0 (Off) */
- /* unmask ONKEY1S - ONKEY held low for 1 second */
- pcf50606_write(0x05, ~0x04);
+ /* unmask the PMU interrupts we want to service */
+ pcf50606_write_multiple(0x05, data, 3);
/* clear INT1-3 as these are left set after standby */
- pcf50606_read_multiple(0x02, read, 3);
+ pcf50606_read_multiple(0x02, data, 3);
/* Set to read pcf50606 INT but keep GPI0 off until init completes */
and_l(~0x00000001, &GPIO_ENABLE);
@@ -184,11 +191,6 @@ void pcf50606_init(void)
pcf50606_write(0x39, 0x00); /* GPOOD0 = green led OFF */
pcf50606_write(0x3a, 0x00); /* GPOOD1 = red led OFF */
- /* D305A datasheet says PWM clock frequency should be 400Hz - 2000Hz so
- * I changed it from 7kHz to 512Hz. The lower frequency looks the same.
- * GPO1 is also inverted so that display brightness increases with PWM
- * cycle.
- */
pcf50606_write(0x35, 0x11); /* Backlight PWM = 512Hz, 8/16, Active */
#ifdef BOOTLOADER
/* Backlight starts OFF in bootloader */
@@ -199,7 +201,14 @@ void pcf50606_init(void)
#endif
/* allow GPI0 interrupts from PMU now */
- or_l(0x6, &INTPRI5); /* INT32 - Priority 6 */
+ or_l(0x3, &INTPRI5); /* INT32 - Priority 3 */
+}
+
+void pcf50606_reset_timeout(void)
+{
+ int level = set_irq_level(HIGHEST_IRQ_LEVEL);
+ pcf50606_write(0x08, pcf50606_read(0x08) | 0x02); /* OOCC1 - TOTRST=1 */
+ set_irq_level(level);
}
/* Handles interrupts generated by the pcf50606 */
@@ -208,15 +217,16 @@ void GPI0(void)
{
char read[3]; /* 0 = INT1, 1 = INT2, 2 = INT3 */
- /* Clear pending interrupts from pcf50606 - reading all INT* registers
- resets the INT pin to high */
+ /* clear pending interrupts from pcf50606 */
pcf50606_read_multiple(0x02, read, 3);
if (read[0] & 0x04)
{
- /** ONKEY1S **/
- /* reset timeout or else pcf50606 will go into standby in 8s */
- pcf50606_write(0x08, pcf50606_read(0x08) | 0x02); /* OOCC1 - TOTRST=1 */
+ /* ONKEY1S */
+ if (GPIO_READ & 0x02000000)
+ sys_poweroff(); /* main ONKEY */
+ else
+ pcf50606_reset_timeout(); /* remote ONKEY */
}
/* Clear pending GPI0 interrupts */