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

Commit 916bfbf6 authored by Anirudh Ghayal's avatar Anirudh Ghayal Committed by Gerrit - the friendly Code Review server
Browse files

power: qpnp-qg: Report averaged VBAT



Report the last FIFO's VBAT for usecases which
need an averaged VBAT instead of instantaneous.

Change-Id: Idf4ca48a06c012ed52ea06b187ee12ab8cfe12d3
Signed-off-by: default avatarAnirudh Ghayal <aghayal@codeaurora.org>
parent 6a56d6a5
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -96,6 +96,8 @@
#define QG_POST_ESR_V_DATA0_REG			0x7C
#define QG_POST_ESR_I_DATA0_REG			0x7E

#define QG_S2_NORMAL_AVG_V_DATA0_REG		0x80

#define QG_V_ACCUM_DATA0_RT_REG			0x88
#define QG_I_ACCUM_DATA0_RT_REG			0x8B
#define QG_ACCUM_CNT_RT_REG			0x8E
+17 −0
Original line number Diff line number Diff line
@@ -427,3 +427,20 @@ int qg_get_battery_voltage(struct qpnp_qg *chip, int *vbat_uv)

	return rc;
}

int qg_get_vbat_avg(struct qpnp_qg *chip, int *vbat_uv)
{
	int rc = 0;
	u64 last_vbat = 0;

	rc = qg_read(chip, chip->qg_base + QG_S2_NORMAL_AVG_V_DATA0_REG,
				(u8 *)&last_vbat, 2);
	if (rc < 0) {
		pr_err("Failed to read S2_NORMAL_AVG_V reg, rc=%d\n", rc);
		return rc;
	}

	*vbat_uv = V_RAW_TO_UV(last_vbat);

	return 0;
}
+1 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ int qg_write_monotonic_soc(struct qpnp_qg *chip, int msoc);
int qg_get_battery_temp(struct qpnp_qg *chip, int *batt_temp);
int qg_get_battery_current(struct qpnp_qg *chip, int *ibat_ua);
int qg_get_battery_voltage(struct qpnp_qg *chip, int *vbat_uv);
int qg_get_vbat_avg(struct qpnp_qg *chip, int *vbat_uv);
s64 qg_iraw_to_ua(struct qpnp_qg *chip, int iraw);

#endif
+4 −0
Original line number Diff line number Diff line
@@ -1872,6 +1872,9 @@ static int qg_psy_get_property(struct power_supply *psy,
	case POWER_SUPPLY_PROP_CC_SOC:
		rc = qg_get_cc_soc(chip, &pval->intval);
		break;
	case POWER_SUPPLY_PROP_VOLTAGE_AVG:
		rc = qg_get_vbat_avg(chip, &pval->intval);
		break;
	default:
		pr_debug("Unsupported property %d\n", psp);
		break;
@@ -1925,6 +1928,7 @@ static enum power_supply_property qg_psy_props[] = {
	POWER_SUPPLY_PROP_SOH,
	POWER_SUPPLY_PROP_FG_RESET,
	POWER_SUPPLY_PROP_CC_SOC,
	POWER_SUPPLY_PROP_VOLTAGE_AVG,
};

static const struct power_supply_desc qg_psy_desc = {