{drivers, lib}: Move low-battery user notification logic outside FSP

This patch refactors low-battery user notification logic (Kconfig,
APIs to check if low-battery rendering is required, low-battery
shutdown is required) outside FSP driver code to ensure in future
non-FSP platforms might still be able to leverage this feature/logics
to render the low-battery indicator icon during boot.

Specifically, it:

- Moves Kconfig options related to low-battery notifications from
  drivers/intel/fsp to lib/
- Relocates the low-battery check and shutdown APIs drivers/intel/fsp
  to bootsplash.h
* Adjusts the vendor driver to utilize the new APIs for low-battery
  rendering decisions.
* Drop the unwanted header file "fsp/api.h" from bmp_logo.c

This change avoids tight coupling of low-battery functionality to FSP,
promoting code reusability across platforms.

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

Change-Id: Iaa730dac2bb4866183408b6390221f0bb8411a48
Signed-off-by: Subrata Banik <subratabanik@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86756
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Kapil Porwal <kapilporwal@google.com>
This commit is contained in:
Subrata Banik 2025-03-06 19:00:40 +00:00
commit 7b36319fd9
7 changed files with 65 additions and 65 deletions

View file

@ -475,53 +475,4 @@ config BUILDING_WITH_DEBUG_FSP
Enable this option if you are using a debug build of the FSP (Firmware Support Package)
in your project.
config PLATFORM_HAS_LOW_BATTERY_INDICATOR
bool "Display low battery indicator"
depends on BMP_LOGO
help
If enabled, this option displays a low battery indicator screen. This screen can be
used to warn the user that the battery is low and that they should plug in the device.
This option requires that the system have a display and that the BMP_LOGO option is
enabled.
config PLATFORM_LOW_BATTERY_SHUTDOWN_DELAY_SEC
int
default 5
depends on PLATFORM_HAS_LOW_BATTERY_INDICATOR
help
Delay, in seconds, before system shutdown due to low battery.
This delay allows the user to observe the low-battery indicator.
The default value of 5 seconds aligns with standard user experience (UX) practices.
Platforms may override this value based on specific product requirements.
config HAVE_ESOL_SUPPORT_FOR_LOW_BATTERY_INDICATOR
bool
depends on FSP_UGOP_EARLY_SIGN_OF_LIFE || MAINBOARD_HAS_EARLY_LIBGFXINIT
help
Enable low-battery indicator support in eSOL.
This option should be selected if the eSOL feature (using either libgfxinit or FSP uGOP)
supports displaying a low-battery indicator.
Platforms selecting `MAINBOARD_HAS_EARLY_LIBGFXINIT` can default enable this option.
For platforms using FSP uGOP, this option should only be enabled if uGOP has implemented
the necessary low-battery handling. This allows platforms to control low-battery
indicator support based on uGOP readiness.
config PLATFORM_HAS_EARLY_LOW_BATTERY_INDICATOR
bool "Display low battery indicator in romstage"
depends on PLATFORM_HAS_LOW_BATTERY_INDICATOR && HAVE_ESOL_SUPPORT_FOR_LOW_BATTERY_INDICATOR
help
If enabled, this option displays a low battery indicator during romstage (before memory
is available) in text mode in the firmware and defer the firmware update. This screen
can be used to warn the user that the battery is low and that they should plug in the
device.
config PLATFORM_LOW_BATTERY_INDICATOR_LOGO_PATH
string "Path to low battery logo file"
depends on PLATFORM_HAS_LOW_BATTERY_INDICATOR
default "3rdparty/blobs/mainboard/\$(MAINBOARDDIR)/low_battery.bmp"
endif

View file

