summaryrefslogtreecommitdiff
path: root/zephyr
diff options
context:
space:
mode:
authorAaron Massey <aaronmassey@google.com>2021-12-09 10:09:38 -0700
committerCommit Bot <commit-bot@chromium.org>2021-12-16 00:13:55 +0000
commitd70f555bb2b9cbd131468ecf941913897d6500b4 (patch)
treed0a26ffa5b7bf110183872b52b716940e4d4b02a /zephyr
parenta31cadf77e57cf9a7a6d6bddb50109582cfb9f27 (diff)
downloadchrome-ec-d70f555bb2b9cbd131468ecf941913897d6500b4.tar.gz
zephyr: test: sn5s330 disables low vbusV interrupt
Verify sn5s330 driver disables chip interrupts from low vbus voltage. BRANCH=none BUG=b:203364783 TEST=zmake configure --test test-drivers Signed-off-by: Aaron Massey <aaronmassey@google.com> Change-Id: Idcff313d2b3bfc1a464a0b01319257d2c37b88d3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3328086 Reviewed-by: Yuval Peress <peress@google.com>
Diffstat (limited to 'zephyr')
-rw-r--r--zephyr/emul/emul_sn5s330.c14
-rw-r--r--zephyr/include/emul/emul_sn5s330.h7
-rw-r--r--zephyr/test/drivers/src/ppc_sn5s330.c14
3 files changed, 35 insertions, 0 deletions
diff --git a/zephyr/emul/emul_sn5s330.c b/zephyr/emul/emul_sn5s330.c
index 496099b50d..238815b11c 100644
--- a/zephyr/emul/emul_sn5s330.c
+++ b/zephyr/emul/emul_sn5s330.c
@@ -290,6 +290,20 @@ void sn5s330_emul_make_vbus_overcurrent(const struct emul *emul)
sn5s330_emul_assert_interrupt(i2c_emul);
}
+void sn5s330_emul_lower_vbus_below_minv(const struct emul *emul)
+{
+ struct sn5s330_emul_data *data = emul->data;
+ struct i2c_emul *i2c_emul = &data->common.emul;
+
+ data->int_status_reg4 |= SN5S330_VSAFE0V_STAT;
+
+ /* driver disabled this interrupt trigger */
+ if (data->int_status_reg4 & SN5S330_VSAFE0V_MASK)
+ return;
+
+ sn5s330_emul_assert_interrupt(i2c_emul);
+}
+
void sn5s330_emul_reset(const struct emul *emul)
{
struct sn5s330_emul_data *data = emul->data;
diff --git a/zephyr/include/emul/emul_sn5s330.h b/zephyr/include/emul/emul_sn5s330.h
index efbfea7b2b..c6ea31b6d6 100644
--- a/zephyr/include/emul/emul_sn5s330.h
+++ b/zephyr/include/emul/emul_sn5s330.h
@@ -40,4 +40,11 @@ void sn5s330_emul_reset(const struct emul *emul);
*/
void sn5s330_emul_make_vbus_overcurrent(const struct emul *emul);
+/**
+ * @brief Emulate vbus voltage is below min 0.6V.
+ *
+ * @param emul The sn5s330 chip emulator.
+ */
+void sn5s330_emul_lower_vbus_below_minv(const struct emul *emul);
+
#endif /* ZEPHYR_INCLUDE_EMUL_EMUL_SN5S330_H_ */
diff --git a/zephyr/test/drivers/src/ppc_sn5s330.c b/zephyr/test/drivers/src/ppc_sn5s330.c
index c3dbd0cc47..af551f7189 100644
--- a/zephyr/test/drivers/src/ppc_sn5s330.c
+++ b/zephyr/test/drivers/src/ppc_sn5s330.c
@@ -298,6 +298,17 @@ static void test_sn5s330_vbus_overcurrent(void)
zassert_equal(int_trip_rise_reg1 & SN5S330_ILIM_PP1_MASK, 0, NULL);
}
+static void test_sn5s330_disable_vbus_low_interrupt(void)
+{
+ const struct emul *emul = EMUL;
+
+ /* Interrupt disabled here */
+ zassert_ok(sn5s330_drv.init(SN5S330_PORT), NULL);
+ /* Would normally cause a vbus low interrupt */
+ sn5s330_emul_lower_vbus_below_minv(emul);
+ zassert_equal(sn5s330_emul_interrupt_set_stub_fake.call_count, 0, NULL);
+}
+
static void reset_sn5s330_state(void)
{
struct i2c_emul *i2c_emul = sn5s330_emul_to_i2c_emul(EMUL);
@@ -312,6 +323,9 @@ void test_suite_ppc_sn5s330(void)
{
ztest_test_suite(
ppc_sn5s330,
+ ztest_unit_test_setup_teardown(
+ test_sn5s330_disable_vbus_low_interrupt,
+ reset_sn5s330_state, reset_sn5s330_state),
ztest_unit_test_setup_teardown(test_sn5s330_vbus_overcurrent,
reset_sn5s330_state,
reset_sn5s330_state),