Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/intel.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,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 @@ -560,6 +565,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