diff options
author | Jett Rink <jettrink@chromium.org> | 2018-04-05 15:07:05 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-04-05 22:12:48 -0700 |
commit | 7e50bfd037af520cafa3e71fafe9e95d1e9487ba (patch) | |
tree | 9380580db7cda1c9741d0286c172e3251a67d274 /driver | |
parent | 8f27e60d82915ca4690e66deb918222509f6bd22 (diff) | |
download | chrome-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.c | 19 |
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, ®); read_reg(port, NX20P3483_INTERRUPT2_REG, ®); - /* Make sure that dead battery mode is exited */ + /* Check for dead battery mode */ rv = read_reg(port, NX20P3483_DEVICE_CONTROL_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; } |