diff options
Diffstat (limited to 'driver/tcpm/fusb302.c')
-rw-r--r-- | driver/tcpm/fusb302.c | 22 |
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, ®); 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, ®); /* clear VCONN switch bits */ |