ec/google/chromeec: Add helper for critical battery state detection
Implement google_chromeec_is_critically_low_on_battery() to check if the system is at risk of an imminent power-off. This function returns true only if the battery is below the critical threshold and no charger is detected. Combining these checks into a single helper ensures that firmware notifications (like a red lightbar) or emergency power-down logic do not trigger while the device is successfully connected to AC power. - Implement google_chromeec_is_critically_low_on_battery in ec.c. - Export the function in ec.h for use in romstage/ramstage. TEST=Verified on Fatcat & Bluey that the function correctly identifies the low-power state and suppresses warnings when a charger is plugged in. Change-Id: I9f0f268d6660d913f989a9deffa24ab1f585b508 Signed-off-by: Subrata Banik <subratabanik@google.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/90963 Reviewed-by: Caveh Jalali <caveh@chromium.org> Reviewed-by: Kapil Porwal <kapilporwal@google.com> Reviewed-by: Jayvik Desai <jayvik@google.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
parent
6fa7f0cba4
commit
57c6f5e995
2 changed files with 18 additions and 0 deletions
|
|
@ -1981,3 +1981,14 @@ int google_chromeec_set_lightbar_rgb(unsigned int led, int red, int green,
|
|||
|
||||
return google_chromeec_command(&cmd);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if the battery is critically low and not currently charging.
|
||||
*
|
||||
* Return true if battery is below threshold and AC is not present.
|
||||
*/
|
||||
bool google_chromeec_is_critically_low_on_battery(void)
|
||||
{
|
||||
return google_chromeec_is_below_critical_threshold() &&
|
||||
!google_chromeec_is_charger_present();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -562,4 +562,11 @@ int google_chromeec_read_batt_state_of_charge(uint32_t *state);
|
|||
int google_chromeec_set_lightbar_rgb(unsigned int led, int red, int green,
|
||||
int blue);
|
||||
|
||||
/*
|
||||
* Check if the battery is critically low and AC is not present.
|
||||
*
|
||||
* Return true if battery is below threshold and AC is not present.
|
||||
*/
|
||||
bool google_chromeec_is_critically_low_on_battery(void);
|
||||
|
||||
#endif /* _EC_GOOGLE_CHROMEEC_EC_H */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue