summaryrefslogtreecommitdiff
path: root/drivers/power/twl4030.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/power/twl4030.c')
-rw-r--r--drivers/power/twl4030.c42
1 files changed, 41 insertions, 1 deletions
diff --git a/drivers/power/twl4030.c b/drivers/power/twl4030.c
index cf79161aaf3..b62ed176d25 100644
--- a/drivers/power/twl4030.c
+++ b/drivers/power/twl4030.c
@@ -86,7 +86,7 @@ void twl4030_power_init(void)
twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VPLL2_DEDICATED,
TWL4030_PM_RECEIVER_VPLL2_VSEL_18,
TWL4030_PM_RECEIVER_VPLL2_DEV_GRP,
- TWL4030_PM_RECEIVER_DEV_GRP_ALL);
+ TWL4030_PM_RECEIVER_DEV_GRP_P1);
/* set VDAC to 1.8V */
twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VDAC_DEDICATED,
@@ -133,6 +133,46 @@ U_BOOT_CMD(poweroff, 1, 1, do_poweroff,
);
#ifdef CONFIG_TWL4030_CHARGING
+/* Enable the battery backup charger */
+int twl4030_enable_bb_charging(unsigned int millivolts, unsigned int microamps)
+{
+ u8 val;
+
+ if (millivolts >= 3200)
+ val = 0x0c;
+ else if (millivolts >= 3100)
+ val = 0x08;
+ else if (millivolts >= 3000)
+ val = 0x04;
+ else if (millivolts < 2500) {
+ val = 0;
+ goto write_it;
+ }
+ if (microamps >= 1000)
+ val |= 0x03;
+ else if (microamps >= 500)
+ val |= 0x02;
+ else if (microamps >= 150)
+ val |= 0x01;
+ else if (microamps < 25) {
+ val = 0;
+ goto write_it;
+ }
+
+ val |= 0x10; /* set BBCHEN */
+
+ printf("Enable battery backup charger (BB_CFG = 0x%02x)\n", val);
+write_it:
+ if (twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER, val,
+ TWL4030_PM_RECEIVER_BB_CFG)) {
+ printf("Error:TWL4030: failed to write BB_CFG\n");
+ return 1;
+ }
+ return 0;
+}
+
+
+/* Enable AC charging */
int twl4030_enable_charging(void)
{
u8 val = 0;