Subrata Banik has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/86361?usp=email )
Change subject: soc/intel/common: Add low battery shutdown function ......................................................................
soc/intel/common: Add low battery shutdown function
This commit adds a `do_low_battery_shutdown()` function to handle system shutdown due to critically low battery levels.
The function logs a low battery event, introduces a short delay for logging, and then initiates a power off sequence.
This provides a standardized way to handle low battery shutdowns across platforms.
BUG=b:339673254 TEST=Able to build and boot google/brox.
Change-Id: I92e9003c70c2608770972f1a302f954ebdf17bc4 Signed-off-by: Subrata Banik subratabanik@google.com --- M src/include/reset.h M src/soc/intel/common/reset.c 2 files changed, 23 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/61/86361/1
diff --git a/src/include/reset.h b/src/include/reset.h index 95fe066..be3460a 100644 --- a/src/include/reset.h +++ b/src/include/reset.h @@ -41,4 +41,16 @@ */ void do_board_reset(void);
+/* + * Issue shutdown due to low battery + * + * Call this function to power off the platform if the battery level is critically low. + * It performs the following actions: + * + * 1. Logs an event indicating a low battery shutdown. + * 2. Introduces a short delay to allow time for logging. + * 3. Sends a shutdown command. + */ +void do_low_battery_shutdown(void); + #endif diff --git a/src/soc/intel/common/reset.c b/src/soc/intel/common/reset.c index c6c394b..6ee4c10 100644 --- a/src/soc/intel/common/reset.c +++ b/src/soc/intel/common/reset.c @@ -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,12 @@ { full_reset(); } + +void do_low_battery_shutdown(void) +{ + elog_add_event_byte(ELOG_TYPE_LOW_BATTERY_INDICATOR, ELOG_FW_ISSUE_SHUTDOWN); + + delay(3); + + poweroff(); +}