summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaveh Jalali <caveh@chromium.org>2020-02-03 20:14:47 -0800
committerCommit Bot <commit-bot@chromium.org>2020-05-28 08:03:07 +0000
commitc284fe7c64aa420f9668c795d06d04cf2e32ad08 (patch)
treea6d7286e6130c5680ba682f4d8186ad2db4671d5
parent9fed1d3f20a8ef30bda6d9f03b9a2446a41f6258 (diff)
downloadchrome-ec-c284fe7c64aa420f9668c795d06d04cf2e32ad08.tar.gz
syv682x: disable VBUS discharge in sink mode
The syv682x needs to have FDSG (force discharge mode) disabled in order to allow charging. BRANCH=none BUG=b:148487130,b:148467221 TEST=verified PD charging works with USB3 daughterboard (crrev.com/c/2013656 needed to enable USB3 board). Change-Id: Ifff20576accf88822228b7bd7b9eeb6b6cff6a6b Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2037097 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org> Tested-by: Keith Short <keithshort@chromium.org> Tested-by: Eric Herrmann <eherrmann@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2214879 Commit-Queue: Marco Chen <marcochen@chromium.org> Tested-by: Marco Chen <marcochen@chromium.org> Reviewed-by: Marco Chen <marcochen@chromium.org>
-rw-r--r--driver/ppc/syv682x.c43
1 files changed, 26 insertions, 17 deletions
diff --git a/driver/ppc/syv682x.c b/driver/ppc/syv682x.c
index 51db2725b1..d8d1482245 100644
--- a/driver/ppc/syv682x.c
+++ b/driver/ppc/syv682x.c
@@ -42,12 +42,38 @@ static int syv682x_is_sourcing_vbus(int port)
return flags[port] & SYV682X_FLAGS_SOURCE_ENABLED;
}
+static int syv682x_discharge_vbus(int port, int enable)
+{
+ int regval;
+ int rv;
+
+ rv = read_reg(port, SYV682X_CONTROL_2_REG, &regval);
+ if (rv)
+ return rv;
+
+ if (enable)
+ regval |= SYV682X_CONTROL_2_FDSG;
+ else
+ regval &= ~SYV682X_CONTROL_2_FDSG;
+
+ return write_reg(port, SYV682X_CONTROL_2_REG, regval);
+}
+
static int syv682x_vbus_sink_enable(int port, int enable)
{
int regval;
int rv;
/*
+ * Force Discharge mode must be off in sink mode
+ */
+ if (enable) {
+ rv = syv682x_discharge_vbus(port, 0);
+ if (rv)
+ return rv;
+ }
+
+ /*
* For sink mode need to make sure high voltage power path is connected
* and sink mode is selected.
*/
@@ -193,23 +219,6 @@ static int syv682x_set_vbus_source_current_limit(int port,
return write_reg(port, SYV682X_CONTROL_1_REG, regval);
}
-static int syv682x_discharge_vbus(int port, int enable)
-{
- int regval;
- int rv;
-
- rv = read_reg(port, SYV682X_CONTROL_2_REG, &regval);
- if (rv)
- return rv;
-
- if (enable)
- regval |= SYV682X_CONTROL_2_FDSG;
- else
- regval &= ~SYV682X_CONTROL_2_FDSG;
-
- return write_reg(port, SYV682X_CONTROL_2_REG, regval);
-}
-
#ifdef CONFIG_USBC_PPC_POLARITY
static int syv682x_set_polarity(int port, int polarity)
{