summaryrefslogtreecommitdiff
path: root/driver/tcpm/ps8xxx.c
diff options
context:
space:
mode:
Diffstat (limited to 'driver/tcpm/ps8xxx.c')
-rw-r--r--driver/tcpm/ps8xxx.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/driver/tcpm/ps8xxx.c b/driver/tcpm/ps8xxx.c
index 09e4a404b9..21a20566ff 100644
--- a/driver/tcpm/ps8xxx.c
+++ b/driver/tcpm/ps8xxx.c
@@ -92,6 +92,25 @@ int ps8xxx_tcpc_get_fw_version(int port, int *version)
return tcpc_read(port, FW_VER_REG, version);
}
+#ifdef CONFIG_USB_PD_VBUS_DETECT_TCPC
+/*
+ * Read Vbus level directly instead of using the cached version because some
+ * TPCPs do not fire the Vbus level change interrupt correctly after resuming
+ * from low-power mode.
+ */
+int ps8xxx_tcpm_get_vbus_level(int port)
+{
+ int reg;
+
+ /* Read Power Status register */
+ if (tcpc_read(port, TCPC_REG_POWER_STATUS, &reg) == EC_SUCCESS)
+ return reg & TCPC_REG_POWER_STATUS_VBUS_PRES ? 1 : 0;
+
+ /* If read failed, report that Vbus is off */
+ return 0;
+}
+#endif
+
static int ps8xxx_tcpc_bist_mode_2(int port)
{
int rv;
@@ -141,7 +160,7 @@ const struct tcpm_drv ps8xxx_tcpm_drv = {
.release = &ps8xxx_tcpm_release,
.get_cc = &tcpci_tcpm_get_cc,
#ifdef CONFIG_USB_PD_VBUS_DETECT_TCPC
- .get_vbus_level = &tcpci_tcpm_get_vbus_level,
+ .get_vbus_level = &ps8xxx_tcpm_get_vbus_level,
#endif
.select_rp_value = &tcpci_tcpm_select_rp_value,
.set_cc = &tcpci_tcpm_set_cc,