power: Add more state transitions

This commit is contained in:
Tim Crawford 2020-02-19 15:18:41 -07:00
parent 3f5c3ead01
commit 0379c6ed35
3 changed files with 27 additions and 9 deletions

View File

@ -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

View File

@ -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

View File

@ -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