mirror of
https://github.com/rd-stuffs/msm-4.14.git
synced 2025-02-20 11:45:48 +08:00
Merge "power: smb1398: Do not read the registers before system resume"
This commit is contained in:
commit
adbb7b2563
@ -1389,6 +1389,7 @@ static int smb1390_get_prop(struct power_supply *psy,
|
||||
rc = smb1390_get_prop_suspended(chip, prop, val);
|
||||
if (!rc)
|
||||
return rc;
|
||||
rc = 0;
|
||||
}
|
||||
|
||||
switch (prop) {
|
||||
|
@ -317,6 +317,12 @@ struct smb1398_chip {
|
||||
u32 pl_input_mode;
|
||||
enum isns_mode current_capability;
|
||||
int cc_mode_taper_main_icl_ua;
|
||||
int cp_status1;
|
||||
int cp_status2;
|
||||
int cp_enable;
|
||||
int cp_isns_master;
|
||||
int cp_isns_slave;
|
||||
int cp_ilim;
|
||||
|
||||
bool status_change_running;
|
||||
bool taper_work_running;
|
||||
@ -834,6 +840,45 @@ static enum power_supply_property div2_cp_master_props[] = {
|
||||
POWER_SUPPLY_PROP_MIN_ICL,
|
||||
};
|
||||
|
||||
static int div2_cp_master_get_prop_suspended(struct smb1398_chip *chip,
|
||||
enum power_supply_property prop,
|
||||
union power_supply_propval *val)
|
||||
{
|
||||
switch (prop) {
|
||||
case POWER_SUPPLY_PROP_CP_STATUS1:
|
||||
val->intval = chip->cp_status1;
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_CP_STATUS2:
|
||||
val->intval = chip->cp_status2;
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_CP_ENABLE:
|
||||
val->intval = chip->cp_enable;
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_CP_SWITCHER_EN:
|
||||
val->intval = chip->switcher_en;
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_CP_DIE_TEMP:
|
||||
val->intval = chip->die_temp;
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_CP_ISNS:
|
||||
val->intval = chip->cp_isns_master;
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_CP_ISNS_SLAVE:
|
||||
val->intval = chip->cp_isns_slave;
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_CP_IRQ_STATUS:
|
||||
val->intval = chip->div2_irq_status;
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_CP_ILIM:
|
||||
val->intval = chip->cp_ilim;
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int div2_cp_master_get_prop(struct power_supply *psy,
|
||||
enum power_supply_property prop,
|
||||
union power_supply_propval *val)
|
||||
@ -842,21 +887,32 @@ static int div2_cp_master_get_prop(struct power_supply *psy,
|
||||
int rc = 0, ilim_ma, temp, isns_ua;
|
||||
u8 status;
|
||||
|
||||
/*
|
||||
* Return the cached values when the system is in suspend state
|
||||
* instead of reading the registers to avoid read failures.
|
||||
*/
|
||||
if (chip->in_suspend) {
|
||||
rc = div2_cp_master_get_prop_suspended(chip, prop, val);
|
||||
if (!rc)
|
||||
return rc;
|
||||
rc = 0;
|
||||
}
|
||||
|
||||
switch (prop) {
|
||||
case POWER_SUPPLY_PROP_CP_STATUS1:
|
||||
rc = smb1398_div2_cp_get_status1(chip, &status);
|
||||
if (!rc)
|
||||
val->intval = status;
|
||||
chip->cp_status1 = val->intval = status;
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_CP_STATUS2:
|
||||
rc = smb1398_div2_cp_get_status2(chip, &status);
|
||||
if (!rc)
|
||||
val->intval = status;
|
||||
chip->cp_status2 = val->intval = status;
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_CP_ENABLE:
|
||||
rc = smb1398_get_enable_status(chip);
|
||||
if (!rc)
|
||||
val->intval = chip->smb_en &&
|
||||
chip->cp_enable = val->intval = chip->smb_en &&
|
||||
!get_effective_result(
|
||||
chip->div2_cp_disable_votable);
|
||||
break;
|
||||
@ -868,27 +924,27 @@ static int div2_cp_master_get_prop(struct power_supply *psy,
|
||||
case POWER_SUPPLY_PROP_CP_ISNS:
|
||||
rc = smb1398_div2_cp_get_master_isns(chip, &isns_ua);
|
||||
if (rc >= 0)
|
||||
val->intval = isns_ua;
|
||||
chip->cp_isns_master = val->intval = isns_ua;
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_CP_ISNS_SLAVE:
|
||||
rc = smb1398_div2_cp_get_slave_isns(chip, &isns_ua);
|
||||
if (rc >= 0)
|
||||
val->intval = isns_ua;
|
||||
chip->cp_isns_slave = val->intval = isns_ua;
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_CP_TOGGLE_SWITCHER:
|
||||
val->intval = 0;
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_CP_DIE_TEMP:
|
||||
if (!chip->in_suspend) {
|
||||
rc = smb1398_get_die_temp(chip, &temp);
|
||||
if ((rc >= 0) && (temp <= THERMAL_SUSPEND_DECIDEGC))
|
||||
rc = smb1398_get_die_temp(chip, &temp);
|
||||
if (rc >= 0) {
|
||||
val->intval = temp;
|
||||
if (temp <= THERMAL_SUSPEND_DECIDEGC)
|
||||
chip->die_temp = temp;
|
||||
else if (chip->die_temp == -ENODATA)
|
||||
rc = -ENODATA;
|
||||
else
|
||||
val->intval = chip->die_temp;
|
||||
}
|
||||
|
||||
if (chip->die_temp != -ENODATA)
|
||||
val->intval = chip->die_temp;
|
||||
else
|
||||
rc = -ENODATA;
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_CP_IRQ_STATUS:
|
||||
val->intval = chip->div2_irq_status;
|
||||
@ -906,6 +962,7 @@ static int div2_cp_master_get_prop(struct power_supply *psy,
|
||||
if (!rc)
|
||||
val->intval = ilim_ma * 1000;
|
||||
}
|
||||
chip->cp_ilim = val->intval;
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_CHIP_VERSION:
|
||||
val->intval = chip->pmic_rev_id->rev4;
|
||||
|
Loading…
x
Reference in New Issue
Block a user