summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/battery_bq20z453.c38
-rw-r--r--common/build.mk1
2 files changed, 39 insertions, 0 deletions
diff --git a/common/battery_bq20z453.c b/common/battery_bq20z453.c
new file mode 100644
index 0000000000..f3ac7dd4d4
--- /dev/null
+++ b/common/battery_bq20z453.c
@@ -0,0 +1,38 @@
+/* Copyright (c) 2012 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.
+ *
+ * Smart battery driver for BQ20Z453.
+ */
+
+#include "host_command.h"
+#include "smart_battery.h"
+#include "timer.h"
+
+#define PARAM_CUT_OFF 0x0010
+
+int battery_command_cut_off(struct host_cmd_handler_args *args)
+{
+ /*
+ * TODO: Since this is a host command, the i2c bus is claimed by host.
+ * Thus, we would send back the response in advanced so that
+ * the host can release the bus and then EC can send command to
+ * battery.
+ *
+ * Refactoring this via task is a way. However, it is wasteful.
+ * Need a light-weight solution.
+ */
+ args->result = EC_RES_SUCCESS;
+ args->send_response(args);
+
+ /* This function would try to claim i2c and then send to battery. */
+ sb_write(SB_MANUFACTURER_ACCESS, PARAM_CUT_OFF);
+
+ return EC_RES_SUCCESS;
+ /*
+ * Not sure if there is a side-effect since this could send result
+ * back to host TWICE.
+ */
+}
+DECLARE_HOST_COMMAND(EC_CMD_BATTERY_CUT_OFF, battery_command_cut_off,
+ EC_VER_MASK(0));
diff --git a/common/build.mk b/common/build.mk
index 10dbb23d8c..fdc65185da 100644
--- a/common/build.mk
+++ b/common/build.mk
@@ -9,6 +9,7 @@
common-y=main.o util.o console_output.o uart_buffering.o
common-y+=memory_commands.o shared_mem.o system_common.o hooks.o
common-y+=gpio_commands.o version.o printf.o queue.o
+common-$(CONFIG_BATTERY_BQ20Z453)+=battery_bq20z453.o
common-$(CONFIG_BATTERY_LINK)+=battery_link.o
common-$(CONFIG_CHARGER_BQ24725)+=charger_bq24725.o
common-$(CONFIG_PMU_TPS65090)+=pmu_tps65090.o pmu_tps65090_charger.o