power: supply: qcom: Add 40ms delay before updating 5V VBUS allowance

When charging with some fixed voltage USBPD adapters and when VBUS voltage
is moving from 9V to 5V, usbin-ov interrupt is triggered because of the
VBUS voltage is not settled before updating 5V VBUS allowance. To avoid
this, adding 40ms delay before updating 5V VBUS allowance.

Change-Id: I1a439210e7ceb46bf59f900f3c72e71715c590d3
Signed-off-by: Fenglin Wu <[email protected]>
This commit is contained in:
Fenglin Wu 2021-09-07 14:35:49 +08:00
commit d58fae4751

View file

@ -789,6 +789,7 @@ static int smblib_set_usb_pd_fsw(struct smb_charger *chg, int voltage)
#define CONT_AICL_HEADROOM_MV 1000
#define AICL_THRESHOLD_MV_IN_CC 5000
#define VSAFE5V_SETTLE_US 40000
static int smblib_set_usb_pd_allowed_voltage(struct smb_charger *chg,
int min_allowed_uv, int max_allowed_uv)
{
@ -814,6 +815,14 @@ static int smblib_set_usb_pd_allowed_voltage(struct smb_charger *chg,
return -EINVAL;
}
/*
* usbin-ov interrupt is seen with some USBPD adapters when moving
* from 9V to 5V. To avoid this, add delay here to wait VBUS voltage
* settled before updating VBUS allowance to 5V.
*/
if (vbus_allowance == FORCE_5V)
usleep_range(VSAFE5V_SETTLE_US, VSAFE5V_SETTLE_US + 1);
rc = smblib_usb_pd_adapter_allowance_override(chg, vbus_allowance);
if (rc < 0) {
smblib_err(chg, "set CONTINUOUS allowance failed, rc=%d\n",