Reset USB real_charger_type to unknown for apsd rerun

In current factory environment, after USB OTG test(USB pins will be reconnected),
the typec mode detection is prior to vbus detection sometimes, and the
typec mode will be DEFAULT.
Then after the first time of apsd, the apsd result and real_charger_type
become SDP.
As a workaround for APSD detection issue, there will be APSD rerun if
the first APSD is SDP.
If there comes a usb_source_change irq right after apsd rerun, the pd policy
will receive the usb power change event and check the typec mode,
and real_charger_type, finally, it starts the USB enumeration as
typec mode greater than DEFAULT and real_charger_type is SDP.
At that time, APSD rerun and USB enumeration may collide and make conflict,
which is the reason why the second APSD gets a wrong result(DCP/HVDCP2)
and USB connection gets lost.
In order to avoid this situation, reset the real_charger_type to unknown
when rerun apsd, so that the USB enumeration will not be triggered by
pd policy unexpectedly but by charger driver.

Change-Id: Ifdde0a847ef18518a204f67843e61c6b5a9e7401
Signed-off-by: yanyh2 <yanyh2@motorola.com>
Reviewed-on: https://gerrit.mot.com/1523010
SME-Granted: SME Approvals Granted
SLTApproved: Slta Waiver
Tested-by: Jira Key
Reviewed-by: Jianqi Yang <yangj@motorola.com>
Submit-Approved: Jira Key
Reviewed-on: https://gerrit.mot.com/1771030
Reviewed-by: Huosheng Liao <liaohs@motorola.com>
This commit is contained in:
yanyh2 2020-03-27 17:53:21 +08:00 • committed by Xiaojun Ji
commit 5ad50d8650

View file

@ -1204,6 +1204,8 @@ void smblib_rerun_apsd(struct smb_charger *chg)
APSD_RERUN_BIT, APSD_RERUN_BIT);
if (rc < 0)
smblib_err(chg, "Couldn't re-run APSD rc=%d\n", rc);
else
chg->real_charger_type = POWER_SUPPLY_TYPE_UNKNOWN;
}
static const struct apsd_result *smblib_update_usb_type(struct smb_charger *chg)