From a45c8441af2aad933210d7ca1da78cff45743549 Mon Sep 17 00:00:00 2001 From: Subrata Banik Date: Tue, 2 Sep 2025 12:14:21 +0000 Subject: [PATCH] lib: Add boot mode information to coreboot tables This change introduces `LB_TAG_BOOT_MODE` to the coreboot tables to convey platform boot information to the payload. The new `lb_boot_mode` struct uses `enum boot_mode_t` to specify whether the device is booting in `normal mode`, `low-battery mode` or `off-mode charging`. This is crucial for platforms where the Application Processor (AP) manages the charging solution, as it provides the necessary context for the payload's charger driver. By passing this data through the coreboot table, we avoid redundant implementation and ensure consistent battery and charging information is available across both coreboot and the payload. A new weak function, `lb_add_boot_mode`, is also introduced. This function can be overridden by platforms that require this data to add the boot mode information to the coreboot table. TEST=Able to build and boot google/quenbi. Change-Id: I5aea72c02b4d6c856e2504f4007de584c59ee89f Signed-off-by: Subrata Banik Reviewed-on: https://review.coreboot.org/c/coreboot/+/88992 Tested-by: build bot (Jenkins) Reviewed-by: Kapil Porwal --- .../include/commonlib/coreboot_tables.h | 19 +++++++++++++++++++ src/include/boot/coreboot_tables.h | 3 +++ src/lib/coreboot_table.c | 9 +++++++++ 3 files changed, 31 insertions(+) diff --git a/src/commonlib/include/commonlib/coreboot_tables.h b/src/commonlib/include/commonlib/coreboot_tables.h index fefafb87e1..ab57ed0270 100644 --- a/src/commonlib/include/commonlib/coreboot_tables.h +++ b/src/commonlib/include/commonlib/coreboot_tables.h @@ -96,6 +96,7 @@ enum { LB_TAG_OPTION_ENUM = 0x00ca, LB_TAG_OPTION_DEFAULTS = 0x00cb, LB_TAG_OPTION_CHECKSUM = 0x00cc, + LB_TAG_BOOT_MODE = 0x00cd, }; /* All table entry base addresses and sizes must be 4-byte aligned. */ @@ -621,4 +622,22 @@ struct lb_cfr { /* struct lb_cfr_option_form forms[] */ }; +enum boot_mode_t { + LB_BOOT_MODE_NORMAL, + LB_BOOT_MODE_LOW_BATTERY, + LB_BOOT_MODE_OFFMODE_CHARGING, +}; + +/* + * Boot Mode: Pass the platform boot mode information to payload about + * booting in low-battery mode or off-mode charging. These information + * is useful for payload to implement charger driver. + */ +struct lb_boot_mode { + uint32_t tag; + uint32_t size; + + enum boot_mode_t boot_mode; +}; + #endif diff --git a/src/include/boot/coreboot_tables.h b/src/include/boot/coreboot_tables.h index 9c258c687e..be737b0bb9 100644 --- a/src/include/boot/coreboot_tables.h +++ b/src/include/boot/coreboot_tables.h @@ -53,6 +53,9 @@ struct lb_record *lb_new_record(struct lb_header *header); /* Add VBOOT VBNV offsets. */ void lb_table_add_vbnv_cmos(struct lb_header *header); +/* Add Boot Mode information */ +void lb_add_boot_mode(struct lb_header *header); + /* Define this in mainboard.c to add board specific CFR entries */ void mb_cfr_setup_menu(struct lb_cfr *cfr_root); diff --git a/src/lib/coreboot_table.c b/src/lib/coreboot_table.c index 3902c88eff..d8ecdce868 100644 --- a/src/lib/coreboot_table.c +++ b/src/lib/coreboot_table.c @@ -464,6 +464,13 @@ static void lb_add_acpi_rsdp(struct lb_header *head) acpi_rsdp->rsdp_pointer = get_coreboot_rsdp(); } +/* + * Not all platform would need to fill in the boot mode information. + * This is useful for platform that would like to implement battery + * charging solution in AP firmware. + */ +void __weak lb_add_boot_mode(struct lb_header *header) { /* NOOP */ } + size_t write_coreboot_forwarding_table(uintptr_t entry, uintptr_t target) { struct lb_header *head; @@ -585,6 +592,8 @@ static uintptr_t write_coreboot_table(uintptr_t rom_table_end) if (CONFIG(HAVE_ACPI_TABLES)) lb_add_acpi_rsdp(head); + lb_add_boot_mode(head); + /* Remember where my valid memory ranges are */ return lb_table_fini(head); }