diff options
Diffstat (limited to 'driver/battery')
-rw-r--r-- | driver/battery/smart.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/driver/battery/smart.c b/driver/battery/smart.c index b3d1787338..4d64c29efa 100644 --- a/driver/battery/smart.c +++ b/driver/battery/smart.c @@ -590,14 +590,25 @@ int battery_wait_for_stable(void) BATTERY_NO_RESPONSE_TIMEOUT); while (get_time().val < wait_timeout) { /* Starting pinging battery */ - if (battery_status(&status) == EC_SUCCESS) { - /* Battery is stable */ - CPRINTS("battery responded with status %x", status); - return EC_SUCCESS; + if (battery_status(&status) != EC_SUCCESS) { + msleep(25); /* clock stretching could hold 25ms */ + continue; + } + +#ifdef CONFIG_BATTERY_STBL_STAT + if (((status & CONFIG_BATT_ALARM_MASK1) == + CONFIG_BATT_ALARM_MASK1) || + ((status & CONFIG_BATT_ALARM_MASK2) == + CONFIG_BATT_ALARM_MASK2)) { + msleep(25); + continue; } - msleep(25); /* clock stretching could hold 25ms */ +#endif + /* Battery is stable */ + CPRINTS("battery responded with status %x", status); + return EC_SUCCESS; } - CPRINTS("battery not responding"); + CPRINTS("battery not responding with status %x", status); return EC_ERROR_NOT_POWERED; } |