summaryrefslogtreecommitdiff
path: root/zephyr/test
diff options
context:
space:
mode:
authorYuval Peress <peress@chromium.org>2021-07-15 10:17:20 -0600
committerCommit Bot <commit-bot@chromium.org>2021-08-31 18:33:19 +0000
commited87c0c1ade57ab6e8bd46a11a2f0484a503f1b8 (patch)
treefc57a496d2c73b9dc4f5a5727c0e7771aa9dbf2f /zephyr/test
parent003ec08f8c67845ae8481d3fb4124555213b04c4 (diff)
downloadchrome-ec-ed87c0c1ade57ab6e8bd46a11a2f0484a503f1b8.tar.gz
zephyr: test: drivers: add eSPI test using host command
Verify that we can call host commands from driver tests by adding a test that calls the EC_CMD_GET_PROTOCOL_INFO host command. Add a few convenience functions to host_command.h when building with CONFIG_ZTEST enabled. Also, add eSPI emulator to support the test. Coverage: - lines 17.4% -> 17.8% - functions 21.4% -> 22.0% BRANCH=none BUG=b:189954415 TEST=zmake configure --test zephyr/test/drivers Signed-off-by: Yuval Peress <peress@chromium.org> Change-Id: Ib9e750eeab555ea629a560cbf3beed28e346c460 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3031842 Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
Diffstat (limited to 'zephyr/test')
-rw-r--r--zephyr/test/drivers/overlay.dts16
-rw-r--r--zephyr/test/drivers/prj.conf8
-rw-r--r--zephyr/test/drivers/src/espi.c35
-rw-r--r--zephyr/test/drivers/src/main.c2
4 files changed, 60 insertions, 1 deletions
diff --git a/zephyr/test/drivers/overlay.dts b/zephyr/test/drivers/overlay.dts
index f0413746d3..4d650551fa 100644
--- a/zephyr/test/drivers/overlay.dts
+++ b/zephyr/test/drivers/overlay.dts
@@ -39,6 +39,11 @@
enum-name = "GPIO_PG_EC_DSW_PWROK";
label = "PG_EC_DSW_PWROK";
};
+ ec_pch_wake_odl {
+ gpios = <&gpio0 5 GPIO_OUT_HIGH>;
+ enum-name = "GPIO_EC_PCH_WAKE_ODL";
+ label = "EC_PCH_WAKE_ODL";
+ };
};
named-i2c-ports {
compatible = "named-i2c-ports";
@@ -392,8 +397,17 @@
};
};
+&espi0 {
+ espi-host@0 {
+ status = "okay";
+ compatible = "zephyr,espi-emul-espi-host";
+ reg = <0x0>;
+ label = "ESPI_HOST";
+ };
+};
+
&gpio0 {
- ngpios = <5>;
+ ngpios = <6>;
};
&i2c0 {
diff --git a/zephyr/test/drivers/prj.conf b/zephyr/test/drivers/prj.conf
index 3fd3636946..4ba0efc2a0 100644
--- a/zephyr/test/drivers/prj.conf
+++ b/zephyr/test/drivers/prj.conf
@@ -61,6 +61,14 @@ CONFIG_PLATFORM_EC_ACCEL_FIFO=y
CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y
CONFIG_PLATFORM_EC_ALS_TCS3400=y
+CONFIG_ESPI=y
+CONFIG_ESPI_EMUL=y
+CONFIG_EMUL_ESPI_HOST=y
+CONFIG_PLATFORM_EC_ESPI=y
+CONFIG_ESPI_PERIPHERAL_ACPI_SHM_REGION=y
+CONFIG_ESPI_PERIPHERAL_CUSTOM_OPCODE=y
+CONFIG_ESPI_PERIPHERAL_EC_HOST_CMD=y
+
# Things that default to on, but aren't working yet
CONFIG_PLATFORM_EC_BACKLIGHT_LID=n
CONFIG_PLATFORM_EC_SWITCH=n
diff --git a/zephyr/test/drivers/src/espi.c b/zephyr/test/drivers/src/espi.c
new file mode 100644
index 0000000000..c852f1b771
--- /dev/null
+++ b/zephyr/test/drivers/src/espi.c
@@ -0,0 +1,35 @@
+/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include <zephyr.h>
+#include <ztest.h>
+
+#include "ec_commands.h"
+#include "host_command.h"
+
+static void test_host_command_get_protocol_info(void)
+{
+ struct ec_response_get_protocol_info response;
+ struct host_cmd_handler_args args =
+ BUILD_HOST_COMMAND(EC_CMD_GET_PROTOCOL_INFO, 0, response);
+
+ zassert_ok(host_command_process(&args), NULL);
+ zassert_ok(args.result, NULL);
+ zassert_equal(args.response_size, sizeof(response), NULL);
+ zassert_equal(response.protocol_versions, BIT(3), NULL);
+ zassert_equal(response.max_request_packet_size, EC_LPC_HOST_PACKET_SIZE,
+ NULL);
+ zassert_equal(response.max_response_packet_size,
+ EC_LPC_HOST_PACKET_SIZE, NULL);
+ zassert_equal(response.flags, 0, NULL);
+}
+
+void test_suite_espi(void)
+{
+ ztest_test_suite(espi,
+ ztest_user_unit_test(
+ test_host_command_get_protocol_info));
+ ztest_run_test_suite(espi);
+}
diff --git a/zephyr/test/drivers/src/main.c b/zephyr/test/drivers/src/main.c
index ca573b98fd..46fd462283 100644
--- a/zephyr/test/drivers/src/main.c
+++ b/zephyr/test/drivers/src/main.c
@@ -18,6 +18,7 @@ extern void test_suite_ppc(void);
extern void test_suite_bmi260(void);
extern void test_suite_bmi160(void);
extern void test_suite_tcs3400(void);
+extern void test_suite_espi(void);
void test_main(void)
{
@@ -37,4 +38,5 @@ void test_main(void)
test_suite_bmi260();
test_suite_bmi160();
test_suite_tcs3400();
+ test_suite_espi();
}