diff options
author | Subbaraman Narayanamurthy <subbaram@codeaurora.org> | 2017-08-11 18:27:08 -0700 |
---|---|---|
committer | Subbaraman Narayanamurthy <subbaram@codeaurora.org> | 2017-08-31 19:25:31 -0700 |
commit | 90d88df47e7009b8cf074aaae763900bbb9606b3 (patch) | |
tree | 96204eba830334514fb1039a2dc9b4bebf6f034c | |
parent | 887e3c20973a6850b81ca14daeca0dba0fbd4a2b (diff) |
power: qpnp-fg-gen3: make CHARGE_FULL property writable by user
CHARGE_FULL property indicates the learnt capacity of the battery
from the last capacity learning cycle. However, in some rare
cases, if the learnt capacity is having an unexpected value, it
requires a reset to a good value which is not possible for an
user who cannot reinsert a battery or do an explicit write to FG
SRAM. Allowing CHARGE_FULL to be writable helps this.
Change-Id: I05aa8392f103685f8fc1ba5a3780122150be0ee6
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
-rw-r--r-- | drivers/power/supply/qcom/qpnp-fg-gen3.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/power/supply/qcom/qpnp-fg-gen3.c b/drivers/power/supply/qcom/qpnp-fg-gen3.c index 361efd4fbbbd..ab6c9b9d925f 100644 --- a/drivers/power/supply/qcom/qpnp-fg-gen3.c +++ b/drivers/power/supply/qcom/qpnp-fg-gen3.c @@ -3500,6 +3500,20 @@ static int fg_psy_set_property(struct power_supply *psy, return -EINVAL; } break; + case POWER_SUPPLY_PROP_CHARGE_FULL: + if (chip->cl.active) { + pr_warn("Capacity learning active!\n"); + return 0; + } + if (pval->intval <= 0 || pval->intval > chip->cl.nom_cap_uah) { + pr_err("charge_full is out of bounds\n"); + return -EINVAL; + } + chip->cl.learned_cc_uah = pval->intval; + rc = fg_save_learned_cap_to_sram(chip); + if (rc < 0) + pr_err("Error in saving learned_cc_uah, rc=%d\n", rc); + break; default: break; } @@ -3515,6 +3529,7 @@ static int fg_property_is_writeable(struct power_supply *psy, case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE: case POWER_SUPPLY_PROP_CC_STEP: case POWER_SUPPLY_PROP_CC_STEP_SEL: + case POWER_SUPPLY_PROP_CHARGE_FULL: return 1; default: break; |