summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2014-10-22 11:08:19 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-10-23 03:32:47 +0000
commit965e6bd9f948392d567d3339850e681096390d0e (patch)
tree6c8382a6097149be85d9fcce99eb6bd79fd1acb9
parent4b7f64cc2bc7d246575ee7484c63bc758345e5a1 (diff)
downloadchrome-ec-965e6bd9f948392d567d3339850e681096390d0e.tar.gz
ryu: Implement battery cut-off
The battery cut-off is achieved by putting BQ27742 in SHUTDOWN mode. BRANCH=None BUG=None TEST=Unplug AC and do 'cutoff' in EC console. The EC console goes unresponsive. Change-Id: I4a1aa359d79333d47aaf53b685a52960e5dfd652 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/225007 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--board/ryu/battery.c38
-rw-r--r--board/ryu/board.c22
-rw-r--r--board/ryu/board.h1
-rw-r--r--board/ryu/build.mk2
-rw-r--r--board/ryu_p2/battery.c38
-rw-r--r--board/ryu_p2/board.c22
-rw-r--r--board/ryu_p2/board.h1
-rw-r--r--board/ryu_p2/build.mk2
8 files changed, 80 insertions, 46 deletions
diff --git a/board/ryu/battery.c b/board/ryu/battery.c
new file mode 100644
index 0000000000..dc65128719
--- /dev/null
+++ b/board/ryu/battery.c
@@ -0,0 +1,38 @@
+/* Copyright 2014 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 "common.h"
+#include "i2c.h"
+
+/* Battery temperature ranges in degrees C */
+static const struct battery_info info = {
+ /* Design voltage */
+ .voltage_max = 4350,
+ .voltage_normal = 3800,
+ .voltage_min = 2800,
+ /* Pre-charge current: I <= 0.01C */
+ .precharge_current = 64, /* mA */
+ /* Operational temperature range */
+ .start_charging_min_c = 0,
+ .start_charging_max_c = 45,
+ .charging_min_c = 0,
+ .charging_max_c = 50,
+ .discharging_min_c = -20,
+ .discharging_max_c = 60,
+};
+
+const struct battery_info *battery_get_info(void)
+{
+ return &info;
+}
+
+int board_cut_off_battery(void)
+{
+ /* Write SET_SHUTDOWN(0x13) to CTRL(0x00) */
+ return i2c_write16(I2C_PORT_BATTERY, 0xaa, 0x0, 0x13);
+}
diff --git a/board/ryu/board.c b/board/ryu/board.c
index e8f770a7ed..eb336131a0 100644
--- a/board/ryu/board.c
+++ b/board/ryu/board.c
@@ -176,25 +176,3 @@ int extpower_is_present(void)
{
return gpio_get_level(GPIO_CHGR_ACOK);
}
-
-/* Battery temperature ranges in degrees C */
-static const struct battery_info info = {
- /* Design voltage */
- .voltage_max = 4350,
- .voltage_normal = 3800,
- .voltage_min = 2800,
- /* Pre-charge current: I <= 0.01C */
- .precharge_current = 64, /* mA */
- /* Operational temperature range */
- .start_charging_min_c = 0,
- .start_charging_max_c = 45,
- .charging_min_c = 0,
- .charging_max_c = 50,
- .discharging_min_c = -20,
- .discharging_max_c = 60,
-};
-
-const struct battery_info *battery_get_info(void)
-{
- return &info;
-}
diff --git a/board/ryu/board.h b/board/ryu/board.h
index 0ce0d59816..4530db90cf 100644
--- a/board/ryu/board.h
+++ b/board/ryu/board.h
@@ -53,6 +53,7 @@
/* Charging/Power configuration */
#undef CONFIG_BATTERY_RYU /* TODO implement */
#define CONFIG_BATTERY_BQ27541
+#define CONFIG_BATTERY_CUT_OFF
#define CONFIG_BATTERY_REQUESTS_NIL_WHEN_DEAD
#define CONFIG_BATTERY_REVIVE_DISCONNECT
#define CONFIG_CHARGER
diff --git a/board/ryu/build.mk b/board/ryu/build.mk
index 83acdab147..150b265120 100644
--- a/board/ryu/build.mk
+++ b/board/ryu/build.mk
@@ -9,5 +9,5 @@ CHIP:=stm32
CHIP_FAMILY:=stm32f0
CHIP_VARIANT:=stm32f07x
-board-y=board.o
+board-y=board.o battery.o
board-$(CONFIG_USB_POWER_DELIVERY)+=usb_pd_policy.o
diff --git a/board/ryu_p2/battery.c b/board/ryu_p2/battery.c
new file mode 100644
index 0000000000..dc65128719
--- /dev/null
+++ b/board/ryu_p2/battery.c
@@ -0,0 +1,38 @@
+/* Copyright 2014 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 "common.h"
+#include "i2c.h"
+
+/* Battery temperature ranges in degrees C */
+static const struct battery_info info = {
+ /* Design voltage */
+ .voltage_max = 4350,
+ .voltage_normal = 3800,
+ .voltage_min = 2800,
+ /* Pre-charge current: I <= 0.01C */
+ .precharge_current = 64, /* mA */
+ /* Operational temperature range */
+ .start_charging_min_c = 0,
+ .start_charging_max_c = 45,
+ .charging_min_c = 0,
+ .charging_max_c = 50,
+ .discharging_min_c = -20,
+ .discharging_max_c = 60,
+};
+
+const struct battery_info *battery_get_info(void)
+{
+ return &info;
+}
+
+int board_cut_off_battery(void)
+{
+ /* Write SET_SHUTDOWN(0x13) to CTRL(0x00) */
+ return i2c_write16(I2C_PORT_BATTERY, 0xaa, 0x0, 0x13);
+}
diff --git a/board/ryu_p2/board.c b/board/ryu_p2/board.c
index 84874695c4..af660017fb 100644
--- a/board/ryu_p2/board.c
+++ b/board/ryu_p2/board.c
@@ -151,25 +151,3 @@ int extpower_is_present(void)
{
return gpio_get_level(GPIO_CHGR_ACOK);
}
-
-/* Battery temperature ranges in degrees C */
-static const struct battery_info info = {
- /* Design voltage */
- .voltage_max = 4350,
- .voltage_normal = 3800,
- .voltage_min = 2800,
- /* Pre-charge current: I <= 0.01C */
- .precharge_current = 64, /* mA */
- /* Operational temperature range */
- .start_charging_min_c = 0,
- .start_charging_max_c = 45,
- .charging_min_c = 0,
- .charging_max_c = 50,
- .discharging_min_c = -20,
- .discharging_max_c = 60,
-};
-
-const struct battery_info *battery_get_info(void)
-{
- return &info;
-}
diff --git a/board/ryu_p2/board.h b/board/ryu_p2/board.h
index d4360ee4cd..928e768398 100644
--- a/board/ryu_p2/board.h
+++ b/board/ryu_p2/board.h
@@ -49,6 +49,7 @@
/* Charging/Power configuration */
#undef CONFIG_BATTERY_RYU /* TODO implement */
#define CONFIG_BATTERY_BQ27541
+#define CONFIG_BATTERY_CUT_OFF
#define CONFIG_BATTERY_REQUESTS_NIL_WHEN_DEAD
#define CONFIG_BATTERY_REVIVE_DISCONNECT
#define CONFIG_CHARGER
diff --git a/board/ryu_p2/build.mk b/board/ryu_p2/build.mk
index 4671ea0c7c..d498972118 100644
--- a/board/ryu_p2/build.mk
+++ b/board/ryu_p2/build.mk
@@ -9,5 +9,5 @@ CHIP:=stm32
CHIP_FAMILY:=stm32f3
CHIP_VARIANT:=stm32f373
-board-y=board.o
+board-y=board.o battery.o
board-$(CONFIG_USB_POWER_DELIVERY)+=usb_pd_policy.o