summaryrefslogtreecommitdiff
path: root/driver
diff options
context:
space:
mode:
authorJett Rink <jettrink@chromium.org>2018-04-03 10:49:22 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-04-03 18:47:09 -0700
commit228dc8d1193d2b4c26f60a9da779803bd41fe172 (patch)
treeeecc8f848bb6f05d07eb8f25e6dee35626d500e3 /driver
parent44c81deec45960c4e3f7f6b11999c28419f6c2ef (diff)
downloadchrome-ec-228dc8d1193d2b4c26f60a9da779803bd41fe172.tar.gz
tcpci: remove vbus level caching
On yorp, the PS8751 TCPC resets its event mask when it goes into low power mode which turns off the VBUS detection event mask. Since the first interrupts after lower power mode should contain the vbus changed interrupt we miss it. We have tried many different permutations of resetting the event mask on reset without achieving 100% detection success. The PPC Vbus detection code calls out to the PPC over i2c every time vbus level is checked; applying that strategy for TPCPs make the detection much more robust. BRANCH=none BUG=b:77458917 TEST=yorp detect vbus on insertion every time with PS8751 Change-Id: I15b5f2ee016f68bac9e4bf4d5d89bbaef323f131 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/993394 Reviewed-by: Scott Collyer <scollyer@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r--driver/tcpm/tcpci.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/driver/tcpm/tcpci.c b/driver/tcpm/tcpci.c
index e1c1efab28..40bcc7765d 100644
--- a/driver/tcpm/tcpci.c
+++ b/driver/tcpm/tcpci.c
@@ -18,8 +18,6 @@
#include "usb_pd_tcpc.h"
#include "util.h"
-static int tcpc_vbus[CONFIG_USB_PD_PORT_COUNT];
-
/* Save the selected rp value */
static int selected_rp[CONFIG_USB_PD_PORT_COUNT];
@@ -96,10 +94,12 @@ int tcpci_tcpm_get_cc(int port, int *cc1, int *cc2)
return rv;
}
+#ifdef CONFIG_USB_PD_VBUS_DETECT_TCPC
static int tcpci_tcpm_get_power_status(int port, int *status)
{
return tcpc_read(port, TCPC_REG_POWER_STATUS, status);
}
+#endif /* #ifdef CONFIG_USB_PD_VBUS_DETECT_TCPC */
int tcpci_tcpm_select_rp_value(int port, int rp)
{
@@ -203,7 +203,12 @@ int tcpci_tcpm_set_rx_enable(int port, int enable)
#ifdef CONFIG_USB_PD_VBUS_DETECT_TCPC
int tcpci_tcpm_get_vbus_level(int port)
{
- return tcpc_vbus[port];
+ int reg;
+
+ /* Read Power Status register */
+ tcpci_tcpm_get_power_status(port, &reg);
+ /* Update VBUS status */
+ return reg & TCPC_REG_POWER_STATUS_VBUS_PRES ? 1 : 0;
}
#endif
@@ -301,15 +306,13 @@ void tcpci_tcpc_alert(int port)
*/
task_set_event(PD_PORT_TO_TASK_ID(port),
PD_EVENT_TCPC_RESET, 0);
+#if defined(CONFIG_USB_PD_VBUS_DETECT_TCPC) && defined(CONFIG_USB_CHARGER)
} else {
/* Read Power Status register */
tcpci_tcpm_get_power_status(port, &reg);
- /* Update VBUS status */
- tcpc_vbus[port] = reg &
- TCPC_REG_POWER_STATUS_VBUS_PRES ? 1 : 0;
-#if defined(CONFIG_USB_PD_VBUS_DETECT_TCPC) && defined(CONFIG_USB_CHARGER)
/* Update charge manager with new VBUS state */
- usb_charger_vbus_change(port, tcpc_vbus[port]);
+ usb_charger_vbus_change(port,
+ reg & TCPC_REG_POWER_STATUS_VBUS_PRES);
task_wake(PD_PORT_TO_TASK_ID(port));
#endif /* CONFIG_USB_PD_VBUS_DETECT_TCPC && CONFIG_USB_CHARGER */
}
@@ -433,12 +436,12 @@ int tcpci_tcpm_init(int port)
msleep(10);
}
+ /* Set Power Status mask */
+ init_power_status_mask(port);
+
+ /* Clear alert request and set alert mask */
tcpc_write16(port, TCPC_REG_ALERT, 0xffff);
/* Initialize power_status_mask */
- init_power_status_mask(port);
- /* Update VBUS status */
- tcpc_vbus[port] = power_status &
- TCPC_REG_POWER_STATUS_VBUS_PRES ? 1 : 0;
error = init_alert_mask(port);
if (error)
return error;