From 5ad50d865083c3102ddaaff662e844367a17f6a7 Mon Sep 17 00:00:00 2001 From: yanyh2 Date: Fri, 27 Mar 2020 17:53:21 +0800 Subject: [PATCH] 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 Reviewed-on: https://gerrit.mot.com/1523010 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Jianqi Yang Submit-Approved: Jira Key Reviewed-on: https://gerrit.mot.com/1771030 Reviewed-by: Huosheng Liao --- drivers/power/supply/qcom/smb5-lib.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/power/supply/qcom/smb5-lib.c b/drivers/power/supply/qcom/smb5-lib.c index 184f8cb93255..53dad590cf07 100644 --- a/drivers/power/supply/qcom/smb5-lib.c +++ b/drivers/power/supply/qcom/smb5-lib.c @@ -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)