summaryrefslogtreecommitdiffstats
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
parent660dbac5c92df2ee12ef20d8aba3686b037fbfb3 (diff)
downloadrockbox-b14c2de523e7ff03dac4cfc351df529114768a97.tar.gz
rockbox-b14c2de523e7ff03dac4cfc351df529114768a97.tar.bz2
rockbox-b14c2de523e7ff03dac4cfc351df529114768a97.zip
D2: Charging detection, plus basic PCF50606 interrupt handler.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17088 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/export/config-cowond2.h5
-rw-r--r--firmware/export/tcc780x.h1
-rw-r--r--firmware/target/arm/tcc780x/cowond2/power-cowond2.c40
3 files changed, 45 insertions, 1 deletions
diff --git a/firmware/export/config-cowond2.h b/firmware/export/config-cowond2.h
index 3938bd0739..9380de57ef 100644
--- a/firmware/export/config-cowond2.h
+++ b/firmware/export/config-cowond2.h
@@ -99,12 +99,15 @@
#define CONFIG_I2C I2C_TCC780X
-#define BATTERY_CAPACITY_DEFAULT 1500 /* default battery capacity */
+#define BATTERY_CAPACITY_DEFAULT 1600 /* default battery capacity */
#define BATTERY_CAPACITY_MIN 1500 /* min. capacity selectable */
#define BATTERY_CAPACITY_MAX 3200 /* max. capacity selectable */
#define BATTERY_CAPACITY_INC 50 /* capacity increment */
#define BATTERY_TYPES_COUNT 1 /* only one type */
+/* Hardware controlled charging */
+#define CONFIG_CHARGING CHARGING_SIMPLE
+
#ifndef SIMULATOR
/* Define this if you have a TCC7801 */
diff --git a/firmware/export/tcc780x.h b/firmware/export/tcc780x.h
index f153d14bfe..cff0a2e576 100644
--- a/firmware/export/tcc780x.h
+++ b/firmware/export/tcc780x.h
@@ -120,6 +120,7 @@
#define IRQ_PRIORITY_TABLE ((volatile unsigned int *)0xF30010A0)
+#define EXT3_IRQ_MASK (1<<3)
#define TIMER0_IRQ_MASK (1<<6)
#define DAI_RX_IRQ_MASK (1<<14)
#define DAI_TX_IRQ_MASK (1<<15)
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)