diff options
author | Vijay Hiremath <vijay.p.hiremath@intel.com> | 2016-11-11 08:19:15 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-11-13 10:58:58 -0800 |
commit | 9b47a0812d963c4c02d47655741f63618bd41a22 (patch) | |
tree | bbef05891b30210b8d84d5fc9c2f054738846e75 /power/skylake.c | |
parent | 98402bb466e53cbe7b0d47287823126f7de0fdb8 (diff) | |
download | chrome-ec-9b47a0812d963c4c02d47655741f63618bd41a22.tar.gz |
skylake: Add support to S0iX based on host commands from Kernel
Picked the code from Glados branch.
Change-Id: I4bf114235c4d542dd7cf0dad6427c771e54d4611
https://chromium-review.googlesource.com/#/c/331358/
BUG=chrome-os-partner:59742
BRANCH=none
TEST=make buildall -j
Change-Id: Ib79f1209dfd9e6a9de0438cb1866bba2939e5393
Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/410036
Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com>
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-by: Kevin K Wong <kevin.k.wong@intel.com>
Diffstat (limited to 'power/skylake.c')
-rw-r--r-- | power/skylake.c | 107 |
1 files changed, 53 insertions, 54 deletions
diff --git a/power/skylake.c b/power/skylake.c index 718ff5aeca..a90921e327 100644 --- a/power/skylake.c +++ b/power/skylake.c @@ -26,21 +26,13 @@ #define CPRINTS(format, args...) cprints(CC_CHIPSET, format, ## args) /* Input state flags */ -#define IN_PCH_SLP_S0_DEASSERTED POWER_SIGNAL_MASK(X86_SLP_S0_DEASSERTED) #define IN_PCH_SLP_S3_DEASSERTED POWER_SIGNAL_MASK(X86_SLP_S3_DEASSERTED) #define IN_PCH_SLP_S4_DEASSERTED POWER_SIGNAL_MASK(X86_SLP_S4_DEASSERTED) #define IN_PCH_SLP_SUS_DEASSERTED POWER_SIGNAL_MASK(X86_SLP_SUS_DEASSERTED) -#ifdef CONFIG_POWER_S0IX -#define IN_ALL_PM_SLP_DEASSERTED (IN_PCH_SLP_S0_DEASSERTED | \ - IN_PCH_SLP_S3_DEASSERTED | \ - IN_PCH_SLP_S4_DEASSERTED | \ - IN_PCH_SLP_SUS_DEASSERTED) -#else #define IN_ALL_PM_SLP_DEASSERTED (IN_PCH_SLP_S3_DEASSERTED | \ IN_PCH_SLP_S4_DEASSERTED | \ IN_PCH_SLP_SUS_DEASSERTED) -#endif /* * DPWROK is NC / stuffing option on initial boards. @@ -63,6 +55,19 @@ enum sys_sleep_state { SYS_SLEEP_S3 }; +#ifdef CONFIG_POWER_S0IX +static int slp_s0ix_host_evt = 1; +static int get_slp_s0ix_host_evt(void) +{ + return slp_s0ix_host_evt; +} + +static void set_slp_s0ix_host_evt(int val) +{ + slp_s0ix_host_evt = val; +} +#endif + /* Get system sleep state through GPIOs or VWs */ static int chipset_get_sleep_signal(enum sys_sleep_state state) { @@ -279,7 +284,7 @@ static enum power_state _power_handle_state(enum power_state state) chipset_force_shutdown(); return POWER_S0S3; #ifdef CONFIG_POWER_S0IX - } else if ((gpio_get_level(GPIO_PCH_SLP_S0_L) == 0) && + } else if ((get_slp_s0ix_host_evt() == 0) && (chipset_get_sleep_signal(SYS_SLEEP_S3) == 1)) { return POWER_S0S0ix; #endif @@ -295,7 +300,7 @@ static enum power_state _power_handle_state(enum power_state state) /* * TODO: add code for unexpected power loss */ - if ((gpio_get_level(GPIO_PCH_SLP_S0_L) == 1) && + if ((get_slp_s0ix_host_evt() == 1) && (chipset_get_sleep_signal(SYS_SLEEP_S3) == 1)) { return POWER_S0ixS0; } @@ -341,6 +346,14 @@ static enum power_state _power_handle_state(enum power_state state) /* Call hooks now that rails are up */ hook_notify(HOOK_CHIPSET_STARTUP); + +#ifdef CONFIG_POWER_S0IX + /* + * Clearing the S0ix flag on the path to S0 + * to handle any reset conditions. + */ + set_slp_s0ix_host_evt(1); +#endif return POWER_S3; case POWER_S3S0: @@ -387,6 +400,10 @@ static enum power_state _power_handle_state(enum power_state state) */ enable_sleep(SLEEP_MASK_AP_RUN); +#ifdef CONFIG_POWER_S0IX + /* re-init S0ix flag */ + set_slp_s0ix_host_evt(1); +#endif return POWER_S3; #ifdef CONFIG_POWER_S0IX @@ -460,53 +477,35 @@ enum power_state power_handle_state(enum power_state state) } #ifdef CONFIG_POWER_S0IX -static struct { - int required; /* indicates de-bounce required. */ - int done; /* debounced */ -} slp_s0_debounce = { - .required = 0, - .done = 1, -}; - -int chipset_get_ps_debounced_level(enum gpio_signal signal) -{ - /* - * If power state is updated in power_update_signal() by any interrupts - * other than SLP_S0 during the 1 msec pulse(invalid SLP_S0 signal), - * reading SLP_S0 should be corrected with slp_s0_debounce.done flag. - */ - int level = gpio_get_level(signal); - return (signal == GPIO_PCH_SLP_S0_L) ? - (level & slp_s0_debounce.done) : level; -} - -static void slp_s0_assertion_deferred(void) +/* + * EC enters S0ix via a host command and exits S0ix via the above + * lid open hook. The host event for exit is received but is a no-op for now. + * + * EC will not react directly to SLP_S0 signal interrupts anymore. + */ +static int host_event_sleep_event(struct host_cmd_handler_args *args) { - int s0_level = gpio_get_level(GPIO_PCH_SLP_S0_L); - /* - (s0_level != 0) || - ((s0_level == 0) && (slp_s0_debounce.required == 0)) - */ - if (s0_level == slp_s0_debounce.required) { - if (s0_level) - slp_s0_debounce.done = 1; /* debounced! */ - - power_signal_interrupt(GPIO_PCH_SLP_S0_L); + const struct ec_params_host_sleep_event *p = args->params; + + if (p->sleep_event == HOST_SLEEP_EVENT_S0IX_SUSPEND) { + CPRINTS("S0ix sus evt"); + set_slp_s0ix_host_evt(0); + task_wake(TASK_ID_CHIPSET); + } else if (p->sleep_event == HOST_SLEEP_EVENT_S0IX_RESUME) { + CPRINTS("S0ix res evt"); + set_slp_s0ix_host_evt(1); + /* + * For all scenarios where lid is not open + * this will be trigerred when other wake + * sources like keyboard, trackpad are used. + */ + if (!chipset_in_state(CHIPSET_STATE_ON)) + task_wake(TASK_ID_CHIPSET); } - slp_s0_debounce.required = 0; + return EC_RES_SUCCESS; } -DECLARE_DEFERRED(slp_s0_assertion_deferred); +DECLARE_HOST_COMMAND(EC_CMD_HOST_SLEEP_EVENT, host_event_sleep_event, + EC_VER_MASK(0)); -void power_signal_interrupt_S0(enum gpio_signal signal) -{ - if (gpio_get_level(GPIO_PCH_SLP_S0_L)) { - slp_s0_debounce.required = 1; - hook_call_deferred(&slp_s0_assertion_deferred_data, 3 * MSEC); - } - else if (slp_s0_debounce.required == 0) { - slp_s0_debounce.done = 0; - slp_s0_assertion_deferred(); - } -} #endif |