summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Honscheid <honscheid@google.com>2021-12-13 16:37:17 -0700
committerCommit Bot <commit-bot@chromium.org>2021-12-16 23:58:11 +0000
commit16ba0109a7ea0592f8a83c4695b963481783c82c (patch)
treec57d6c14b64c83d2d6622c07e2f480fc0ef53812
parent32dbddfa436185e707ab006c3d6fdff00de339ac (diff)
downloadchrome-ec-16ba0109a7ea0592f8a83c4695b963481783c82c.tar.gz
zephyr: isl923x: Test hibernation (disable_adc true)
* Test raa489000_hibernate() with disable_adc true BRANCH=None BUG=b:184856906 TEST=zmake -D configure --test test-drivers Signed-off-by: Tristan Honscheid <honscheid@google.com> Change-Id: I7a40a22b9e87d0d40022de1cc7ddb057fe1f43f8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3336696 Reviewed-by: Keith Short <keithshort@chromium.org>
-rw-r--r--zephyr/test/drivers/src/isl923x.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/zephyr/test/drivers/src/isl923x.c b/zephyr/test/drivers/src/isl923x.c
index 453c925a8b..c94b11ac5f 100644
--- a/zephyr/test/drivers/src/isl923x.c
+++ b/zephyr/test/drivers/src/isl923x.c
@@ -948,6 +948,26 @@ static void test_isl923x_hibernate__fail_at_ISL9238_REG_CONTROL4(void)
ISL9238_REG_CONTROL3, MOCK_IGNORE_VALUE);
}
+static void test_isl923x_hibernate__adc_disable(void)
+{
+ const struct emul *isl923x_emul = ISL923X_EMUL;
+ struct i2c_emul *i2c_emul = isl923x_emul_get_i2c_emul(isl923x_emul);
+ uint16_t expected;
+
+ raa489000_hibernate(CHARGER_NUM, true);
+
+ /* Check ISL9238_REG_CONTROL3 (disable_adc = true) */
+ expected = isl923x_emul_peek_reg(i2c_emul, ISL9238_REG_CONTROL3);
+ expected &= ~RAA489000_ENABLE_ADC;
+
+ MOCK_ASSERT_I2C_READ(hibernate_mock_read_fn, 4, ISL9238_REG_CONTROL3);
+ MOCK_ASSERT_I2C_READ(hibernate_mock_read_fn, 5, ISL9238_REG_CONTROL3);
+ MOCK_ASSERT_I2C_WRITE(hibernate_mock_write_fn, 4, ISL9238_REG_CONTROL3,
+ expected & 0xff);
+ MOCK_ASSERT_I2C_WRITE(hibernate_mock_write_fn, 5, ISL9238_REG_CONTROL3,
+ expected >> 8);
+}
+
void test_suite_isl923x(void)
{
ztest_test_suite(
@@ -983,6 +1003,9 @@ void test_suite_isl923x(void)
hibernate_test_setup, hibernate_test_teardown),
ztest_unit_test_setup_teardown(
test_isl923x_hibernate__fail_at_ISL9238_REG_CONTROL4,
+ hibernate_test_setup, hibernate_test_teardown),
+ ztest_unit_test_setup_teardown(
+ test_isl923x_hibernate__adc_disable,
hibernate_test_setup, hibernate_test_teardown));
ztest_run_test_suite(isl923x);
}