From: Li Jun Date: Wed, 9 Jan 2019 10:01:47 +0000 (+0530) Subject: MLK-18531 usb: typec: don't do vbus source disable for dead battery X-Git-Tag: rel_imx_4.19.35_1.1.0~2206 X-Git-Url: https://git.somdevices.com/?a=commitdiff_plain;h=1e4ca473cb2a71eb95997248bbf469dd3c0070eb;p=linux.git MLK-18531 usb: typec: don't do vbus source disable for dead battery In PTN5110 design, DisableSourceVBUS command also disables the sink enable signal because the EN_SNK can be used to source higher voltage, and, there is only one TCPC command to disable sourcing voltage without telling whether to disable 5V or the high voltage, and to keep the design simple they designed the PTN5110 to disable both. with this fact, we use the flag drive_vbus to check if the source vbus enable was issued, if yes we then do vbus source disable, in dead battery case, we never did vbus source enable, so will not issue vbus source disable command. Acked-by: Peter Chen Signed-off-by: Li Jun Signed-off-by: Vipul Kumar --- diff --git a/drivers/usb/typec/tcpci.c b/drivers/usb/typec/tcpci.c index 5567a93d1bf0..40b8f3bae90b 100644 --- a/drivers/usb/typec/tcpci.c +++ b/drivers/usb/typec/tcpci.c @@ -403,9 +403,8 @@ static int tcpci_set_vbus(struct tcpc_dev *tcpc, bool source, bool sink) struct tcpci *tcpci = tcpc_to_tcpci(tcpc); int ret; - /* Disable both source and sink first before enabling anything */ - - if (!source) { + /* Only disable source if it was enabled */ + if (!source && tcpci->drive_vbus) { ret = regmap_write(tcpci->regmap, TCPC_COMMAND, TCPC_CMD_DISABLE_SRC_VBUS); if (ret < 0)