soc/intel/common: Add low battery shutdown function

This commit adds a `do_low_battery_poweroff()` function to handle
platform power off due to critically low battery levels.

This provides a standardized way to handle low battery shutdowns across
platforms.

Additionally, the delay to the `do_low_battery_poweroff()` function,
allowing time for the low battery indicator to be displayed before
powering off. The delay is configurable through the
`PLATFORM_LOW_BATTERY_SHUTDOWN_DELAY_SEC` Kconfig option.

Finally, a low battery indicator event is logged using `elog`
before the delay.

This functionality (elog and delay) is enabled when the
`PLATFORM_HAS_LOW_BATTERY_INDICATOR` Kconfig option is selected.

BUG=b:339673254
TEST=Able to build and boot google/brox.

Change-Id: I92e9003c70c2608770972f1a302f954ebdf17bc4
Signed-off-by: Subrata Banik <subratabanik@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86361
Reviewed-by: Karthik Ramasubramanian <kramasub@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Subrata Banik 2025-02-11 09:09:56 +00:00
commit e5cc73cb94
2 changed files with 19 additions and 0 deletions

View file

@ -3,6 +3,8 @@
#include <arch/cache.h>
#include <cf9_reset.h>
#include <console/console.h>
#include <delay.h>
#include <elog.h>
#include <halt.h>
#include <reset.h>
@ -21,3 +23,13 @@ void do_board_reset(void)
{
full_reset();
}
void do_low_battery_poweroff(void)
{
if (CONFIG(PLATFORM_HAS_LOW_BATTERY_INDICATOR)) {
elog_add_event_byte(ELOG_TYPE_LOW_BATTERY_INDICATOR, ELOG_FW_ISSUE_SHUTDOWN);
delay(CONFIG_PLATFORM_LOW_BATTERY_SHUTDOWN_DELAY_SEC);
}
poweroff();
}

View file

@ -25,4 +25,11 @@ __noreturn void global_reset(void);
*/
efi_return_status_t fsp_get_pch_reset_status(void);
/*
* Issue power off due to low battery
*
* Call this function to power off the platform if the battery level is critically low.
*/
void do_low_battery_poweroff(void);
#endif /* _INTEL_COMMON_RESET_H_ */