summaryrefslogtreecommitdiff
path: root/driver
diff options
context:
space:
mode:
authorJett Rink <jettrink@chromium.org>2018-04-05 15:07:05 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-04-05 22:12:48 -0700
commit7e50bfd037af520cafa3e71fafe9e95d1e9487ba (patch)
tree9380580db7cda1c9741d0286c172e3251a67d274 /driver
parent8f27e60d82915ca4690e66deb918222509f6bd22 (diff)
downloadchrome-ec-7e50bfd037af520cafa3e71fafe9e95d1e9487ba.tar.gz
ppc: enter SNK mode before leaving dead battery mode
If we don't enable the SNK mode before leaving dead battery mode (which does keep the inflow path open), then we will brown out our only source of power. BRANCH=none BUG=b:77561535 TEST=yorp can boot into ec without battery Change-Id: I095e3cb1ed466fd6497bbc9e7b6851fc92005c75 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/999024 Reviewed-by: Scott Collyer <scollyer@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r--driver/ppc/nx20p3483.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/driver/ppc/nx20p3483.c b/driver/ppc/nx20p3483.c
index 7a3893443e..331945ccbb 100644
--- a/driver/ppc/nx20p3483.c
+++ b/driver/ppc/nx20p3483.c
@@ -202,14 +202,23 @@ static int nx20p3483_init(int port)
read_reg(port, NX20P3483_INTERRUPT1_REG, &reg);
read_reg(port, NX20P3483_INTERRUPT2_REG, &reg);
- /* Make sure that dead battery mode is exited */
+ /* Check for dead battery mode */
rv = read_reg(port, NX20P3483_DEVICE_CONTROL_REG, &reg);
if (rv)
return rv;
- reg |= NX20P3483_CTRL_DB_EXIT;
- rv = write_reg(port, NX20P3483_DEVICE_CONTROL_REG, reg);
- if (rv)
- return rv;
+
+ /* If in dead battery mode switch to SNK mode before exiting */
+ if (!(reg & ~NX20P3483_CTRL_DB_EXIT)) {
+ rv = nx20p3483_vbus_sink_enable(port, 1);
+ if (rv)
+ return rv;
+
+ /* Exit dead battery mode. */
+ reg |= NX20P3483_CTRL_DB_EXIT;
+ rv = write_reg(port, NX20P3483_DEVICE_CONTROL_REG, reg);
+ if (rv)
+ return rv;
+ }
return EC_SUCCESS;
}