summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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__