From 2a0f6e2bf42a9989ade2f74fddd52af53069a4f8 Mon Sep 17 00:00:00 2001 From: Guocheng Wang Date: Tue, 24 Oct 2023 15:14:52 +0800 Subject: [PATCH] charge: Fix OCP charger icl more then 1A in COM When using OCP charger in charge only mode,the input current limit is 2A. But the expected icl is 1A. In smblib_apsd_results: [OCP] = { .name = "OCP", .bit = OCP_CHARGER_BIT, .val = POWER_SUPPLY_TYPE_USB_DCP } So the OCP charger power supply type is USB_DCP. And in func update_sw_icl_max,it will using "vote(chg->usb_icl_votable, SW_ICL_MAX_VOTER, true, rp_ua);" to set the usb_icl to be 2A. So we need to recheck the OCP_CHARGER_BIT and reset usb_icl to OCP_CURRENT_UA (1A). Change-Id: Ifd4ccceb91c227c12e5f4b628606f2de166155af Signed-off-by: Guocheng Wang Reviewed-on: https://gerrit.mot.com/2775176 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Haijian Ma Reviewed-by: Huosheng Liao Submit-Approved: Jira Key --- drivers/power/supply/qcom/smb5-lib.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/power/supply/qcom/smb5-lib.c b/drivers/power/supply/qcom/smb5-lib.c index 3c6c2e2bfd07..bc5c4f28e8da 100644 --- a/drivers/power/supply/qcom/smb5-lib.c +++ b/drivers/power/supply/qcom/smb5-lib.c @@ -6156,6 +6156,7 @@ static void update_sw_icl_max(struct smb_charger *chg, int val) { int typec_mode; int rp_ua; + const struct apsd_result *apsd = NULL; /* while PD is active it should have complete ICL control */ if (chg->pd_active) @@ -6198,8 +6199,14 @@ static void update_sw_icl_max(struct smb_charger *chg, int val) vote(chg->usb_icl_votable, USB_PSY_VOTER, false, 0); break; case POWER_SUPPLY_TYPE_USB_DCP: - rp_ua = get_rp_based_dcp_current(chg, typec_mode); - vote(chg->usb_icl_votable, SW_ICL_MAX_VOTER, true, rp_ua); + apsd = smblib_get_apsd_result(chg); + if (apsd->bit == OCP_CHARGER_BIT) { + vote(chg->usb_icl_votable, SW_ICL_MAX_VOTER, true, + OCP_CURRENT_UA); + } else { + rp_ua = get_rp_based_dcp_current(chg, typec_mode); + vote(chg->usb_icl_votable, SW_ICL_MAX_VOTER, true, rp_ua); + } vote(chg->usb_icl_votable, USB_PSY_VOTER, false, 0); break; case QTI_POWER_SUPPLY_TYPE_USB_FLOAT: