Add typec mode check for charger presence

When usb is in suspend state, the power supply usb
and pc_port will be offline. The demo mode cannot exit
from this situation.
Use typec mode as additional condition check for
charger presence, so that the step charge can keep
in demo mode and handle recharge event.

Change-Id: I7c22bb814affd92ab0ef29be149facd6c49f60d5
Signed-off-by: Yonghua Yan <yanyh2@motorola.com>
Reviewed-on: https://gerrit.mot.com/1381455
SLTApproved: Slta Waiver
SME-Granted: SME Approvals Granted
Tested-by: Jira Key
Reviewed-by: Jianqi Yang <yangj@motorola.com>
Submit-Approved: Jira Key
This commit is contained in:
Yonghua Yan 2019-07-04 12:56:42 +08:00
commit 8eff437c3f

View file

@ -1520,7 +1520,6 @@ static int get_prop_charger_present(struct smb_mmi_charger *chg,
union power_supply_propval *val)
{
int rc = -EINVAL;
bool chg_online = false;
val->intval = 0;
@ -1529,18 +1528,32 @@ static int get_prop_charger_present(struct smb_mmi_charger *chg,
POWER_SUPPLY_PROP_ONLINE, val);
if (rc < 0)
mmi_err(chg, "Couldn't read USB online rc=%d\n", rc);
else if (val->intval)
return rc;
}
chg_online = !!val->intval;
if (chg->pc_port_psy) {
rc = power_supply_get_property(chg->pc_port_psy,
POWER_SUPPLY_PROP_ONLINE, val);
if (rc < 0)
mmi_err(chg, "Couldn't read PC online rc=%d\n", rc);
else if (val->intval)
return rc;
}
chg_online = chg_online || !!val->intval;
val->intval = chg_online;
val->intval = 0;
if (chg->usb_psy) {
rc = power_supply_get_property(chg->usb_psy,
POWER_SUPPLY_PROP_TYPEC_MODE, val);
if (rc < 0)
mmi_err(chg, "Couldn't read typec mode rc=%d\n", rc);
else if (val->intval == POWER_SUPPLY_TYPEC_SOURCE_DEFAULT ||
val->intval == POWER_SUPPLY_TYPEC_SOURCE_MEDIUM ||
val->intval == POWER_SUPPLY_TYPEC_SOURCE_HIGH) {
val->intval = 1;
return rc;
}
}
return rc;
}