diff options
author | Graeme Gregory <gg@slimlogic.co.uk> | 2012-04-25 08:38:09 +0200 |
---|---|---|
committer | Ziyann <jaraidaniel@gmail.com> | 2014-10-01 13:00:26 +0200 |
commit | 3483b1d5e6144266eff0528a11497999e6be0db2 (patch) | |
tree | ea2d646d760ab95a06a0919c605bcf218e5e68f2 /drivers/power | |
parent | f27179388616995a9f7cb5cf05c5a590c27967fa (diff) | |
download | kernel_samsung_tuna-3483b1d5e6144266eff0528a11497999e6be0db2.zip kernel_samsung_tuna-3483b1d5e6144266eff0528a11497999e6be0db2.tar.gz kernel_samsung_tuna-3483b1d5e6144266eff0528a11497999e6be0db2.tar.bz2 |
twl6030_bci_battery alter the hw mode start logic
In Active state the omap does not update the CHRG_DET_N signal so to
change the current limits based on the information of USB stack in
HW mode the CINLIMIT register needs to be written. This does not
take the charger out of HW mode.
Because the new logic started to make start fuction messy I have split
into seperate hw/sw start functions.
Change-Id: I647d2934a9b8e39e0d00049444c79ca196e8820b
Signed-off-by: Graeme Gregory <gg@slimlogic.co.uk>
Diffstat (limited to 'drivers/power')
-rw-r--r-- | drivers/power/twl6030_bci_battery.c | 58 |
1 files changed, 42 insertions, 16 deletions
diff --git a/drivers/power/twl6030_bci_battery.c b/drivers/power/twl6030_bci_battery.c index 1ae3239..7d3c78e 100644 --- a/drivers/power/twl6030_bci_battery.c +++ b/drivers/power/twl6030_bci_battery.c @@ -645,26 +645,11 @@ err: pr_err("%s: Error access to TWL6030 (%d)\n", __func__, ret); } -static void twl6030_start_usb_charger(struct twl6030_bci_device_info *di) +static void twl6030_start_usb_charger_sw(struct twl6030_bci_device_info *di) { int ret; u8 reg = 0; - if (di->use_hw_charger) { - ret = twl_i2c_read_u8(TWL6030_MODULE_CHARGER, ®, - CHARGERUSB_CTRL1); - if (ret) - goto err; - - reg &= ~HZ_MODE; - ret = twl_i2c_write_u8(TWL6030_MODULE_CHARGER, reg, - CHARGERUSB_CTRL1); - if (ret) - goto err; - - return; - } - if (!is_battery_present(di)) { dev_dbg(di->dev, "BATTERY NOT DETECTED!\n"); return; @@ -712,6 +697,47 @@ err: pr_err("%s: Error access to TWL6030 (%d)\n", __func__, ret); } +static void twl6032_start_usb_charger_hw(struct twl6030_bci_device_info *di) +{ + int ret; + u8 reg = 0; + + ret = twl_i2c_read_u8(TWL6030_MODULE_CHARGER, ®, + CHARGERUSB_CTRL1); + if (ret) + goto err; + + if (di->charger_incurrentmA < 50) { + reg |= HZ_MODE; + di->charge_status = POWER_SUPPLY_STATUS_NOT_CHARGING; + } else { + reg &= ~HZ_MODE; + twl6030_config_cinlimit_reg(di, di->charger_incurrentmA); + } + + ret = twl_i2c_write_u8(TWL6030_MODULE_CHARGER, reg, + CHARGERUSB_CTRL1); + if (ret) + goto err; + + return; + +err: + pr_err("%s: Error access to TWL6030 (%d)\n", __func__, ret); + + return; +} + +static void twl6030_start_usb_charger(struct twl6030_bci_device_info *di) +{ + if (di->use_hw_charger) + twl6032_start_usb_charger_hw(di); + else + twl6030_start_usb_charger_sw(di); + + return; +} + static void twl6030_stop_ac_charger(struct twl6030_bci_device_info *di) { long int events; |