summaryrefslogtreecommitdiff
path: root/driver
diff options
context:
space:
mode:
authorMary Ruthven <mruthven@chromium.org>2015-12-01 14:52:13 -0800
committerchrome-bot <chrome-bot@chromium.org>2015-12-03 02:22:03 -0800
commitbf91b0048620b5b22a8636f989cbfa89c0a4ee59 (patch)
treec5ce83aa412e857ae8a5aa67d2af56b1c80360e2 /driver
parent08daf923b0f88bb356e13589b87d96a8691ed556 (diff)
downloadchrome-ec-bf91b0048620b5b22a8636f989cbfa89c0a4ee59.tar.gz
Smart battery: wait for any battery response
Currently the EC waits until it reads a battery status with the flag STATUS_INITIALIZED set, but the EC does not use this flag for charging or any other battery operation. If this flag is not set, it does not mean that the battery is unusable, it just means that its values may not be trustworthy. This change will remove the check for STATUS_INITIALIZED and just check that the battery responds. The battery response shows that the battery is connected and can be used by the EC. BRANCH=none BUG=chromium:564893 TEST=see that device without STATUS_INITIALIZED set will exit battery_wait_for_stable() without timing out. Change-Id: I07778e8570b6d9400b61beec6b2e222984a40692 Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/315200 Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r--driver/battery/smart.c28
1 files changed, 7 insertions, 21 deletions
diff --git a/driver/battery/smart.c b/driver/battery/smart.c
index 212457866e..66774e15a9 100644
--- a/driver/battery/smart.c
+++ b/driver/battery/smart.c
@@ -18,7 +18,6 @@
#define CPUTS(outstr) cputs(CC_CHARGER, outstr);
#define CPRINTS(format, args...) cprints(CC_CHARGER, format, ## args)
-#define BATTERY_WAIT_TIMEOUT (2800*MSEC)
#define BATTERY_NO_RESPONSE_TIMEOUT (1000*MSEC)
static int fake_state_of_charge = -1;
@@ -357,35 +356,22 @@ void battery_get_params(struct batt_params *batt)
/* Wait until battery is totally stable */
int battery_wait_for_stable(void)
{
- int status, got_response;
- uint64_t wait_timeout = get_time().val + BATTERY_WAIT_TIMEOUT;
- uint64_t no_response_timeout = get_time().val +
- BATTERY_NO_RESPONSE_TIMEOUT;
-
- got_response = 0;
+ int status;
+ uint64_t wait_timeout = get_time().val + BATTERY_NO_RESPONSE_TIMEOUT;
CPRINTS("Wait for battery stabilized during %d",
- BATTERY_WAIT_TIMEOUT);
+ BATTERY_NO_RESPONSE_TIMEOUT);
while (get_time().val < wait_timeout) {
/* Starting pinging battery */
if (battery_status(&status) == EC_SUCCESS) {
- got_response = 1;
/* Battery is stable */
- if (status & STATUS_INITIALIZED) {
- CPRINTS("battery initialized");
- return EC_SUCCESS;
- }
- }
- /* Assume no battery connected if no response for a while */
- else if (!got_response &&
- get_time().val > no_response_timeout) {
- CPRINTS("battery not responding");
- return EC_ERROR_NOT_POWERED;
+ CPRINTS("battery responded with status %x", status);
+ return EC_SUCCESS;
}
msleep(25); /* clock stretching could hold 25ms */
}
- CPRINTS("battery wait stable timeout");
- return EC_ERROR_TIMEOUT;
+ CPRINTS("battery not responding");
+ return EC_ERROR_NOT_POWERED;
}
#ifndef CONFIG_CHARGER_V1