summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbe Levkoy <alevkoy@chromium.org>2021-12-06 10:08:18 -0700
committerCommit Bot <commit-bot@chromium.org>2021-12-09 00:19:27 +0000
commit31752262229d96f78021d02a8176f0ee2bea7020 (patch)
tree1fa1894c8728b58fff3bbd906cd7a2890a038575
parenteb8c9ddd6b3b649e0e1e3b75cd417055783897cd (diff)
downloadchrome-ec-31752262229d96f78021d02a8176f0ee2bea7020.tar.gz
zephyr test: Test VBUS sink enable/disable
Verify register values after enabling VBUS sink and after disabling it. BUG=b:190519131 TEST=zmake congfigure --test zephyr/test/drivers BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: Ibfb17252d3c31131101a6ba5682584148f747164 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3318726 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
-rw-r--r--zephyr/test/drivers/src/ppc.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/zephyr/test/drivers/src/ppc.c b/zephyr/test/drivers/src/ppc.c
index 314543b316..0484d98c86 100644
--- a/zephyr/test/drivers/src/ppc.c
+++ b/zephyr/test/drivers/src/ppc.c
@@ -335,6 +335,49 @@ static void test_ppc_syv682x_dev_is_connected(void)
"Could not connect device as source");
}
+static void test_ppc_syv682x_vbus_sink_enable(void)
+{
+ struct i2c_emul *emul = syv682x_emul_get(SYV682X_ORD);
+ uint8_t reg;
+ int ilim;
+
+ /*
+ * If VBUS source is already enabled, disabling VBUS sink should
+ * trivially succeed.
+ */
+ zassert_ok(ppc_vbus_source_enable(syv682x_port, true),
+ "VBUS enable failed");
+ zassert_ok(ppc_vbus_sink_enable(syv682x_port, false),
+ "Sink disable failed");
+
+ /*
+ * After enabling VBUS sink, the HV power path should be enabled in sink
+ * mode with the configured current limit.
+ */
+ zassert_ok(ppc_vbus_source_enable(syv682x_port, false),
+ "VBUS enable failed");
+ zassert_ok(ppc_vbus_sink_enable(syv682x_port, true),
+ "Sink disable failed");
+ zassert_ok(syv682x_emul_get_reg(emul, SYV682X_CONTROL_1_REG, &reg),
+ NULL);
+ zassert_true(reg & SYV682X_CONTROL_1_CH_SEL,
+ "Sink enabled, but CH_SEL set to 5V power path");
+ zassert_false(reg & SYV682X_CONTROL_1_PWR_ENB,
+ "Sink enabled, but power path disabled");
+ zassert_false(reg & SYV682X_CONTROL_1_HV_DR,
+ "Sink enabled, but high-voltage path in source mode");
+ ilim = (reg & SYV682X_HV_ILIM_MASK) >> SYV682X_HV_ILIM_BIT_SHIFT;
+ zassert_equal(ilim, CONFIG_PLATFORM_EC_USBC_PPC_SYV682X_HV_ILIM,
+ "Sink enabled, but HV current limit set to %d", ilim);
+
+ zassert_ok(ppc_vbus_sink_enable(syv682x_port, false),
+ "Sink disable failed");
+ zassert_ok(syv682x_emul_get_reg(emul, SYV682X_CONTROL_1_REG, &reg),
+ NULL);
+ zassert_true(reg & SYV682X_CONTROL_1_PWR_ENB,
+ "Sink disabled, but power path enabled");
+}
+
static void test_ppc_syv682x(void)
{
zassert_ok(ppc_init(syv682x_port), "PPC init failed");
@@ -345,6 +388,7 @@ static void test_ppc_syv682x(void)
test_ppc_syv682x_source_current_limit();
test_ppc_syv682x_write_busy();
test_ppc_syv682x_dev_is_connected();
+ test_ppc_syv682x_vbus_sink_enable();
}
void test_suite_ppc(void)