summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRachel Nancollas <rachelsn@google.com>2016-08-02 15:25:33 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-08-02 23:20:50 -0700
commit299e44ac8b63081b75901974af19def27ac088c3 (patch)
treedd65327baa314140e5e90ebdd7aed0e359f51afb
parent0152ba2c831feae4c8a1348a2a684adc847a001e (diff)
downloadchrome-ec-299e44ac8b63081b75901974af19def27ac088c3.tar.gz
reef: battery: Revive batteries in soft-disconnect state
ESC+F3+Power+AC removal puts the battery into a soft-disconnect state where is stops supplying current. Revive batteries in this state by supplying a precharge current. BUG=chrome-os-partner:55858 BRANCH=None TEST=Manual on reef. Put battery into soft-disconnect state. Attach charger and verify EC doesn't lose power and battery again supplies current. Change-Id: I9a772bf02a8bd40edc1db51de66de135f7299212 Signed-off-by: Rachel Nancollas <rachelsn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/365495 Commit-Ready: Rachel Nancollas <rachelsn@google.com> Tested-by: Rachel Nancollas <rachelsn@google.com> Reviewed-by: David Hendricks <dhendrix@chromium.org>
-rw-r--r--board/reef/battery.c65
-rw-r--r--board/reef/board.h1
2 files changed, 61 insertions, 5 deletions
diff --git a/board/reef/battery.c b/board/reef/battery.c
index 38801bd4be..5227a4b556 100644
--- a/board/reef/battery.c
+++ b/board/reef/battery.c
@@ -10,6 +10,7 @@
#include "charge_state.h"
#include "console.h"
#include "ec_commands.h"
+#include "extpower.h"
#include "gpio.h"
#include "i2c.h"
#include "util.h"
@@ -21,10 +22,10 @@
/* Battery info for BQ40Z55 */
static const struct battery_info info = {
/* FIXME(dhendrix): where do these values come from? */
- .voltage_max = 8700, /* mV */
+ .voltage_max = 8700, /* mV */
.voltage_normal = 7600,
.voltage_min = 6100,
- .precharge_current = 256, /* mA */
+ .precharge_current = 256, /* mA */
.start_charging_min_c = 0,
.start_charging_max_c = 46,
.charging_min_c = 0,
@@ -58,6 +59,59 @@ int board_cut_off_battery(void)
return rv;
}
+enum battery_disconnect_state battery_get_disconnect_state(void)
+{
+ uint8_t data[6];
+ int rv;
+
+ /*
+ * Take note if we find that the battery isn't in disconnect state,
+ * and always return NOT_DISCONNECTED without probing the battery.
+ * This assumes the battery will not go to disconnect state during
+ * runtime.
+ */
+ static int not_disconnected;
+
+ if (not_disconnected)
+ return BATTERY_NOT_DISCONNECTED;
+
+ if (extpower_is_present()) {
+ /* Check if battery charging + discharging is disabled. */
+ rv = sb_write(SB_MANUFACTURER_ACCESS,
+ PARAM_OPERATION_STATUS);
+ if (rv)
+ return BATTERY_DISCONNECT_ERROR;
+
+ rv = sb_read_string(I2C_PORT_BATTERY, BATTERY_ADDR,
+ SB_ALT_MANUFACTURER_ACCESS, data, 6);
+
+ if (rv || (~data[3] & (BATTERY_DISCHARGING_DISABLED |
+ BATTERY_CHARGING_DISABLED))) {
+ not_disconnected = 1;
+ return BATTERY_NOT_DISCONNECTED;
+ }
+
+ /*
+ * Battery is neither charging nor discharging. Verify that
+ * we didn't enter this state due to a safety fault.
+ */
+ rv = sb_write(SB_MANUFACTURER_ACCESS, PARAM_SAFETY_STATUS);
+ if (rv)
+ return BATTERY_DISCONNECT_ERROR;
+
+ rv = sb_read_string(I2C_PORT_BATTERY, BATTERY_ADDR,
+ SB_ALT_MANUFACTURER_ACCESS, data, 6);
+
+ if (rv || data[2] || data[3] || data[4] || data[5])
+ return BATTERY_DISCONNECT_ERROR;
+
+ /* No safety fault, battery is disconnected */
+ return BATTERY_DISCONNECTED;
+ }
+ not_disconnected = 1;
+ return BATTERY_NOT_DISCONNECTED;
+}
+
#ifdef CONFIG_CHARGER_PROFILE_OVERRIDE
static int fast_charging_allowed = 1;
@@ -70,6 +124,7 @@ static int fast_charging_allowed = 1;
* Return the next poll period in usec, or zero to use the default (which is
* state dependent).
*/
+
int charger_profile_override(struct charge_state_data *curr)
{
/* temp in 0.1 deg C */
@@ -225,12 +280,12 @@ static int command_fastcharge(int argc, char **argv)
return EC_SUCCESS;
}
+
DECLARE_CONSOLE_COMMAND(fastcharge, command_fastcharge,
"[on|off]",
- "Get or set fast charging profile",
- NULL);
+ "Get or set fast charging profile", NULL);
-#endif /* CONFIG_CHARGER_PROFILE_OVERRIDE */
+#endif /* CONFIG_CHARGER_PROFILE_OVERRIDE */
#ifdef CONFIG_BATTERY_PRESENT_CUSTOM
/*
diff --git a/board/reef/board.h b/board/reef/board.h
index bd06f25e25..40f9416335 100644
--- a/board/reef/board.h
+++ b/board/reef/board.h
@@ -20,6 +20,7 @@
/* Battery */
#define CONFIG_BATTERY_CUT_OFF
#define CONFIG_BATTERY_PRESENT_CUSTOM
+#define CONFIG_BATTERY_REVIVE_DISCONNECT
#define CONFIG_BATTERY_SMART
/* Charger */