Skip to content

Commit

Permalink
Record SMBIOS Wake-up Type
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
crawfxrd committed Jul 19, 2023
1 parent 0d83819 commit d455346
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/board/system76/common/include/board/power.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions src/board/system76/common/power.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d455346

Please sign in to comment.