From 90d88df47e7009b8cf074aaae763900bbb9606b3 Mon Sep 17 00:00:00 2001 From: Subbaraman Narayanamurthy Date: Fri, 11 Aug 2017 18:27:08 -0700 Subject: [PATCH 1/2] 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 --- drivers/power/supply/qcom/qpnp-fg-gen3.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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; From 063d7870ec696d4e07bddd68566e5ca02c35821f Mon Sep 17 00:00:00 2001 From: Subbaraman Narayanamurthy Date: Fri, 11 Aug 2017 18:37:26 -0700 Subject: [PATCH 2/2] power_supply: add POWER_SUPPLY_PROP_{COLD,HOT}_TEMP properties Add POWER_SUPPLY_PROP_COLD_TEMP and POWER_SUPPLY_PROP_HOT_TEMP properties to represent Cold and Hot JEITA thresholds of the battery. Change-Id: Id5e16a4f7b20bb05d997277d20db05fc08db9f33 Signed-off-by: Subbaraman Narayanamurthy --- drivers/power/power_supply_sysfs.c | 2 ++ include/linux/power_supply.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c index a45a51490817..2e9ff2afcba2 100644 --- a/drivers/power/power_supply_sysfs.c +++ b/drivers/power/power_supply_sysfs.c @@ -247,6 +247,8 @@ static struct device_attribute power_supply_attrs[] = { POWER_SUPPLY_ATTR(low_power), POWER_SUPPLY_ATTR(temp_cool), POWER_SUPPLY_ATTR(temp_warm), + POWER_SUPPLY_ATTR(temp_cold), + POWER_SUPPLY_ATTR(temp_hot), POWER_SUPPLY_ATTR(system_temp_level), POWER_SUPPLY_ATTR(resistance), POWER_SUPPLY_ATTR(resistance_capacitive), diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index 982b93ccfbe4..8b8a46ce32d0 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -199,6 +199,8 @@ enum power_supply_property { POWER_SUPPLY_PROP_LOW_POWER, POWER_SUPPLY_PROP_COOL_TEMP, POWER_SUPPLY_PROP_WARM_TEMP, + POWER_SUPPLY_PROP_COLD_TEMP, + POWER_SUPPLY_PROP_HOT_TEMP, POWER_SUPPLY_PROP_SYSTEM_TEMP_LEVEL, POWER_SUPPLY_PROP_RESISTANCE, POWER_SUPPLY_PROP_RESISTANCE_CAPACITIVE,