diff options
| author | Linux Build Service Account <lnxbuild@quicinc.com> | 2017-11-30 03:23:38 -0800 |
|---|---|---|
| committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2017-11-30 03:23:38 -0800 |
| commit | ddf3b70d707569c022cce3f3e2b3cfc17fa30fc8 (patch) | |
| tree | ab0c2c13384d0e5d10c5eaf9f9843c190ba14e1d | |
| parent | aa5d40233b168b5e52b0d322ffe4d7abf7aa14a1 (diff) | |
| parent | 1ecbc6d7ead288248e46defc5759e96ddf6d16ef (diff) | |
Merge "battery: fix ordering of ICL/FCC configuration"
| -rw-r--r-- | drivers/power/supply/qcom/battery.c | 114 |
1 files changed, 88 insertions, 26 deletions
diff --git a/drivers/power/supply/qcom/battery.c b/drivers/power/supply/qcom/battery.c index cb26658e564e..68640e349765 100644 --- a/drivers/power/supply/qcom/battery.c +++ b/drivers/power/supply/qcom/battery.c @@ -145,22 +145,52 @@ static void split_settled(struct pl_data *chip) total_current_ua = pval.intval; } - pval.intval = total_current_ua - slave_ua; - /* Set ICL on main charger */ - rc = power_supply_set_property(chip->main_psy, + /* + * If there is an increase in slave share + * (Also handles parallel enable case) + * Set Main ICL then slave ICL + * else + * (Also handles parallel disable case) + * Set slave ICL then main ICL. + */ + if (slave_ua > chip->pl_settled_ua) { + pval.intval = total_current_ua - slave_ua; + /* Set ICL on main charger */ + rc = power_supply_set_property(chip->main_psy, POWER_SUPPLY_PROP_CURRENT_MAX, &pval); - if (rc < 0) { - pr_err("Couldn't change slave suspend state rc=%d\n", rc); - return; - } + if (rc < 0) { + pr_err("Couldn't change slave suspend state rc=%d\n", + rc); + return; + } - /* set parallel's ICL could be 0mA when pl is disabled */ - pval.intval = slave_ua; - rc = power_supply_set_property(chip->pl_psy, - POWER_SUPPLY_PROP_CURRENT_MAX, &pval); - if (rc < 0) { - pr_err("Couldn't set parallel icl, rc=%d\n", rc); - return; + /* set parallel's ICL could be 0mA when pl is disabled */ + pval.intval = slave_ua; + rc = power_supply_set_property(chip->pl_psy, + POWER_SUPPLY_PROP_CURRENT_MAX, &pval); + if (rc < 0) { + pr_err("Couldn't set parallel icl, rc=%d\n", rc); + return; + } + } else { + /* set parallel's ICL could be 0mA when pl is disabled */ + pval.intval = slave_ua; + rc = power_supply_set_property(chip->pl_psy, + POWER_SUPPLY_PROP_CURRENT_MAX, &pval); + if (rc < 0) { + pr_err("Couldn't set parallel icl, rc=%d\n", rc); + return; + } + + pval.intval = total_current_ua - slave_ua; + /* Set ICL on main charger */ + rc = power_supply_set_property(chip->main_psy, + POWER_SUPPLY_PROP_CURRENT_MAX, &pval); + if (rc < 0) { + pr_err("Couldn't change slave suspend state rc=%d\n", + rc); + return; + } } chip->total_settled_ua = total_settled_ua; @@ -429,24 +459,56 @@ static int pl_fcc_vote_callback(struct votable *votable, void *data, get_fcc_split(chip, total_fcc_ua, &master_fcc_ua, &slave_fcc_ua); - pval.intval = slave_fcc_ua; - rc = power_supply_set_property(chip->pl_psy, + /* + * If there is an increase in slave share + * (Also handles parallel enable case) + * Set Main ICL then slave FCC + * else + * (Also handles parallel disable case) + * Set slave ICL then main FCC. + */ + if (slave_fcc_ua > chip->slave_fcc_ua) { + pval.intval = master_fcc_ua; + rc = power_supply_set_property(chip->main_psy, POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX, &pval); - if (rc < 0) { - pr_err("Couldn't set parallel fcc, rc=%d\n", rc); - return rc; - } + if (rc < 0) { + pr_err("Could not set main fcc, rc=%d\n", rc); + return rc; + } + + pval.intval = slave_fcc_ua; + rc = power_supply_set_property(chip->pl_psy, + POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX, + &pval); + if (rc < 0) { + pr_err("Couldn't set parallel fcc, rc=%d\n", + rc); + return rc; + } + + chip->slave_fcc_ua = slave_fcc_ua; + } else { + pval.intval = slave_fcc_ua; + rc = power_supply_set_property(chip->pl_psy, + POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX, + &pval); + if (rc < 0) { + pr_err("Couldn't set parallel fcc, rc=%d\n", + rc); + return rc; + } - chip->slave_fcc_ua = slave_fcc_ua; + chip->slave_fcc_ua = slave_fcc_ua; - pval.intval = master_fcc_ua; - rc = power_supply_set_property(chip->main_psy, + pval.intval = master_fcc_ua; + rc = power_supply_set_property(chip->main_psy, POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX, &pval); - if (rc < 0) { - pr_err("Could not set main fcc, rc=%d\n", rc); - return rc; + if (rc < 0) { + pr_err("Could not set main fcc, rc=%d\n", rc); + return rc; + } } } |
