summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Huang <david.huang@quanta.corp-partner.google.com>2020-02-26 16:04:14 +0800
committerCommit Bot <commit-bot@chromium.org>2020-03-17 10:35:16 +0000
commite54818593e239ea60cde55736c4dc55864508994 (patch)
tree21f56cce6d5d456f443b7a9082c176648c523fcc
parent57d7636cb077c4b5d1fbcf2dd0f0a912203b2867 (diff)
downloadchrome-ec-e54818593e239ea60cde55736c4dc55864508994.tar.gz
Juniper: Return BP_NOT_SURE when DFET status is off
Make battery_is_present and battery_check_present_status overridable for customize by device. Do not return BP_NO when DFET status is off. Battery might need more charge time to wake up from shutdown. Return BP_NOT_SURE to keep charge battery. BUG=b:149971271 BRANCH=jacuzzi TEST=Insert UVP/shutdown battery and check battery resume normally. Change-Id: I68841e4e6e0457711fc4f43e6346b54805b7217c Signed-off-by: David Huang <david.huang@quanta.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2091131 Reviewed-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-by: Ting Shen <phoenixshen@chromium.org>
-rw-r--r--baseboard/kukui/battery_smart.c4
-rw-r--r--baseboard/kukui/battery_smart.h20
-rw-r--r--board/jacuzzi/battery.c49
3 files changed, 71 insertions, 2 deletions
diff --git a/baseboard/kukui/battery_smart.c b/baseboard/kukui/battery_smart.c
index 473b1c19ce..7a58644e53 100644
--- a/baseboard/kukui/battery_smart.c
+++ b/baseboard/kukui/battery_smart.c
@@ -9,12 +9,12 @@
#include "battery_fuel_gauge.h"
#include "battery_smart.h"
-static enum battery_present batt_pres_prev = BP_NOT_SURE;
+enum battery_present batt_pres_prev = BP_NOT_SURE;
/*
* Physical detection of battery.
*/
-static enum battery_present battery_check_present_status(void)
+__overridable enum battery_present battery_check_present_status(void)
{
enum battery_present batt_pres = BP_NOT_SURE;
diff --git a/baseboard/kukui/battery_smart.h b/baseboard/kukui/battery_smart.h
new file mode 100644
index 0000000000..2171bfb95d
--- /dev/null
+++ b/baseboard/kukui/battery_smart.h
@@ -0,0 +1,20 @@
+/* Copyright 2019 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
+ */
+
+#ifndef __CROS_EC_BATTERY_SMART_H
+#define __CROS_EC_BATTERY_SMART_H
+
+#include "battery.h"
+
+/*
+ * Physical detection of battery.
+ */
+__override_proto enum battery_present battery_check_present_status(void);
+
+extern enum battery_present batt_pres_prev;
+
+#endif /* __CROS_EC_BATTERY_SMART_H */
diff --git a/board/jacuzzi/battery.c b/board/jacuzzi/battery.c
index 7fd56ea7a3..4f8ae97451 100644
--- a/board/jacuzzi/battery.c
+++ b/board/jacuzzi/battery.c
@@ -3,6 +3,7 @@
* found in the LICENSE file.
*/
+#include "baseboard/kukui/battery_smart.h"
#include "battery.h"
#include "battery_fuel_gauge.h"
#include "gpio.h"
@@ -99,3 +100,51 @@ enum battery_present battery_hw_present(void)
{
return gpio_get_level(GPIO_EC_BATT_PRES_ODL) ? BP_NO : BP_YES;
}
+
+/*
+ * Physical detection of battery.
+ */
+__override enum battery_present battery_check_present_status(void)
+{
+ enum battery_present batt_pres = BP_NOT_SURE;
+
+#ifdef CONFIG_BATTERY_HW_PRESENT_CUSTOM
+ /* Get the physical hardware status */
+ batt_pres = battery_hw_present();
+#endif
+
+ /*
+ * If the battery is not physically connected, then no need to perform
+ * any more checks.
+ */
+ if (batt_pres == BP_NO)
+ return batt_pres;
+
+ /*
+ * If the battery is present now and was present last time we checked,
+ * return early.
+ */
+ if (batt_pres == batt_pres_prev)
+ return batt_pres;
+
+ /*
+ * Check battery disconnect status. If we are unable to read battery
+ * disconnect status or DFET is off, then return BP_NOT_SURE. Battery
+ * could be in ship mode and might require pre-charge current to wake
+ * it up. BP_NO is not returned here because charger state machine
+ * will not provide pre-charge current assuming that battery is not
+ * present.
+ */
+ if (battery_get_disconnect_state() != BATTERY_NOT_DISCONNECTED)
+ return BP_NOT_SURE;
+
+ /*
+ * Ensure that battery is:
+ * 1. Not in cutoff
+ */
+ if (battery_is_cut_off() != BATTERY_CUTOFF_STATE_NORMAL)
+ return BP_NO;
+
+ return batt_pres;
+}
+