summaryrefslogtreecommitdiff
path: root/driver/tcpm/nct38xx.c
diff options
context:
space:
mode:
authorDenis Brockus <dbrockus@chromium.org>2020-02-12 10:24:53 -0700
committerCommit Bot <commit-bot@chromium.org>2020-02-13 00:58:36 +0000
commit10ff776b895124ec06b81bd26ec3b2d99f834ece (patch)
treeec67d71a935a6e541ba07a822fc7c29bb62be60f /driver/tcpm/nct38xx.c
parent88808c3dda819f9da22272850d2b56ab1e538c9f (diff)
downloadchrome-ec-10ff776b895124ec06b81bd26ec3b2d99f834ece.tar.gz
tcpmv2: make connect after auto-toggle driver specific
nct38xx needs to have the cached polarity set in order to leave DRP mode without going back to an OPEN line. Other TCPCI implementations break when this happens. So moved it to a driver specific function instead TODO(b/149415919): Consider trying to clear the DRP mode instead of changing the polarity BUG=b:149311437 BRANCH=none TEST=verify charger functions on Trogdor Change-Id: I5092a468d860b573a6e5acaf7c013b3425916efb Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2050336 Tested-by: Wai-Hong Tam <waihong@google.com> Commit-Queue: Diana Z <dzigterman@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
Diffstat (limited to 'driver/tcpm/nct38xx.c')
-rw-r--r--driver/tcpm/nct38xx.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/driver/tcpm/nct38xx.c b/driver/tcpm/nct38xx.c
index 633c2155c9..23d97b25bb 100644
--- a/driver/tcpm/nct38xx.c
+++ b/driver/tcpm/nct38xx.c
@@ -13,6 +13,8 @@
#include "nct38xx.h"
#include "task.h"
#include "tcpci.h"
+#include "usb_common.h"
+#include "usb_pd.h"
#if !defined(CONFIG_USB_PD_TCPM_TCPCI)
#error "NCT38XX is using part of standard TCPCI control"
@@ -180,6 +182,33 @@ static void nct38xx_tcpc_alert(int port)
}
+#ifdef CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE
+static void nct38xx_auto_toggle_connection(int port,
+ enum tcpc_cc_voltage_status cc1,
+ enum tcpc_cc_voltage_status cc2)
+{
+ int polarity;
+
+ /*
+ * Get the current polarity so we can make sure the
+ * PD stack will set the CC lines as we expect and
+ * not to setting both CC lines the same due to
+ * NO-POLARITY still being set in the cache. This
+ * will cause this chip to go back to searching
+ * auto toggle with an open on both CC lines.
+ *
+ * TODO(b/149415919): Consider trying to clear the DRP
+ * mode instead of changing the polarity
+ */
+ if (cc_is_rp(cc1) || cc_is_rp(cc2))
+ polarity = get_snk_polarity(cc1, cc2);
+ else
+ polarity = get_src_polarity(cc1, cc2);
+
+ pd_set_polarity(port, polarity);
+}
+#endif
+
const struct tcpm_drv nct38xx_tcpm_drv = {
.init = &nct38xx_tcpm_init,
.release = &tcpci_tcpm_release,
@@ -203,6 +232,7 @@ const struct tcpm_drv nct38xx_tcpm_drv = {
&tcpci_tcpc_enable_auto_discharge_disconnect,
#ifdef CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE
.drp_toggle = &tcpci_tcpc_drp_toggle,
+ .tcpc_auto_toggle_connection = &nct38xx_auto_toggle_connection,
#endif
#ifdef CONFIG_USBC_PPC
.set_snk_ctrl = &tcpci_tcpm_set_snk_ctrl,