From c7574ffbe744d80d07488af7ccf681cbc4996347 Mon Sep 17 00:00:00 2001 From: Shawn Nematbakhsh Date: Thu, 10 Nov 2016 08:45:24 -0800 Subject: [PATCH] tcpm: fusb302: Mask BC_LVL interrupt when PD is enabled Avoid needless alerts due to CC lines toggling during PD communication. BUG=chrome-os-partner:58298 BRANCH=gru TEST=Manual on kevin. Verify PD communication with Apple USB-C dongle is functional. Verify Source caps are sent with 100ms-200ms delay. Verify Rp change on Donette is still detected. Signed-off-by; Shawn Nematbakhsh Change-Id: I83fcd1b3235969c8462d23c5159564db2c6a8392 Reviewed-on: https://chromium-review.googlesource.com/409693 Reviewed-by: Vincent Palatin Commit-Queue: Shawn N Tested-by: Shawn N (cherry picked from commit ae9691d0225c78bb183774d585d34de0e7399d7d) Reviewed-on: https://chromium-review.googlesource.com/412033 Commit-Ready: Shawn N Reviewed-by: Shawn N --- driver/tcpm/fusb302.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/driver/tcpm/fusb302.c b/driver/tcpm/fusb302.c index 728c1deb09..3e650b8df5 100644 --- a/driver/tcpm/fusb302.c +++ b/driver/tcpm/fusb302.c @@ -668,6 +668,11 @@ static int fusb302_tcpm_set_rx_enable(int port, int enable) } tcpc_write(port, TCPC_REG_SWITCHES0, reg); + /* Disable BC_LVL interrupt when enabling PD comm */ + if (!tcpc_read(port, TCPC_REG_MASK, ®)) + tcpc_write(port, TCPC_REG_MASK, + reg | TCPC_REG_MASK_BC_LVL); + /* flush rx fifo in case messages have been coming our way */ fusb302_flush_rx_fifo(port); @@ -686,6 +691,11 @@ static int fusb302_tcpm_set_rx_enable(int port, int enable) tcpm_set_cc(port, state[port].previous_pull); tcpc_write(port, TCPC_REG_SWITCHES0, reg); + + /* Enable BC_LVL interrupt when disabling PD comm */ + if (!tcpc_read(port, TCPC_REG_MASK, ®)) + tcpc_write(port, TCPC_REG_MASK, + reg & ~TCPC_REG_MASK_BC_LVL); } fusb302_auto_goodcrc_enable(port, enable); @@ -836,6 +846,13 @@ void fusb302_tcpc_alert(int port) tcpc_read(port, TCPC_REG_INTERRUPTA, &interrupta); tcpc_read(port, TCPC_REG_INTERRUPTB, &interruptb); + /* + * Ignore BC_LVL changes when transmitting / receiving PD, + * since CC level will constantly change. + */ + if (state[port].rx_enable) + interrupt &= ~TCPC_REG_INTERRUPT_BC_LVL; + if (interrupt & TCPC_REG_INTERRUPT_BC_LVL) { /* CC Status change */ task_set_event(PD_PORT_TO_TASK_ID(port), PD_EVENT_CC, 0);