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:
parent
9e07ef2b0a
commit
3ba0e05ab5
3 changed files with 35 additions and 4 deletions
|
@ -605,6 +605,7 @@ Michael Goerner
|
|||
Richard Brittain
|
||||
Andrew Ryabinin
|
||||
Maksim Postolati
|
||||
Stanislav Chizhik
|
||||
|
||||
The libmad team
|
||||
The wavpack team
|
||||
|
|
|
@ -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) */
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue