summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Yilun Lin <yllin@chromium.org>2023-03-13 10:37:29 +0800
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-03-14 05:41:53 +0000
commit3b6293d3027c03c42d700747d7dfc152174e8e74 (patch)
treee4d36be98dfc8e444dedba18fe7a469d307ede76
parentdba461e5e1821175757addfb4f58198b117b378f (diff)
downloadchrome-ec-3b6293d3027c03c42d700747d7dfc152174e8e74.tar.gz
tcpci: add tcpci_get_vbus_voltage_no_check
The function is identical to get_vbus_voltage but without checking the DEV_CAP_1. This is a refactor for some TCPCI (e.g. ANX7447) support VBUS sensing, but doesn't report it in DEV_CAP_1. BUG=b:272664811 TEST=./twister -T zephyr/test/drivers BRANCH=none Change-Id: Ic66fc1dd86eea363f82388453c0181f35bfc5ae6 Signed-off-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4333418 Reviewed-by: Ting Shen <phoenixshen@chromium.org> Commit-Queue: Eric Yilun Lin <yllin@google.com> Auto-Submit: Eric Yilun Lin <yllin@google.com> Tested-by: Eric Yilun Lin <yllin@google.com>
-rw-r--r--driver/tcpm/tcpci.c13
-rw-r--r--include/driver/tcpm/tcpci.h10
2 files changed, 19 insertions, 4 deletions
diff --git a/driver/tcpm/tcpci.c b/driver/tcpm/tcpci.c
index 6c6e7a01c1..b78cfbb74c 100644
--- a/driver/tcpm/tcpci.c
+++ b/driver/tcpm/tcpci.c
@@ -1360,13 +1360,10 @@ void tcpci_tcpc_alert(int port)
task_set_event(PD_PORT_TO_TASK_ID(port), pd_event);
}
-int tcpci_get_vbus_voltage(int port, int *vbus)
+int tcpci_get_vbus_voltage_no_check(int port, int *vbus)
{
int error, val;
- if (!(dev_cap_1[port] & TCPC_REG_DEV_CAP_1_VBUS_MEASURE_ALARM_CAPABLE))
- return EC_ERROR_UNIMPLEMENTED;
-
error = tcpc_read16(port, TCPC_REG_VBUS_VOLTAGE, &val);
if (error)
return error;
@@ -1375,6 +1372,14 @@ int tcpci_get_vbus_voltage(int port, int *vbus)
return EC_SUCCESS;
}
+int tcpci_get_vbus_voltage(int port, int *vbus)
+{
+ if (!(dev_cap_1[port] & TCPC_REG_DEV_CAP_1_VBUS_MEASURE_ALARM_CAPABLE))
+ return EC_ERROR_UNIMPLEMENTED;
+
+ return tcpci_get_vbus_voltage_no_check(port, vbus);
+}
+
int tcpci_get_chip_info_mutable(
int port, int live, struct ec_response_pd_chip_info_v1 *const chip_info,
int (*const mutator)(int port, bool live,
diff --git a/include/driver/tcpm/tcpci.h b/include/driver/tcpm/tcpci.h
index 4ded8c23e7..917b2b65aa 100644
--- a/include/driver/tcpm/tcpci.h
+++ b/include/driver/tcpm/tcpci.h
@@ -380,6 +380,16 @@ int tcpci_get_chip_info_mutable(
int (*mutator)(int port, bool live,
struct ec_response_pd_chip_info_v1 *cached));
+/**
+ * This function is identical to the tcpci_get_vbus_voltage without
+ * checking the DEV_CAP_1.
+ *
+ * @param port: The USB-C port to query
+ * @param vbus: VBUS voltage in mV the TCPC sensed
+ *
+ * @return EC_SUCCESS on success, and otherwise on failure.
+ */
+int tcpci_get_vbus_voltage_no_check(int port, int *vbus);
int tcpci_get_vbus_voltage(int port, int *vbus);
bool tcpci_tcpm_get_snk_ctrl(int port);
int tcpci_tcpm_set_snk_ctrl(int port, int enable);