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

Commit 70cf9e96 authored by Anirudh Ghayal's avatar Anirudh Ghayal
Browse files

Revert "power: qpnp-qg: Use both charge & discharge tables for PON SOC"



This reverts commit fb26eef34d31c2f11dff26cc44e9133148a7d9dc. This change
is not required due to an update in the userspace logic.

Change-Id: Ib67174b8cf9f42f71840fc4d9bdf63c17172de02
Signed-off-by: default avatarAnirudh Ghayal <aghayal@codeaurora.org>
parent dd3c2725
Loading
Loading
Loading
Loading
+4 −18
Original line number Diff line number Diff line
@@ -393,33 +393,19 @@ static int qg_parse_battery_profile(struct qg_battery_data *battery)
	return rc;
}

int lookup_soc_ocv(u32 *soc, u32 ocv_uv, int batt_temp, u8 lookup)
int lookup_soc_ocv(u32 *soc, u32 ocv_uv, int batt_temp, bool charging)
{
	u8 table_index = 0;
	int soc_avg = 0, soc_charge = 0, soc_discharge = 0;
	u8 table_index = charging ? TABLE_SOC_OCV1 : TABLE_SOC_OCV2;

	if (!the_battery || !the_battery->profile) {
		pr_err("Battery profile not loaded\n");
		return -ENODEV;
	}

	if (lookup == SOC_AVERAGE) {
		soc_charge = interpolate_soc(
				&the_battery->profile[TABLE_SOC_OCV1],
	*soc = interpolate_soc(&the_battery->profile[table_index],
				batt_temp, UV_TO_DECIUV(ocv_uv));
		soc_discharge = interpolate_soc(
				&the_battery->profile[TABLE_SOC_OCV2],
				batt_temp, UV_TO_DECIUV(ocv_uv));
		soc_avg = (soc_charge + soc_discharge) / 2;
	} else {
		table_index = (lookup == SOC_CHARGE) ?
				TABLE_SOC_OCV1 : TABLE_SOC_OCV2;
		soc_avg = interpolate_soc(
				&the_battery->profile[table_index],
				batt_temp, UV_TO_DECIUV(ocv_uv));
	}

	*soc = CAP(0, 100, DIV_ROUND_CLOSEST(soc_avg, 100));
	*soc = CAP(0, 100, DIV_ROUND_CLOSEST(*soc, 100));

	return 0;
}
+1 −1
Original line number Diff line number Diff line
@@ -14,6 +14,6 @@

int qg_batterydata_init(struct device_node *node);
void qg_batterydata_exit(void);
int lookup_soc_ocv(u32 *soc, u32 ocv_uv, int batt_temp, u8 lookup);
int lookup_soc_ocv(u32 *soc, u32 ocv_uv, int batt_temp, bool charging);

#endif /* __QG_BATTERY_PROFILE_H__ */
+0 −6
Original line number Diff line number Diff line
@@ -45,10 +45,4 @@
#define CAP(min, max, value)			\
		((min > value) ? min : ((value > max) ? max : value))

enum soc_lookup {
	SOC_CHARGE,
	SOC_DISCHARGE,
	SOC_AVERAGE,
};

#endif /* __QG_DEFS_H__ */
+2 −3
Original line number Diff line number Diff line
@@ -1495,8 +1495,7 @@ static int qg_determine_pon_soc(struct qpnp_qg *chip)
			pr_err("Failed to read good_ocv rc=%d\n", rc);
			use_pon_ocv = true;
		} else {
			rc = lookup_soc_ocv(&soc, ocv_uv, batt_temp,
							SOC_AVERAGE);
			rc = lookup_soc_ocv(&soc, ocv_uv, batt_temp, false);
			if (rc < 0) {
				pr_err("Failed to lookup SOC (GOOD_OCV) @ PON rc=%d\n",
					rc);
@@ -1549,7 +1548,7 @@ static int qg_determine_pon_soc(struct qpnp_qg *chip)
			pr_err("Failed to read HW PON ocv rc=%d\n", rc);
			return rc;
		}
		rc = lookup_soc_ocv(&soc, ocv_uv, batt_temp, SOC_AVERAGE);
		rc = lookup_soc_ocv(&soc, ocv_uv, batt_temp, false);
		if (rc < 0) {
			pr_err("Failed to lookup SOC @ PON rc=%d\n", rc);
			soc = 50;