summaryrefslogtreecommitdiff
path: root/driver/tcpm/fusb302.c
diff options
context:
space:
mode:
authorDenis Brockus <dbrockus@chromium.org>2019-12-11 16:04:03 -0700
committerCommit Bot <commit-bot@chromium.org>2020-01-08 17:15:04 +0000
commitb560141a1d8ce034ae5b85718c163fb7ab83c24f (patch)
tree1b0505d2eeaa5bc7c1f521e6fed1015e9ab2d023 /driver/tcpm/fusb302.c
parent5750cc926d64033fe7f19b760165011120915ab0 (diff)
downloadchrome-ec-b560141a1d8ce034ae5b85718c163fb7ab83c24f.tar.gz
tcpci: Only drive one CC line when attached
Some of the NCT38XX driver code was more generic TCPCI than specific to the chip. So moved a number of the functions over to be generically handled. In doing this I propagated the idea of tri-state polarity. It is now either NORMAL, FLIPPED, or NONE for unattached. This is needed for the generic handling of correctly setting CC. This required changing the polarity from NONE to the appropriate detected polarity when in auto toggle. tcpci_tcpm_set_cc will now only set a single CC line when attached and both when unattached. BUG=b:146003980, chromium:951681 BRANCH=none TEST=Charging works with both plug orientations with AP on TEST=Device works with both plug orientations with AP on TEST=Charging works with both plug orientations with AP off Change-Id: Ie4b5cc998902a346a4f4a2c1480204b3a81017dd Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1967932 Commit-Queue: Tim Wawrzynczak <twawrzynczak@chromium.org> Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Diffstat (limited to 'driver/tcpm/fusb302.c')
-rw-r--r--driver/tcpm/fusb302.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/driver/tcpm/fusb302.c b/driver/tcpm/fusb302.c
index c6465cd162..3514b2e865 100644
--- a/driver/tcpm/fusb302.c
+++ b/driver/tcpm/fusb302.c
@@ -11,6 +11,7 @@
#include "fusb302.h"
#include "task.h"
#include "hooks.h"
+#include "tcpci.h"
#include "tcpm.h"
#include "timer.h"
#include "usb_charge.h"
@@ -351,6 +352,9 @@ static int fusb302_tcpm_select_rp_value(int port, int rp)
int rv;
uint8_t vnc, rd;
+ /* Keep track of current RP value */
+ tcpci_set_cached_rp(port, rp);
+
rv = tcpc_read(port, TCPC_REG_CONTROL0, &reg);
if (rv)
return rv;
@@ -383,6 +387,9 @@ static int fusb302_tcpm_init(int port)
{
int reg;
+ /* Start with an unknown connection */
+ tcpci_set_cached_pull(port, TYPEC_CC_OPEN);
+
/* set default */
state[port].cc_polarity = -1;
@@ -485,6 +492,9 @@ static int fusb302_tcpm_set_cc(int port, int pull)
{
int reg;
+ /* Keep track of current CC pull value */
+ tcpci_set_cached_pull(port, pull);
+
/* NOTE: FUSB302 toggles a single pull-up between CC1 and CC2 */
/* NOTE: FUSB302 Does not support Ra. */
switch (pull) {
@@ -553,11 +563,21 @@ static int fusb302_tcpm_set_cc(int port, int pull)
return 0;
}
-static int fusb302_tcpm_set_polarity(int port, int polarity)
+static int fusb302_tcpm_set_polarity(int port, enum tcpc_cc_polarity polarity)
{
/* Port polarity : 0 => CC1 is CC line, 1 => CC2 is CC line */
int reg;
+ /*
+ * TCPCI sets the CC lines based on polarity. If it is set to
+ * no connection then both CC lines are driven, otherwise only
+ * one is driven. This driver does not appear to do this. If
+ * that changes, this would be the location you would want to
+ * adjust the CC lines for the current polarity
+ */
+ if (polarity == POLARITY_NONE)
+ return EC_SUCCESS;
+
tcpc_read(port, TCPC_REG_SWITCHES0, &reg);
/* clear VCONN switch bits */