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: Nicholas Troast <ntroast@codeaurora.org>
This commit is contained in:
parent
e93616b414
commit
683a347835
7 changed files with 26 additions and 14 deletions
|
@ -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 */
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -432,7 +432,7 @@ static enum power_supply_property smb138x_parallel_props[] = {
|
|||
POWER_SUPPLY_PROP_CHARGER_TEMP_MAX,
|
||||
POWER_SUPPLY_PROP_MODEL_NAME,
|
||||
POWER_SUPPLY_PROP_PARALLEL_MODE,
|
||||
POWER_SUPPLY_PROP_CONNECTOR_THERM_ZONE,
|
||||
POWER_SUPPLY_PROP_CONNECTOR_HEALTH,
|
||||
};
|
||||
|
||||
static int smb138x_parallel_get_prop(struct power_supply *psy,
|
||||
|
@ -485,8 +485,8 @@ static int smb138x_parallel_get_prop(struct power_supply *psy,
|
|||
case POWER_SUPPLY_PROP_PARALLEL_MODE:
|
||||
val->intval = POWER_SUPPLY_PARALLEL_MID_MID;
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_CONNECTOR_THERM_ZONE:
|
||||
rc = smblib_get_prop_connector_therm_zone(chg, val);
|
||||
case POWER_SUPPLY_PROP_CONNECTOR_HEALTH:
|
||||
rc = smblib_get_prop_die_health(chg, val);
|
||||
break;
|
||||
default:
|
||||
pr_err("parallel power supply get prop %d not supported\n",
|
||||
|
|
|
@ -238,7 +238,6 @@ enum power_supply_property {
|
|||
POWER_SUPPLY_PROP_FCC_DELTA,
|
||||
POWER_SUPPLY_PROP_ICL_REDUCTION,
|
||||
POWER_SUPPLY_PROP_PARALLEL_MODE,
|
||||
POWER_SUPPLY_PROP_CONNECTOR_THERM_ZONE,
|
||||
POWER_SUPPLY_PROP_DIE_HEALTH,
|
||||
POWER_SUPPLY_PROP_CONNECTOR_HEALTH,
|
||||
/* Local extensions of type int64_t */
|
||||
|
|
Loading…
Add table
Reference in a new issue