UPSTREAM: {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.
(cherry picked from commit 7b36319fd9384935e94306b2c3203dccbb7a793f)
Original-Change-Id: Iaa730dac2bb4866183408b6390221f0bb8411a48
Original-Signed-off-by: Subrata Banik <subratabanik@google.com>
Original-Reviewed-on: https://review.coreboot.org/c/coreboot/+/86756
Original-Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Original-Reviewed-by: Kapil Porwal <kapilporwal@google.com>
GitOrigin-RevId: 7b36319fd9384935e94306b2c3203dccbb7a793f
Cr-Build-Id: 8720983542579323457
Cr-Build-Url: https://cr-buildbucket.appspot.com/build/8720983542579323457
Copybot-Job-Name: coreboot-main-copybot-downstream
Change-Id: I64fcb1049ef0fc8f698c37a45ddab7b5fc33fc48
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/coreboot/+/6337382
Commit-Queue: ChromeOS Prod (Robot) <chromeos-ci-prod@chromeos-bot.iam.gserviceaccount.com>
Tested-by: ChromeOS Prod (Robot) <chromeos-ci-prod@chromeos-bot.iam.gserviceaccount.com>
Reviewed-by: Yidi Lin <yidilin@google.com>
Bot-Commit: ChromeOS Prod (Robot) <chromeos-ci-prod@chromeos-bot.iam.gserviceaccount.com>
diff --git a/src/drivers/intel/fsp2_0/Kconfig b/src/drivers/intel/fsp2_0/Kconfig
index ffe0778..9425915 100644
--- a/src/drivers/intel/fsp2_0/Kconfig
+++ b/src/drivers/intel/fsp2_0/Kconfig
@@ -475,53 +475,4 @@
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
diff --git a/src/drivers/intel/fsp2_0/include/fsp/api.h b/src/drivers/intel/fsp2_0/include/fsp/api.h
index d159b71..0cbefbe 100644
--- a/src/drivers/intel/fsp2_0/include/fsp/api.h
+++ b/src/drivers/intel/fsp2_0/include/fsp/api.h
@@ -51,20 +51,6 @@
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.
*
* This function is responsible to perform the needful operations for informing
diff --git a/src/drivers/intel/fsp2_0/memory_init.c b/src/drivers/intel/fsp2_0/memory_init.c
index 38627c6..f6945a2 100644
--- a/src/drivers/intel/fsp2_0/memory_init.c
+++ b/src/drivers/intel/fsp2_0/memory_init.c
@@ -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>
diff --git a/src/include/bootsplash.h b/src/include/bootsplash.h
index 372e8c2..7a57cd9 100644
--- a/src/include/bootsplash.h
+++ b/src/include/bootsplash.h
@@ -22,5 +22,18 @@
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
diff --git a/src/lib/Kconfig b/src/lib/Kconfig
index dce3c44..be3a198 100644
--- a/src/lib/Kconfig
+++ b/src/lib/Kconfig
@@ -204,6 +204,56 @@
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
diff --git a/src/lib/bmp_logo.c b/src/lib/bmp_logo.c
index 6e3267e..bc636a6 100644
--- a/src/lib/bmp_logo.c
+++ b/src/lib/bmp_logo.c
@@ -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>
diff --git a/src/vendorcode/google/chromeos/battery.c b/src/vendorcode/google/chromeos/battery.c
index febc4dc..4380982 100644
--- a/src/vendorcode/google/chromeos/battery.c
+++ b/src/vendorcode/google/chromeos/battery.c
@@ -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