diff options
| author | Harry Yang <harryy@codeaurora.org> | 2017-02-09 17:45:12 -0800 |
|---|---|---|
| committer | Harry Yang <harryy@codeaurora.org> | 2017-02-10 16:36:50 -0800 |
| commit | 491c847cd23313c987cab1cdd70e6a7dabea5db7 (patch) | |
| tree | b6f546b99e05b6bc03937448768264df172bfa7c | |
| parent | 5e55ca1847b0d05b23b5c5462c0e61dc29f76058 (diff) | |
qpnp-smb2: expose forcing fcc/fv values via battery psy
CURRENT_QNOVO and VOLTAGE_QNOVO allow "forcing" fast charge
current and float voltage value, implemented around votable
such that one can have previlige in FCC and FV voting.
CRs-Fixed: 2004173
Change-Id: I2df30220aa89e15c4bace9980990f227218a5bdd
Signed-off-by: Harry Yang <harryy@codeaurora.org>
| -rw-r--r-- | drivers/power/supply/qcom/battery.c | 36 | ||||
| -rw-r--r-- | drivers/power/supply/qcom/qpnp-smb2.c | 14 | ||||
| -rw-r--r-- | drivers/power/supply/qcom/smb-lib.c | 2 | ||||
| -rw-r--r-- | drivers/power/supply/qcom/smb-lib.h | 4 |
4 files changed, 52 insertions, 4 deletions
diff --git a/drivers/power/supply/qcom/battery.c b/drivers/power/supply/qcom/battery.c index efa88c239379..6f083f1bbe80 100644 --- a/drivers/power/supply/qcom/battery.c +++ b/drivers/power/supply/qcom/battery.c @@ -298,6 +298,19 @@ static int pl_fcc_vote_callback(struct votable *votable, void *data, if (!chip->main_psy) return 0; + if (chip->batt_psy) { + rc = power_supply_get_property(chip->batt_psy, + POWER_SUPPLY_PROP_CURRENT_QNOVO, + &pval); + if (rc < 0) { + pr_err("Couldn't get qnovo fcc, rc=%d\n", rc); + return rc; + } + + if (pval.intval != -EINVAL) + total_fcc_ua = pval.intval; + } + if (chip->pl_mode == POWER_SUPPLY_PARALLEL_NONE || get_effective_result_locked(chip->pl_disable_votable)) { pval.intval = total_fcc_ua; @@ -343,6 +356,7 @@ static int pl_fv_vote_callback(struct votable *votable, void *data, struct pl_data *chip = data; union power_supply_propval pval = {0, }; int rc = 0; + int effective_fv_uv = fv_uv; if (fv_uv < 0) return 0; @@ -350,7 +364,21 @@ static int pl_fv_vote_callback(struct votable *votable, void *data, if (!chip->main_psy) return 0; - pval.intval = fv_uv; + if (chip->batt_psy) { + rc = power_supply_get_property(chip->batt_psy, + POWER_SUPPLY_PROP_VOLTAGE_QNOVO, + &pval); + if (rc < 0) { + pr_err("Couldn't get qnovo fv, rc=%d\n", rc); + return rc; + } + + if (pval.intval != -EINVAL) + effective_fv_uv = pval.intval; + } + + pval.intval = effective_fv_uv; + rc = power_supply_set_property(chip->main_psy, POWER_SUPPLY_PROP_VOLTAGE_MAX, &pval); if (rc < 0) { @@ -359,7 +387,7 @@ static int pl_fv_vote_callback(struct votable *votable, void *data, } if (chip->pl_mode != POWER_SUPPLY_PARALLEL_NONE) { - pval.intval = fv_uv + PARALLEL_FLOAT_VOLTAGE_DELTA_UV; + pval.intval += PARALLEL_FLOAT_VOLTAGE_DELTA_UV; rc = power_supply_set_property(chip->pl_psy, POWER_SUPPLY_PROP_VOLTAGE_MAX, &pval); if (rc < 0) { @@ -514,9 +542,9 @@ static bool is_parallel_available(struct pl_data *chip) return false; } /* - * Note that pl_mode only be udpated to anything other than a _NONE + * Note that pl_mode will be updated to anything other than a _NONE * only after pl_psy is found. IOW pl_mode != _NONE implies that - * pl_psy is present and valid + * pl_psy is present and valid. */ chip->pl_mode = pval.intval; vote(chip->pl_disable_votable, PARALLEL_PSY_VOTER, false, 0); diff --git a/drivers/power/supply/qcom/qpnp-smb2.c b/drivers/power/supply/qcom/qpnp-smb2.c index 2fd2619f890d..ced66122a156 100644 --- a/drivers/power/supply/qcom/qpnp-smb2.c +++ b/drivers/power/supply/qcom/qpnp-smb2.c @@ -894,9 +894,15 @@ static int smb2_batt_get_prop(struct power_supply *psy, case POWER_SUPPLY_PROP_VOLTAGE_MAX: val->intval = get_client_vote(chg->fv_votable, DEFAULT_VOTER); break; + case POWER_SUPPLY_PROP_VOLTAGE_QNOVO: + val->intval = chg->qnovo_fv_uv; + break; case POWER_SUPPLY_PROP_CURRENT_NOW: rc = smblib_get_prop_batt_current_now(chg, val); break; + case POWER_SUPPLY_PROP_CURRENT_QNOVO: + val->intval = chg->qnovo_fcc_ua; + break; case POWER_SUPPLY_PROP_TEMP: rc = smblib_get_prop_batt_temp(chg, val); break; @@ -953,6 +959,14 @@ static int smb2_batt_set_prop(struct power_supply *psy, case POWER_SUPPLY_PROP_VOLTAGE_MAX: vote(chg->fv_votable, DEFAULT_VOTER, true, val->intval); break; + case POWER_SUPPLY_PROP_VOLTAGE_QNOVO: + chg->qnovo_fv_uv = val->intval; + rc = rerun_election(chg->fv_votable); + break; + case POWER_SUPPLY_PROP_CURRENT_QNOVO: + chg->qnovo_fcc_ua = val->intval; + rc = rerun_election(chg->fcc_votable); + break; case POWER_SUPPLY_PROP_SET_SHIP_MODE: /* Not in ship mode as long as the device is active */ if (!val->intval) diff --git a/drivers/power/supply/qcom/smb-lib.c b/drivers/power/supply/qcom/smb-lib.c index f523333390bc..64c5f3e99bb1 100644 --- a/drivers/power/supply/qcom/smb-lib.c +++ b/drivers/power/supply/qcom/smb-lib.c @@ -3891,6 +3891,8 @@ int smblib_init(struct smb_charger *chg) switch (chg->mode) { case PARALLEL_MASTER: + chg->qnovo_fcc_ua = -EINVAL; + chg->qnovo_fv_uv = -EINVAL; rc = smblib_create_votables(chg); if (rc < 0) { smblib_err(chg, "Couldn't create votables rc=%d\n", diff --git a/drivers/power/supply/qcom/smb-lib.h b/drivers/power/supply/qcom/smb-lib.h index c8e32789cde1..a220ad4d214b 100644 --- a/drivers/power/supply/qcom/smb-lib.h +++ b/drivers/power/supply/qcom/smb-lib.h @@ -257,6 +257,10 @@ struct smb_charger { bool usb_ever_removed; int icl_reduction_ua; + + /* qnovo */ + int qnovo_fcc_ua; + int qnovo_fv_uv; }; int smblib_read(struct smb_charger *chg, u16 addr, u8 *val); |
