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

Commit ace31fa6 authored by Subbaraman Narayanamurthy's avatar Subbaraman Narayanamurthy Committed by Guru Das Srinagesh
Browse files

power: qcom: smb5-lib: Update charging status for handling Qnovo



Currently, whenever the charging status register shows that the
charging is paused, charger driver shows it as not charging.
In case of Qnovo, this could be due to a momentary pause of
charging. Hence, read charging pause command register to see if
the charging pause is requested and update the charging status.

Change-Id: Ibbd9acf69a38d71f6970d2a86134b0f92853b8b5
Signed-off-by: default avatarSubbaraman Narayanamurthy <subbaram@codeaurora.org>
parent e631b423
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -1586,6 +1586,20 @@ int smblib_get_prop_batt_capacity(struct smb_charger *chg,
	return rc;
}

static bool is_charging_paused(struct smb_charger *chg)
{
	int rc;
	u8 val;

	rc = smblib_read(chg, CHARGING_PAUSE_CMD_REG, &val);
	if (rc < 0) {
		smblib_err(chg, "Couldn't read CHARGING_PAUSE_CMD rc=%d\n", rc);
		return false;
	}

	return val & CHARGING_PAUSE_CMD_BIT;
}

int smblib_get_prop_batt_status(struct smb_charger *chg,
				union power_supply_propval *val)
{
@@ -1651,6 +1665,11 @@ int smblib_get_prop_batt_status(struct smb_charger *chg,
		break;
	}

	if (is_charging_paused(chg)) {
		val->intval = POWER_SUPPLY_STATUS_CHARGING;
		return 0;
	}

	if (val->intval != POWER_SUPPLY_STATUS_CHARGING)
		return 0;

+3 −0
Original line number Diff line number Diff line
@@ -58,6 +58,9 @@ enum {
#define CHARGING_ENABLE_CMD_REG			(CHGR_BASE + 0x42)
#define CHARGING_ENABLE_CMD_BIT			BIT(0)

#define CHARGING_PAUSE_CMD_REG			(CHGR_BASE + 0x43)
#define CHARGING_PAUSE_CMD_BIT			BIT(0)

#define CHGR_CFG2_REG				(CHGR_BASE + 0x51)
#define RECHG_MASK				GENMASK(2, 1)
#define VBAT_BASED_RECHG_BIT			BIT(2)