summaryrefslogtreecommitdiff
path: root/firmware/target
diff options
context:
space:
mode:
authorRob Purchase <shotofadds@rockbox.org>2008-04-12 18:17:15 +0000
committerRob Purchase <shotofadds@rockbox.org>2008-04-12 18:17:15 +0000
commitb14c2de523e7ff03dac4cfc351df529114768a97 (patch)
tree5462b01a2893d1b98c11610a7e135abd1ed147a2 /firmware/target
parent660dbac5c92df2ee12ef20d8aba3686b037fbfb3 (diff)
D2: Charging detection, plus basic PCF50606 interrupt handler.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17088 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target')
-rw-r--r--firmware/target/arm/tcc780x/cowond2/power-cowond2.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/firmware/target/arm/tcc780x/cowond2/power-cowond2.c b/firmware/target/arm/tcc780x/cowond2/power-cowond2.c
index 92969de203..af5559dfb5 100644
--- a/firmware/target/arm/tcc780x/cowond2/power-cowond2.c
+++ b/firmware/target/arm/tcc780x/cowond2/power-cowond2.c
@@ -27,6 +27,11 @@
void power_init(void)
{
+ unsigned char data[3]; /* 0 = INT1, 1 = INT2, 2 = INT3 */
+
+ /* Clear pending interrupts from pcf50606 */
+ pcf50606_read_multiple(0x02, data, 3);
+
/* Set outputs as per OF - further investigation required. */
pcf50606_write(PCF5060X_DCDEC1, 0xe4);
pcf50606_write(PCF5060X_IOREGC, 0xf5);
@@ -36,6 +41,10 @@ void power_init(void)
pcf50606_write(PCF5060X_DCUDC1, 0xe7);
pcf50606_write(PCF5060X_LPREGC1, 0x0);
pcf50606_write(PCF5060X_LPREGC2, 0x2);
+
+#ifndef BOOTLOADER
+ IEN |= EXT3_IRQ_MASK; /* Unmask EXT3 */
+#endif
}
void ide_power_enable(bool on)
@@ -54,6 +63,37 @@ void power_off(void)
pcf50606_write(PCF5060X_OOCC1, GOSTDBY | CHGWAK | EXTONWAK);
}
+#ifndef BOOTLOADER
+void EXT3(void)
+{
+ unsigned char data[3]; /* 0 = INT1, 1 = INT2, 2 = INT3 */
+
+ /* Clear pending interrupts from pcf50606 */
+ int fiq_status = disable_fiq_save();
+ pcf50606_read_multiple(0x02, data, 3);
+
+ if (data[0] & 0x04)
+ {
+ /* ONKEY1S: reset timeout as we're using SW poweroff */
+ pcf50606_write(0x08, pcf50606_read(0x08) | 0x02); /* OOCC1: TOTRST=1 */
+ }
+
+ if (data[2] & 0x08)
+ {
+ /* TODO: Touchscreen pen down event, do something about it */
+ }
+
+ restore_fiq(fiq_status);
+}
+#endif
+
+#if CONFIG_CHARGING
+bool charger_inserted(void)
+{
+ return (GPIOC & (1<<26)) ? false:true;
+}
+#endif
+
#else /* SIMULATOR */
bool charger_inserted(void)