summaryrefslogtreecommitdiff
path: root/zephyr/emul/emul_isl923x.c
diff options
context:
space:
mode:
authorYuval Peress <peress@google.com>2021-10-01 13:10:51 -0600
committerCommit Bot <commit-bot@chromium.org>2021-10-05 14:23:01 +0000
commit00d382845ee04c53cf44079081ba27619f1cef27 (patch)
tree78a91fb47b47066bbee0462e6b368c4f5ca7ef71 /zephyr/emul/emul_isl923x.c
parentbd131adb7e78d11c883a8e7734dff93b87bfac8e (diff)
downloadchrome-ec-00d382845ee04c53cf44079081ba27619f1cef27.tar.gz
zephyr: test: isl923x DC prochot
Verify setting the prochot amps as well as edge conditions BRANCH=none BUG=b:201602829 TEST=zmake configure --test zephyr/test/drivers Signed-off-by: Yuval Peress <peress@google.com> Change-Id: I12cd413172bfdf395a1c60ef7e487b33687202bc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3200055 Reviewed-by: Aaron Massey <aaronmassey@google.com> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
Diffstat (limited to 'zephyr/emul/emul_isl923x.c')
-rw-r--r--zephyr/emul/emul_isl923x.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/zephyr/emul/emul_isl923x.c b/zephyr/emul/emul_isl923x.c
index db2a7a654a..5ee94dfaec 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 AC PROCHOT register */
#define REG_PROCHOT_AC_MASK GENMASK(12, 7)
+/** Mask used for the DC PROCHOT register */
+#define REG_PROCHOT_DC_MASK GENMASK(13, 8)
+
struct isl923x_emul_data {
/** Common I2C data */
struct i2c_common_emul_data common;
@@ -67,6 +70,8 @@ struct isl923x_emul_data {
uint16_t control_1_reg;
/** Emulated AC PROCHOT register */
uint16_t ac_prochot_reg;
+ /** Emulated DC PROCHOT register */
+ uint16_t dc_prochot_reg;
};
struct isl923x_emul_cfg {
@@ -198,6 +203,13 @@ static int isl923x_emul_read_byte(struct i2c_emul *emul, int reg, uint8_t *val,
else
*val = (uint8_t)((data->ac_prochot_reg >> 8) & 0xff);
break;
+ case ISL923X_REG_PROCHOT_DC:
+ __ASSERT_NO_MSG(bytes == 0 || bytes == 1);
+ if (bytes == 0)
+ *val = (uint8_t)(data->dc_prochot_reg & 0xff);
+ else
+ *val = (uint8_t)((data->dc_prochot_reg >> 8) & 0xff);
+ break;
default:
return -EINVAL;
}
@@ -266,6 +278,14 @@ static int isl923x_emul_write_byte(struct i2c_emul *emul, int reg, uint8_t val,
data->ac_prochot_reg |= (val << 8) &
REG_PROCHOT_AC_MASK;
break;
+ case ISL923X_REG_PROCHOT_DC:
+ __ASSERT_NO_MSG(bytes == 1 || bytes == 2);
+ if (bytes == 1)
+ data->dc_prochot_reg = val & REG_PROCHOT_DC_MASK;
+ else
+ data->dc_prochot_reg |= (val << 8) &
+ REG_PROCHOT_DC_MASK;
+ break;
default:
return -EINVAL;
}