mirror of
https://github.com/rd-stuffs/msm-4.14.git
synced 2025-02-20 11:45:48 +08:00
power: smb5-lib: add support for s/w based health of parallel charger
For some parallel chargers(SMB1390/SMB1395) temperature and current reporting is done via same h/w line, this sometimes leads to an unreliable reporting of SMB DIE health via main charger. Fix this by moving to s/w based reporting of SMB health by reading the SMB temperature via ADC channel and comparing it with the predefined thresholds. Change-Id: Ifc42a630d4fb6800b6d4f96656f03936d81abe8f Signed-off-by: Ashay Jaiswal <ashayj@codeaurora.org>
This commit is contained in:
parent
3db6f4c3b1
commit
3e7646e99b
@ -1244,7 +1244,7 @@ static int smb5_usb_main_get_prop(struct power_supply *psy,
|
||||
break;
|
||||
/* Use this property to report SMB health */
|
||||
case POWER_SUPPLY_PROP_HEALTH:
|
||||
val->intval = smblib_get_prop_smb_health(chg);
|
||||
rc = val->intval = smblib_get_prop_smb_health(chg);
|
||||
break;
|
||||
/* Use this property to report overheat status */
|
||||
case POWER_SUPPLY_PROP_HOT_TEMP:
|
||||
@ -1255,12 +1255,10 @@ static int smb5_usb_main_get_prop(struct power_supply *psy,
|
||||
rc = -EINVAL;
|
||||
break;
|
||||
}
|
||||
if (rc < 0) {
|
||||
if (rc < 0)
|
||||
pr_debug("Couldn't get prop %d rc = %d\n", psp, rc);
|
||||
return -ENODATA;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int smb5_usb_main_set_prop(struct power_supply *psy,
|
||||
|
@ -3832,7 +3832,6 @@ int smblib_get_pe_start(struct smb_charger *chg,
|
||||
int smblib_get_prop_smb_health(struct smb_charger *chg)
|
||||
{
|
||||
int rc;
|
||||
u8 stat;
|
||||
int input_present;
|
||||
union power_supply_propval prop = {0, };
|
||||
|
||||
@ -3840,50 +3839,21 @@ int smblib_get_prop_smb_health(struct smb_charger *chg)
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
|
||||
if (input_present == INPUT_NOT_PRESENT)
|
||||
if ((input_present == INPUT_NOT_PRESENT) || (!is_cp_available(chg)))
|
||||
return POWER_SUPPLY_HEALTH_UNKNOWN;
|
||||
|
||||
/*
|
||||
* SMB health is used only for CP, report UNKNOWN if
|
||||
* switcher is not enabled.
|
||||
*/
|
||||
if (is_cp_available(chg)) {
|
||||
rc = power_supply_get_property(chg->cp_psy,
|
||||
POWER_SUPPLY_PROP_CP_SWITCHER_EN, &prop);
|
||||
if (!rc && !prop.intval)
|
||||
return POWER_SUPPLY_HEALTH_UNKNOWN;
|
||||
}
|
||||
rc = power_supply_get_property(chg->cp_psy,
|
||||
POWER_SUPPLY_PROP_CP_DIE_TEMP, &prop);
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
|
||||
if (chg->wa_flags & SW_THERM_REGULATION_WA) {
|
||||
if (chg->smb_temp == -ENODATA)
|
||||
return POWER_SUPPLY_HEALTH_UNKNOWN;
|
||||
|
||||
if (chg->smb_temp > SMB_TEMP_RST_THRESH)
|
||||
return POWER_SUPPLY_HEALTH_OVERHEAT;
|
||||
|
||||
if (chg->smb_temp > SMB_TEMP_REG_H_THRESH)
|
||||
return POWER_SUPPLY_HEALTH_HOT;
|
||||
|
||||
if (chg->smb_temp > SMB_TEMP_REG_L_THRESH)
|
||||
return POWER_SUPPLY_HEALTH_WARM;
|
||||
|
||||
return POWER_SUPPLY_HEALTH_COOL;
|
||||
}
|
||||
|
||||
rc = smblib_read(chg, SMB_TEMP_STATUS_REG, &stat);
|
||||
if (rc < 0) {
|
||||
smblib_err(chg, "Couldn't read SMB_TEMP_STATUS_REG, rc=%d\n",
|
||||
rc);
|
||||
return POWER_SUPPLY_HEALTH_UNKNOWN;
|
||||
}
|
||||
|
||||
if (stat & SMB_TEMP_RST_BIT)
|
||||
if (prop.intval > SMB_TEMP_RST_THRESH)
|
||||
return POWER_SUPPLY_HEALTH_OVERHEAT;
|
||||
|
||||
if (stat & SMB_TEMP_UB_BIT)
|
||||
if (prop.intval > SMB_TEMP_REG_H_THRESH)
|
||||
return POWER_SUPPLY_HEALTH_HOT;
|
||||
|
||||
if (stat & SMB_TEMP_LB_BIT)
|
||||
if (prop.intval > SMB_TEMP_REG_L_THRESH)
|
||||
return POWER_SUPPLY_HEALTH_WARM;
|
||||
|
||||
return POWER_SUPPLY_HEALTH_COOL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user