Skip to content

Commit 8c7fd7c

Browse files
committed
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 <tcrawford@system76.com>
1 parent 01be30f commit 8c7fd7c

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/board/system76/common/include/board/power.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,21 @@ enum PowerState {
1313
extern enum PowerState power_state;
1414
void update_power_state(void);
1515

16+
// SMBIOS Wake-up Type
17+
enum PowerWakeupType {
18+
POWER_WAKEUP_TYPE_RESERVED = 0,
19+
POWER_WAKEUP_TYPE_OTHER = 1,
20+
POWER_WAKEUP_TYPE_UNKNOWN = 2,
21+
POWER_WAKEUP_TYPE_APM_TIMER = 3,
22+
POWER_WAKEUP_TYPE_MODEM_RING = 4,
23+
POWER_WAKEUP_TYPE_LAN_REMOTE = 5,
24+
POWER_WAKEUP_TYPE_POWER_SWITCH = 6,
25+
POWER_WAKEUP_TYPE_PCI_PME = 7,
26+
POWER_WAKEUP_TYPE_AC_POWER_RESTORED = 8,
27+
};
28+
29+
extern enum PowerWakeupType power_wakeup_type;
30+
1631
void power_init(void);
1732
void power_on(void);
1833
void power_off(void);

src/board/system76/common/power.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ extern uint8_t main_cycle;
124124

125125
enum PowerState power_state = POWER_STATE_OFF;
126126

127+
// Event that caused the system to power on.
128+
// Note: Must not be Reserved (0x00) or Unknown (0x02) when reported.
129+
enum PowerWakeupType power_wakeup_type = POWER_WAKEUP_TYPE_UNKNOWN;
130+
127131
enum PowerState calculate_power_state(void) {
128132
if (!gpio_get(&EC_RSMRST_N)) {
129133
// S5 plane not powered
@@ -437,6 +441,7 @@ void power_event(void) {
437441
if (config_should_reset())
438442
config_reset();
439443
power_on();
444+
power_wakeup_type = POWER_WAKEUP_TYPE_POWER_SWITCH;
440445

441446
// After power on ensure there is no secondary press sent to PCH
442447
ps_new = ps_last;
@@ -564,6 +569,7 @@ void power_event(void) {
564569
DEBUG("%02X: LAN_WAKEUP# asserted\n", main_cycle);
565570
if (power_state == POWER_STATE_OFF) {
566571
power_on();
572+
power_wakeup_type = POWER_WAKEUP_TYPE_LAN_REMOTE;
567573
}
568574
}
569575
#if LEVEL >= LEVEL_DEBUG

0 commit comments

Comments
 (0)