diff options
author | Robert Zieba <robertzieba@google.com> | 2023-02-08 18:25:38 +0000 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-02-16 18:47:55 +0000 |
commit | 2fa17baa833de281f79d8b62bd7f52241d3690b5 (patch) | |
tree | 7e3f988fc717dd16329cecfbc4b97c9aea0f74eb | |
parent | 214569d3c739492e3bd2783088fed25b8cdb9e59 (diff) | |
download | chrome-ec-2fa17baa833de281f79d8b62bd7f52241d3690b5.tar.gz |
zephyr/test: Add AMD STB dumping test
Add `amd.stb_dump` test.
BRANCH=none
BUG=b:246770811
TEST=Ran test
Change-Id: I44b3afd2003b0792bc17cbcdfe31be1f6f4fd6a9
Signed-off-by: Robert Zieba <robertzieba@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4233498
Reviewed-by: Diana Z <dzigterman@chromium.org>
Reviewed-by: Keith Short <keithshort@chromium.org>
-rw-r--r-- | zephyr/test/amd/CMakeLists.txt | 11 | ||||
-rw-r--r-- | zephyr/test/amd/Kconfig | 9 | ||||
-rw-r--r-- | zephyr/test/amd/boards/native_posix.overlay | 35 | ||||
-rw-r--r-- | zephyr/test/amd/prj.conf | 15 | ||||
-rw-r--r-- | zephyr/test/amd/src/stb_dump.c | 40 | ||||
-rw-r--r-- | zephyr/test/amd/testcase.yaml | 10 |
6 files changed, 120 insertions, 0 deletions
diff --git a/zephyr/test/amd/CMakeLists.txt b/zephyr/test/amd/CMakeLists.txt new file mode 100644 index 0000000000..a46cb31520 --- /dev/null +++ b/zephyr/test/amd/CMakeLists.txt @@ -0,0 +1,11 @@ +# Copyright 2023 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +cmake_minimum_required(VERSION 3.13.1) +find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}") +project(amd) + +add_subdirectory(${PLATFORM_EC}/zephyr/test/test_utils test_utils) + +target_sources_ifdef(CONFIG_TEST_AMD_STB_DUMP app PRIVATE src/stb_dump.c)
\ No newline at end of file diff --git a/zephyr/test/amd/Kconfig b/zephyr/test/amd/Kconfig new file mode 100644 index 0000000000..e5fe04dee8 --- /dev/null +++ b/zephyr/test/amd/Kconfig @@ -0,0 +1,9 @@ +# Copyright 2023 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +config TEST_AMD_STB_DUMP + bool "Enable STB dump test" + select PLATFORM_EC_AMD_STB_DUMP + +source "Kconfig.zephyr" diff --git a/zephyr/test/amd/boards/native_posix.overlay b/zephyr/test/amd/boards/native_posix.overlay new file mode 100644 index 0000000000..477a989e1a --- /dev/null +++ b/zephyr/test/amd/boards/native_posix.overlay @@ -0,0 +1,35 @@ +/* Copyright 2023 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include <board-overlays/native_posix.dts> +#include <dt-bindings/gpio_defines.h> + +/ { + named-gpios { + compatible = "named-gpios"; + + /* STB dumping GPIOs */ + gpio_ec_sfh_int_h: ec_sfh_int_h { + gpios = <&gpio0 0 GPIO_OUTPUT_LOW>; + }; + gpio_sfh_ec_int_h: sfh_ec_int_h { + gpios = <&gpio0 1 GPIO_INPUT>; + }; + }; + + gpio-interrupts { + compatible = "cros-ec,gpio-interrupts"; + + int_stb_dump: stb_dump { + irq-pin = <&gpio_sfh_ec_int_h>; + flags = <GPIO_INT_EDGE_RISING>; + handler = "amd_stb_dump_interrupt"; + }; + }; +}; + +&gpio0 { + ngpios = <2>; +};
\ No newline at end of file diff --git a/zephyr/test/amd/prj.conf b/zephyr/test/amd/prj.conf new file mode 100644 index 0000000000..ced2cda8f5 --- /dev/null +++ b/zephyr/test/amd/prj.conf @@ -0,0 +1,15 @@ +# Copyright 2023 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +CONFIG_ZTEST=y +CONFIG_ZTEST_ASSERT_VERBOSE=1 +CONFIG_ZTEST_NEW_API=y +CONFIG_ASSERT=y + +CONFIG_CROS_EC=y +CONFIG_PLATFORM_EC=y +CONFIG_EMUL=y +CONFIG_GPIO=y + +CONFIG_AP_X86_AMD=y diff --git a/zephyr/test/amd/src/stb_dump.c b/zephyr/test/amd/src/stb_dump.c new file mode 100644 index 0000000000..d05041c7dc --- /dev/null +++ b/zephyr/test/amd/src/stb_dump.c @@ -0,0 +1,40 @@ +/* Copyright 2023 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +#include <zephyr/devicetree.h> +#include <zephyr/drivers/gpio.h> +#include <zephyr/drivers/gpio/gpio_emul.h> +#include <zephyr/fff.h> +#include <zephyr/ztest.h> + +#include <driver/amd_stb.h> +#include <gpio.h> +#include <gpio/gpio_int.h> + +ZTEST_SUITE(stb_dump, NULL, NULL, NULL, NULL, NULL); + +ZTEST(stb_dump, test_stb_dump) +{ + const struct gpio_dt_spec *ec_sfh_int = + GPIO_DT_FROM_NODELABEL(gpio_ec_sfh_int_h); + const struct gpio_dt_spec *sfh_ec_int = + GPIO_DT_FROM_NODELABEL(gpio_sfh_ec_int_h); + int rv; + + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_stb_dump)); + amd_stb_dump_init(ec_sfh_int, sfh_ec_int); + + amd_stb_dump_trigger(); + rv = gpio_emul_output_get(ec_sfh_int->port, ec_sfh_int->pin); + zassert_equal(rv, 1); + zassert_true(amd_stb_dump_in_progress()); + + rv = gpio_emul_input_set(sfh_ec_int->port, sfh_ec_int->pin, true); + zassert_ok(rv); + /* Give the interrupt handler plenty of time to run. */ + k_msleep(10); + zassert_false(amd_stb_dump_in_progress()); + rv = gpio_emul_output_get(ec_sfh_int->port, ec_sfh_int->pin); + zassert_equal(rv, 0); +} diff --git a/zephyr/test/amd/testcase.yaml b/zephyr/test/amd/testcase.yaml new file mode 100644 index 0000000000..f124f8d9e2 --- /dev/null +++ b/zephyr/test/amd/testcase.yaml @@ -0,0 +1,10 @@ +# Copyright 2023 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +common: + platform_allow: native_posix +tests: + amd.stb_dump: + extra_configs: + - CONFIG_TEST_AMD_STB_DUMP=y |