summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorMichael Giacomelli <giac2000@hotmail.com>2011-11-15 20:37:47 +0000
committerMichael Giacomelli <giac2000@hotmail.com>2011-11-15 20:37:47 +0000
commit3ba0e05ab5b731e09478ed089ff954ad3580be63 (patch)
tree53a6de6fc66e031060ae4a75479c20e8840b37cf /firmware
parent9e07ef2b0adb8fca7e5a9e516397e533653f8836 (diff)
Commit FS#12352 by Stanislav Chizhik. Add support for the PCF50635. Enables detection of USB power sources.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30992 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/drivers/pcf50635.c4
-rw-r--r--firmware/target/arm/tcc780x/cowond2/power-cowond2.c34
2 files changed, 34 insertions, 4 deletions
diff --git a/firmware/drivers/pcf50635.c b/firmware/drivers/pcf50635.c
index 9ccf5e29e2..38104b8d04 100644
--- a/firmware/drivers/pcf50635.c
+++ b/firmware/drivers/pcf50635.c
@@ -102,9 +102,9 @@ void pcf50635_init(void)
PCF5063X_REG_GPIO3CFG, 0x0,
/* IRQ masks (OF values in brackets) */
- PCF5063X_REG_INT1M, 0xff, /* (0x8a enable alarm, usbins, adpins) */
+ PCF5063X_REG_INT1M, 0xfa, /* (0x8a enable alarm, usbins, adpins) */
PCF5063X_REG_INT2M, 0xff, /* (0xff all masked) */
- PCF5063X_REG_INT3M, 0xff, /* (0x7f enable onkey1s) */
+ PCF5063X_REG_INT3M, 0x7f, /* (0x7f enable onkey1s) */
PCF5063X_REG_INT4M, 0xff, /* (0xfd enable lowbat) */
PCF5063X_REG_INT5M, 0xff, /* (0xff all masked) */
diff --git a/firmware/target/arm/tcc780x/cowond2/power-cowond2.c b/firmware/target/arm/tcc780x/cowond2/power-cowond2.c
index 7e8f066c58..02e0282ead 100644
--- a/firmware/target/arm/tcc780x/cowond2/power-cowond2.c
+++ b/firmware/target/arm/tcc780x/cowond2/power-cowond2.c
@@ -51,6 +51,10 @@ void power_init(void)
pmu = PCF50635;
pcf50635_init();
+
+ /* Clear pending interrupts from pcf50635 */
+ unsigned char data[5]; /* 0 = INT1, 1 = INT2, 2 = INT3, ... 4 = INT5 */
+ pcf50635_read_multiple(PCF5063X_REG_INT1, data, 5);
}
else
{
@@ -64,11 +68,11 @@ void power_init(void)
/* Clear pending interrupts */
unsigned char data[3]; /* 0 = INT1, 1 = INT2, 2 = INT3 */
pcf50606_read_multiple(0x02, data, 3);
+ }
#ifndef BOOTLOADER
IEN |= EXT3_IRQ_MASK; /* Unmask EXT3 */
#endif
- }
}
void power_off(void)
@@ -85,6 +89,8 @@ void power_off(void)
#ifndef BOOTLOADER
void EXT3(void)
{
+ if (get_pmu_type() == PCF50606)
+ {
unsigned char data[3]; /* 0 = INT1, 1 = INT2, 2 = INT3 */
/* Clear pending interrupts from pcf50606 */
@@ -104,6 +110,21 @@ void EXT3(void)
/* Touchscreen event, do something about it */
touchscreen_handle_device_irq();
}
+ }
+ else
+ {
+ unsigned char data[5]; /* 0 = INT1, 1 = INT2, 2 = INT3, ... 4 = INT5 */
+
+ /* Clear pending interrupts from pcf50635 */
+ pcf50635_read_multiple(PCF5063X_REG_INT1, data, 5);
+
+ if (data[2] & PCF5063X_INT3_ONKEY1S)
+ {
+
+ if (!charger_inserted())
+ sys_poweroff();
+ }
+ }
}
#endif
@@ -126,7 +147,16 @@ unsigned int power_input_status(void)
}
else
{
- /* TODO: use adapter/usb connection state from PCF50635 driver */
+ /* pcf50635 power input status can be obtained from MBCS1 register */
+
+ int mbcs1 = pcf50635_read(PCF5063X_REG_MBCS1);
+ /* Check AC adapter presence*/
+ if (mbcs1 & PCF5063X_MBCS1_ADAPTPRES)
+ return POWER_INPUT_MAIN_CHARGER;
+
+ /* Check USB presence */
+ if (mbcs1 & PCF5063X_MBCS1_USBPRES)
+ return POWER_INPUT_USB_CHARGER;
}
return POWER_INPUT_NONE;