From c4ee22e2675b2a980f7ebb1924fd13d60b967cab Mon Sep 17 00:00:00 2001 From: Kapil Porwal Date: Wed, 17 Dec 2025 18:44:33 +0530 Subject: [PATCH] Reapply "mb/google/bluey: Implement EC-based off-mode detection" This reverts commit b67725d3f51c141b9ee3c4ad9c16cafd38a54e44. Reason: Warm reset issue is fixed in new QC blobs. Change-Id: Iab1e0b7085f5d116704c54da4d286bb41b502853 Signed-off-by: Kapil Porwal Reviewed-on: https://review.coreboot.org/c/coreboot/+/90542 Reviewed-by: Subrata Banik Tested-by: build bot (Jenkins) --- src/mainboard/google/bluey/charging.c | 16 ---------------- src/mainboard/google/bluey/romstage.c | 26 +++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/src/mainboard/google/bluey/charging.c b/src/mainboard/google/bluey/charging.c index 56deedcdb9..bbb849d438 100644 --- a/src/mainboard/google/bluey/charging.c +++ b/src/mainboard/google/bluey/charging.c @@ -43,19 +43,3 @@ void disable_slow_battery_charging(void) spmi_write8(SMB1_CHGR_CHRG_EN_CMD, CHRG_DISABLE); spmi_write8(SMB2_CHGR_CHRG_EN_CMD, CHRG_DISABLE); } - -/* - * is_off_mode - Check if the system is booting due to an off-mode power event. - * - * This function provides the board-level policy wrapper for detecting if the - * system power-on was triggered by an external charging event (e.g., cable - * insertion). This is typically used to enter LB_BOOT_MODE_OFFMODE_CHARGING. - * - * @return true if the system was triggered by a specific off-mode reason - * (e.g., charging cable insertion). - * @return false otherwise. - */ -bool is_off_mode(void) -{ - return is_pon_on_ac(); -} diff --git a/src/mainboard/google/bluey/romstage.c b/src/mainboard/google/bluey/romstage.c index c2cbf5b7c4..657c7ad177 100644 --- a/src/mainboard/google/bluey/romstage.c +++ b/src/mainboard/google/bluey/romstage.c @@ -14,6 +14,31 @@ static enum boot_mode_t boot_mode = LB_BOOT_MODE_NORMAL; +/* + * is_off_mode - Check if the system is booting due to an off-mode power event. + * + * This function provides the board-level policy wrapper for detecting if the + * system power-on was triggered by an external charging event (e.g., cable + * insertion). This is typically used to enter LB_BOOT_MODE_OFFMODE_CHARGING. + * + * @return true if the system was triggered by a specific off-mode reason + * (e.g., charging cable insertion). + * @return false otherwise. + */ +bool is_off_mode(void) +{ + const uint64_t manual_pwron_event_mask = + (EC_HOST_EVENT_MASK(EC_HOST_EVENT_POWER_BUTTON) | + EC_HOST_EVENT_MASK(EC_HOST_EVENT_LID_OPEN)); + uint64_t ec_events = google_chromeec_get_events_b(); + + if (!(ec_events & manual_pwron_event_mask) && + (ec_events & EC_HOST_EVENT_MASK(EC_HOST_EVENT_AC_CONNECTED))) + return true; + + return false; +} + static void set_boot_mode(void) { if (!CONFIG(EC_GOOGLE_CHROMEEC)) @@ -35,7 +60,6 @@ void platform_romstage_main(void) /* QCLib: DDR init & train */ qclib_load_and_run(); - /* Underlying PMIC registers are accessible only at this point */ set_boot_mode(); aop_fw_load_reset();