Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4a22d02b authored by Shilpa Suresh's avatar Shilpa Suresh Committed by Gerrit - the friendly Code Review server
Browse files

power: qpnp-smbcharger: expose CHARGE_COUNTER/CYCLE_COUNT props



CHARGE_COUNTER and CYCLE_COUNT are required battery power supply
properties. Expose them via "battery" power_supply class.

Change-Id: Idf17f3dd5e0ce8634055de09071ba5b0d0b59611
Signed-off-by: default avatarShilpa Suresh <sbsure@codeaurora.org>
parent db6ef570
Loading
Loading
Loading
Loading
+31 −1
Original line number Diff line number Diff line
/* Copyright (c) 2014-2016, 2018 The Linux Foundation. All rights reserved.
/* Copyright (c) 2014-2016, 2018-2019, 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
@@ -1133,6 +1133,28 @@ static int get_prop_batt_voltage_max_design(struct smbchg_chip *chip)
	return uv;
}

static int get_prop_batt_charge_counter(struct smbchg_chip *chip)
{
	int bcc = 0, rc;

	rc = get_property_from_fg(chip,
				POWER_SUPPLY_PROP_CHARGE_COUNTER, &bcc);
	if (rc)
		pr_smb(PR_STATUS, "Couldn't get charge_counter rc = %d\n", rc);
	return bcc;
}

static int get_prop_batt_cycle_count(struct smbchg_chip *chip)
{
	int bcc = 0, rc;

	rc = get_property_from_fg(chip,
				POWER_SUPPLY_PROP_CYCLE_COUNT, &bcc);
	if (rc)
		pr_smb(PR_STATUS, "Couldn't get cycle_count rc = %d\n", rc);
	return bcc;
}

static int get_prop_batt_health(struct smbchg_chip *chip)
{
	if (chip->batt_hot)
@@ -5899,6 +5921,8 @@ static enum power_supply_property smbchg_battery_properties[] = {
	POWER_SUPPLY_PROP_RESTRICTED_CHARGING,
	POWER_SUPPLY_PROP_ALLOW_HVDCP3,
	POWER_SUPPLY_PROP_MAX_PULSE_ALLOWED,
	POWER_SUPPLY_PROP_CHARGE_COUNTER,
	POWER_SUPPLY_PROP_CYCLE_COUNT,
};

static int smbchg_battery_set_property(struct power_supply *psy,
@@ -6118,6 +6142,12 @@ static int smbchg_battery_get_property(struct power_supply *psy,
	case POWER_SUPPLY_PROP_MAX_PULSE_ALLOWED:
		val->intval = chip->max_pulse_allowed;
		break;
	case POWER_SUPPLY_PROP_CHARGE_COUNTER:
		val->intval = get_prop_batt_charge_counter(chip);
		break;
	case POWER_SUPPLY_PROP_CYCLE_COUNT:
		val->intval = get_prop_batt_cycle_count(chip);
		break;
	default:
		return -EINVAL;
	}