From 126a303c69a77a7bf7317bc5778c68ed16ed326a Mon Sep 17 00:00:00 2001 From: Furquan Shaikh Date: Wed, 22 Nov 2017 20:55:14 -0800 Subject: chipset: Introduce CHIPSET_STATE_ANY_SUSPEND There are two different types of suspend states that are supported on x86 platforms -- S3 and S0ix. When AP enters S3, the chipset state is identified as CHIPSET_STATE_SUSPEND. On the other hand, when AP enters S0ix, the chipset state is identified as CHIPSET_STATE_STANDBY. There are several components within the EC e.g. charger state machine, usb pd task, motion sense task that take actions based on the chipset suspend state (and checked only for CHIPSET_STATE_SUSPEND until now). In order to ensure that different EC components do not have to worry about checking for all the different types of suspend states that are supported, introduce a new combination CHIPSET_STATE_ANY_SUSPEND which is a combination of CHIPSET_STATE_SUSPEND(S3) and CHIPSET_STATE_STANDBY(S0ix). BUG=b:69690699 BRANCH=None TEST=make -j buildall. Ruben verified that with this change, EC power consumption in S0ix drops from 7.85mW to 6.59mW on Soraka. Change-Id: I599a0ea2fe2f39132764a6068fa77c3aea02affa Signed-off-by: Furquan Shaikh Reviewed-on: https://chromium-review.googlesource.com/786919 Reviewed-by: Aaron Durbin --- board/chell/led.c | 2 +- board/coral/led.c | 6 ++---- board/grunt/led.c | 2 +- board/kahlee/led.c | 2 +- board/reef/led.c | 3 +-- board/reef_it8320/led.c | 3 +-- board/zoombini/led.c | 3 +-- common/charge_state_v2.c | 2 +- common/led_policy_std.c | 3 +-- common/usb_pd_protocol.c | 2 +- include/chipset.h | 3 +++ include/motion_sense.h | 2 +- 12 files changed, 15 insertions(+), 18 deletions(-) diff --git a/board/chell/led.c b/board/chell/led.c index c117e53a3e..51808e9071 100644 --- a/board/chell/led.c +++ b/board/chell/led.c @@ -85,7 +85,7 @@ static void board_led_set_battery(void) battery_ticks++; power_ticks++; - if (chipset_in_state(CHIPSET_STATE_SUSPEND | CHIPSET_STATE_STANDBY)) { + if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND)) { /* * Reset ticks if entering suspend so LED turns white * as soon as possible. diff --git a/board/coral/led.c b/board/coral/led.c index 6050ba64b9..6b2200ffed 100644 --- a/board/coral/led.c +++ b/board/coral/led.c @@ -196,8 +196,7 @@ static enum led_states led_get_state(void) case PWR_STATE_DISCHARGE /* and PWR_STATE_DISCHARGE_FULL */: if (chipset_in_state(CHIPSET_STATE_ON)) new_state = STATE_DISCHARGE_S0; - else if (chipset_in_state(CHIPSET_STATE_SUSPEND) | - chipset_in_state(CHIPSET_STATE_STANDBY)) + else if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND)) new_state = STATE_DISCHARGE_S3; else new_state = STATE_DISCHARGE_S5; @@ -270,8 +269,7 @@ static void led_robo_update_power(void) /* In S0 power LED is always on */ level = LED_ON_LVL; ticks = 0; - } else if ((chipset_in_state(CHIPSET_STATE_SUSPEND) | - chipset_in_state(CHIPSET_STATE_STANDBY)) && + } else if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND) && led.state <= STATE_CHARGING_LVL_3) { int period; diff --git a/board/grunt/led.c b/board/grunt/led.c index 5770252331..43e35848a0 100644 --- a/board/grunt/led.c +++ b/board/grunt/led.c @@ -157,7 +157,7 @@ static void led_set_power(void) suspend_ticks++; - if (chipset_in_state(CHIPSET_STATE_SUSPEND | CHIPSET_STATE_STANDBY)) { + if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND)) { if (!previous_state_suspend) suspend_ticks = 0; /* Blink once every four seconds. */ diff --git a/board/kahlee/led.c b/board/kahlee/led.c index dce9e27864..9e60018ae5 100644 --- a/board/kahlee/led.c +++ b/board/kahlee/led.c @@ -157,7 +157,7 @@ static void led_set_power(void) suspend_ticks++; - if (chipset_in_state(CHIPSET_STATE_SUSPEND | CHIPSET_STATE_STANDBY)) { + if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND)) { if (!previous_state_suspend) suspend_ticks = 0; /* Blink once every four seconds. */ diff --git a/board/reef/led.c b/board/reef/led.c index b559a00da8..807b1c109c 100644 --- a/board/reef/led.c +++ b/board/reef/led.c @@ -109,8 +109,7 @@ static void led_set_battery(void) case PWR_STATE_DISCHARGE /* and PWR_STATE_DISCHARGE_FULL */: if (chipset_in_state(CHIPSET_STATE_ON)) { led_set_color_battery(LED_BLUE); - } else if (chipset_in_state(CHIPSET_STATE_SUSPEND | - CHIPSET_STATE_STANDBY)) { + } else if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND)) { /* Blink once every four seconds. */ led_set_color_battery( (suspend_ticks % LED_TOTAL_4SECS_TICKS) diff --git a/board/reef_it8320/led.c b/board/reef_it8320/led.c index 5c2c15482d..a1ea5964a8 100644 --- a/board/reef_it8320/led.c +++ b/board/reef_it8320/led.c @@ -110,8 +110,7 @@ static void led_set_battery(void) case PWR_STATE_DISCHARGE /* and PWR_STATE_DISCHARGE_FULL */: if (chipset_in_state(CHIPSET_STATE_ON)) { led_set_color_battery(LED_BLUE); - } else if (chipset_in_state(CHIPSET_STATE_SUSPEND | - CHIPSET_STATE_STANDBY)) { + } else if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND)) { /* Blink once every four seconds. */ led_set_color_battery( (suspend_ticks % LED_TOTAL_4SECS_TICKS) diff --git a/board/zoombini/led.c b/board/zoombini/led.c index 30a2eea94c..2ba4d6511e 100644 --- a/board/zoombini/led.c +++ b/board/zoombini/led.c @@ -64,8 +64,7 @@ static void power_led_update(void) power_led_is_pulsing = 0; /* The power LED must be on in the Active state. */ set_led_state(EC_LED_ID_POWER, 1); - } else if (chipset_in_state(CHIPSET_STATE_SUSPEND | - CHIPSET_STATE_STANDBY)) { + } else if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND)) { /* The power LED must pulse in the Suspend state. */ if (!power_led_is_pulsing) { power_led_is_pulsing = 1; diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c index 4de4faf51a..014a647cce 100644 --- a/common/charge_state_v2.c +++ b/common/charge_state_v2.c @@ -959,7 +959,7 @@ wait_for_it: curr.state == ST_DISCHARGE) { /* If AP is off, we can sleep a long time */ if (chipset_in_state(CHIPSET_STATE_ANY_OFF | - CHIPSET_STATE_SUSPEND)) + CHIPSET_STATE_ANY_SUSPEND)) sleep_usec = CHARGE_POLL_PERIOD_VERY_LONG; else diff --git a/common/led_policy_std.c b/common/led_policy_std.c index 631d905754..e9fe4568a2 100644 --- a/common/led_policy_std.c +++ b/common/led_policy_std.c @@ -142,8 +142,7 @@ static void std_led_set_power(void) pwr_led_set_color(LED_OFF); else if (chipset_in_state(CHIPSET_STATE_ON)) pwr_led_set_color(LED_WHITE); - else if (chipset_in_state(CHIPSET_STATE_SUSPEND | - CHIPSET_STATE_STANDBY)) + else if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND)) pwr_led_set_color((power_second & 3) ? LED_OFF : LED_WHITE); } diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index 5dd8c87b1e..ab485963ee 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -1974,7 +1974,7 @@ static void pd_init_tasks(void) /* Set dual-role state based on chipset power state */ if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) drp_state = PD_DRP_FORCE_SINK; - else if (chipset_in_state(CHIPSET_STATE_SUSPEND)) + else if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND)) drp_state = PD_DRP_TOGGLE_OFF; else /* CHIPSET_STATE_ON */ drp_state = PD_DRP_TOGGLE_ON; diff --git a/include/chipset.h b/include/chipset.h index 3113643e17..ed19ba4df3 100644 --- a/include/chipset.h +++ b/include/chipset.h @@ -34,6 +34,9 @@ enum chipset_state_mask { /* Common combinations */ CHIPSET_STATE_ANY_OFF = (CHIPSET_STATE_HARD_OFF | CHIPSET_STATE_SOFT_OFF), /* Any off state */ + /* This combination covers any kind of suspend i.e. S3 or S0ix. */ + CHIPSET_STATE_ANY_SUSPEND = (CHIPSET_STATE_SUSPEND | + CHIPSET_STATE_STANDBY), }; #ifdef HAS_TASK_CHIPSET diff --git a/include/motion_sense.h b/include/motion_sense.h index 10ebfd05b3..0699824830 100644 --- a/include/motion_sense.h +++ b/include/motion_sense.h @@ -31,7 +31,7 @@ enum sensor_config { }; #define SENSOR_ACTIVE_S5 (CHIPSET_STATE_SOFT_OFF | CHIPSET_STATE_HARD_OFF) -#define SENSOR_ACTIVE_S3 CHIPSET_STATE_SUSPEND +#define SENSOR_ACTIVE_S3 CHIPSET_STATE_ANY_SUSPEND #define SENSOR_ACTIVE_S0 CHIPSET_STATE_ON #define SENSOR_ACTIVE_S0_S3 (SENSOR_ACTIVE_S3 | SENSOR_ACTIVE_S0) #define SENSOR_ACTIVE_S0_S3_S5 (SENSOR_ACTIVE_S0_S3 | SENSOR_ACTIVE_S5) -- cgit v1.2.1