From 0379c6ed35381d9ba8f964bb55722a10de3b710d Mon Sep 17 00:00:00 2001 From: Tim Crawford Date: Wed, 19 Feb 2020 15:18:41 -0700 Subject: [PATCH] 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