soc/mediatek: Add common low battery poweroff handling

Add a common low battery poweroff implementation in
soc/mediatek/common/low_battery.c. This implementation checks
if a low battery shutdown is needed and triggers a poweroff
via Chrome EC if necessary.

Also enable this for mt8196 in ramstage.

BUG=b:424707341
TEST=The FW draws low battery indicator and powers off the DUT after 5
     seconds.
TEST=Use `elogtool list` and see `Low Battery boot | Power Off`

Change-Id: I2fcd242fbf26bdebc4acfb477c95c381adf645f5
Signed-off-by: Yidi Lin <yidilin@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/91431
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Subrata Banik <subratabanik@google.com>
Reviewed-by: Chen-Tsung Hsieh <chentsung@google.com>
This commit is contained in:
Yidi Lin 2026-02-25 19:00:41 +08:00
commit ca9b46d341
2 changed files with 29 additions and 0 deletions

View file

@ -0,0 +1,28 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#include <bootsplash.h>
#include <bootstate.h>
#include <delay.h>
#include <ec/google/chromeec/ec.h>
#include <elog.h>
#include <halt.h>
void __weak poweroff(void)
{
if (!CONFIG(EC_GOOGLE_CHROMEEC))
return;
google_chromeec_ap_poweroff();
}
static void low_battery_poweroff(void *unused)
{
if (!platform_is_low_battery_shutdown_needed())
return;
printk(BIOS_INFO, "%s: powering off...\n", __func__);
platform_handle_emergency_low_battery();
poweroff();
}
BOOT_STATE_INIT_ENTRY(BS_POST_DEVICE, BS_ON_EXIT, low_battery_poweroff, NULL);

View file

@ -69,6 +69,7 @@ ramstage-y += ../common/early_init.c
ramstage-y += ../common/emi.c
ramstage-y += gpueb.c
ramstage-y += l2c_ops.c
ramstage-y += ../common/low_battery.c
ramstage-y += ../common/mcu.c mcupm.c
ramstage-y += ../common/mmu_operations.c
ramstage-y += ../common/mtk_mipi_dphy.c mtk_mipi_dphy.c