From 1e4ca473cb2a71eb95997248bbf469dd3c0070eb Mon Sep 17 00:00:00 2001 From: Li Jun Date: Wed, 9 Jan 2019 15:31:47 +0530 Subject: [PATCH] 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 --- drivers/usb/typec/tcpci.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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) -- 2.17.1