Loading drivers/power/qpnp-linear-charger.c +22 −1 Original line number Diff line number Diff line /* Copyright (c) 2013-2015, 2017, The Linux Foundation. All rights reserved. /* Copyright (c) 2013-2015, 2017-2018, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -206,6 +206,7 @@ static enum power_supply_property msm_batt_power_props[] = { POWER_SUPPLY_PROP_VOLTAGE_NOW, POWER_SUPPLY_PROP_CAPACITY, POWER_SUPPLY_PROP_CURRENT_NOW, POWER_SUPPLY_PROP_CHARGE_COUNTER, POWER_SUPPLY_PROP_TEMP, POWER_SUPPLY_PROP_COOL_TEMP, POWER_SUPPLY_PROP_WARM_TEMP, Loading Loading @@ -1348,6 +1349,23 @@ static int get_prop_capacity(struct qpnp_lbc_chip *chip) return DEFAULT_CAPACITY; } static int get_prop_charge_count(struct qpnp_lbc_chip *chip) { union power_supply_propval ret = {0,}; if (!chip->bms_psy) chip->bms_psy = power_supply_get_by_name("bms"); if (chip->bms_psy) { chip->bms_psy->get_property(chip->bms_psy, POWER_SUPPLY_PROP_CHARGE_COUNTER, &ret); } else { pr_debug("No BMS supply registered return 0\n"); } return ret.intval; } #define DEFAULT_TEMP 250 static int get_prop_batt_temp(struct qpnp_lbc_chip *chip) { Loading Loading @@ -1719,6 +1737,9 @@ static int qpnp_batt_power_get_property(struct power_supply *psy, case POWER_SUPPLY_PROP_CURRENT_NOW: val->intval = get_prop_current_now(chip); break; case POWER_SUPPLY_PROP_CHARGE_COUNTER: val->intval = get_prop_charge_count(chip); break; case POWER_SUPPLY_PROP_CHARGING_ENABLED: val->intval = !(chip->cfg_charging_disabled); break; Loading drivers/power/qpnp-vm-bms.c +29 −1 Original line number Diff line number Diff line /* Copyright (c) 2014-2016, The Linux Foundation. All rights reserved. /* Copyright (c) 2014-2016, 2018, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -2203,6 +2203,30 @@ static int get_prop_bms_current_now(struct qpnp_bms_chip *chip) return chip->current_now; } static int get_current_cc(struct qpnp_bms_chip *chip) { int soc, cc_full; int64_t current_charge; if (chip->batt_data == NULL) return -EINVAL; cc_full = chip->batt_data->fcc; if (chip->dt.cfg_use_voltage_soc) soc = chip->prev_voltage_based_soc; else soc = chip->last_soc; /* * Full charge capacity is in mAh and soc is in % * current_charge capacity is defined in uAh * Hence conversion ((mAh * pct * 1000) / 100) => (mAh * pct * 10) */ current_charge = cc_full * soc * 10; return current_charge; } static enum power_supply_property bms_power_props[] = { POWER_SUPPLY_PROP_CAPACITY, POWER_SUPPLY_PROP_STATUS, Loading @@ -2216,6 +2240,7 @@ static enum power_supply_property bms_power_props[] = { POWER_SUPPLY_PROP_BATTERY_TYPE, POWER_SUPPLY_PROP_TEMP, POWER_SUPPLY_PROP_CYCLE_COUNT, POWER_SUPPLY_PROP_CHARGE_COUNTER, }; static int Loading Loading @@ -2294,6 +2319,9 @@ static int qpnp_vm_bms_power_get_property(struct power_supply *psy, else val->intval = -EINVAL; break; case POWER_SUPPLY_PROP_CHARGE_COUNTER: val->intval = get_current_cc(chip); break; default: return -EINVAL; } Loading Loading
drivers/power/qpnp-linear-charger.c +22 −1 Original line number Diff line number Diff line /* Copyright (c) 2013-2015, 2017, The Linux Foundation. All rights reserved. /* Copyright (c) 2013-2015, 2017-2018, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -206,6 +206,7 @@ static enum power_supply_property msm_batt_power_props[] = { POWER_SUPPLY_PROP_VOLTAGE_NOW, POWER_SUPPLY_PROP_CAPACITY, POWER_SUPPLY_PROP_CURRENT_NOW, POWER_SUPPLY_PROP_CHARGE_COUNTER, POWER_SUPPLY_PROP_TEMP, POWER_SUPPLY_PROP_COOL_TEMP, POWER_SUPPLY_PROP_WARM_TEMP, Loading Loading @@ -1348,6 +1349,23 @@ static int get_prop_capacity(struct qpnp_lbc_chip *chip) return DEFAULT_CAPACITY; } static int get_prop_charge_count(struct qpnp_lbc_chip *chip) { union power_supply_propval ret = {0,}; if (!chip->bms_psy) chip->bms_psy = power_supply_get_by_name("bms"); if (chip->bms_psy) { chip->bms_psy->get_property(chip->bms_psy, POWER_SUPPLY_PROP_CHARGE_COUNTER, &ret); } else { pr_debug("No BMS supply registered return 0\n"); } return ret.intval; } #define DEFAULT_TEMP 250 static int get_prop_batt_temp(struct qpnp_lbc_chip *chip) { Loading Loading @@ -1719,6 +1737,9 @@ static int qpnp_batt_power_get_property(struct power_supply *psy, case POWER_SUPPLY_PROP_CURRENT_NOW: val->intval = get_prop_current_now(chip); break; case POWER_SUPPLY_PROP_CHARGE_COUNTER: val->intval = get_prop_charge_count(chip); break; case POWER_SUPPLY_PROP_CHARGING_ENABLED: val->intval = !(chip->cfg_charging_disabled); break; Loading
drivers/power/qpnp-vm-bms.c +29 −1 Original line number Diff line number Diff line /* Copyright (c) 2014-2016, The Linux Foundation. All rights reserved. /* Copyright (c) 2014-2016, 2018, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -2203,6 +2203,30 @@ static int get_prop_bms_current_now(struct qpnp_bms_chip *chip) return chip->current_now; } static int get_current_cc(struct qpnp_bms_chip *chip) { int soc, cc_full; int64_t current_charge; if (chip->batt_data == NULL) return -EINVAL; cc_full = chip->batt_data->fcc; if (chip->dt.cfg_use_voltage_soc) soc = chip->prev_voltage_based_soc; else soc = chip->last_soc; /* * Full charge capacity is in mAh and soc is in % * current_charge capacity is defined in uAh * Hence conversion ((mAh * pct * 1000) / 100) => (mAh * pct * 10) */ current_charge = cc_full * soc * 10; return current_charge; } static enum power_supply_property bms_power_props[] = { POWER_SUPPLY_PROP_CAPACITY, POWER_SUPPLY_PROP_STATUS, Loading @@ -2216,6 +2240,7 @@ static enum power_supply_property bms_power_props[] = { POWER_SUPPLY_PROP_BATTERY_TYPE, POWER_SUPPLY_PROP_TEMP, POWER_SUPPLY_PROP_CYCLE_COUNT, POWER_SUPPLY_PROP_CHARGE_COUNTER, }; static int Loading Loading @@ -2294,6 +2319,9 @@ static int qpnp_vm_bms_power_get_property(struct power_supply *psy, else val->intval = -EINVAL; break; case POWER_SUPPLY_PROP_CHARGE_COUNTER: val->intval = get_current_cc(chip); break; default: return -EINVAL; } Loading