diff options
author | David <David.Huang@quantatw.com> | 2013-09-09 15:43:23 +0800 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2013-09-11 16:26:01 +0000 |
commit | dfe34f9026090603040e10c82de07107d089926e (patch) | |
tree | fa05a538b27b2c6ef451588b42068437bbd9590b | |
parent | 5f5b9be523296102e152bc1d4bbecbe8f58c782d (diff) | |
download | chrome-ec-dfe34f9026090603040e10c82de07107d089926e.tar.gz |
Add battery ship mode function
Add battery cutoff command and resume 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: I9ff37aa809e2a6c4ea7abe7924512ff15a92d781
Signed-off-by: David Huang <David.Huang@quantatw.com>
Reviewed-on: https://chromium-review.googlesource.com/168396
Reviewed-by: Shawn Nematbakhsh <shawnn@chromium.org>
-rw-r--r-- | common/battery_leon.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/common/battery_leon.c b/common/battery_leon.c index 64d5c09d1e..9b64af2c30 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)); + /* FIXME: The smart battery should do the right thing - that's why it's * called "smart". Do we really want to second-guess it? For now, let's not. */ void battery_vendor_params(struct batt_params *batt) |