From a518709e2583fb683ac9cc1d578e3b962ed089d4 Mon Sep 17 00:00:00 2001 From: Subrata Banik Date: Wed, 5 Feb 2025 15:38:50 +0000 Subject: [PATCH] drivers/intel/fsp2_0: Add platform callback for critical shutdown This commit adds the `platform_is_low_battery_shutdown_needed` callback to the FSP API. This allows platforms to integrate low-battery handling logic directly into the FSP silicon initialization process. By checking for critical conditions (e.g., low battery) within this callback after FSP silicon initialization, the platform can initiate a controlled shutdown before proceeding with further boot stages, preventing abrupt shutdowns later in the boot process. BUG=b:339673254 TEST=Able to build and boot google/brox. Change-Id: I2d6677d70dea3d24f5a19d70608fd21229a271a0 Signed-off-by: Subrata Banik Reviewed-on: https://review.coreboot.org/c/coreboot/+/86226 Reviewed-by: Julius Werner Tested-by: build bot (Jenkins) Reviewed-by: Karthik Ramasubramanian --- src/drivers/intel/fsp2_0/include/fsp/api.h | 13 +++++++++++++ src/drivers/intel/fsp2_0/silicon_init.c | 3 +++ src/lib/bmp_logo.c | 9 ++++++++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/drivers/intel/fsp2_0/include/fsp/api.h b/src/drivers/intel/fsp2_0/include/fsp/api.h index 971be0d207..28b24ce95f 100644 --- a/src/drivers/intel/fsp2_0/include/fsp/api.h +++ b/src/drivers/intel/fsp2_0/include/fsp/api.h @@ -50,6 +50,19 @@ 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 /* Check if MultiPhase Si Init is enabled */ bool fsp_is_multi_phase_init_enabled(void); /* diff --git a/src/drivers/intel/fsp2_0/silicon_init.c b/src/drivers/intel/fsp2_0/silicon_init.c index fdac9f5b85..f3472420bc 100644 --- a/src/drivers/intel/fsp2_0/silicon_init.c +++ b/src/drivers/intel/fsp2_0/silicon_init.c @@ -259,6 +259,9 @@ void fsp_silicon_init(void) fsps_load(); do_silicon_init(&fsps_hdr); + if (platform_is_low_battery_shutdown_needed()) + do_low_battery_poweroff(); + if (CONFIG(CACHE_MRC_SETTINGS) && CONFIG(FSP_NVS_DATA_POST_SILICON_INIT)) save_memory_training_data(); diff --git a/src/lib/bmp_logo.c b/src/lib/bmp_logo.c index becb605645..5a5adaafb5 100644 --- a/src/lib/bmp_logo.c +++ b/src/lib/bmp_logo.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -19,6 +20,7 @@ const char *bmp_logo_filename(void) void *bmp_load_logo(size_t *logo_size) { void *logo_buffer; + const char *logo_name; /* CBMEM is locked for S3 resume path. */ if (acpi_is_wakeup_s3()) @@ -32,7 +34,12 @@ void *bmp_load_logo(size_t *logo_size) if (!logo_buffer) return NULL; - *logo_size = cbfs_load(bmp_logo_filename(), logo_buffer, 1 * MiB); + if (platform_is_low_battery_shutdown_needed()) + logo_name = "low_battery.bmp"; + else + logo_name = bmp_logo_filename(); + + *logo_size = cbfs_load(logo_name, logo_buffer, 1 * MiB); if (*logo_size == 0) return NULL;