diff --git a/src/board/system76/common/include/board/power.h b/src/board/system76/common/include/board/power.h index ee372da94..b1c789984 100644 --- a/src/board/system76/common/include/board/power.h +++ b/src/board/system76/common/include/board/power.h @@ -13,6 +13,21 @@ enum PowerState { extern enum PowerState power_state; void update_power_state(void); +// SMBIOS Wake-up Type +enum PowerWakeupType { + POWER_WAKEUP_TYPE_RESERVED = 0, + POWER_WAKEUP_TYPE_OTHER = 1, + POWER_WAKEUP_TYPE_UNKNOWN = 2, + POWER_WAKEUP_TYPE_APM_TIMER = 3, + POWER_WAKEUP_TYPE_MODEM_RING = 4, + POWER_WAKEUP_TYPE_LAN_REMOTE = 5, + POWER_WAKEUP_TYPE_POWER_SWITCH = 6, + POWER_WAKEUP_TYPE_PCI_PME = 7, + POWER_WAKEUP_TYPE_AC_POWER_RESTORED = 8, +}; + +extern enum PowerWakeupType power_wakeup_type; + void power_init(void); void power_on(void); void power_off(void); diff --git a/src/board/system76/common/power.c b/src/board/system76/common/power.c index 66fedc75d..9e3668c15 100644 --- a/src/board/system76/common/power.c +++ b/src/board/system76/common/power.c @@ -123,6 +123,10 @@ extern uint8_t main_cycle; enum PowerState power_state = POWER_STATE_OFF; +// Event that caused the system to power on. +// Note: Must not be Reserved (0x00) or Unknown (0x02) when reported. +enum PowerWakeupType power_wakeup_type = POWER_WAKEUP_TYPE_UNKNOWN; + enum PowerState calculate_power_state(void) { if (!gpio_get(&EC_RSMRST_N)) { // S5 plane not powered @@ -435,6 +439,7 @@ void power_event(void) { if (config_should_reset()) config_reset(); power_on(); + power_wakeup_type = POWER_WAKEUP_TYPE_POWER_SWITCH; // After power on ensure there is no secondary press sent to PCH ps_new = ps_last; @@ -562,6 +567,7 @@ void power_event(void) { DEBUG("%02X: LAN_WAKEUP# asserted\n", main_cycle); if (power_state == POWER_STATE_OFF) { power_on(); + power_wakeup_type = POWER_WAKEUP_TYPE_LAN_REMOTE; } } #if LEVEL >= LEVEL_DEBUG