usb: redriver: Avoid disabling regulator if regmap_write fails

While disconnecting USB cable, we clear the General Device
Setting Register (GEN_DEV_SET_REG) in order to disable the
redriver. This is done using the regmap_write API over I2C
interface. There are some cases where this write fails, so
the redriver would still be active, and its regulator would
transition to LPM as we unvote it afterwards. Since redriver
is active, if it consumes current more than the LPM threshold,
it can trigger an OCP. Avoid this situation by not removing
the votes on LDO, so that it would be in NPM.

Change-Id: I0db2cb80ea3ab610240dbec3fa423696eecbe39d
Signed-off-by: Prashanth K <quic_prashk@quicinc.com>
This commit is contained in:
Prashanth K 2024-02-20 14:32:30 +05:30
parent 8d96318c6c
commit d11bc6a8ad

View File

@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2018-2021, The Linux Foundation. All rights reserved.
* Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
* Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#include <linux/module.h>
@ -502,6 +502,7 @@ static int nb7vpq904m_notify_connect(struct usb_redriver *r, int ort)
static int nb7vpq904m_notify_disconnect(struct usb_redriver *r)
{
int ret = 0;
struct nb7vpq904m_redriver *redriver =
container_of(r, struct nb7vpq904m_redriver, r);
@ -512,9 +513,10 @@ static int nb7vpq904m_notify_disconnect(struct usb_redriver *r)
return 0;
redriver->op_mode = OP_MODE_NONE;
nb7vpq904m_reg_set(redriver, GEN_DEV_SET_REG, 0);
ret = nb7vpq904m_reg_set(redriver, GEN_DEV_SET_REG, 0);
nb7vpq904m_vdd_enable(redriver, false);
if (!ret)
nb7vpq904m_vdd_enable(redriver, false);
return 0;
}