summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlec Berg <alecaberg@chromium.org>2015-06-10 10:04:14 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-06-10 21:35:54 +0000
commit9c35b4840067ba67e5314c67a160604abe758055 (patch)
tree7da9949ebe70191e77e2177454e52e255bc60778
parente05ed041cfe60db7d1bff5424d4579a52aea402f (diff)
downloadchrome-ec-9c35b4840067ba67e5314c67a160604abe758055.tar.gz
glados: add battery cutoff functionality
Add battery cutoff functionality to glados. BUG=none BRANCH=none TEST=use console cutoff command to verify that it cuts off battery and plug in zinger to verify that it comes out of it when AC is applied. Change-Id: I71ae113c398278ad9f67f3a4cedf6885754a5a72 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/276690 Reviewed-by: Rong Chang <rongchang@chromium.org>
-rw-r--r--board/glados/battery.c27
-rw-r--r--board/glados/board.h3
2 files changed, 29 insertions, 1 deletions
diff --git a/board/glados/battery.c b/board/glados/battery.c
index 2311120145..3365c93be1 100644
--- a/board/glados/battery.c
+++ b/board/glados/battery.c
@@ -6,6 +6,13 @@
*/
#include "battery.h"
+#include "battery_smart.h"
+#include "i2c.h"
+#include "util.h"
+
+/* Shutdown mode parameter to write to manufacturer access register */
+#define PARAM_CUT_OFF_LOW 0x10
+#define PARAM_CUT_OFF_HIGH 0x00
/* Battery info for BQ40Z55 */
static const struct battery_info info = {
@@ -25,3 +32,23 @@ const struct battery_info *battery_get_info(void)
{
return &info;
}
+
+int board_cut_off_battery(void)
+{
+ int rv;
+ uint8_t buf[3];
+
+ /* Ship mode command must be sent twice to take effect */
+ 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;
+}
diff --git a/board/glados/board.h b/board/glados/board.h
index da54b2a861..923289388b 100644
--- a/board/glados/board.h
+++ b/board/glados/board.h
@@ -10,6 +10,7 @@
/* Optional features */
#define CONFIG_ADC
+#define CONFIG_BATTERY_CUT_OFF
#define CONFIG_BATTERY_PRESENT_GPIO GPIO_BAT_PRESENT_L
#define CONFIG_BATTERY_SMART
#define CONFIG_BUTTON_COUNT 2
@@ -67,7 +68,7 @@
#define I2C_PORT_PMIC MEC1322_I2C3
#undef DEFERRABLE_MAX_COUNT
-#define DEFERRABLE_MAX_COUNT 9
+#define DEFERRABLE_MAX_COUNT 10
#ifndef __ASSEMBLER__