vc/google/chromeos: Implement splash text for low-battery/off-mode boot

This patch adds platform-level support for dynamic splash screen text
rendering on ChromeOS devices. This implementation interfaces with the
ChromeEC to retrieve battery state-of-charge and charging status,
formatting these into human-readable strings during the bootsplash
stage.

TEST=Able to build and boot google/fatcat.

Change-Id: I5dc57d60cd6be0dc9c79668a8b1560d421e4d6cc
Signed-off-by: Subrata Banik <subratabanik@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/91095
Reviewed-by: Kapil Porwal <kapilporwal@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Subrata Banik 2026-02-04 21:04:00 +05:30
commit ce431ac056
2 changed files with 42 additions and 0 deletions

View file

@ -24,6 +24,7 @@ romstage-$(CONFIG_CHROMEOS_DRAM_PART_NUMBER_IN_CBI) += dram_part_num_override.c
ramstage-$(CONFIG_PLATFORM_HAS_LOW_BATTERY_INDICATOR) += battery.c
ramstage-$(CONFIG_CHROMEOS_FW_SPLASH_SCREEN) += splash.c
ramstage-$(CONFIG_FRAMEBUFFER_SPLASH_TEXT) += splash_text.c
ramstage-$(CONFIG_CHROMEOS_PVMFW_CBMEM) += pvmfw_cbmem.c
# Add logo to the cbfs image

View file

@ -0,0 +1,41 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#include <bootsplash.h>
#include <console/console.h>
#include <ec/google/chromeec/ec.h>
#include <stdio.h>
#include <string.h>
static bool get_battery_status_msg(char *msg, size_t msg_max)
{
uint32_t batt_pct;
if (google_chromeec_read_batt_state_of_charge(&batt_pct)) {
printk(BIOS_WARNING, "Failed to get battery level\n");
return false;
}
if (google_chromeec_is_critically_low_on_battery()) {
snprintf(msg, msg_max, "%u%%", batt_pct);
} else if (google_chromeec_is_charger_present()) {
if (batt_pct == 100)
snprintf(msg, msg_max, "Charged");
else
snprintf(msg, msg_max, "Charging: %u%%", batt_pct);
}
return true;
}
bool platform_get_splash_text(enum bootsplash_type logo_type, char *msg, size_t msg_max)
{
if (!CONFIG(EC_GOOGLE_CHROMEEC) || !msg || msg_max == 0)
return false;
memset(msg, 0, msg_max);
if (logo_type == BOOTSPLASH_LOW_BATTERY || logo_type == BOOTSPLASH_OFF_MODE_CHARGING)
return get_battery_status_msg(msg, msg_max);
return false;
}