From 7b0206a3a4d69c199fb26527f7cd38fc33732323 Mon Sep 17 00:00:00 2001 From: Divya Sasidharan Date: Fri, 29 Jul 2016 09:57:13 -0700 Subject: tcpm: anx74xx: Fix cable orientation detection Aux switch settings set the polarity and this happens once on every cable connect. But when the cable is kept connected if the mux is set to 0 this is also reset and remains 0 for any next valid mux state. BRANCH=ToT BUG=chrome-os-partner:55757 TEST=manual:on reef, plug HDMI type-C dongle and check if DUT screen is displayed on HDMI display for both the orientation. Change-Id: Ie1320d11d1927acb292dbaf4c932b48cdfd7768e Signed-off-by: Divya Sasidharan Reviewed-on: https://chromium-review.googlesource.com/364693 Commit-Ready: Divya S Sasidharan Tested-by: Divya S Sasidharan Reviewed-by: Kevin K Wong Reviewed-by: Shawn N --- driver/tcpm/anx74xx.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'driver') diff --git a/driver/tcpm/anx74xx.c b/driver/tcpm/anx74xx.c index bd5032376c..58fcc26536 100644 --- a/driver/tcpm/anx74xx.c +++ b/driver/tcpm/anx74xx.c @@ -25,6 +25,8 @@ struct anx_state { }; static struct anx_state anx[CONFIG_USB_PD_PORT_COUNT]; +static int anx74xx_set_mux(int port, int polarity); + static void anx74xx_tcpm_set_auto_good_crc(int port, int enable) { int reg; @@ -156,6 +158,11 @@ static int anx74xx_tcpm_mux_set(int i2c_addr, mux_state_t mux_state) int rv; int port = i2c_addr; + if (!(mux_state & ~MUX_POLARITY_INVERTED)) { + anx[port].mux_state = mux_state; + return anx74xx_tcpm_mux_exit(port); + } + rv = tcpc_read(port, ANX74XX_REG_ANALOG_CTRL_5, ®); if (rv) return EC_ERROR_UNKNOWN; @@ -179,14 +186,14 @@ static int anx74xx_tcpm_mux_set(int i2c_addr, mux_state_t mux_state) val = ANX74XX_REG_MUX_DP_MODE_ACE_CC1; reg |= ANX74XX_REG_MUX_ML2_A; } - } else if (!mux_state) { - return anx74xx_tcpm_mux_exit(port); - } else { - return EC_ERROR_UNIMPLEMENTED; - } + } else + return EC_ERROR_UNIMPLEMENTED; rv = tcpc_write(port, ANX74XX_REG_ANALOG_CTRL_1, val); rv |= tcpc_write(port, ANX74XX_REG_ANALOG_CTRL_5, reg); + + anx74xx_set_mux(port, mux_state & MUX_POLARITY_INVERTED ? 1 : 0); + anx[port].mux_state = mux_state; return rv; -- cgit v1.2.1