summaryrefslogtreecommitdiff
path: root/board/eve/battery.c
diff options
context:
space:
mode:
authorDuncan Laurie <dlaurie@google.com>2017-01-17 10:27:29 -0800
committerchrome-bot <chrome-bot@chromium.org>2017-01-18 19:18:57 -0800
commit383fea37f6b0240c876cc9a09ff93e405f4632a6 (patch)
treea2f4b875009b9094cf849708025262fb2e93cc6d /board/eve/battery.c
parent268b510f0b981b2bb9d861dce291172687c6a5e5 (diff)
downloadchrome-ec-383fea37f6b0240c876cc9a09ff93e405f4632a6.tar.gz
eve: Updates from P1 build
- revert the change for issue 61431 as main build systems have updated resistor values - enable CONFIG_CHARGER_BD9995X_CHGEN, with the necessary changes in battery.c to support the custom battery present functions - enable CONFIG_CHARGER_MAINTAIN_VBAT - enable CONFIG_CHARGE_MANAGER_EXTERNAL_POWER_LIMIT for testing - set pre-charge current to 256mA to better wake up batteries - set voltage-min to 6.1V to account for charger inaccuracies since the battery expects >= 6V to wake up - enable CONFIG_BACKLIGHT_LID to enforce backlight off with lid closed - put all CONFIG_CMD enables in the same place - make PCH_ACOK open drain (pull-up to be enabled on PCH) BUG=chrome-os-partner:61431,chrome-os-partner:61676 BRANCH=none TEST=manual testing on P1 boards at the factory Change-Id: Ib20693c8200d253819873d03b54f91e12bda8270 Signed-off-by: Duncan Laurie <dlaurie@google.com> Reviewed-on: https://chromium-review.googlesource.com/428902 Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'board/eve/battery.c')
-rw-r--r--board/eve/battery.c59
1 files changed, 57 insertions, 2 deletions
diff --git a/board/eve/battery.c b/board/eve/battery.c
index c9dca4abb0..84d13244bc 100644
--- a/board/eve/battery.c
+++ b/board/eve/battery.c
@@ -7,21 +7,25 @@
#include "battery.h"
#include "battery_smart.h"
+#include "bd9995x.h"
#include "charge_state.h"
#include "console.h"
#include "ec_commands.h"
#include "extpower.h"
+#include "gpio.h"
#include "util.h"
/* Shutdown mode parameter to write to manufacturer access register */
#define SB_SHUTDOWN_DATA 0x0010
+static enum battery_present batt_pres_prev = BP_NOT_SURE;
+
/* Battery info for proto */
static const struct battery_info info = {
.voltage_max = 8800, /* mV */
.voltage_normal = 7700,
- .voltage_min = 6000,
- .precharge_current = 64, /* mA */
+ .voltage_min = 6100, /* Add 100mV for charger accuracy */
+ .precharge_current = 256, /* mA */
.start_charging_min_c = 0,
.start_charging_max_c = 46,
.charging_min_c = 0,
@@ -129,3 +133,54 @@ enum ec_status charger_profile_override_set_param(uint32_t param,
{
return EC_RES_INVALID_PARAM;
}
+
+static inline enum battery_present battery_hw_present(void)
+{
+ /* The GPIO is low when the battery is physically present */
+ return gpio_get_level(GPIO_BATTERY_PRESENT_L) ? BP_NO : BP_YES;
+}
+
+static int battery_init(void)
+{
+ int batt_status;
+
+ return battery_status(&batt_status) ? 0 :
+ !!(batt_status & STATUS_INITIALIZED);
+}
+
+/*
+ * Physical detection of battery.
+ */
+enum battery_present battery_is_present(void)
+{
+ enum battery_present batt_pres;
+
+ /* Get the physical hardware status */
+ batt_pres = battery_hw_present();
+
+ /*
+ * Make sure battery status is implemented, I2C transactions are
+ * success & the battery status is Initialized to find out if it
+ * is a working battery and it is not in the cut-off mode.
+ *
+ * If battery I2C fails but VBATT is high, battery is booting from
+ * cut-off mode.
+ *
+ * FETs are turned off after Power Shutdown time.
+ * The device will wake up when a voltage is applied to PACK.
+ * Battery status will be inactive until it is initialized.
+ */
+ if (batt_pres == BP_YES && batt_pres_prev != batt_pres &&
+ !battery_is_cut_off() && !battery_init()) {
+ batt_pres = BP_NO;
+ }
+
+ batt_pres_prev = batt_pres;
+
+ return batt_pres;
+}
+
+int board_battery_initialized(void)
+{
+ return battery_hw_present() == batt_pres_prev;
+}