summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryh.huang <yh.huang@mediatek.com>2015-01-29 20:07:49 +0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-03-09 06:15:46 +0000
commit9eb1380d63752967306b6f0af8456ad7f94d8b17 (patch)
tree8f997a88dabe41bce30428f2bbe4e607046df349
parent28d77f0c534227ec60d2b6a476033c42927c05ba (diff)
downloadchrome-ec-9eb1380d63752967306b6f0af8456ad7f94d8b17.tar.gz
llama: implement battery ship shutdown mode
Support battery cut-off as host command and console command. BUG=none BRANCH=master TEST=tested "cutoff" console command cuts off battery BOARD=llama Change-Id: Id5c67d296b7ecfac99389d5cfcdcaa79da9ad4f3 Signed-off-by: Ben Lok <ben.lok@mediatek.com> (cherry picked from commit 0274ffd14a35b478b8efa74cdd2d3303da96ec54) Reviewed-on: https://chromium-review.googlesource.com/255440 Reviewed-by: Alec Berg <alecaberg@chromium.org>
-rw-r--r--board/llama/battery.c39
-rw-r--r--board/llama/board.h2
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