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
This commit is contained in:
Michael Giacomelli 2011-11-15 20:37:47 +00:00
parent 9e07ef2b0a
commit 3ba0e05ab5
3 changed files with 35 additions and 4 deletions

View file

@ -605,6 +605,7 @@ Michael Goerner
Richard Brittain Richard Brittain
Andrew Ryabinin Andrew Ryabinin
Maksim Postolati Maksim Postolati
Stanislav Chizhik
The libmad team The libmad team
The wavpack team The wavpack team

View file

@ -102,9 +102,9 @@ void pcf50635_init(void)
PCF5063X_REG_GPIO3CFG, 0x0, PCF5063X_REG_GPIO3CFG, 0x0,
/* IRQ masks (OF values in brackets) */ /* 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_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_INT4M, 0xff, /* (0xfd enable lowbat) */
PCF5063X_REG_INT5M, 0xff, /* (0xff all masked) */ PCF5063X_REG_INT5M, 0xff, /* (0xff all masked) */

View file

@ -51,6 +51,10 @@ void power_init(void)
pmu = PCF50635; pmu = PCF50635;
pcf50635_init(); 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 else
{ {
@ -64,11 +68,11 @@ void power_init(void)
/* Clear pending interrupts */ /* Clear pending interrupts */
unsigned char data[3]; /* 0 = INT1, 1 = INT2, 2 = INT3 */ unsigned char data[3]; /* 0 = INT1, 1 = INT2, 2 = INT3 */
pcf50606_read_multiple(0x02, data, 3); pcf50606_read_multiple(0x02, data, 3);
}
#ifndef BOOTLOADER #ifndef BOOTLOADER
IEN |= EXT3_IRQ_MASK; /* Unmask EXT3 */ IEN |= EXT3_IRQ_MASK; /* Unmask EXT3 */
#endif #endif
}
} }
void power_off(void) void power_off(void)
@ -85,6 +89,8 @@ void power_off(void)
#ifndef BOOTLOADER #ifndef BOOTLOADER
void EXT3(void) void EXT3(void)
{ {
if (get_pmu_type() == PCF50606)
{
unsigned char data[3]; /* 0 = INT1, 1 = INT2, 2 = INT3 */ unsigned char data[3]; /* 0 = INT1, 1 = INT2, 2 = INT3 */
/* Clear pending interrupts from pcf50606 */ /* Clear pending interrupts from pcf50606 */
@ -104,6 +110,21 @@ void EXT3(void)
/* Touchscreen event, do something about it */ /* Touchscreen event, do something about it */
touchscreen_handle_device_irq(); 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 #endif
@ -126,7 +147,16 @@ unsigned int power_input_status(void)
} }
else 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; return POWER_INPUT_NONE;