summaryrefslogtreecommitdiff
path: root/driver/battery/smart.c
diff options
context:
space:
mode:
authorSiyu Qin <qinsiyu@huaqin.corp-partner.google.com>2023-04-28 16:02:11 +0800
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-05-16 03:13:12 +0000
commit4291f8eefd66c0d64742f58dc1ae1c26c30427b2 (patch)
treee0cf1e32f61f3a28c03c5f1d31b2f2ea9c37eb39 /driver/battery/smart.c
parentef5d1e3f1d9dcabe007ccbbc71b81a85412e0087 (diff)
downloadchrome-ec-4291f8eefd66c0d64742f58dc1ae1c26c30427b2.tar.gz
battery: check the battery stable state when battery wake up
Check the specific battery status to judge whether the battery is initialized and stable when the battery wakes up from ship mode. Use two MASKs to provide logical AND and logical OR options for different status. BUG=b:275392868 TEST=zmake build -a Change-Id: I7c5b4c9a74024846b6611ed49bf4823cf877469c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4486658 Reviewed-by: Mike Lee <mike5@huaqin.corp-partner.google.com> Tested-by: Siyu Qin <qinsiyu@huaqin.corp-partner.google.com> Reviewed-by: Eric Yilun Lin <yllin@google.com> Commit-Queue: Siyu Qin <qinsiyu@huaqin.corp-partner.google.com>
Diffstat (limited to 'driver/battery/smart.c')
-rw-r--r--driver/battery/smart.c23
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;
}