summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlec Berg <alecaberg@chromium.org>2015-01-23 09:06:36 -0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-01-24 06:41:59 +0000
commit0ef55f5899481249a073cfecea53fea3ab154ea6 (patch)
tree0ab14c5673a705f616ded5f3a2b69f633dc62984
parent0cefc2eeb5cd87cd42163379cfcf75d417b77f80 (diff)
downloadchrome-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>
-rw-r--r--board/samus/board.h1
-rw-r--r--driver/battery/samus.c24
2 files changed, 25 insertions, 0 deletions
diff --git a/board/samus/board.h b/board/samus/board.h
index cd17381767..da51e73631 100644
--- a/board/samus/board.h
+++ b/board/samus/board.h
@@ -24,6 +24,7 @@
#define CONFIG_CMD_ACCEL_INFO
#undef CONFIG_BATTERY_CRITICAL_SHUTDOWN_TIMEOUT
#define CONFIG_BATTERY_CRITICAL_SHUTDOWN_TIMEOUT 60
+#define CONFIG_BATTERY_CUT_OFF
#define CONFIG_POWER_COMMON
#define CONFIG_CHIPSET_CAN_THROTTLE
#define CONFIG_KEYBOARD_BOARD_CONFIG
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;
+}
+