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

Commit 09878820 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "power: qpnp-smbcharger: expose CHARGE_COUNTER prop via batt psy"

parents c45ceb2c f24b7f41
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -5922,6 +5922,24 @@ static int smbchg_dp_dm(struct smbchg_chip *chip, int val)
	return rc;
}

static int smbchg_get_prop_batt_charge_counter(struct smbchg_chip *chip)
{
	int rc;
	union power_supply_propval val;

	if (!chip->bms_psy)
		return -EINVAL;

	rc = power_supply_get_property(chip->bms_psy,
				POWER_SUPPLY_PROP_CHARGE_COUNTER, &val);
	if (rc < 0) {
		pr_smb(PR_STATUS, "Couldn't get charge count rc = %d\n", rc);
		return rc;
	}

	return val.intval;
}

static void update_typec_capability_status(struct smbchg_chip *chip,
					const union power_supply_propval *val)
{
@@ -6112,6 +6130,7 @@ static enum power_supply_property smbchg_battery_properties[] = {
	POWER_SUPPLY_PROP_FLASH_ACTIVE,
	POWER_SUPPLY_PROP_FLASH_TRIGGER,
	POWER_SUPPLY_PROP_DP_DM,
	POWER_SUPPLY_PROP_CHARGE_COUNTER,
	POWER_SUPPLY_PROP_INPUT_CURRENT_LIMITED,
	POWER_SUPPLY_PROP_RERUN_AICL,
	POWER_SUPPLY_PROP_RESTRICTED_CHARGING,
@@ -6322,6 +6341,9 @@ static int smbchg_battery_get_property(struct power_supply *psy,
	case POWER_SUPPLY_PROP_DP_DM:
		val->intval = chip->pulse_cnt;
		break;
	case POWER_SUPPLY_PROP_CHARGE_COUNTER:
		val->intval = smbchg_get_prop_batt_charge_counter(chip);
		break;
	case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMITED:
		val->intval = smbchg_is_input_current_limited(chip);
		break;