diff options
author | Shawn Nematbakhsh <shawnn@chromium.org> | 2016-10-12 12:20:55 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-12-01 19:58:52 -0800 |
commit | f5f3bcfe57998e99cf451eb88dbc0567e3c91844 (patch) | |
tree | 8225c81f12cef12fe6283dae374034992e1c481f | |
parent | 81d32b8106908470178096cde00097ff48b94d18 (diff) | |
download | chrome-ec-f5f3bcfe57998e99cf451eb88dbc0567e3c91844.tar.gz |
tcpm: fusb302: Remove dead rev.A code
Auto-toggle isn't used on rev. >= B so remove related dead code, and fix
VCONN setting on Rp selection.t
BUG=None.
TEST=Verify charging + DP dongles still work properly on Kevin.
BRANCH=gru.
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Change-Id: I2ce98760d3435a5721831864f8ea241151b5a54d
Reviewed-on: https://chromium-review.googlesource.com/397658
(cherry picked from commit 4d42d16fe97d35d1d9ea6200f2343934bba4341e)
Reviewed-on: https://chromium-review.googlesource.com/415487
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
-rw-r--r-- | driver/tcpm/fusb302.c | 116 |
1 files changed, 3 insertions, 113 deletions
diff --git a/driver/tcpm/fusb302.c b/driver/tcpm/fusb302.c index 3db4102232..0fb04ba1ff 100644 --- a/driver/tcpm/fusb302.c +++ b/driver/tcpm/fusb302.c @@ -23,11 +23,6 @@ static struct fusb302_chip_state { /* 1 = pulling up (DFP) 0 = pulling down (UFP) */ int pulling_up; int rx_enable; - int dfp_toggling_on; - int previous_pull; - int togdone_pullup_cc1; - int togdone_pullup_cc2; - struct mutex set_cc_lock; uint8_t mdac_vnc; uint8_t mdac_rd; } state[CONFIG_USB_PD_PORT_COUNT]; @@ -364,7 +359,6 @@ static int fusb302_tcpm_init(int port) /* set default */ state[port].cc_polarity = -1; - state[port].previous_pull = TYPEC_CC_RD; /* set the voltage threshold for no connect detection (vOpen) */ state[port].mdac_vnc = TCPC_REG_MEASURE_MDAC_MV(PD_SRC_DEF_VNC_MV); /* set the voltage threshold for Rd vs Ra detection */ @@ -426,19 +420,6 @@ static int fusb302_tcpm_init(int port) static int fusb302_tcpm_get_cc(int port, int *cc1, int *cc2) { - /* - * can't measure while doing DFP toggling - - * FUSB302 takes control of the switches. - * During this time, tell software that CCs are open - - * at least until we get the TOGDONE interrupt... - * which signals that the hardware found something. - */ - if (state[port].dfp_toggling_on) { - *cc1 = TYPEC_CC_VOLT_OPEN; - *cc2 = TYPEC_CC_VOLT_OPEN; - return 0; - } - if (state[port].pulling_up) { /* Source mode? */ detect_cc_pin_source_manual(port, cc1, cc2); @@ -454,16 +435,6 @@ static int fusb302_tcpm_set_cc(int port, int pull) { int reg; - /* - * Ensure we aren't in the process of changing CC from the alert - * handler, then cancel any pending toggle-triggered CC change. - */ - mutex_lock(&state[port].set_cc_lock); - state[port].dfp_toggling_on = 0; - mutex_unlock(&state[port].set_cc_lock); - - state[port].previous_pull = pull; - /* NOTE: FUSB302 toggles a single pull-up between CC1 and CC2 */ /* NOTE: FUSB302 Does not support Ra. */ switch (pull) { @@ -482,14 +453,13 @@ static int fusb302_tcpm_set_cc(int port, int pull) TCPC_REG_SWITCHES0_CC2_PU_EN; if (state[port].vconn_enabled) - reg |= state[port].togdone_pullup_cc1 ? - TCPC_REG_SWITCHES0_VCONN_CC2 : - TCPC_REG_SWITCHES0_VCONN_CC1; + reg |= state[port].cc_polarity ? + TCPC_REG_SWITCHES0_VCONN_CC1 : + TCPC_REG_SWITCHES0_VCONN_CC2; tcpc_write(port, TCPC_REG_SWITCHES0, reg); state[port].pulling_up = 1; - state[port].dfp_toggling_on = 0; break; case TYPEC_CC_RD: /* Enable UFP Mode */ @@ -509,7 +479,6 @@ static int fusb302_tcpm_set_cc(int port, int pull) tcpc_write(port, TCPC_REG_SWITCHES0, reg); state[port].pulling_up = 0; - state[port].dfp_toggling_on = 0; break; case TYPEC_CC_OPEN: /* Disable toggling */ @@ -526,7 +495,6 @@ static int fusb302_tcpm_set_cc(int port, int pull) tcpc_write(port, TCPC_REG_SWITCHES0, reg); state[port].pulling_up = 0; - state[port].dfp_toggling_on = 0; break; default: /* Unsupported... */ @@ -677,18 +645,6 @@ static int fusb302_tcpm_set_rx_enable(int port, int enable) } else { - /* - * bit of a hack here. - * when this function is called to disable rx (enable=0) - * using it as an indication of detach (gulp!) - * to reset our knowledge of where - * the toggle state machine landed. - */ - state[port].togdone_pullup_cc1 = 0; - state[port].togdone_pullup_cc2 = 0; - - tcpm_set_cc(port, state[port].previous_pull); - tcpc_write(port, TCPC_REG_SWITCHES0, reg); /* Enable BC_LVL interrupt when disabling PD comm */ @@ -832,8 +788,6 @@ void fusb302_tcpc_alert(int port) int interrupt; int interrupta; int interruptb; - int reg; - int toggle_answer; int head; uint32_t payload[7]; @@ -870,70 +824,6 @@ void fusb302_tcpc_alert(int port) pd_transmit_complete(port, TCPC_TX_COMPLETE_SUCCESS); } - if (interrupta & TCPC_REG_INTERRUPTA_TOGDONE) { - /* Don't allow other tasks to change CC PUs */ - mutex_lock(&state[port].set_cc_lock); - /* If our toggle request is obsolete then we're done */ - if (state[port].dfp_toggling_on) { - /* read what 302 settled on for an answer...*/ - tcpc_read(port, TCPC_REG_STATUS1A, ®); - reg = reg >> TCPC_REG_STATUS1A_TOGSS_POS; - reg = reg & TCPC_REG_STATUS1A_TOGSS_MASK; - - toggle_answer = reg; - - /* Turn off toggle so we can take over the switches */ - tcpc_read(port, TCPC_REG_CONTROL2, ®); - reg &= ~TCPC_REG_CONTROL2_TOGGLE; - tcpc_write(port, TCPC_REG_CONTROL2, reg); - - switch (toggle_answer) { - case TCPC_REG_STATUS1A_TOGSS_SRC1: - state[port].togdone_pullup_cc1 = 1; - state[port].togdone_pullup_cc2 = 0; - break; - case TCPC_REG_STATUS1A_TOGSS_SRC2: - state[port].togdone_pullup_cc1 = 0; - state[port].togdone_pullup_cc2 = 1; - break; - case TCPC_REG_STATUS1A_TOGSS_SNK1: - case TCPC_REG_STATUS1A_TOGSS_SNK2: - case TCPC_REG_STATUS1A_TOGSS_AA: - state[port].togdone_pullup_cc1 = 0; - state[port].togdone_pullup_cc2 = 0; - break; - default: - /* TODO: should never get here, but? */ - ASSERT(0); - break; - } - - /* enable the pull-up we know to be necessary */ - tcpc_read(port, TCPC_REG_SWITCHES0, ®); - - reg &= ~(TCPC_REG_SWITCHES0_CC2_PU_EN | - TCPC_REG_SWITCHES0_CC1_PU_EN | - TCPC_REG_SWITCHES0_CC1_PD_EN | - TCPC_REG_SWITCHES0_CC2_PD_EN | - TCPC_REG_SWITCHES0_VCONN_CC1 | - TCPC_REG_SWITCHES0_VCONN_CC2); - - reg |= TCPC_REG_SWITCHES0_CC1_PU_EN | - TCPC_REG_SWITCHES0_CC2_PU_EN; - - if (state[port].vconn_enabled) - reg |= state[port].togdone_pullup_cc1 ? - TCPC_REG_SWITCHES0_VCONN_CC2 : - TCPC_REG_SWITCHES0_VCONN_CC1; - - tcpc_write(port, TCPC_REG_SWITCHES0, reg); - /* toggle done */ - state[port].dfp_toggling_on = 0; - } - - mutex_unlock(&state[port].set_cc_lock); - } - if (interrupta & TCPC_REG_INTERRUPTA_RETRYFAIL) { /* all retries have failed to get a GoodCRC */ pd_transmit_complete(port, TCPC_TX_COMPLETE_FAILED); |