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

Commit 683a3478 authored by Nicholas Troast's avatar Nicholas Troast Committed by Ashay Jaiswal
Browse files

power: supply: qcom: implement die and connector health property



The die and connector health properties expose the comparator output of
the thermal regulation. If both die and skin temperature regulation is
enabled then the output of the comparator will be the higher of the two.
The property values can be one of: Unknown, Cool, Warm, Hot, Overheat.

Change-Id: Ic92c9cb08ec42fd2c2f26a54687a17e3b05b388f
Signed-off-by: default avatarNicholas Troast <ntroast@codeaurora.org>
parent e93616b4
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -286,7 +286,6 @@ static struct device_attribute power_supply_attrs[] = {
	POWER_SUPPLY_ATTR(fcc_delta),
	POWER_SUPPLY_ATTR(icl_reduction),
	POWER_SUPPLY_ATTR(parallel_mode),
	POWER_SUPPLY_ATTR(connector_therm_zone),
	POWER_SUPPLY_ATTR(die_health),
	POWER_SUPPLY_ATTR(connector_health),
	/* Local extensions of type int64_t */
+4 −0
Original line number Diff line number Diff line
@@ -832,6 +832,7 @@ static enum power_supply_property smb2_batt_props[] = {
	POWER_SUPPLY_PROP_CHARGE_DONE,
	POWER_SUPPLY_PROP_PARALLEL_DISABLE,
	POWER_SUPPLY_PROP_SET_SHIP_MODE,
	POWER_SUPPLY_PROP_DIE_HEALTH,
};

static int smb2_batt_get_prop(struct power_supply *psy,
@@ -908,6 +909,9 @@ static int smb2_batt_get_prop(struct power_supply *psy,
		/* Not in ship mode as long as device is active */
		val->intval = 0;
		break;
	case POWER_SUPPLY_PROP_DIE_HEALTH:
		rc = smblib_get_prop_die_health(chg, val);
		break;
	default:
		pr_err("batt power supply prop %d not supported\n", psp);
		return -EINVAL;
+18 −7
Original line number Diff line number Diff line
@@ -2027,10 +2027,10 @@ int smblib_get_pe_start(struct smb_charger *chg,
	return 0;
}

int smblib_get_prop_connector_therm_zone(struct smb_charger *chg,
int smblib_get_prop_die_health(struct smb_charger *chg,
						union power_supply_propval *val)
{
	int rc, i;
	int rc;
	u8 stat;

	rc = smblib_read(chg, TEMP_RANGE_STATUS_REG, &stat);
@@ -2040,13 +2040,24 @@ int smblib_get_prop_connector_therm_zone(struct smb_charger *chg,
		return rc;
	}

	i = fls((stat & TEMP_RANGE_MASK) >> TEMP_RANGE_SHIFT) - 1;
	if (i < 0) {
		smblib_err(chg, "TEMP_RANGE is invalid\n");
		return -EINVAL;
	/* TEMP_RANGE bits are mutually exclusive */
	switch (stat & TEMP_RANGE_MASK) {
	case TEMP_BELOW_RANGE_BIT:
		val->intval = POWER_SUPPLY_HEALTH_COOL;
		break;
	case TEMP_WITHIN_RANGE_BIT:
		val->intval = POWER_SUPPLY_HEALTH_WARM;
		break;
	case TEMP_ABOVE_RANGE_BIT:
		val->intval = POWER_SUPPLY_HEALTH_HOT;
		break;
	case ALERT_LEVEL_BIT:
		val->intval = POWER_SUPPLY_HEALTH_OVERHEAT;
		break;
	default:
		val->intval = POWER_SUPPLY_HEALTH_UNKNOWN;
	}

	val->intval = i;
	return 0;
}

+1 −1
Original line number Diff line number Diff line
@@ -384,7 +384,7 @@ int smblib_get_prop_charger_temp(struct smb_charger *chg,
				union power_supply_propval *val);
int smblib_get_prop_charger_temp_max(struct smb_charger *chg,
				union power_supply_propval *val);
int smblib_get_prop_connector_therm_zone(struct smb_charger *chg,
int smblib_get_prop_die_health(struct smb_charger *chg,
			       union power_supply_propval *val);
int smblib_set_prop_pd_current_max(struct smb_charger *chg,
				const union power_supply_propval *val);
+0 −1
Original line number Diff line number Diff line
@@ -825,7 +825,6 @@ enum {
#define THERM_REG_ACTIVE_BIT			BIT(6)
#define TLIM_BIT				BIT(5)
#define TEMP_RANGE_MASK				GENMASK(4, 1)
#define TEMP_RANGE_SHIFT			1
#define ALERT_LEVEL_BIT				BIT(4)
#define TEMP_ABOVE_RANGE_BIT			BIT(3)
#define TEMP_WITHIN_RANGE_BIT			BIT(2)
Loading