diff --git a/src/vendorcode/google/chromeos/Makefile.mk b/src/vendorcode/google/chromeos/Makefile.mk index cfb4af45de..644003e603 100644 --- a/src/vendorcode/google/chromeos/Makefile.mk +++ b/src/vendorcode/google/chromeos/Makefile.mk @@ -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 diff --git a/src/vendorcode/google/chromeos/splash_text.c b/src/vendorcode/google/chromeos/splash_text.c new file mode 100644 index 0000000000..bad33f3b49 --- /dev/null +++ b/src/vendorcode/google/chromeos/splash_text.c @@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include +#include +#include +#include +#include + +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; +}