summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Massey <aaronmassey@google.com>2021-09-23 12:25:12 -0600
committerCommit Bot <commit-bot@chromium.org>2021-09-28 19:37:22 +0000
commita4a2e61e61965d3c5f34fd8a3b03f696aa2582da (patch)
tree015414734a973aacc020c67b73f43faaadbe18bb
parent6faafa7d2ebeec9df5f7eb0375da57a932155347 (diff)
downloadchrome-ec-a4a2e61e61965d3c5f34fd8a3b03f696aa2582da.tar.gz
zephyr: emul: ln9310
Add INT1_MSK registor to ln9310 emulator. BRANCH=none BUG=b:184856083 TEST=zmake configure --test zephyr/test/drivers Signed-off-by: Aaron Massey <aaronmassey@chromium.org> Change-Id: I864d355767f0c2d091f830329e511be8d293fac4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3179310 Commit-Queue: Aaron Massey <aaronmassey@google.com> Tested-by: Aaron Massey <aaronmassey@google.com> Reviewed-by: Yuval Peress <peress@google.com>
-rw-r--r--zephyr/emul/emul_ln9310.c17
-rw-r--r--zephyr/include/emul/emul_ln9310.h10
-rw-r--r--zephyr/test/drivers/src/ln9310.c2
3 files changed, 29 insertions, 0 deletions
diff --git a/zephyr/emul/emul_ln9310.c b/zephyr/emul/emul_ln9310.c
index 9298767d67..d4eaa8e38d 100644
--- a/zephyr/emul/emul_ln9310.c
+++ b/zephyr/emul/emul_ln9310.c
@@ -29,6 +29,8 @@ struct ln9310_emul_data {
struct i2c_common_emul_data common;
/** The current emulated battery cell type */
enum battery_cell_type battery_cell_type;
+ /** Emulated INT1 MSK register */
+ uint8_t int1_msk_reg;
/** Emulated Lion control register */
uint8_t lion_ctrl_reg;
/** Emulated startup control register */
@@ -122,6 +124,13 @@ void ln9310_emul_set_vin_gt_10v(const struct emul *emulator, bool is_gt_10v)
data->bc_sts_b_reg &= ~LN9310_BC_STS_B_INFET_OUT_SWITCH_OK;
}
+bool ln9310_emul_is_init(const struct emul *emulator)
+{
+ struct ln9310_emul_data *data = emulator->data;
+
+ return (data->int1_msk_reg & LN9310_INT1_MODE) == 0;
+}
+
enum battery_cell_type board_get_battery_cell_type(void)
{
struct ln9310_emul_data *data = singleton->data;
@@ -149,6 +158,10 @@ static int ln9310_emul_write_byte(struct i2c_emul *emul, int reg, uint8_t val,
struct ln9310_emul_data *data = LN9310_DATA_FROM_I2C_EMUL(emul);
switch (reg) {
+ case LN9310_REG_INT1_MSK:
+ __ASSERT_NO_MSG(bytes == 1);
+ data->int1_msk_reg = val;
+ break;
case LN9310_REG_STARTUP_CTRL:
__ASSERT_NO_MSG(bytes == 1);
data->startup_ctrl_reg = val;
@@ -242,6 +255,10 @@ static int ln9310_emul_read_byte(struct i2c_emul *emul, int reg, uint8_t *val,
struct ln9310_emul_data *data = LN9310_DATA_FROM_I2C_EMUL(emul);
switch (reg) {
+ case LN9310_REG_INT1_MSK:
+ __ASSERT_NO_MSG(bytes == 0);
+ *val = data->int1_msk_reg;
+ break;
case LN9310_REG_STARTUP_CTRL:
__ASSERT_NO_MSG(bytes == 0);
*val = data->startup_ctrl_reg;
diff --git a/zephyr/include/emul/emul_ln9310.h b/zephyr/include/emul/emul_ln9310.h
index 8c9101dfab..dfa03eaa28 100644
--- a/zephyr/include/emul/emul_ln9310.h
+++ b/zephyr/include/emul/emul_ln9310.h
@@ -14,6 +14,7 @@
#include <emul.h>
#include "driver/ln9310.h"
+#include <stdbool.h>
/**
* @brief Select the current emulator to use.
@@ -60,4 +61,13 @@ void ln9310_emul_set_version(const struct emul *emulator, int version);
*/
void ln9310_emul_set_vin_gt_10v(const struct emul *emulator, bool is_gt_10v);
+/**
+ * @brief Get whether or not the LN9310 is initialized.
+ *
+ * @param emulator The LN9310 emulator to read.
+ *
+ * @return true if the LN9310 was correctly initialized.
+ */
+bool ln9310_emul_is_init(const struct emul *emulator);
+
#endif /* ZEPHYR_INCLUDE_EMUL_EMUL_LN9310_H_ */
diff --git a/zephyr/test/drivers/src/ln9310.c b/zephyr/test/drivers/src/ln9310.c
index d41625f98f..0033931039 100644
--- a/zephyr/test/drivers/src/ln9310.c
+++ b/zephyr/test/drivers/src/ln9310.c
@@ -21,6 +21,7 @@ void test_ln9310_2s_no_startup__passes_init(void)
ln9310_emul_set_version(emulator, LN9310_BC_STS_C_CHIP_REV_FIXED);
zassert_ok(ln9310_init(), NULL);
+ zassert_true(ln9310_emul_is_init(emulator), NULL);
}
void test_ln9310_3s_no_startup__passes_init(void)
@@ -36,6 +37,7 @@ void test_ln9310_3s_no_startup__passes_init(void)
ln9310_emul_set_version(emulator, LN9310_BC_STS_C_CHIP_REV_FIXED);
zassert_ok(ln9310_init(), NULL);
+ zassert_true(ln9310_emul_is_init(emulator), NULL);
}
void test_suite_ln9310(void)