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