diff options
author | Yuval Peress <peress@google.com> | 2021-10-03 22:35:19 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-10-05 14:23:28 +0000 |
commit | a3de5c56673b3e02a9bf86f5dc07313c2323e008 (patch) | |
tree | aee9f110be7431a0ae1057bb94edd869c184ba8a | |
parent | 5baaa5c440cfb4ed0c1b8f20c8d2bb0236ab62d5 (diff) | |
download | chrome-ec-a3de5c56673b3e02a9bf86f5dc07313c2323e008.tar.gz |
zephyr: test: Add ctrl3 register for isl9238 emulator
Adding support for this register improves code coverage for the existing
init function. No additional tests are needed at this point.
BRANCH=none
BUG=b:201819565
TEST=zmake configure --test zephyr/test/drivers
Signed-off-by: Yuval Peress <peress@google.com>
Change-Id: I9e19372501775940f1a23d05317ba3971212083a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3201913
Reviewed-by: Keith Short <keithshort@chromium.org>
-rw-r--r-- | zephyr/emul/emul_isl923x.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/zephyr/emul/emul_isl923x.c b/zephyr/emul/emul_isl923x.c index dcbaaf641b..f97af88da0 100644 --- a/zephyr/emul/emul_isl923x.c +++ b/zephyr/emul/emul_isl923x.c @@ -46,6 +46,9 @@ LOG_MODULE_REGISTER(isl923x_emul, CONFIG_ISL923X_EMUL_LOG_LEVEL); /** Mask used for the control 2 register */ #define REG_CONTROL2_MASK GENMASK(15, 0) +/** Mask used for the control 3 register */ +#define REG_CONTROL3_MASK GENMASK(15, 0) + /** Mask used for the AC PROCHOT register */ #define REG_PROCHOT_AC_MASK GENMASK(12, 7) @@ -73,6 +76,8 @@ struct isl923x_emul_data { uint16_t control_1_reg; /** Emulated control 2 register */ uint16_t control_2_reg; + /** Emulated control 3 register */ + uint16_t control_3_reg; /** Emulated AC PROCHOT register */ uint16_t ac_prochot_reg; /** Emulated DC PROCHOT register */ @@ -208,6 +213,13 @@ static int isl923x_emul_read_byte(struct i2c_emul *emul, int reg, uint8_t *val, else *val = (uint8_t)((data->control_2_reg >> 8) & 0xff); break; + case ISL9238_REG_CONTROL3: + __ASSERT_NO_MSG(bytes == 0 || bytes == 1); + if (bytes == 0) + *val = (uint8_t)(data->control_3_reg & 0xff); + else + *val = (uint8_t)((data->control_3_reg >> 8) & 0xff); + break; case ISL923X_REG_PROCHOT_AC: __ASSERT_NO_MSG(bytes == 0 || bytes == 1); if (bytes == 0) @@ -289,6 +301,13 @@ static int isl923x_emul_write_byte(struct i2c_emul *emul, int reg, uint8_t val, else data->control_2_reg |= (val << 8) & REG_CONTROL2_MASK; break; + case ISL9238_REG_CONTROL3: + __ASSERT_NO_MSG(bytes == 1 || bytes == 2); + if (bytes == 1) + data->control_3_reg = val & REG_CONTROL3_MASK; + else + data->control_3_reg |= (val << 8) & REG_CONTROL3_MASK; + break; case ISL923X_REG_PROCHOT_AC: __ASSERT_NO_MSG(bytes == 1 || bytes == 2); if (bytes == 1) |