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

Commit 5b048614 authored by Anirudh Ghayal's avatar Anirudh Ghayal Committed by Subbaraman Narayanamurthy
Browse files

power: qpnp-qg/fg-gen4: Report the REAL_CAPACITY



REAL_CAPACITY reports the unscaled battery capacity.

Change-Id: I7a016cdf89904f4d5ecbfd9b9afbd05fbfe62442
Signed-off-by: default avatarAnirudh Ghayal <aghayal@codeaurora.org>
parent f2977772
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -959,6 +959,11 @@ static int fg_gen4_get_prop_capacity(struct fg_dev *fg, int *val)
	return 0;
}

static int fg_gen4_get_prop_real_capacity(struct fg_dev *fg, int *val)
{
	return fg_get_msoc(fg, val);
}

static int fg_gen4_get_prop_capacity_raw(struct fg_gen4_chip *chip, int *val)
{
	struct fg_dev *fg = &chip->fg;
@@ -4196,6 +4201,9 @@ static int fg_psy_get_property(struct power_supply *psy,
	case POWER_SUPPLY_PROP_CAPACITY:
		rc = fg_gen4_get_prop_capacity(fg, &pval->intval);
		break;
	case POWER_SUPPLY_PROP_REAL_CAPACITY:
		rc = fg_gen4_get_prop_real_capacity(fg, &pval->intval);
		break;
	case POWER_SUPPLY_PROP_CAPACITY_RAW:
		rc = fg_gen4_get_prop_capacity_raw(chip, &pval->intval);
		break;
@@ -4439,6 +4447,7 @@ static int fg_property_is_writeable(struct power_supply *psy,

static enum power_supply_property fg_psy_props[] = {
	POWER_SUPPLY_PROP_CAPACITY,
	POWER_SUPPLY_PROP_REAL_CAPACITY,
	POWER_SUPPLY_PROP_CAPACITY_RAW,
	POWER_SUPPLY_PROP_CC_SOC,
	POWER_SUPPLY_PROP_TEMP,
+13 −0
Original line number Diff line number Diff line
@@ -1580,6 +1580,15 @@ static int qg_get_battery_capacity(struct qpnp_qg *chip, int *soc)
	return 0;
}

static int qg_get_battery_capacity_real(struct qpnp_qg *chip, int *soc)
{
	mutex_lock(&chip->soc_lock);
	*soc = chip->msoc;
	mutex_unlock(&chip->soc_lock);

	return 0;
}

static int qg_get_charge_counter(struct qpnp_qg *chip, int *charge_counter)
{
	int rc, cc_soc = 0;
@@ -1833,6 +1842,9 @@ static int qg_psy_get_property(struct power_supply *psy,
	case POWER_SUPPLY_PROP_CAPACITY:
		rc = qg_get_battery_capacity(chip, &pval->intval);
		break;
	case POWER_SUPPLY_PROP_REAL_CAPACITY:
		rc = qg_get_battery_capacity_real(chip, &pval->intval);
		break;
	case POWER_SUPPLY_PROP_VOLTAGE_NOW:
		rc = qg_get_battery_voltage(chip, &pval->intval);
		break;
@@ -1953,6 +1965,7 @@ static int qg_property_is_writeable(struct power_supply *psy,

static enum power_supply_property qg_psy_props[] = {
	POWER_SUPPLY_PROP_CAPACITY,
	POWER_SUPPLY_PROP_REAL_CAPACITY,
	POWER_SUPPLY_PROP_TEMP,
	POWER_SUPPLY_PROP_VOLTAGE_NOW,
	POWER_SUPPLY_PROP_VOLTAGE_OCV,