diff options
author | Alec Berg <alecaberg@chromium.org> | 2015-01-23 09:06:36 -0800 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-01-24 06:41:59 +0000 |
commit | 0ef55f5899481249a073cfecea53fea3ab154ea6 (patch) | |
tree | 0ab14c5673a705f616ded5f3a2b69f633dc62984 /driver/battery/samus.c | |
parent | 0cefc2eeb5cd87cd42163379cfcf75d417b77f80 (diff) | |
download | chrome-ec-0ef55f5899481249a073cfecea53fea3ab154ea6.tar.gz |
samus: add battery cutoff
Add battery cutoff to samus.
BUG=chrome-os-partner:35744
BRANCH=samus
TEST=tested "cutoff" console command cuts off battery
and "ectool batterycutoff" from host cuts off battery
Change-Id: I88194c9c601594dee144933cabef5b1dc536ab0d
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/242830
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'driver/battery/samus.c')
-rw-r--r-- | driver/battery/samus.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/driver/battery/samus.c b/driver/battery/samus.c index 89f6dc9b68..88ee48310d 100644 --- a/driver/battery/samus.c +++ b/driver/battery/samus.c @@ -10,6 +10,7 @@ #include "console.h" #include "ec_commands.h" #include "extpower.h" +#include "i2c.h" #include "util.h" static const struct battery_info info = { @@ -220,3 +221,26 @@ enum battery_disconnect_state battery_get_disconnect_state(void) return BATTERY_NOT_DISCONNECTED; } #endif /* CONFIG_BATTERY_REVIVE_DISCONNECT */ + +#define PARAM_CUT_OFF_LOW 0x10 +#define PARAM_CUT_OFF_HIGH 0x00 + +int board_cut_off_battery(void) +{ + int rv; + uint8_t buf[3]; + + buf[0] = SB_MANUFACTURER_ACCESS & 0xff; + buf[1] = PARAM_CUT_OFF_LOW; + buf[2] = PARAM_CUT_OFF_HIGH; + + i2c_lock(I2C_PORT_BATTERY, 1); + rv = i2c_xfer(I2C_PORT_BATTERY, BATTERY_ADDR, buf, 3, NULL, 0, + I2C_XFER_SINGLE); + rv |= i2c_xfer(I2C_PORT_BATTERY, BATTERY_ADDR, buf, 3, NULL, 0, + I2C_XFER_SINGLE); + i2c_lock(I2C_PORT_BATTERY, 0); + + return rv; +} + |