summaryrefslogtreecommitdiff
path: root/zephyr/test/drivers
diff options
context:
space:
mode:
authorDevin Lu <Devin.Lu@quantatw.com>2022-08-18 16:23:27 +0800
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-08-24 20:35:07 +0000
commita9cbf4e19e1a534be8f4b0cbe0d09d94cbe570d3 (patch)
tree97e016d7abbea3d20b24afca5876a5bae4553813 /zephyr/test/drivers
parent4c8ba5d95b22713dbd9f3367162c4d99eeb43ca3 (diff)
downloadchrome-ec-a9cbf4e19e1a534be8f4b0cbe0d09d94cbe570d3.tar.gz
zephyr: test: Add tcpci_hard_reset_reinit test
Add coverage for tcpci_hard_reset_reinit. BUG=b:239183823 BRANCH=none TEST=twister -T zephyr/test/drivers Signed-off-by: Devin Lu <Devin.Lu@quantatw.com> Change-Id: Ibc61086f7531654a2d400fa9554141538f5166ec Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3837606 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Tested-by: Devin Lu <devin.lu@quantatw.com> Commit-Queue: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
Diffstat (limited to 'zephyr/test/drivers')
-rw-r--r--zephyr/test/drivers/common/include/test/drivers/tcpci_test_common.h12
-rw-r--r--zephyr/test/drivers/default/src/tcpci.c9
-rw-r--r--zephyr/test/drivers/default/src/tcpci_test_common.c17
3 files changed, 38 insertions, 0 deletions
diff --git a/zephyr/test/drivers/common/include/test/drivers/tcpci_test_common.h b/zephyr/test/drivers/common/include/test/drivers/tcpci_test_common.h
index 6ace7a9e15..83af366fc6 100644
--- a/zephyr/test/drivers/common/include/test/drivers/tcpci_test_common.h
+++ b/zephyr/test/drivers/common/include/test/drivers/tcpci_test_common.h
@@ -222,4 +222,16 @@ void test_tcpci_set_bist_mode(const struct emul *emul,
struct i2c_common_emul_data *common_data,
enum usbc_port port);
+/**
+ * @brief Test TCPCI hard reset re-init callback
+ *
+ * @param emul Pointer to TCPCI emulator
+ * @param common_data Pointer to emulated I2C bus
+ * @param port Select USBC port that will be used to obtain tcpm_drv from
+ * tcpc_config
+ */
+void test_tcpci_hard_reset_reinit(const struct emul *emul,
+ struct i2c_common_emul_data *common_data,
+ enum usbc_port port);
+
#endif /* __TCPCI_TEST_COMMON_H */
diff --git a/zephyr/test/drivers/default/src/tcpci.c b/zephyr/test/drivers/default/src/tcpci.c
index 2dbafae8c5..eeb471ea77 100644
--- a/zephyr/test/drivers/default/src/tcpci.c
+++ b/zephyr/test/drivers/default/src/tcpci.c
@@ -496,6 +496,15 @@ ZTEST(tcpci, test_generic_tcpci_mux_set_get__not_tcpc)
set_usb_mux_tcpc();
}
+ZTEST(tcpci, test_generic_tcpci_hard_reset_reinit)
+{
+ const struct emul *emul = emul_get_binding(EMUL_LABEL);
+ struct i2c_common_emul_data *common_data =
+ emul_tcpci_generic_get_i2c_common_data(emul);
+
+ test_tcpci_hard_reset_reinit(emul, common_data, USBC_PORT_C0);
+}
+
static void *tcpci_setup(void)
{
/* This test suite assumes that first usb mux for port C0 is TCPCI */
diff --git a/zephyr/test/drivers/default/src/tcpci_test_common.c b/zephyr/test/drivers/default/src/tcpci_test_common.c
index 1369b44a08..3fb1cd40e9 100644
--- a/zephyr/test/drivers/default/src/tcpci_test_common.c
+++ b/zephyr/test/drivers/default/src/tcpci_test_common.c
@@ -1011,3 +1011,20 @@ void test_tcpci_set_bist_mode(const struct emul *emul,
check_tcpci_reg(emul, TCPC_REG_TCPC_CTRL, exp_ctrl);
check_tcpci_reg(emul, TCPC_REG_ALERT_MASK, exp_mask);
}
+
+void test_tcpci_hard_reset_reinit(const struct emul *emul,
+ struct i2c_common_emul_data *common_data,
+ enum usbc_port port)
+{
+ const struct tcpm_drv *drv = tcpc_config[port].drv;
+ uint16_t power_status_mask;
+ uint16_t alert_mask;
+
+ zassume_equal(EC_SUCCESS, drv->init(port), NULL);
+ tcpci_emul_get_reg(emul, TCPC_REG_POWER_STATUS_MASK,
+ &power_status_mask);
+ tcpci_emul_get_reg(emul, TCPC_REG_ALERT_MASK, &alert_mask);
+ zassert_ok(tcpci_hard_reset_reinit(USBC_PORT_C0), NULL);
+ check_tcpci_reg(emul, TCPC_REG_POWER_STATUS_MASK, power_status_mask);
+ check_tcpci_reg(emul, TCPC_REG_ALERT_MASK, alert_mask);
+}