summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbe Levkoy <alevkoy@chromium.org>2021-12-03 15:57:00 -0700
committerCommit Bot <commit-bot@chromium.org>2021-12-08 07:14:07 +0000
commitde14a76701c668270f19c8d6af41aaa321f1c8c2 (patch)
tree1b432e579ecaa02331a216f382553a23daac14e5
parent5d570f8deb75af989f12acb2c6adca0aa78df6a3 (diff)
downloadchrome-ec-de14a76701c668270f19c8d6af41aaa321f1c8c2.tar.gz
zephyr test: Verify SYV682x device connection
Verify that device connection and disconnection succeeds and enables and disables force VBUS discharge as appropriate. BUG=b:190519131 TEST=zmake configure --test zephyr/test/drivers BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: I49074b25a47430126416d23fcdc31511e28d6c2d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3315229 Reviewed-by: Yuval Peress <peress@google.com> Commit-Queue: Yuval Peress <peress@google.com>
-rw-r--r--zephyr/test/drivers/src/ppc.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/zephyr/test/drivers/src/ppc.c b/zephyr/test/drivers/src/ppc.c
index eafe079168..314543b316 100644
--- a/zephyr/test/drivers/src/ppc.c
+++ b/zephyr/test/drivers/src/ppc.c
@@ -312,6 +312,29 @@ static void test_ppc_syv682x_write_busy(void)
syv682x_emul_set_busy_reads(emul, 0);
}
+static void test_ppc_syv682x_dev_is_connected(void)
+{
+ struct i2c_emul *emul = syv682x_emul_get(SYV682X_ORD);
+ uint8_t reg;
+
+ zassert_ok(ppc_dev_is_connected(syv682x_port, PPC_DEV_SRC),
+ "Could not connect device as source");
+ zassert_ok(syv682x_emul_get_reg(emul, SYV682X_CONTROL_2_REG, &reg),
+ "Reading CONTROL_2 failed");
+ zassert_false(reg & SYV682X_CONTROL_2_FDSG,
+ "Connected as source, but force discharge enabled");
+
+ zassert_ok(ppc_dev_is_connected(syv682x_port, PPC_DEV_DISCONNECTED),
+ "Could not disconnect device");
+ zassert_ok(syv682x_emul_get_reg(emul, SYV682X_CONTROL_2_REG, &reg),
+ "Reading CONTROL_2 failed");
+ zassert_true(reg & SYV682X_CONTROL_2_FDSG,
+ "Disconnected, but force discharge disabled");
+
+ zassert_ok(ppc_dev_is_connected(syv682x_port, PPC_DEV_SNK),
+ "Could not connect device as source");
+}
+
static void test_ppc_syv682x(void)
{
zassert_ok(ppc_init(syv682x_port), "PPC init failed");
@@ -321,6 +344,7 @@ static void test_ppc_syv682x(void)
test_ppc_syv682x_frs();
test_ppc_syv682x_source_current_limit();
test_ppc_syv682x_write_busy();
+ test_ppc_syv682x_dev_is_connected();
}
void test_suite_ppc(void)