diff --git a/payloads/libpayload/include/coreboot_tables.h b/payloads/libpayload/include/coreboot_tables.h index b43a558b49..04d205c053 100644 --- a/payloads/libpayload/include/coreboot_tables.h +++ b/payloads/libpayload/include/coreboot_tables.h @@ -90,6 +90,7 @@ enum { CB_TAG_OPTION_ENUM = 0x00ca, CB_TAG_OPTION_DEFAULTS = 0x00cb, CB_TAG_OPTION_CHECKSUM = 0x00cc, + CB_TAG_BOOT_MODE = 0x00cd, }; typedef __aligned(4) uint64_t cb_uint64_t; @@ -443,6 +444,23 @@ struct cb_acpi_rsdp { cb_uint64_t rsdp_pointer; /* Address of the ACPI RSDP */ }; +enum boot_mode_t { + CB_BOOT_MODE_NORMAL, + CB_BOOT_MODE_LOW_BATTERY, + CB_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 cb_boot_mode { + uint32_t tag; + uint32_t size; + + enum boot_mode_t boot_mode; +}; /* Helpful inlines */ diff --git a/payloads/libpayload/include/sysinfo.h b/payloads/libpayload/include/sysinfo.h index 2db306eba9..7c47074aa1 100644 --- a/payloads/libpayload/include/sysinfo.h +++ b/payloads/libpayload/include/sysinfo.h @@ -173,6 +173,7 @@ struct sysinfo_t { /* pvmfw buffer location */ uintptr_t pvmfw; uint32_t pvmfw_size; + enum boot_mode_t boot_mode; }; extern struct sysinfo_t lib_sysinfo; diff --git a/payloads/libpayload/libc/coreboot.c b/payloads/libpayload/libc/coreboot.c index 2788f870be..11703ee178 100644 --- a/payloads/libpayload/libc/coreboot.c +++ b/payloads/libpayload/libc/coreboot.c @@ -285,6 +285,13 @@ static void cb_parse_pcie(void *ptr, struct sysinfo_t *info) info->pcie_ctrl_base = pcie->ctrl_base; } +static void cb_parse_boot_mode(void *ptr, struct sysinfo_t *info) +{ + const struct cb_boot_mode *mode = ptr; + + info->boot_mode = mode->boot_mode; +} + static void cb_parse_rsdp(void *ptr, struct sysinfo_t *info) { const struct cb_acpi_rsdp *cb_acpi_rsdp = ptr; @@ -437,6 +444,9 @@ int cb_parse_header(void *addr, int len, struct sysinfo_t *info) case CB_TAG_PCIE: cb_parse_pcie(ptr, info); break; + case CB_TAG_BOOT_MODE: + cb_parse_boot_mode(ptr, info); + break; default: cb_parse_arch_specific(rec, info); break;