From 8c7fd7c44b2e793e24eaf0500a29e031458181ef Mon Sep 17 00:00:00 2001 From: Tim Crawford Date: Tue, 10 Jan 2023 13:09:36 -0700 Subject: [PATCH] Record SMBIOS Wake-up Type Wake-up Type identifies the event that caused the system to power on. Only power switch and Wake-on-LAN are currently implemented. The list of values is defined in section 7.2.2 System - Wake-up Type. Ref: SMBIOS Reference Specification 3.6.0 Signed-off-by: Tim Crawford --- src/board/system76/common/include/board/power.h | 15 +++++++++++++++ src/board/system76/common/power.c | 6 ++++++ 2 files changed, 21 insertions(+) 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 d2f838729..e0f21cb93 100644 --- a/src/board/system76/common/power.c +++ b/src/board/system76/common/power.c @@ -124,6 +124,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 @@ -437,6 +441,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; @@ -564,6 +569,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