summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Collyer <scollyer@google.com>2017-07-25 15:58:39 -0700
committerCommit Bot <commit-bot@chromium.org>2020-08-30 15:38:50 +0000
commitfe521237b361da3be09aac94c976d038046f0752 (patch)
treeb7e4111bc9e5cccd06b708e5cbc5ee3f64b2565b
parent5e6b8db7fe0585be19009dc028b886a15d9fe1b8 (diff)
downloadchrome-ec-fe521237b361da3be09aac94c976d038046f0752.tar.gz
eve: Check for XCHG|XDSG bits for determining battery presence
When the battery is cutoff by the EC via I2C sb message, when the system is is booted again (after applying external power) the EC does not detect the battery and therefore batt.is_present is set to BP_NO and this kicks in the 1 second delay to prevent the AP from turning on right away. However, if the battery is cutoff via H1, when the EC is powered back up, it would detect the battery present and the 1 second delay is not activated, even though the battery isn't ready to supply power to the system. This CL adds a check to the eve specific battery_is_present() function. The bits XCHG and XDSG are checked for the condition of both being set to also indicate batt.is_present = BP_NO which triggers the 1 second delay to the AP power up and makes recovering from both methods of battery cutoff have equivalent paths. BUG=b:63360549 BRANCH=eve TEST=manual Iniated battery cutoff in the following 3 methods: 1) issue 'cutoff' command on EC console 2) discharge the battery so that the EC initateds the battery shutdown sequence when the battery voltage drops too low. 3) H1 generated battery cutoff For methods 1 and 2, the following console output is found: [0.006188 battery not found] For all 3 methods the next two console outputs are found. [1.486592 battery woke up] [2.487140 battery will now allow booting] In addition to these tests, also put the EC into hibernate, then using an external discharge circuit, discharged the battery below v_min (~5.0 V), then tested that the system powered back up and the battery resumed charging. Change-Id: I64747cab406ef194ee546c7520ae6479b3a8301d Signed-off-by: Scott Collyer <scollyer@google.com> Reviewed-on: https://chromium-review.googlesource.com/585837 Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Duncan Laurie <dlaurie@google.com> Commit-Queue: Duncan Laurie <dlaurie@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2320247 Commit-Queue: Patryk Duda <pdk@semihalf.com> Tested-by: Patryk Duda <pdk@semihalf.com> Reviewed-by: Jett Rink <jettrink@chromium.org>
-rw-r--r--board/eve/battery.c36
1 files changed, 34 insertions, 2 deletions
diff --git a/board/eve/battery.c b/board/eve/battery.c
index 30c769dfec..fd93b7d63d 100644
--- a/board/eve/battery.c
+++ b/board/eve/battery.c
@@ -248,6 +248,37 @@ static int battery_init(void)
}
/*
+ * Check for case where both XCHG and XDSG bits are set indicating that even
+ * though the FG can be read from the battery, the battery is not able to be
+ * charged or discharged. This situation will happen if a battery disconnect was
+ * intiaited via H1 setting the DISCONN signal to the battery. This will put the
+ * battery pack into a sleep state and when power is reconnected, the FG can be
+ * read, but the battery is still not able to provide power to the system. The
+ * calling function returns batt_pres = BP_NO, which instructs the charging
+ * state machine to prevent powering up the AP on battery alone which could lead
+ * to a brownout event when the battery isn't able yet to provide power to the
+ * system. .
+ */
+static int battery_check_disconnect(void)
+{
+ int rv;
+ uint8_t data[6];
+
+ /* Check if battery charging + discharging is disabled. */
+ rv = sb_read_mfgacc(PARAM_OPERATION_STATUS,
+ SB_ALT_MANUFACTURER_ACCESS, data, sizeof(data));
+ if (rv)
+ return BATTERY_DISCONNECT_ERROR;
+
+ if ((data[3] & (BATTERY_DISCHARGING_DISABLED |
+ BATTERY_CHARGING_DISABLED)) ==
+ (BATTERY_DISCHARGING_DISABLED | BATTERY_CHARGING_DISABLED))
+ return BATTERY_DISCONNECTED;
+
+ return BATTERY_NOT_DISCONNECTED;
+}
+
+/*
* Physical detection of battery.
*/
enum battery_present battery_is_present(void)
@@ -269,8 +300,9 @@ enum battery_present battery_is_present(void)
* 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()) {
+ if ((batt_pres == BP_YES && batt_pres_prev != batt_pres &&
+ !battery_is_cut_off() && !battery_init()) ||
+ battery_check_disconnect() != BATTERY_NOT_DISCONNECTED) {
batt_pres = BP_NO;
}