summaryrefslogtreecommitdiff
path: root/driver/tcpm
diff options
context:
space:
mode:
authorDenis Brockus <dbrockus@google.com>2020-05-20 11:47:03 -0600
committerCommit Bot <commit-bot@chromium.org>2020-05-20 23:38:07 +0000
commit8c8dfe993965fc17b7fc88815a5bdfc1aab57a6e (patch)
tree0a336af64478a7825c4aec4477ffc26004552cc1 /driver/tcpm
parenta4faf04189c22ea5169bdd96690aca5774797a7c (diff)
downloadchrome-ec-8c8dfe993965fc17b7fc88815a5bdfc1aab57a6e.tar.gz
tcpci: manual Safe0V when check_vbus_level only when needed
The adjustments for Safe0V clearing are not needed when check_bus_level is checking PRESENT. So remove the extra overhead of getting the current Safe0V value. BUG=none BRANCH=none TEST=verify USB-C still works Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I97148bd9801a8e37fc0b6220cd27ae3cc596edec Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2210751 Tested-by: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'driver/tcpm')
-rw-r--r--driver/tcpm/tcpci.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/driver/tcpm/tcpci.c b/driver/tcpm/tcpci.c
index a0d6650c0d..5e72e9dd5f 100644
--- a/driver/tcpm/tcpci.c
+++ b/driver/tcpm/tcpci.c
@@ -651,25 +651,26 @@ void tcpci_tcpc_fast_role_swap_enable(int port, int enable)
#ifdef CONFIG_USB_PD_VBUS_DETECT_TCPC
bool tcpci_tcpm_check_vbus_level(int port, enum vbus_level level)
{
- /*
- * Alerts only tell us when Safe0V is entered, have
- * to poll when requesting to see if we left it and
- * have not yet entered Safe5V
- */
- if ((tcpc_config[port].flags & TCPC_FLAGS_TCPCI_REV2_0) &&
- (tcpc_vbus[port] & BIT(VBUS_SAFE0V))) {
- int ext_status = 0;
-
- /* Determine if we left Safe0V */
- tcpm_ext_status(port, &ext_status);
- if (!(ext_status & TCPC_REG_EXT_STATUS_SAFE0V))
- tcpc_vbus[port] &= ~BIT(VBUS_SAFE0V);
- }
+ if (level == VBUS_SAFE0V) {
+ /*
+ * Alerts only tell us when Safe0V is entered, have
+ * to poll when requesting to see if we left it and
+ * have not yet entered Safe5V
+ */
+ if ((tcpc_config[port].flags & TCPC_FLAGS_TCPCI_REV2_0) &&
+ (tcpc_vbus[port] & BIT(VBUS_SAFE0V))) {
+ int ext_status = 0;
+
+ /* Determine if we left Safe0V */
+ tcpm_ext_status(port, &ext_status);
+ if (!(ext_status & TCPC_REG_EXT_STATUS_SAFE0V))
+ tcpc_vbus[port] &= ~BIT(VBUS_SAFE0V);
+ }
- if (level == VBUS_SAFE0V)
return !!(tcpc_vbus[port] & BIT(VBUS_SAFE0V));
- else
+ } else {
return !!(tcpc_vbus[port] & BIT(VBUS_PRESENT));
+ }
}
#endif