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

Commit 57cd7711 authored by Harry Yang's avatar Harry Yang
Browse files

qcom-charger: show correct battery status while charging via wireless



POWER_SUPPLY_STATUS shows 'Discharging' when DCIN is the only charging
input, because current input online report is solely based on USB.
DCIN is included to fix the issue.

CRs-Fixed: 1034899
Change-Id: I58b8ca712a7900caf37bf79f5281fb3b6dab80f2
Signed-off-by: default avatarHarry Yang <harryy@codeaurora.org>
parent 400520a6
Loading
Loading
Loading
Loading
+15 −6
Original line number Diff line number Diff line
@@ -662,7 +662,8 @@ int smblib_vconn_regulator_is_enabled(struct regulator_dev *rdev)
int smblib_get_prop_input_suspend(struct smb_charger *chg,
				  union power_supply_propval *val)
{
	val->intval = get_client_vote(chg->usb_suspend_votable, USER_VOTER);
	val->intval = get_client_vote(chg->usb_suspend_votable, USER_VOTER) &&
			get_client_vote(chg->dc_suspend_votable, USER_VOTER);
	return 0;
}

@@ -697,15 +698,23 @@ int smblib_get_prop_batt_status(struct smb_charger *chg,
{
	int rc;
	u8 stat;
	union power_supply_propval online_pval = {0, };
	union power_supply_propval pval = {0, };

	smblib_get_prop_input_suspend(chg, &pval);
	if (pval.intval) {
		val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
		return rc;
	}

	rc = smblib_get_prop_usb_online(chg, &online_pval);
	rc = smblib_read(chg, POWER_PATH_STATUS_REG, &stat);
	if (rc < 0) {
		dev_err(chg->dev, "Couldn't get prop usb online rc=%d\n", rc);
		dev_err(chg->dev, "Couldn't read POWER_PATH_STATUS rc=%d\n",
			rc);
		return rc;
	}

	if (!online_pval.intval) {
	if (!(stat & (USE_USBIN_BIT | USE_DCIN_BIT)) ||
				!(stat & VALID_INPUT_POWER_SOURCE_BIT)) {
		val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
		return rc;
	}
@@ -720,7 +729,7 @@ int smblib_get_prop_batt_status(struct smb_charger *chg,
		 stat);

	stat = stat & BATTERY_CHARGER_STATUS_MASK;
	if (stat == COMPLETED_CHARGE || stat == INHIBIT_CHARGE)
	if (stat >= COMPLETED_CHARGE)
		val->intval = POWER_SUPPLY_STATUS_FULL;
	else
		val->intval = POWER_SUPPLY_STATUS_CHARGING;