summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaveh Jalali <caveh@chromium.org>2021-07-20 22:43:34 -0700
committerCommit Bot <commit-bot@chromium.org>2021-07-22 04:11:06 +0000
commit1cac4e5adeb5e64dc1e2856561e1dfdc06e7776e (patch)
treea0e6a6197fa35685d74858d17753dcee26232dfc
parent3e1f91586faa6dd94dca5d3a1fc72ec117c9296b (diff)
downloadchrome-ec-1cac4e5adeb5e64dc1e2856561e1dfdc06e7776e.tar.gz
ppc/nx20p348x: Disable VBUS discharge in sink mode
This explicitly disables VBUS discharge when entering sink mode. According to the vendor, keeping VBUS discharge enabled can cause some noise and that explains some of the instability we had observed when charging from another chromebook and 5V3A charger. BRANCH=none BUG=b:193211352 TEST=charging from another chromebook is reliable now Signed-off-by: Caveh Jalali <caveh@chromium.org> Change-Id: I117dd3f7f9efddce00f903c2b290fa85c6052c5d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3044411 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
-rw-r--r--driver/ppc/nx20p348x.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/driver/ppc/nx20p348x.c b/driver/ppc/nx20p348x.c
index 0de40c153b..bb6236c143 100644
--- a/driver/ppc/nx20p348x.c
+++ b/driver/ppc/nx20p348x.c
@@ -110,6 +110,7 @@ static int nx20p348x_set_vbus_source_current_limit(int port,
static int nx20p348x_discharge_vbus(int port, int enable)
{
int regval;
+ int newval;
int status;
status = read_reg(port, NX20P348X_DEVICE_CONTROL_REG, &regval);
@@ -117,13 +118,16 @@ static int nx20p348x_discharge_vbus(int port, int enable)
return status;
if (enable)
- regval |= NX20P348X_CTRL_VBUSDIS_EN;
+ newval = regval | NX20P348X_CTRL_VBUSDIS_EN;
else
- regval &= ~NX20P348X_CTRL_VBUSDIS_EN;
+ newval = regval & ~NX20P348X_CTRL_VBUSDIS_EN;
- status = write_reg(port, NX20P348X_DEVICE_CONTROL_REG, regval);
+ if (newval == regval)
+ return EC_SUCCESS;
+
+ status = write_reg(port, NX20P348X_DEVICE_CONTROL_REG, newval);
if (status) {
- CPRINTS("Failed to %s vbus discharge",
+ CPRINTS("Failed to %s VBUS discharge",
enable ? "enable" : "disable");
return status;
}
@@ -137,6 +141,15 @@ __maybe_unused static int nx20p3481_vbus_sink_enable(int port, int enable)
int rv;
int control = enable ? NX20P3481_SWITCH_CONTROL_HVSNK : 0;
+ if (enable) {
+ /*
+ * VBUS Discharge must be off in sink mode.
+ */
+ rv = nx20p348x_discharge_vbus(port, 0);
+ if (rv)
+ return rv;
+ }
+
rv = write_reg(port, NX20P348X_SWITCH_CONTROL_REG, control);
if (rv)
return rv;
@@ -202,6 +215,15 @@ __maybe_unused static int nx20p3483_vbus_sink_enable(int port, int enable)
enable = !!enable;
+ if (enable) {
+ /*
+ * VBUS Discharge must be off in sink mode.
+ */
+ rv = nx20p348x_discharge_vbus(port, 0);
+ if (rv)
+ return rv;
+ }
+
/*
* We cannot use an EC GPIO for EN_SNK since an EC reset
* will float the GPIO thus browning out the board (without