From b1e912585c275247bf4f2ad89249c5d1736cc8f2 Mon Sep 17 00:00:00 2001 From: Li Jun Date: Wed, 9 Jan 2019 15:26:13 +0530 Subject: [PATCH] MLK-17108-3 usb: typec: tcpci: don't do force discharge if enable vbus sink We use vbus force discharge to have a quick vbus off for power role swap, which works like this: enable vbus force discharge and wait the vbus fall below vbus low threshold, when reaches, an alarm generated and tcpm can go forward. but current code do vbus force discharge in any disable source vbus case, in enable vbus charge case, we firstly disable source vbus and then turn on vbus sink, in between, vbus force discharge should not be enabled. Acked-by: Peter Chen Signed-off-by: Li Jun Signed-off-by: Vipul Kumar --- drivers/usb/typec/tcpci.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/usb/typec/tcpci.c b/drivers/usb/typec/tcpci.c index dd81f3867ca1..e2fdac42bde4 100644 --- a/drivers/usb/typec/tcpci.c +++ b/drivers/usb/typec/tcpci.c @@ -412,8 +412,6 @@ static int tcpci_set_vbus(struct tcpc_dev *tcpc, bool source, bool sink) return ret; tcpci->drive_vbus = false; - /* Enable force discharge */ - tcpci_vbus_force_discharge(tcpc, true); } if (!sink) { @@ -423,6 +421,10 @@ static int tcpci_set_vbus(struct tcpc_dev *tcpc, bool source, bool sink) return ret; } + /* Enable force discharge */ + if (!source && !sink) + tcpci_vbus_force_discharge(tcpc, true); + if (source) { ret = regmap_write(tcpci->regmap, TCPC_COMMAND, TCPC_CMD_SRC_VBUS_DEFAULT); -- 2.17.1