summaryrefslogtreecommitdiff
path: root/driver/tcpm/fusb302.c
diff options
context:
space:
mode:
authorScott <scollyer@chromium.org>2016-07-18 18:55:52 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-07-20 13:04:37 -0700
commit17f02ee5a709ceccc5f9447b120aac8d93008039 (patch)
tree92675ec27a9e1cf53487485ff58e2c5efc8c1b1d /driver/tcpm/fusb302.c
parent819239f00b0a4d1335b2f2a7cab7b4630fc9c096 (diff)
downloadchrome-ec-17f02ee5a709ceccc5f9447b120aac8d93008039.tar.gz
tcpm: fusb302: Fix issue with MDAC register definition
There was a mistake in the initial driver implementation regarding the MDAC field in the measure register (address 0x04). The header file and associated code defined this 6 bit field to be the upper 6 bits of the 8 bit register. However, the data sheet for both rev A and B silicon show this field as being the lower 6 bits of this register. In addition, when using this threshold to distinguish between a Rd and Ra attach, the threshold test logic was backwards. If the threhold bit is set, then it means the voltage is higher than the 200mV setting and should indicate a Rd attach. BUG=chrome-os-partner:54790 BRANCH=none TEST=manual Tested with Anker TypeC hub using known polarity (CC1). Previously, would see CC2 be selected as the active polarity. This resulted in USB PD state machine getting stuck in SRC_DISCOVERY due to SRC_CAP messages not being received correctly. With the changes, verified that correct CC polarity is always detected and results in reaching SRC_READY state. Change-Id: Ia522abdac31642ff99bbf13ccc73a0a77bbdb32d Signed-off-by: Scott <scollyer@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/361614 Commit-Ready: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Joe Bauman <joe.bauman@fairchildsemi.com> Reviewed-by: Guenter Roeck <groeck@google.com> Reviewed-by: Shawn N <shawnn@chromium.org>
Diffstat (limited to 'driver/tcpm/fusb302.c')
-rw-r--r--driver/tcpm/fusb302.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/driver/tcpm/fusb302.c b/driver/tcpm/fusb302.c
index d2c6ee3e04..4693c7ccf9 100644
--- a/driver/tcpm/fusb302.c
+++ b/driver/tcpm/fusb302.c
@@ -118,8 +118,8 @@ static void detect_cc_pin_source(int port, int *cc1_lvl, int *cc2_lvl)
TCPC_REG_SWITCHES0_MEAS_CC1);
}
- /* Set MDAC Value to High. MDAC Reg is 7:2 */
- tcpc_write(port, TCPC_REG_MEASURE, 0x26 << 2);
+ /* Set MDAC Value to High (1.6V). MDAC Reg is 5:0 */
+ tcpc_write(port, TCPC_REG_MEASURE, 0x26);
/* CC1 is now being measured by FUSB302. */
@@ -133,8 +133,8 @@ static void detect_cc_pin_source(int port, int *cc1_lvl, int *cc2_lvl)
*cc1_lvl = TYPEC_CC_VOLT_OPEN;
} else {
- /* Set MDAC Value to Low. MDAC Reg is 7:2 */
- tcpc_write(port, TCPC_REG_MEASURE, 0x05 << 2);
+ /* Set MDAC Value to Low (200 mV). MDAC Reg is 5:0 */
+ tcpc_write(port, TCPC_REG_MEASURE, 0x05);
/* Wait on measurement */
usleep(250);
@@ -143,9 +143,9 @@ static void detect_cc_pin_source(int port, int *cc1_lvl, int *cc2_lvl)
tcpc_read(port, TCPC_REG_STATUS0, &reg);
if (reg & TCPC_REG_STATUS0_COMP)
- *cc1_lvl = TYPEC_CC_VOLT_RA;
- else
*cc1_lvl = TYPEC_CC_VOLT_RD;
+ else
+ *cc1_lvl = TYPEC_CC_VOLT_RA;
}
} else if (state[port].togdone_pullup_cc2 == 1) {
/* Measure CC2 */
@@ -162,8 +162,8 @@ static void detect_cc_pin_source(int port, int *cc1_lvl, int *cc2_lvl)
TCPC_REG_SWITCHES0_MEAS_CC2);
}
- /* Set MDAC Value to High. MDAC Reg is 7:2 */
- tcpc_write(port, TCPC_REG_MEASURE, 0x26 << 2);
+ /* Set MDAC Value to High (~1.6V). MDAC Reg is 5:0 */
+ tcpc_write(port, TCPC_REG_MEASURE, 0x26);
/* CC2 is now being measured by FUSB302. */
@@ -177,8 +177,8 @@ static void detect_cc_pin_source(int port, int *cc1_lvl, int *cc2_lvl)
*cc2_lvl = TYPEC_CC_VOLT_OPEN;
} else {
- /* Set MDAC Value to Low. MDAC Reg is 7:2 */
- tcpc_write(port, TCPC_REG_MEASURE, 0x05 << 2);
+ /* Set MDAC Value to Low (~200mV). MDAC Reg is 5:0 */
+ tcpc_write(port, TCPC_REG_MEASURE, 0x05);
/* Wait on measurement */
usleep(250);
@@ -187,9 +187,9 @@ static void detect_cc_pin_source(int port, int *cc1_lvl, int *cc2_lvl)
tcpc_read(port, TCPC_REG_STATUS0, &reg);
if (reg & TCPC_REG_STATUS0_COMP)
- *cc2_lvl = TYPEC_CC_VOLT_RA;
- else
*cc2_lvl = TYPEC_CC_VOLT_RD;
+ else
+ *cc2_lvl = TYPEC_CC_VOLT_RA;
}
}
}