@ -50,20 +50,6 @@ void platform_fsp_silicon_init_params_cb(FSPS_UPD *supd);
/* Callbacks for SoC/Mainboard specific overrides */
void platform_fsp_memory_multi_phase_init_cb(uint32_t phase_index);
void platform_fsp_silicon_multi_phase_init_cb(uint32_t phase_index);
/*
* Platform specific callbacks for power-off handling.
*
* These callbacks allow the platform to determine if a power-off is
* necessary due to various reasons, such as low battery detection.
*
* Additionally, API to perform platform specific power-off
*/
#if CONFIG(PLATFORM_HAS_LOW_BATTERY_INDICATOR)
bool platform_is_low_battery_shutdown_needed(void);
#else
static inline bool platform_is_low_battery_shutdown_needed(void) { return false; }
#endif
/*
* Displays an early shutdown notification to the user.
*

View file

@ -4,6 +4,7 @@
#include <arch/stack_canary_breakpoint.h>
#include <arch/symbols.h>
#include <assert.h>
#include <bootsplash.h>
#include <cbfs.h>
#include <cbmem.h>
#include <cf9_reset.h>

View file

@ -22,5 +22,18 @@ void set_bootsplash(unsigned char *framebuffer, unsigned int x_resolution,
const char *bmp_logo_filename(void);
void *bmp_load_logo(size_t *logo_size);
void bmp_release_logo(void);
/*
* Platform specific callbacks for power-off handling.
*
* These callbacks allow the platform to determine if a power-off is
* necessary due to various reasons, such as low battery detection.
*
* Additionally, API to perform platform specific power-off
*/
#if CONFIG(PLATFORM_HAS_LOW_BATTERY_INDICATOR)
bool platform_is_low_battery_shutdown_needed(void);
#else
static inline bool platform_is_low_battery_shutdown_needed(void) { return false; }
#endif
#endif

View file

@ -204,6 +204,56 @@ config BMP_LOGO_FILE_NAME
depends on BMP_LOGO
default "3rdparty/blobs/mainboard/\$(MAINBOARDDIR)/logo.bmp"
config HAVE_ESOL_SUPPORT_FOR_LOW_BATTERY_INDICATOR
bool
depends on FSP_UGOP_EARLY_SIGN_OF_LIFE || MAINBOARD_HAS_EARLY_LIBGFXINIT
help
Enable low-battery indicator support in eSOL.
This option should be selected if the eSOL feature (using either libgfxinit or FSP uGOP)
supports displaying a low-battery indicator.
Platforms selecting `MAINBOARD_HAS_EARLY_LIBGFXINIT` can default enable this option.
For platforms using FSP uGOP, this option should only be enabled if uGOP has implemented
the necessary low-battery handling. This allows platforms to control low-battery
indicator support based on uGOP readiness.
config PLATFORM_HAS_LOW_BATTERY_INDICATOR
bool "Display low battery indicator"
depends on BMP_LOGO
help
If enabled, this option displays a low battery indicator screen. This screen can be
used to warn the user that the battery is low and that they should plug in the device.
This option requires that the system have a display and that the BMP_LOGO option is
enabled.
if PLATFORM_HAS_LOW_BATTERY_INDICATOR
config PLATFORM_LOW_BATTERY_SHUTDOWN_DELAY_SEC
int
default 5
help
Delay, in seconds, before system shutdown due to low battery.
This delay allows the user to observe the low-battery indicator.
The default value of 5 seconds aligns with standard user experience (UX) practices.
Platforms may override this value based on specific product requirements.
config PLATFORM_HAS_EARLY_LOW_BATTERY_INDICATOR
bool "Display low battery indicator in romstage"
depends on HAVE_ESOL_SUPPORT_FOR_LOW_BATTERY_INDICATOR
help
If enabled, this option displays a low battery indicator during romstage (before memory
is available) in text mode in the firmware and defer the firmware update. This screen
can be used to warn the user that the battery is low and that they should plug in the
device.
config PLATFORM_LOW_BATTERY_INDICATOR_LOGO_PATH
string "Path to low battery logo file"
default "3rdparty/blobs/mainboard/\$(MAINBOARDDIR)/low_battery.bmp"
endif
endmenu
config HAVE_EARLY_POWEROFF_SUPPORT

View file

@ -4,7 +4,6 @@
#include <bootsplash.h>
#include <cbfs.h>
#include <cbmem.h>
#include <fsp/api.h>
#include <stdint.h>
#include <vendorcode/google/chromeos/chromeos.h>

View file

@ -1,7 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#include <ec/google/chromeec/ec.h>
#include <fsp/api.h>
#include <bootsplash.h>
/*
* Check if low battery shutdown is needed