diff options
author | Aaron Massey <aaronmassey@google.com> | 2021-11-24 11:34:48 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-11-30 17:53:59 +0000 |
commit | daa5b96aaa6a9450d96e351265f691f9a70fb599 (patch) | |
tree | 7b3ca7875012478b7eaf42d2efa345536d405593 /zephyr/test/drivers/src | |
parent | 895909f4173dedfe91c7a4f0aa85182bb674bda5 (diff) | |
download | chrome-ec-daa5b96aaa6a9450d96e351265f691f9a70fb599.tar.gz |
zephyr: test: sn5s330 vbus source sink enable
Verify vbus_source/sink_enable function sets corresponding PP bits.
BRANCH=none
BUG=b:203364783
TEST=zmake configure --test test-drivers
Signed-off-by: Aaron Massey <aaronmassey@google.com>
Change-Id: I1e91132a3b2517032e7ebf65ec1790c93dfb420f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3300182
Reviewed-by: Tristan Honscheid <honscheid@google.com>
Diffstat (limited to 'zephyr/test/drivers/src')
-rw-r--r-- | zephyr/test/drivers/src/ppc_sn5s330.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/zephyr/test/drivers/src/ppc_sn5s330.c b/zephyr/test/drivers/src/ppc_sn5s330.c index a9733c1ed4..0dbd7b26a9 100644 --- a/zephyr/test/drivers/src/ppc_sn5s330.c +++ b/zephyr/test/drivers/src/ppc_sn5s330.c @@ -159,6 +159,32 @@ static void test_enter_low_power_mode(void) zassert_equal(func_set9_reg & SN5S330_FORCE_ON_VBUS_UVP, 0, NULL); } +static void test_vbus_source_sink_enable(void) +{ + const struct emul *emul = EMUL; + uint8_t func_set3_reg; + + zassert_ok(sn5s330_drv.init(SN5S330_PORT), NULL); + + /* Test enable/disable VBUS source FET */ + zassert_ok(sn5s330_drv.vbus_source_enable(SN5S330_PORT, true), NULL); + sn5s330_emul_peek_reg(emul, SN5S330_FUNC_SET3, &func_set3_reg); + zassert_not_equal(func_set3_reg & SN5S330_PP1_EN, 0, NULL); + + zassert_ok(sn5s330_drv.vbus_source_enable(SN5S330_PORT, false), NULL); + sn5s330_emul_peek_reg(emul, SN5S330_FUNC_SET3, &func_set3_reg); + zassert_equal(func_set3_reg & SN5S330_PP1_EN, 0, NULL); + + /* Test enable/disable VBUS sink FET */ + zassert_ok(sn5s330_drv.vbus_sink_enable(SN5S330_PORT, true), NULL); + sn5s330_emul_peek_reg(emul, SN5S330_FUNC_SET3, &func_set3_reg); + zassert_not_equal(func_set3_reg & SN5S330_PP2_EN, 0, NULL); + + zassert_ok(sn5s330_drv.vbus_sink_enable(SN5S330_PORT, false), NULL); + sn5s330_emul_peek_reg(emul, SN5S330_FUNC_SET3, &func_set3_reg); + zassert_equal(func_set3_reg & SN5S330_PP2_EN, 0, NULL); +} + static void reset_sn5s330_state(void) { struct i2c_emul *i2c_emul = sn5s330_emul_to_i2c_emul(EMUL); @@ -172,6 +198,9 @@ void test_suite_ppc_sn5s330(void) { ztest_test_suite( ppc_sn5s330, + ztest_unit_test_setup_teardown(test_vbus_source_sink_enable, + reset_sn5s330_state, + reset_sn5s330_state), ztest_unit_test_setup_teardown(test_enter_low_power_mode, reset_sn5s330_state, reset_sn5s330_state), |