summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid <David.Huang@quantatw.com>2013-09-13 10:43:27 +0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2013-10-01 02:44:22 +0000
commite540827b9201f2c24fdb6e5839384bf7d2dbe382 (patch)
tree3070dae710a2d358586ef8b688818ef01f44e8b2
parent974c50312bd7f384ddefa6ba2bf7488a363891ee (diff)
downloadchrome-ec-e540827b9201f2c24fdb6e5839384bf7d2dbe382.tar.gz
Implement battery cut-off in leon EC
Implement battery cut-off in leon EC for ectool command 'batterycutoff' and batteryresume command when AC plug in. BRANCH=leon BUG=chrome-os-partner:22567 TEST=manual 1. Use ectool batterycutoff to check battery enter ship mode. 2. Plug in AC and boot on, then plug out AC to check battery resume from ship mode. Change-Id: Iec5440f35993eb4b9cb753e2aefe195d99fe8f1c Signed-off-by: David Huang <David.Huang@quantatw.com> Reviewed-on: https://chromium-review.googlesource.com/169089 Reviewed-by: Dave Parker <dparker@chromium.org>
-rw-r--r--common/battery_leon.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/common/battery_leon.c b/common/battery_leon.c
index 75a179f291..4daaafc27a 100644
--- a/common/battery_leon.c
+++ b/common/battery_leon.c
@@ -7,6 +7,14 @@
#include "battery_pack.h"
#include "gpio.h"
+#include "host_command.h"
+#include "smart_battery.h"
+#include "extpower.h"
+#include "hooks.h"
+
+#define SB_SHIP_MODE_ADDR 0x35
+#define SB_SHIP_MODE_DATA 0x0004
+#define SB_SHIP_RESET_DATA 0x0003
/* FIXME: We need REAL values for all this stuff */
const struct battery_temperature_ranges bat_temp_ranges = {
@@ -33,6 +41,20 @@ const struct battery_info *battery_get_info(void)
return &info;
}
+static void battery_leon_ac_change(void)
+{
+ if (extpower_is_present())
+ sb_write(SB_SHIP_MODE_ADDR, SB_SHIP_RESET_DATA);
+}
+DECLARE_HOOK(HOOK_AC_CHANGE, battery_leon_ac_change, HOOK_PRIO_DEFAULT);
+
+int battery_command_cut_off(struct host_cmd_handler_args *args)
+{
+ return sb_write(SB_SHIP_MODE_ADDR, SB_SHIP_MODE_DATA);
+}
+DECLARE_HOST_COMMAND(EC_CMD_BATTERY_CUT_OFF, battery_command_cut_off,
+ EC_VER_MASK(0));
+
/**
* Physical detection of battery connection.
*/