summaryrefslogtreecommitdiff
path: root/board/scarlet
diff options
context:
space:
mode:
authorPhilip Chen <philipchen@google.com>2018-06-29 18:23:37 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-08-02 21:50:23 -0700
commit535c4d4a6a0e1c669ddee3c81b45faa22ac27196 (patch)
tree07ff04aed8a27784032b5706121cc0ec3c661127 /board/scarlet
parentcbcf963069165059b1b61a2268a3dbd9cdffd872 (diff)
downloadchrome-ec-535c4d4a6a0e1c669ddee3c81b45faa22ac27196.tar.gz
scarlet: Cut off battery in a custom battery condition
We want to shut down AP when the battery charge drops below BATTERY_LEVEL_SHUTDOWN. Then we want to cut off the battery to protect the battery from over-discharging. But we don't want to cut off the battery right after the battery charge drops below BATTERY_LEVEL_SHUTDOWN so that we can retain the RTC timestamp for functionality reasons. So let's add a custom check before we move on to cut off the battery in shutdown_on_critical_battery(). BUG=b:68723854 BRANCH=scarlet TEST=make buildall -j TEST=keep the battery discharging, see AP shut down when battery charge hits 2% and later EC cut off battery when battery voltage hits 3.2V Change-Id: I9950cf32558c11a2f55ee6ca64c157146d449110 Signed-off-by: Philip Chen <philipchen@google.com> Reviewed-on: https://chromium-review.googlesource.com/1121593 Reviewed-by: Alexandru M Stan <amstan@chromium.org> Commit-Queue: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org> Trybot-Ready: Philip Chen <philipchen@chromium.org> (cherry picked from commit 91171747b4ca01ac929186c96d4d6aa3489c60ab) Reviewed-on: https://chromium-review.googlesource.com/1140795 Commit-Ready: Philip Chen <philipchen@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Diffstat (limited to 'board/scarlet')
-rw-r--r--board/scarlet/board.c7
-rw-r--r--board/scarlet/board.h2
2 files changed, 9 insertions, 0 deletions
diff --git a/board/scarlet/board.c b/board/scarlet/board.c
index f4a6ae0b91..4a785e8655 100644
--- a/board/scarlet/board.c
+++ b/board/scarlet/board.c
@@ -9,6 +9,7 @@
#include "button.h"
#include "charge_manager.h"
#include "charge_state.h"
+#include "charge_state_v2.h"
#include "charger.h"
#include "chipset.h"
#include "common.h"
@@ -140,6 +141,12 @@ void board_reset_pd_mcu(void)
{
}
+int board_critical_shutdown_check(struct charge_state_data *curr)
+{
+ return ((curr->batt.flags & BATT_FLAG_BAD_VOLTAGE) ||
+ (curr->batt.voltage <= BAT_LOW_VOLTAGE_THRESH));
+}
+
uint16_t tcpc_get_alert_status(void)
{
uint16_t status = 0;
diff --git a/board/scarlet/board.h b/board/scarlet/board.h
index ee580193a3..16bc02168a 100644
--- a/board/scarlet/board.h
+++ b/board/scarlet/board.h
@@ -118,6 +118,8 @@
#define CONFIG_USBC_VCONN_SWAP
#define CONFIG_USB_PD_COMM_LOCKED
+#define CONFIG_BATTERY_CRITICAL_SHUTDOWN_CUT_OFF
+#define CONFIG_BATTERY_CRITICAL_CUT_OFF_CUSTOM_CONDITION
#define CONFIG_BATTERY_CUT_OFF
#define CONFIG_BATTERY_PRESENT_CUSTOM
#define CONFIG_BATTERY_RETRY_NACK