summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbe Levkoy <alevkoy@chromium.org>2021-10-08 15:03:11 -0600
committerCommit Bot <commit-bot@chromium.org>2021-10-14 02:15:46 +0000
commitebe1007d3dc274b2f7eb34cdae12ab7b1de41553 (patch)
tree487f8c8dfadd10d92f8b7667566bda64d9e36726
parent41ee17ad17806fc742a9622341d34b0f0fe5c80d (diff)
downloadchrome-ec-ebe1007d3dc274b2f7eb34cdae12ab7b1de41553.tar.gz
zephyr test: SYV682X HC_OV interrupt
Test high-voltage over-current interrupts. Verify that the driver restores the power path until the over-current limit is reached. Increase coverage of syv682x.c: line 47.5->55.1%; branch 13.2->15.5%. BUG=b:190519131 TEST=zmake configure --test zephyr/test/drivers BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: I84f2eb31796eec4e2106f29f52ee49c9e9662928 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3214776 Commit-Queue: Yuval Peress <peress@google.com> Reviewed-by: Yuval Peress <peress@google.com>
-rw-r--r--zephyr/emul/emul_syv682x.c4
-rw-r--r--zephyr/test/drivers/src/ppc.c32
2 files changed, 35 insertions, 1 deletions
diff --git a/zephyr/emul/emul_syv682x.c b/zephyr/emul/emul_syv682x.c
index e565e06958..2148851b56 100644
--- a/zephyr/emul/emul_syv682x.c
+++ b/zephyr/emul/emul_syv682x.c
@@ -68,8 +68,10 @@ void syv682x_emul_set_status(struct i2c_emul *emul, uint8_t val)
data->status_cond = val;
data->reg[SYV682X_STATUS_REG] |= val;
- if (val & (SYV682X_STATUS_TSD | SYV682X_STATUS_OVP))
+ if (val & (SYV682X_STATUS_TSD | SYV682X_STATUS_OVP |
+ SYV682X_STATUS_OC_HV)) {
data->reg[SYV682X_CONTROL_1_REG] |= SYV682X_CONTROL_1_PWR_ENB;
+ }
/*
* TODO(b/190519131): Make this emulator trigger GPIO-based interrupts
diff --git a/zephyr/test/drivers/src/ppc.c b/zephyr/test/drivers/src/ppc.c
index 815c97aed5..1b66c6dcd4 100644
--- a/zephyr/test/drivers/src/ppc.c
+++ b/zephyr/test/drivers/src/ppc.c
@@ -43,6 +43,7 @@ static void test_ppc_syv682x_vbus_enable(void)
static void test_ppc_syv682x_interrupt(void)
{
struct i2c_emul *emul = syv682x_emul_get(SYV682X_ORD);
+ uint8_t reg;
syv682x_emul_set_status(emul, SYV682X_STATUS_OC_5V);
syv682x_interrupt(syv682x_port);
@@ -90,6 +91,37 @@ static void test_ppc_syv682x_interrupt(void)
zassert_false(ppc_is_sourcing_vbus(syv682x_port),
"PPC is sourcing power after OVP");
syv682x_emul_set_status(emul, 0);
+
+ /*
+ * A high-voltage OC while sinking should cause the driver to try to
+ * re-enable the sink path until the OC count limit is reached, at which
+ * point the driver should leave it disabled.
+ */
+ zassert_ok(ppc_vbus_sink_enable(syv682x_port, true),
+ "Sink enable failed");
+ syv682x_emul_set_status(emul, SYV682X_STATUS_OC_HV);
+ syv682x_interrupt(syv682x_port);
+ msleep(1);
+ zassert_ok(syv682x_emul_get_reg(emul, SYV682X_CONTROL_1_REG, &reg),
+ "Reading CONTROL_1 failed");
+ zassert_equal(reg & SYV682X_CONTROL_1_PWR_ENB, 0,
+ "Power path disabled after HV_OC handled");
+ syv682x_emul_set_status(emul, SYV682X_STATUS_OC_HV);
+ syv682x_interrupt(syv682x_port);
+ msleep(1);
+ zassert_ok(syv682x_emul_get_reg(emul, SYV682X_CONTROL_1_REG, &reg),
+ "Reading CONTROL_1 failed");
+ zassert_equal(reg & SYV682X_CONTROL_1_PWR_ENB, 0,
+ "Power path disabled after HV_OC handled");
+ syv682x_emul_set_status(emul, SYV682X_STATUS_OC_HV);
+ syv682x_interrupt(syv682x_port);
+ msleep(1);
+ zassert_ok(syv682x_emul_get_reg(emul, SYV682X_CONTROL_1_REG, &reg),
+ "Reading CONTROL_1 failed");
+ zassert_equal(reg & SYV682X_CONTROL_1_PWR_ENB,
+ SYV682X_CONTROL_1_PWR_ENB,
+ "Power path enabled after HV_OC handled 3 times");
+ syv682x_emul_set_status(emul, 0);
}
static void test_ppc_syv682x(void)