diff options
-rw-r--r-- | board/llama/battery.c | 39 | ||||
-rw-r--r-- | board/llama/board.h | 2 |
2 files changed, 40 insertions, 1 deletions
diff --git a/board/llama/battery.c b/board/llama/battery.c index a7d46e33c3..b3c2d53210 100644 --- a/board/llama/battery.c +++ b/board/llama/battery.c @@ -1,4 +1,18 @@ +/* Copyright 2015 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * Battery pack vendor provided charging profile + */ + #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 static const struct battery_info info = { .voltage_max = 8700, @@ -20,3 +34,28 @@ const struct battery_info *battery_get_info(void) { return &info; } + +static int cutoff(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; +} + +int board_cut_off_battery(void) +{ + return cutoff(); +} diff --git a/board/llama/board.h b/board/llama/board.h index fc2d37ec29..a2091be9cc 100644 --- a/board/llama/board.h +++ b/board/llama/board.h @@ -10,7 +10,7 @@ #define CONFIG_CHIPSET_MEDIATEK /* Add for AC adaptor, charger, battery */ -#undef CONFIG_BATTERY_CUT_OFF +#define CONFIG_BATTERY_CUT_OFF #define CONFIG_BATTERY_SMART #define CONFIG_BOARD_PRE_INIT #define CONFIG_CHARGER |