diff --git a/payloads/libpayload/include/coreboot_tables.h b/payloads/libpayload/include/coreboot_tables.h index 36ec6e9125..6cb2558f3a 100644 --- a/payloads/libpayload/include/coreboot_tables.h +++ b/payloads/libpayload/include/coreboot_tables.h @@ -456,8 +456,11 @@ struct cb_panel_poweroff { }; enum boot_mode_t { + /* Regular boot scenarios */ CB_BOOT_MODE_NORMAL, - CB_BOOT_MODE_LOW_BATTERY, + /* Device is booting in low-batter w/ charger attached */ + CB_BOOT_MODE_LOW_BATTERY_CHARGING, + /* Device is booting in due to charger insertion */ CB_BOOT_MODE_OFFMODE_CHARGING, }; diff --git a/src/commonlib/include/commonlib/coreboot_tables.h b/src/commonlib/include/commonlib/coreboot_tables.h index ed5d52f0b5..d4582559df 100644 --- a/src/commonlib/include/commonlib/coreboot_tables.h +++ b/src/commonlib/include/commonlib/coreboot_tables.h @@ -639,8 +639,11 @@ struct lb_panel_poweroff { }; enum boot_mode_t { + /* Regular boot scenarios */ LB_BOOT_MODE_NORMAL, - LB_BOOT_MODE_LOW_BATTERY, + /* Device is booting in low-batter w/ charger attached */ + LB_BOOT_MODE_LOW_BATTERY_CHARGING, + /* Device is booting in due to charger insertion */ LB_BOOT_MODE_OFFMODE_CHARGING, }; diff --git a/src/mainboard/google/bluey/mainboard.c b/src/mainboard/google/bluey/mainboard.c index ad02b2ea3c..6d3538dcde 100644 --- a/src/mainboard/google/bluey/mainboard.c +++ b/src/mainboard/google/bluey/mainboard.c @@ -63,13 +63,15 @@ static enum boot_mode_t get_boot_mode(void) return boot_mode; } -static bool is_low_power_boot(void) +static bool is_low_power_boot_with_charger(void) { + bool ret = false; enum boot_mode_t boot_mode = get_boot_mode(); - if ((boot_mode == LB_BOOT_MODE_LOW_BATTERY) || + if ((boot_mode == LB_BOOT_MODE_LOW_BATTERY_CHARGING) || (boot_mode == LB_BOOT_MODE_OFFMODE_CHARGING)) - return true; - return false; + ret = true; + + return ret; } static void enable_usb_camera(void) @@ -99,7 +101,7 @@ static void setup_usb(void) static void setup_usb_late(void *unused) { /* Skip USB initialization if boot mode is "low-battery" or "off-mode charging"*/ - if (is_low_power_boot()) + if (is_low_power_boot_with_charger()) return; setup_usb_host0(); @@ -119,15 +121,15 @@ void lb_add_boot_mode(struct lb_header *header) mode->size = sizeof(*mode); mode->boot_mode = get_boot_mode(); - /* Enable charging only during off-mode or low-battery mode and charger present */ - if (is_low_power_boot() && google_chromeec_is_charger_present()) + /* Enable charging only during off-mode or low-battery mode with charger present */ + if (is_low_power_boot_with_charger()) enable_slow_battery_charging(); } bool mainboard_needs_pcie_init(void) { /* Skip PCIe initialization if boot mode is "low-battery" or "off-mode charging"*/ - if (is_low_power_boot()) + if (is_low_power_boot_with_charger()) return false; return true; @@ -152,7 +154,7 @@ static void mainboard_init(struct device *dev) configure_parallel_charging(); /* Skip mainboard initialization if boot mode is "low-battery" or "off-mode charging"*/ - if (is_low_power_boot()) + if (is_low_power_boot_with_charger()) return; gpi_firmware_load(QUP_0_GSI_BASE); diff --git a/src/mainboard/google/bluey/romstage.c b/src/mainboard/google/bluey/romstage.c index aeb1eeda6b..c25704f077 100644 --- a/src/mainboard/google/bluey/romstage.c +++ b/src/mainboard/google/bluey/romstage.c @@ -39,8 +39,9 @@ static enum boot_mode_t set_boot_mode(void) enum boot_mode_t boot_mode_new = LB_BOOT_MODE_NORMAL; if (is_off_mode()) boot_mode_new = LB_BOOT_MODE_OFFMODE_CHARGING; - else if (google_chromeec_is_below_critical_threshold()) - boot_mode_new = LB_BOOT_MODE_LOW_BATTERY; + else if (google_chromeec_is_below_critical_threshold() && + google_chromeec_is_charger_present()) + boot_mode_new = LB_BOOT_MODE_LOW_BATTERY_CHARGING; boot_mode = boot_mode_new; return boot_mode_new; }