diff options
author | Caveh Jalali <caveh@chromium.org> | 2020-02-03 20:14:47 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-07-16 16:21:00 +0000 |
commit | f000fcd31f63ed34b1000a1be512a886d7d265aa (patch) | |
tree | 604deb95bd26487a8a98689bf8dd9a6a43493545 | |
parent | 10541fe4c71f0c0f44919abe96a7a54154121aee (diff) | |
download | chrome-ec-f000fcd31f63ed34b1000a1be512a886d7d265aa.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>
(cherry picked from commit dd5b97c3e86d71919ec1287e19e740e86081fdde)
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2291468
Tested-by: Devin Lu <Devin.Lu@quantatw.com>
Reviewed-by: Edward Hill <ecgh@chromium.org>
Commit-Queue: Edward Hill <ecgh@chromium.org>
-rw-r--r-- | driver/ppc/syv682x.c | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/driver/ppc/syv682x.c b/driver/ppc/syv682x.c index 22222e59ba..ee875cd34f 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, ®val); + 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, ®val); - 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) { |