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

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

power: qpnp-qg: Report SOC in centi-percentage



CAPACITY_RAW reports SOC in centi-percentage. In QG
use the system SOC as CAPACITY_RAW.

Change-Id: I3e51dc34cea5c97a7f901d9981f908e35b8b0fb5
Signed-off-by: default avatarAnirudh Ghayal <aghayal@codeaurora.org>
parent 4e5c3775
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -1994,6 +1994,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_CAPACITY_RAW:
		pval->intval = chip->sys_soc;
		break;
	case POWER_SUPPLY_PROP_REAL_CAPACITY:
		rc = qg_get_battery_capacity_real(chip, &pval->intval);
		break;
@@ -2123,6 +2126,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_CAPACITY_RAW,
	POWER_SUPPLY_PROP_REAL_CAPACITY,
	POWER_SUPPLY_PROP_TEMP,
	POWER_SUPPLY_PROP_VOLTAGE_NOW,
@@ -2951,7 +2955,7 @@ static int qg_determine_pon_soc(struct qpnp_qg *chip)
	bool use_pon_ocv = true;
	unsigned long rtc_sec = 0;
	u32 ocv_uv = 0, soc = 0, pon_soc = 0, full_soc = 0, cutoff_soc = 0;
	u32 shutdown[SDAM_MAX] = {0};
	u32 shutdown[SDAM_MAX] = {0}, soc_raw = 0;
	char ocv_type[20] = "NONE";

	if (!chip->profile_loaded) {
@@ -3030,6 +3034,7 @@ static int qg_determine_pon_soc(struct qpnp_qg *chip)
	use_pon_ocv = false;
	ocv_uv = shutdown[SDAM_OCV_UV];
	soc = shutdown[SDAM_SOC];
	soc_raw = shutdown[SDAM_SOC] * 100;
	strlcpy(ocv_type, "SHUTDOWN_SOC", 20);
	qg_dbg(chip, QG_DEBUG_PON, "Using SHUTDOWN_SOC @ PON\n");

@@ -3097,7 +3102,9 @@ static int qg_determine_pon_soc(struct qpnp_qg *chip)
			soc = DIV_ROUND_UP(((pon_soc - cutoff_soc) * 100),
						(full_soc - cutoff_soc));
			soc = CAP(0, 100, soc);
			soc_raw = soc * 100;
		} else {
			soc_raw = pon_soc * 100;
			soc = pon_soc;
		}

@@ -3111,6 +3118,7 @@ static int qg_determine_pon_soc(struct qpnp_qg *chip)
		return rc;
	}

	chip->cc_soc = chip->sys_soc = soc_raw;
	chip->last_adj_ssoc = chip->catch_up_soc = chip->msoc = soc;
	chip->kdata.param[QG_PON_OCV_UV].data = ocv_uv;
	chip->kdata.param[QG_PON_OCV_UV].valid = true;