diff options
author | Shawn Nematbakhsh <shawnn@chromium.org> | 2016-03-27 20:46:48 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-03-29 15:56:22 -0700 |
commit | bfb7b69029a7efb1a4f08332a39479860e8771b7 (patch) | |
tree | 35bfe54d5eaf2af3e9c3139cb890cee91ed02fad /power | |
parent | 4e1ddc02c67ba692c459cb0cb49f1e1a6d77543e (diff) | |
download | chrome-ec-bfb7b69029a7efb1a4f08332a39479860e8771b7.tar.gz |
power: rk3399: Add power down sequencing
Add simple power down control for rk3399.
BUG=chrome-os-partner:51722
TEST=Verify power button powers up SOC. Verify next power button press
powers down SOC.
BRANCH=None
Change-Id: Ibf4c9c3cb155b59ca7f2b6feb4f51ff173f407c7
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/335531
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
Diffstat (limited to 'power')
-rw-r--r-- | power/rk3399.c | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/power/rk3399.c b/power/rk3399.c index aee07cce82..1ae89e3d3f 100644 --- a/power/rk3399.c +++ b/power/rk3399.c @@ -15,6 +15,7 @@ #include "power.h" #include "power_button.h" #include "system.h" +#include "task.h" #include "timer.h" #include "usb_charge.h" #include "util.h" @@ -56,10 +57,10 @@ static const struct power_signal_info power_control_outputs[] = { { GPIO_PP5000_EN, 1 }, - { GPIO_SYS_RST, 1 }, + { GPIO_SYS_RST_L, 0 }, }; - +static int want_s0_exit; void chipset_force_shutdown(void) { @@ -102,14 +103,20 @@ enum power_state power_handle_state(enum power_state state) break; case POWER_S5: - /* Power up to next state */ - return POWER_S5S3; + if (want_s0_exit) + return POWER_S5G3; + else + return POWER_S5S3; case POWER_S3: - /* Power up to next state */ - return POWER_S3S0; + if (want_s0_exit) + return POWER_S3S5; + else + return POWER_S3S0; case POWER_S0: + if (want_s0_exit) + return POWER_S0S3; break; case POWER_G3S5: @@ -157,9 +164,9 @@ enum power_state power_handle_state(enum power_state state) msleep(10); /* TBD */ /* Pulse SYS_RST */ - gpio_set_level(GPIO_SYS_RST, 1); + gpio_set_level(GPIO_SYS_RST_L, 0); msleep(10); - gpio_set_level(GPIO_SYS_RST, 0); + gpio_set_level(GPIO_SYS_RST_L, 1); gpio_set_level(GPIO_PP1800_LID_EN_L, 0); gpio_set_level(GPIO_PP1800_SENSOR_EN_L, 0); @@ -205,8 +212,26 @@ enum power_state power_handle_state(enum power_state state) return POWER_S5; case POWER_S5G3: - return POWER_G3; + want_s0_exit = 0; + /* Initialize power signal outputs to default. */ + return power_chipset_init(); } return state; } + +static void power_button_changed(void) +{ + /* Only pay attention to power button presses, not releases */ + if (!power_button_is_pressed()) + return; + + if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) + /* Power up */ + chipset_exit_hard_off(); + else + want_s0_exit = 1; + + task_wake(TASK_ID_CHIPSET); +} +DECLARE_HOOK(HOOK_POWER_BUTTON_CHANGE, power_button_changed, HOOK_PRIO_DEFAULT); |