diff options
author | Graeme Gregory <gg@slimlogic.co.uk> | 2012-03-26 12:01:32 +0100 |
---|---|---|
committer | Ziyann <jaraidaniel@gmail.com> | 2014-10-01 13:00:19 +0200 |
commit | 095dec1eeca2fe0b6099399966bc8dceefde0bf8 (patch) | |
tree | 1a949fe16726e7bba7306e6c069e28475b3ec5cd | |
parent | 53d15f4a4bc6590de09989dd8ca4d05fca3892cd (diff) | |
download | kernel_samsung_tuna-095dec1eeca2fe0b6099399966bc8dceefde0bf8.zip kernel_samsung_tuna-095dec1eeca2fe0b6099399966bc8dceefde0bf8.tar.gz kernel_samsung_tuna-095dec1eeca2fe0b6099399966bc8dceefde0bf8.tar.bz2 |
POWER: twl6030_bci_battery fix boot charge state in hw mode
Change the method to detect the charging state on boot. The
_STS bits used previously did not contain the complete charging
state so in some situations state was incorrectly indicated.
Change-Id: I6e276765d36f41df263ef5588aef4c792c8cbb7e
Signed-off-by: Graeme Gregory <gg@slimlogic.co.uk>
-rw-r--r-- | drivers/power/twl6030_bci_battery.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/drivers/power/twl6030_bci_battery.c b/drivers/power/twl6030_bci_battery.c index 61fa316..04da390 100644 --- a/drivers/power/twl6030_bci_battery.c +++ b/drivers/power/twl6030_bci_battery.c @@ -2407,12 +2407,25 @@ static int __devinit twl6030_bci_battery_probe(struct platform_device *pdev) } } } else { - twl_i2c_read_u8(TWL6032_MODULE_CHARGER, ®, LINEAR_CHRG_STS); + int fault, charge_usb, charge_ac; - if (reg & (LINEAR_CHRG_STS_CC_STS | LINEAR_CHRG_STS_CV_STS)) + twl_i2c_read_u8(TWL6032_MODULE_CHARGER, ®, + CHARGERUSB_INT_STATUS); + + fault = !(di->stat1 & CONTROLLER_STAT1_LINCH_GATED) && + !(di->stat1 & CONTROLLER_STAT1_FAULT_WDG); + charge_usb = (di->stat1 & VBUS_DET) && + !(reg & CHARGERUSB_FAULT); + charge_ac = (di->stat1 & VAC_DET) && + !(di->stat1 & CONTROLLER_STAT1_EXTCHRG_STATZ); + + dev_dbg(di->dev, "boot charge state fault %d, usb %d, ac %d\n", + fault, charge_usb, charge_ac); + + if (fault && (charge_usb || charge_ac)) di->charge_status = POWER_SUPPLY_STATUS_CHARGING; else { - if (controller_stat & (VBUS_DET | VAC_DET)) + if (di->stat1 & (VBUS_DET | VAC_DET)) di->charge_status = POWER_SUPPLY_STATUS_NOT_CHARGING; else |