diff options
author | Grzegorz Bernacki <bernacki@google.com> | 2023-02-08 17:25:03 +0000 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-04-14 10:34:09 +0000 |
commit | cbf9f6e5df8f6f5cc8fbf284ba45d1b901542cd7 (patch) | |
tree | dd54b85b8c326a7e928be146bdac22beda474e6c | |
parent | 228f4510e653952f8a1d26ed663cde4d01c6f7f5 (diff) | |
download | chrome-ec-cbf9f6e5df8f6f5cc8fbf284ba45d1b901542cd7.tar.gz |
ap_power.alderlake: Add test for s0ix counter.
This commit adds test to verify if s0ix counter is
incremented on change to s0ix state.
BUG=b:261869264
TEST=Run with twister
BRANCH=none
Change-Id: Ic0d53d01fe84207999ce1007e5081097464b1b6b
Signed-off-by: Grzegorz Bernacki <bernacki@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4239447
Reviewed-by: Robert Zieba <robertzieba@google.com>
-rw-r--r-- | zephyr/test/ap_power/boards/alderlake.dts | 31 | ||||
-rw-r--r-- | zephyr/test/ap_power/src/ap_pwrseq.c | 86 | ||||
-rw-r--r-- | zephyr/test/ap_power/testcase.yaml | 1 |
3 files changed, 118 insertions, 0 deletions
diff --git a/zephyr/test/ap_power/boards/alderlake.dts b/zephyr/test/ap_power/boards/alderlake.dts index 4d641cad4a..58c68529c3 100644 --- a/zephyr/test/ap_power/boards/alderlake.dts +++ b/zephyr/test/ap_power/boards/alderlake.dts @@ -362,4 +362,35 @@ nodes = <&en_pp3300_emul &en_pp5000_emul &ec_soc_dsw_pwrok_emul &ec_pch_rsmrst_s3_dsw_pwrok_fail_emul>; }; + + pch_sleep: pch-sleep { + compatible = "intel,ap-pwr-signal-emul"; + input-signal = <&pch_pwrok>; + + slp-s0-suspend-emul { + output-signal = <&slp_s0>; + init-value=<1>; + }; + }; + + tp-sys-sleep { + compatible = "intel,ap-pwr-test-platform"; + nodes = <&pch_sleep>; + }; + + pch_wake: pch-wake { + compatible = "intel,ap-pwr-signal-emul"; + input-signal = <&pch_pwrok>; + + slp-s0-resume-emul { + output-signal = <&slp_s0>; + init-value=<0>; + }; + }; + + tp-sys-wake { + compatible = "intel,ap-pwr-test-platform"; + nodes = <&pch_wake>; + }; + }; diff --git a/zephyr/test/ap_power/src/ap_pwrseq.c b/zephyr/test/ap_power/src/ap_pwrseq.c index 3081272d27..a968b0c38d 100644 --- a/zephyr/test/ap_power/src/ap_pwrseq.c +++ b/zephyr/test/ap_power/src/ap_pwrseq.c @@ -6,7 +6,9 @@ #include "ap_power/ap_power.h" #include "ap_power/ap_power_interface.h" #include "chipset.h" +#include "ec_commands.h" #include "emul/emul_power_signals.h" +#include "host_command.h" #include "test_mocks.h" #include "test_state.h" @@ -84,6 +86,90 @@ ZTEST(ap_pwrseq, test_ap_pwrseq_0) "AP_POWER_RESUME event not generated"); } +ZTEST(ap_pwrseq, test_ap_pwrseq_0_sleep) +{ + struct ec_params_host_sleep_event_v1 host_sleep_ev_p = { + .sleep_event = HOST_SLEEP_EVENT_S0IX_SUSPEND, + .suspend_params = { EC_HOST_SLEEP_TIMEOUT_DEFAULT }, + }; + struct ec_response_host_sleep_event_v1 host_sleep_ev_r; + struct host_cmd_handler_args host_sleep_ev_args = BUILD_HOST_COMMAND( + EC_CMD_HOST_SLEEP_EVENT, 1, host_sleep_ev_r, host_sleep_ev_p); + + struct ec_params_s0ix_cnt s0ix_cnt_ev_p = { + .flags = EC_S0IX_COUNTER_RESET + }; + struct ec_response_s0ix_cnt s0ix_cnt_ev_r; + struct host_cmd_handler_args s0ix_cnt_ev_args = BUILD_HOST_COMMAND( + EC_CMD_GET_S0IX_COUNTER, 0, s0ix_cnt_ev_r, s0ix_cnt_ev_p); + + /* Verify that counter is set to 0 */ + zassert_ok(host_command_process(&s0ix_cnt_ev_args), + "Failed to get s0ix counter"); + zassert_equal(s0ix_cnt_ev_r.s0ix_counter, 0); + + /* Send host sleep event */ + zassert_ok(host_command_process(&host_sleep_ev_args)); + + /* Assert SLP_S0# */ + zassert_equal(0, + power_signal_emul_load( + EMUL_POWER_SIGNAL_TEST_PLATFORM(tp_sys_sleep)), + "Unable to load test platform `tp_sys_g3_to_s0`"); + + k_msleep(500); + + /* + * Verify that counter has been increased, + * clear the flag for get command + */ + s0ix_cnt_ev_p.flags = 0; + zassert_ok(host_command_process(&s0ix_cnt_ev_args), + "Failed to get s0ix counter"); + zassert_equal(s0ix_cnt_ev_r.s0ix_counter, 1); +} + +ZTEST(ap_pwrseq, test_ap_pwrseq_0_wake) +{ + struct ec_params_host_sleep_event_v1 p = { + .sleep_event = HOST_SLEEP_EVENT_S0IX_RESUME, + .suspend_params = { EC_HOST_SLEEP_TIMEOUT_DEFAULT }, + }; + struct ec_response_host_sleep_event_v1 r; + struct host_cmd_handler_args args = + BUILD_HOST_COMMAND(EC_CMD_HOST_SLEEP_EVENT, 1, r, p); + struct ec_params_s0ix_cnt s0ix_cnt_ev_p = { .flags = 0 }; + struct ec_response_s0ix_cnt s0ix_cnt_ev_r; + struct host_cmd_handler_args s0ix_cnt_ev_args = BUILD_HOST_COMMAND( + EC_CMD_GET_S0IX_COUNTER, 0, s0ix_cnt_ev_r, s0ix_cnt_ev_p); + + /* Confirm that counters keeps the same value through wakeup */ + zassert_ok(host_command_process(&s0ix_cnt_ev_args), + "Failed to get s0ix counter"); + zassert_equal(s0ix_cnt_ev_r.s0ix_counter, 1); + + zassert_equal(0, + power_signal_emul_load( + EMUL_POWER_SIGNAL_TEST_PLATFORM(tp_sys_wake)), + "Unable to load test platform `tp_sys_g3_to_s0`"); + + k_msleep(500); + zassert_ok(host_command_process(&args)); + zassert_ok(host_command_process(&s0ix_cnt_ev_args), + "Failed to get sleep counter"); + zassert_equal(s0ix_cnt_ev_r.s0ix_counter, 1); + + /* Verify the reset command sets the counter to zero */ + s0ix_cnt_ev_p.flags = EC_S0IX_COUNTER_RESET; + zassert_ok(host_command_process(&s0ix_cnt_ev_args), + "Failed to get s0ix counter"); + + s0ix_cnt_ev_p.flags = 0; + zassert_ok(host_command_process(&s0ix_cnt_ev_args), + "Failed to get s0ix counter"); + zassert_equal(s0ix_cnt_ev_r.s0ix_counter, 0); +} + ZTEST(ap_pwrseq, test_ap_pwrseq_1) { zassert_equal(0, diff --git a/zephyr/test/ap_power/testcase.yaml b/zephyr/test/ap_power/testcase.yaml index 8fbea99560..cba1157944 100644 --- a/zephyr/test/ap_power/testcase.yaml +++ b/zephyr/test/ap_power/testcase.yaml @@ -8,6 +8,7 @@ tests: extra_configs: - CONFIG_EMUL_POWER_SIGNALS=y - CONFIG_X86_NON_DSX_PWRSEQ_ADL=y + - CONFIG_AP_PWRSEQ_S0IX=y - CONFIG_AP_X86_INTEL_ADL=y - CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S4=y - CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S5=y |