diff options
author | Wai-Hong Tam <waihong@google.com> | 2020-07-28 11:48:28 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-07-30 04:32:28 +0000 |
commit | b40786b4b8f543e8e33537582ca0b5b71f57b1f1 (patch) | |
tree | ad75941eb56558692e21944a1f6fdfbfde026b4e | |
parent | 1691a707af5cc3dbd3e4353cf2d0773ef931b178 (diff) | |
download | chrome-ec-b40786b4b8f543e8e33537582ca0b5b71f57b1f1.tar.gz |
sc7180: Add debug command to fake AP_SUSPEND signal to enter/exit S3
The AP_SUSPEND signal doesn't work on ToT kernel. It needs more work.
Introduce a way to fake the signal for testing.
BRANCH=None
BUG=b:148149387
TEST=Typing "fakesuspend on" in S0, transit into S3;
then typing "fakesuspend off" in S3, transit into S0;
then typing "fakesuspend reset", back to using AP_SUSPEND signal.
Change-Id: I706b576a848f9875e8ce6bed4c71ea7e33dfc315
Signed-off-by: Wai-Hong Tam <waihong@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2324988
Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
-rw-r--r-- | power/sc7180.c | 48 |
1 files changed, 45 insertions, 3 deletions
diff --git a/power/sc7180.c b/power/sc7180.c index 06ac54479b..886f22078b 100644 --- a/power/sc7180.c +++ b/power/sc7180.c @@ -733,6 +733,49 @@ void chipset_reset(enum chipset_reset_reason reason) } } +/* + * Flag to fake the suspend signal to 1 or 0, or -1 means not fake it. + * + * TODO(waihong): Remove this flag and debug command when the AP_SUSPEND + * signal is working. + */ +static int fake_suspend = -1; + +static int command_fake_suspend(int argc, char **argv) +{ + int v; + + if (argc < 2) { + ccprintf("fake_suspend: %s\n", + fake_suspend == -1 ? "reset" + : (fake_suspend ? "on" : "off")); + return EC_SUCCESS; + } + + if (!strcasecmp(argv[1], "reset")) + fake_suspend = -1; + else if (parse_bool(argv[1], &v)) + fake_suspend = v; + else + return EC_ERROR_PARAM1; + + task_wake(TASK_ID_CHIPSET); + + return EC_SUCCESS; +} +DECLARE_CONSOLE_COMMAND(fakesuspend, command_fake_suspend, + "on/off/reset", + "Fake the AP_SUSPEND signal"); + +/* Get system sleep state through GPIOs */ +static inline int chipset_get_sleep_signal(void) +{ + if (fake_suspend == -1) + return (power_get_signals() & IN_SUSPEND) == IN_SUSPEND; + else + return fake_suspend; +} + /** * Power handler for steady states * @@ -815,7 +858,7 @@ enum power_state power_handle_state(enum power_state state) * host event before transits the state. It prevents changing * the state for modem paging. */ - if (!(power_get_signals() & IN_SUSPEND)) + if (!chipset_get_sleep_signal()) return POWER_S3S0; break; @@ -827,8 +870,7 @@ enum power_state power_handle_state(enum power_state state) case POWER_S0: shutdown_from_s0 = check_for_power_off_event(); - if (shutdown_from_s0 || - power_get_signals() & IN_SUSPEND) + if (shutdown_from_s0 || chipset_get_sleep_signal()) return POWER_S0S3; break; |