From d08bfc8fddce8d6068f8bb4f54ee8dbe440e0f13 Mon Sep 17 00:00:00 2001 From: Tim Crawford Date: Fri, 21 Feb 2020 14:31:46 -0700 Subject: [PATCH 1/4] pmc: Reduce logs from DEBUG to TRACE --- src/board/system76/darp5/pmc.c | 14 +++++++------- src/board/system76/galp3-c/pmc.c | 14 +++++++------- src/board/system76/lemp9/pmc.c | 14 +++++++------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/board/system76/darp5/pmc.c b/src/board/system76/darp5/pmc.c index 0db98f8..8387b6d 100644 --- a/src/board/system76/darp5/pmc.c +++ b/src/board/system76/darp5/pmc.c @@ -63,7 +63,7 @@ void pmc_event(struct Pmc * pmc) { if (sts & PMC_STS_IBF) { uint8_t data = pmc_read(pmc); if (sts & PMC_STS_CMD) { - DEBUG("pmc cmd: %02X\n", data); + TRACE("pmc cmd: %02X\n", data); state = PMC_STATE_DEFAULT; switch (data) { @@ -78,7 +78,7 @@ void pmc_event(struct Pmc * pmc) { pmc_sci_interrupt(); break; case 0x82: - DEBUG(" burst enable\n"); + TRACE(" burst enable\n"); // Set burst bit pmc_set_status(pmc, sts | (1 << 4)); // Send acknowledgement byte @@ -86,14 +86,14 @@ void pmc_event(struct Pmc * pmc) { state_data = 0x90; break; case 0x83: - DEBUG(" burst disable\n"); + TRACE(" burst disable\n"); // Clear burst bit pmc_set_status(pmc, sts & ~(1 << 4)); // Send SCI for IBF=0 pmc_sci_interrupt(); break; case 0x84: - DEBUG(" SCI queue\n"); + TRACE(" SCI queue\n"); // Clear SCI pending bit pmc_set_status(pmc, sts & ~(1 << 5)); // Send SCI queue @@ -104,13 +104,13 @@ void pmc_event(struct Pmc * pmc) { break; case 0xEC: - DEBUG(" scratch rom\n"); + TRACE(" scratch rom\n"); pmc_write(pmc, 0x76); scratch_trampoline(); break; } } else { - DEBUG("pmc data: %02X\n", data); + TRACE("pmc data: %02X\n", data); switch (state) { case PMC_STATE_ACPI_READ: @@ -141,7 +141,7 @@ void pmc_event(struct Pmc * pmc) { if (!(sts & PMC_STS_OBF)) { switch (state) { case PMC_STATE_WRITE: - DEBUG("pmc write: %02X\n", state_data); + TRACE("pmc write: %02X\n", state_data); state = PMC_STATE_DEFAULT; pmc_write(pmc, state_data); // Send SCI for OBF=1 diff --git a/src/board/system76/galp3-c/pmc.c b/src/board/system76/galp3-c/pmc.c index 0db98f8..8387b6d 100644 --- a/src/board/system76/galp3-c/pmc.c +++ b/src/board/system76/galp3-c/pmc.c @@ -63,7 +63,7 @@ void pmc_event(struct Pmc * pmc) { if (sts & PMC_STS_IBF) { uint8_t data = pmc_read(pmc); if (sts & PMC_STS_CMD) { - DEBUG("pmc cmd: %02X\n", data); + TRACE("pmc cmd: %02X\n", data); state = PMC_STATE_DEFAULT; switch (data) { @@ -78,7 +78,7 @@ void pmc_event(struct Pmc * pmc) { pmc_sci_interrupt(); break; case 0x82: - DEBUG(" burst enable\n"); + TRACE(" burst enable\n"); // Set burst bit pmc_set_status(pmc, sts | (1 << 4)); // Send acknowledgement byte @@ -86,14 +86,14 @@ void pmc_event(struct Pmc * pmc) { state_data = 0x90; break; case 0x83: - DEBUG(" burst disable\n"); + TRACE(" burst disable\n"); // Clear burst bit pmc_set_status(pmc, sts & ~(1 << 4)); // Send SCI for IBF=0 pmc_sci_interrupt(); break; case 0x84: - DEBUG(" SCI queue\n"); + TRACE(" SCI queue\n"); // Clear SCI pending bit pmc_set_status(pmc, sts & ~(1 << 5)); // Send SCI queue @@ -104,13 +104,13 @@ void pmc_event(struct Pmc * pmc) { break; case 0xEC: - DEBUG(" scratch rom\n"); + TRACE(" scratch rom\n"); pmc_write(pmc, 0x76); scratch_trampoline(); break; } } else { - DEBUG("pmc data: %02X\n", data); + TRACE("pmc data: %02X\n", data); switch (state) { case PMC_STATE_ACPI_READ: @@ -141,7 +141,7 @@ void pmc_event(struct Pmc * pmc) { if (!(sts & PMC_STS_OBF)) { switch (state) { case PMC_STATE_WRITE: - DEBUG("pmc write: %02X\n", state_data); + TRACE("pmc write: %02X\n", state_data); state = PMC_STATE_DEFAULT; pmc_write(pmc, state_data); // Send SCI for OBF=1 diff --git a/src/board/system76/lemp9/pmc.c b/src/board/system76/lemp9/pmc.c index 0db98f8..8387b6d 100644 --- a/src/board/system76/lemp9/pmc.c +++ b/src/board/system76/lemp9/pmc.c @@ -63,7 +63,7 @@ void pmc_event(struct Pmc * pmc) { if (sts & PMC_STS_IBF) { uint8_t data = pmc_read(pmc); if (sts & PMC_STS_CMD) { - DEBUG("pmc cmd: %02X\n", data); + TRACE("pmc cmd: %02X\n", data); state = PMC_STATE_DEFAULT; switch (data) { @@ -78,7 +78,7 @@ void pmc_event(struct Pmc * pmc) { pmc_sci_interrupt(); break; case 0x82: - DEBUG(" burst enable\n"); + TRACE(" burst enable\n"); // Set burst bit pmc_set_status(pmc, sts | (1 << 4)); // Send acknowledgement byte @@ -86,14 +86,14 @@ void pmc_event(struct Pmc * pmc) { state_data = 0x90; break; case 0x83: - DEBUG(" burst disable\n"); + TRACE(" burst disable\n"); // Clear burst bit pmc_set_status(pmc, sts & ~(1 << 4)); // Send SCI for IBF=0 pmc_sci_interrupt(); break; case 0x84: - DEBUG(" SCI queue\n"); + TRACE(" SCI queue\n"); // Clear SCI pending bit pmc_set_status(pmc, sts & ~(1 << 5)); // Send SCI queue @@ -104,13 +104,13 @@ void pmc_event(struct Pmc * pmc) { break; case 0xEC: - DEBUG(" scratch rom\n"); + TRACE(" scratch rom\n"); pmc_write(pmc, 0x76); scratch_trampoline(); break; } } else { - DEBUG("pmc data: %02X\n", data); + TRACE("pmc data: %02X\n", data); switch (state) { case PMC_STATE_ACPI_READ: @@ -141,7 +141,7 @@ void pmc_event(struct Pmc * pmc) { if (!(sts & PMC_STS_OBF)) { switch (state) { case PMC_STATE_WRITE: - DEBUG("pmc write: %02X\n", state_data); + TRACE("pmc write: %02X\n", state_data); state = PMC_STATE_DEFAULT; pmc_write(pmc, state_data); // Send SCI for OBF=1 From 3f5c3ead01bba8eb6224da5929079f5773986e82 Mon Sep 17 00:00:00 2001 From: Tim Crawford Date: Wed, 19 Feb 2020 14:15:43 -0700 Subject: [PATCH 2/4] power: Make power state global --- .../system76/darp5/include/board/power.h | 11 ++++++++ src/board/system76/darp5/power.c | 25 ++++++------------- .../system76/galp3-c/include/board/power.h | 11 ++++++++ src/board/system76/galp3-c/power.c | 25 ++++++------------- .../system76/lemp9/include/board/power.h | 11 ++++++++ src/board/system76/lemp9/power.c | 25 ++++++------------- 6 files changed, 57 insertions(+), 51 deletions(-) diff --git a/src/board/system76/darp5/include/board/power.h b/src/board/system76/darp5/include/board/power.h index 504ed64..9c29f84 100644 --- a/src/board/system76/darp5/include/board/power.h +++ b/src/board/system76/darp5/include/board/power.h @@ -1,6 +1,17 @@ #ifndef _BOARD_POWER_H #define _BOARD_POWER_H +enum PowerState { + POWER_STATE_DEFAULT, + POWER_STATE_DS5, + POWER_STATE_S5, + POWER_STATE_DS3, + POWER_STATE_S3, + POWER_STATE_S0, +}; + +extern enum PowerState power_state; + void power_event(void); #endif // _BOARD_POWER_H diff --git a/src/board/system76/darp5/power.c b/src/board/system76/darp5/power.c index 21898c2..d628657 100644 --- a/src/board/system76/darp5/power.c +++ b/src/board/system76/darp5/power.c @@ -51,6 +51,8 @@ extern uint8_t main_cycle; // RSMRST# de-assertion to SUSPWRDNACK valid #define tPLT01 delay_ms(200) +enum PowerState power_state = POWER_STATE_DEFAULT; + // Enable deep sleep well power void power_on_ds5() { DEBUG("%02X: power_on_ds5\n", main_cycle); @@ -159,22 +161,11 @@ void power_off_s5() { #endif // DEEP_SX } -enum PowerState { - POWER_STATE_DEFAULT, - POWER_STATE_DS5, - POWER_STATE_S5, - POWER_STATE_DS3, - POWER_STATE_S3, - POWER_STATE_S0, -}; - void power_event(void) { - static enum PowerState state = POWER_STATE_DEFAULT; - // Always switch to ds5 if EC is running - if (state == POWER_STATE_DEFAULT) { + if (power_state == POWER_STATE_DEFAULT) { power_on_ds5(); - state = POWER_STATE_DS5; + power_state = POWER_STATE_DS5; } // Check if the adapter line goes low @@ -223,9 +214,9 @@ void power_event(void) { DEBUG("%02X: Power switch press\n", main_cycle); // Enable S5 power if necessary, before sending PWR_BTN - if (state == POWER_STATE_DS5) { + if (power_state == POWER_STATE_DS5) { power_on_s5(); - state = POWER_STATE_S5; + power_state = POWER_STATE_S5; } } } @@ -331,9 +322,9 @@ void power_event(void) { if (s4_new) { DEBUG("%02X: entering S3 state\n", main_cycle); - } else if (state == POWER_STATE_S5) { + } else if (power_state == POWER_STATE_S5) { power_off_s5(); - state = POWER_STATE_DS5; + power_state = POWER_STATE_DS5; } } #if LEVEL >= LEVEL_DEBUG diff --git a/src/board/system76/galp3-c/include/board/power.h b/src/board/system76/galp3-c/include/board/power.h index 504ed64..9c29f84 100644 --- a/src/board/system76/galp3-c/include/board/power.h +++ b/src/board/system76/galp3-c/include/board/power.h @@ -1,6 +1,17 @@ #ifndef _BOARD_POWER_H #define _BOARD_POWER_H +enum PowerState { + POWER_STATE_DEFAULT, + POWER_STATE_DS5, + POWER_STATE_S5, + POWER_STATE_DS3, + POWER_STATE_S3, + POWER_STATE_S0, +}; + +extern enum PowerState power_state; + void power_event(void); #endif // _BOARD_POWER_H diff --git a/src/board/system76/galp3-c/power.c b/src/board/system76/galp3-c/power.c index daeb04b..a884512 100644 --- a/src/board/system76/galp3-c/power.c +++ b/src/board/system76/galp3-c/power.c @@ -50,6 +50,8 @@ extern uint8_t main_cycle; // RSMRST# de-assertion to SUSPWRDNACK valid #define tPLT01 delay_ms(200) +enum PowerState power_state = POWER_STATE_DEFAULT; + // Enable deep sleep well power void power_on_ds5() { DEBUG("%02X: power_on_ds5\n", main_cycle); @@ -158,22 +160,11 @@ void power_off_s5() { #endif // DEEP_SX } -enum PowerState { - POWER_STATE_DEFAULT, - POWER_STATE_DS5, - POWER_STATE_S5, - POWER_STATE_DS3, - POWER_STATE_S3, - POWER_STATE_S0, -}; - void power_event(void) { - static enum PowerState state = POWER_STATE_DEFAULT; - // Always switch to ds5 if EC is running - if (state == POWER_STATE_DEFAULT) { + if (power_state == POWER_STATE_DEFAULT) { power_on_ds5(); - state = POWER_STATE_DS5; + power_state = POWER_STATE_DS5; } // Check if the adapter line goes low @@ -222,9 +213,9 @@ void power_event(void) { DEBUG("%02X: Power switch press\n", main_cycle); // Enable S5 power if necessary, before sending PWR_BTN - if (state == POWER_STATE_DS5) { + if (power_state == POWER_STATE_DS5) { power_on_s5(); - state = POWER_STATE_S5; + power_state = POWER_STATE_S5; } } } @@ -328,9 +319,9 @@ void power_event(void) { if (s4_new) { DEBUG("%02X: entering S3 state\n", main_cycle); - } else if (state == POWER_STATE_S5) { + } else if (power_state == POWER_STATE_S5) { power_off_s5(); - state = POWER_STATE_DS5; + power_state = POWER_STATE_DS5; } } #if LEVEL >= LEVEL_DEBUG diff --git a/src/board/system76/lemp9/include/board/power.h b/src/board/system76/lemp9/include/board/power.h index 504ed64..9c29f84 100644 --- a/src/board/system76/lemp9/include/board/power.h +++ b/src/board/system76/lemp9/include/board/power.h @@ -1,6 +1,17 @@ #ifndef _BOARD_POWER_H #define _BOARD_POWER_H +enum PowerState { + POWER_STATE_DEFAULT, + POWER_STATE_DS5, + POWER_STATE_S5, + POWER_STATE_DS3, + POWER_STATE_S3, + POWER_STATE_S0, +}; + +extern enum PowerState power_state; + void power_event(void); #endif // _BOARD_POWER_H diff --git a/src/board/system76/lemp9/power.c b/src/board/system76/lemp9/power.c index 9ca2950..63b1b8d 100644 --- a/src/board/system76/lemp9/power.c +++ b/src/board/system76/lemp9/power.c @@ -50,6 +50,8 @@ extern uint8_t main_cycle; // RSMRST# de-assertion to SUSPWRDNACK valid #define tPLT01 delay_ms(200) +enum PowerState power_state = POWER_STATE_DEFAULT; + // Enable deep sleep well power void power_on_ds5() { DEBUG("%02X: power_on_ds5\n", main_cycle); @@ -184,22 +186,11 @@ void power_off_s5() { #endif // DEEP_SX } -enum PowerState { - POWER_STATE_DEFAULT, - POWER_STATE_DS5, - POWER_STATE_S5, - POWER_STATE_DS3, - POWER_STATE_S3, - POWER_STATE_S0, -}; - void power_event(void) { - static enum PowerState state = POWER_STATE_DEFAULT; - // Always switch to ds5 if EC is running - if (state == POWER_STATE_DEFAULT) { + if (power_state == POWER_STATE_DEFAULT) { power_on_ds5(); - state = POWER_STATE_DS5; + power_state = POWER_STATE_DS5; } // Check if the adapter line goes low @@ -248,9 +239,9 @@ void power_event(void) { DEBUG("%02X: Power switch press\n", main_cycle); // Enable S5 power if necessary, before sending PWR_BTN - if (state == POWER_STATE_DS5) { + if (power_state == POWER_STATE_DS5) { power_on_s5(); - state = POWER_STATE_S5; + power_state = POWER_STATE_S5; } } } @@ -354,9 +345,9 @@ void power_event(void) { if (s4_new) { DEBUG("%02X: entering S3 state\n", main_cycle); - } else if (state == POWER_STATE_S5) { + } else if (power_state == POWER_STATE_S5) { power_off_s5(); - state = POWER_STATE_DS5; + power_state = POWER_STATE_DS5; } } #if LEVEL >= LEVEL_DEBUG From 0379c6ed35381d9ba8f964bb55722a10de3b710d Mon Sep 17 00:00:00 2001 From: Tim Crawford Date: Wed, 19 Feb 2020 15:18:41 -0700 Subject: [PATCH 3/4] power: Add more state transitions --- src/board/system76/darp5/power.c | 12 +++++++++--- src/board/system76/galp3-c/power.c | 12 +++++++++--- src/board/system76/lemp9/power.c | 12 +++++++++--- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/board/system76/darp5/power.c b/src/board/system76/darp5/power.c index d628657..00492aa 100644 --- a/src/board/system76/darp5/power.c +++ b/src/board/system76/darp5/power.c @@ -82,6 +82,8 @@ void power_on_ds5() { // tPCH04 is the ideal delay tPCH04; #endif // DEEP_SX + + power_state = POWER_STATE_DS5; } // Enable S5 power @@ -128,6 +130,8 @@ void power_on_s5() { // Extra wait - TODO remove delay_ms(200); #endif // DEEP_SX + + power_state = POWER_STATE_S5; } void power_off_s5() { @@ -159,13 +163,14 @@ void power_off_s5() { gpio_set(&PCH_DPWROK_EC, false); tPCH14; #endif // DEEP_SX + + power_state = POWER_STATE_DS5; } void power_event(void) { // Always switch to ds5 if EC is running if (power_state == POWER_STATE_DEFAULT) { power_on_ds5(); - power_state = POWER_STATE_DS5; } // Check if the adapter line goes low @@ -216,7 +221,6 @@ void power_event(void) { // Enable S5 power if necessary, before sending PWR_BTN if (power_state == POWER_STATE_DS5) { power_on_s5(); - power_state = POWER_STATE_S5; } } } @@ -277,6 +281,8 @@ void power_event(void) { //TODO: reset KBC and touchpad states kbled_reset(); + + power_state = POWER_STATE_S0; } rst_last = rst_new; @@ -322,9 +328,9 @@ void power_event(void) { if (s4_new) { DEBUG("%02X: entering S3 state\n", main_cycle); + power_state = POWER_STATE_S3; } else if (power_state == POWER_STATE_S5) { power_off_s5(); - power_state = POWER_STATE_DS5; } } #if LEVEL >= LEVEL_DEBUG diff --git a/src/board/system76/galp3-c/power.c b/src/board/system76/galp3-c/power.c index a884512..a5954a5 100644 --- a/src/board/system76/galp3-c/power.c +++ b/src/board/system76/galp3-c/power.c @@ -81,6 +81,8 @@ void power_on_ds5() { // tPCH04 is the ideal delay tPCH04; #endif // DEEP_SX + + power_state = POWER_STATE_DS5; } // Enable S5 power @@ -127,6 +129,8 @@ void power_on_s5() { // Extra wait - TODO remove delay_ms(200); #endif // DEEP_SX + + power_state = POWER_STATE_S5; } void power_off_s5() { @@ -158,13 +162,14 @@ void power_off_s5() { gpio_set(&PCH_DPWROK_EC, false); tPCH14; #endif // DEEP_SX + + power_state = POWER_STATE_DS5; } void power_event(void) { // Always switch to ds5 if EC is running if (power_state == POWER_STATE_DEFAULT) { power_on_ds5(); - power_state = POWER_STATE_DS5; } // Check if the adapter line goes low @@ -215,7 +220,6 @@ void power_event(void) { // Enable S5 power if necessary, before sending PWR_BTN if (power_state == POWER_STATE_DS5) { power_on_s5(); - power_state = POWER_STATE_S5; } } } @@ -274,6 +278,8 @@ void power_event(void) { // LPC was just reset, enable PNP devices pnp_enable(); //TODO: reset KBC and touchpad states + + power_state = POWER_STATE_S0; } rst_last = rst_new; @@ -319,9 +325,9 @@ void power_event(void) { if (s4_new) { DEBUG("%02X: entering S3 state\n", main_cycle); + power_state = POWER_STATE_S3; } else if (power_state == POWER_STATE_S5) { power_off_s5(); - power_state = POWER_STATE_DS5; } } #if LEVEL >= LEVEL_DEBUG diff --git a/src/board/system76/lemp9/power.c b/src/board/system76/lemp9/power.c index 63b1b8d..44c0649 100644 --- a/src/board/system76/lemp9/power.c +++ b/src/board/system76/lemp9/power.c @@ -81,6 +81,8 @@ void power_on_ds5() { // tPCH04 is the ideal delay tPCH04; #endif // DEEP_SX + + power_state = POWER_STATE_DS5; } // Enable S5 power @@ -153,6 +155,8 @@ void power_on_s5() { // Extra wait - TODO remove delay_ms(200); #endif // DEEP_SX + + power_state = POWER_STATE_S5; } void power_off_s5() { @@ -184,13 +188,14 @@ void power_off_s5() { gpio_set(&PCH_DPWROK_EC, false); tPCH14; #endif // DEEP_SX + + power_state = POWER_STATE_DS5; } void power_event(void) { // Always switch to ds5 if EC is running if (power_state == POWER_STATE_DEFAULT) { power_on_ds5(); - power_state = POWER_STATE_DS5; } // Check if the adapter line goes low @@ -241,7 +246,6 @@ void power_event(void) { // Enable S5 power if necessary, before sending PWR_BTN if (power_state == POWER_STATE_DS5) { power_on_s5(); - power_state = POWER_STATE_S5; } } } @@ -300,6 +304,8 @@ void power_event(void) { // LPC was just reset, enable PNP devices pnp_enable(); //TODO: reset KBC and touchpad states + + power_state = POWER_STATE_S0; } rst_last = rst_new; @@ -345,9 +351,9 @@ void power_event(void) { if (s4_new) { DEBUG("%02X: entering S3 state\n", main_cycle); + power_state = POWER_STATE_S3; } else if (power_state == POWER_STATE_S5) { power_off_s5(); - power_state = POWER_STATE_DS5; } } #if LEVEL >= LEVEL_DEBUG From 3014fb3a41720477bd9d3b7692fe63d3bb9b97ed Mon Sep 17 00:00:00 2001 From: Tim Crawford Date: Thu, 20 Feb 2020 13:51:09 -0700 Subject: [PATCH 4/4] Wake from S3 using any key --- src/board/system76/darp5/kbscan.c | 8 ++++++++ src/board/system76/galp3-c/kbscan.c | 8 ++++++++ src/board/system76/lemp9/kbscan.c | 8 ++++++++ 3 files changed, 24 insertions(+) diff --git a/src/board/system76/darp5/kbscan.c b/src/board/system76/darp5/kbscan.c index 9659320..0257d89 100644 --- a/src/board/system76/darp5/kbscan.c +++ b/src/board/system76/darp5/kbscan.c @@ -5,6 +5,7 @@ #include #include #include +#include #include bool kbscan_enabled = false; @@ -29,6 +30,13 @@ void kbscan_init(void) { #define DEBOUNCE_DELAY 20 bool kbscan_press(uint16_t key, bool pressed, uint8_t * layer) { + if (pressed && + (power_state == POWER_STATE_S3 || power_state == POWER_STATE_DS3)) { + gpio_set(&SWI_N, false); + delay_ticks(10); //TODO: find correct delay + gpio_set(&SWI_N, true); + } + switch (key & KT_MASK) { case (KT_NORMAL): if (kbscan_enabled) { diff --git a/src/board/system76/galp3-c/kbscan.c b/src/board/system76/galp3-c/kbscan.c index a14be2d..f19e54e 100644 --- a/src/board/system76/galp3-c/kbscan.c +++ b/src/board/system76/galp3-c/kbscan.c @@ -6,6 +6,7 @@ #include #include #include +#include #include bool kbscan_enabled = false; @@ -30,6 +31,13 @@ void kbscan_init(void) { #define DEBOUNCE_DELAY 20 bool kbscan_press(uint16_t key, bool pressed, uint8_t * layer) { + if (pressed && + (power_state == POWER_STATE_S3 || power_state == POWER_STATE_DS3)) { + gpio_set(&SWI_N, false); + delay_ticks(10); //TODO: find correct delay + gpio_set(&SWI_N, true); + } + switch (key & KT_MASK) { case (KT_NORMAL): if (kbscan_enabled) { diff --git a/src/board/system76/lemp9/kbscan.c b/src/board/system76/lemp9/kbscan.c index a14be2d..f19e54e 100644 --- a/src/board/system76/lemp9/kbscan.c +++ b/src/board/system76/lemp9/kbscan.c @@ -6,6 +6,7 @@ #include #include #include +#include #include bool kbscan_enabled = false; @@ -30,6 +31,13 @@ void kbscan_init(void) { #define DEBOUNCE_DELAY 20 bool kbscan_press(uint16_t key, bool pressed, uint8_t * layer) { + if (pressed && + (power_state == POWER_STATE_S3 || power_state == POWER_STATE_DS3)) { + gpio_set(&SWI_N, false); + delay_ticks(10); //TODO: find correct delay + gpio_set(&SWI_N, true); + } + switch (key & KT_MASK) { case (KT_NORMAL): if (kbscan_enabled) {