summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorDenis Brockus <dbrockus@chromium.org>2020-01-27 09:45:58 -0700
committerCommit Bot <commit-bot@chromium.org>2020-01-30 17:45:27 +0000
commit7dec638eb577aaa3a00d0551d73c276b94ebacb2 (patch)
tree18bae7940876301320ce569984f2d4ee58dea091 /common
parent41614aba60ca77cd566b9bf29494aaf562225292 (diff)
downloadchrome-ec-7dec638eb577aaa3a00d0551d73c276b94ebacb2.tar.gz
usb: differentiate DTS polarity and normal device polarity
When we have SNK_DTS polarity, we still want to drive both CC lines with the appropriate pull. SRC_DTS should not show as having a polarity. Non-DTS should show the correct polarity. We were only handling the last sentence of that. BUG=b:147754772 BRANCH=none TEST=verify SuzyQ works on zork Change-Id: I013f9d881427d6d97b655f88cfb3a94e3ed10c61 Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2022914 Tested-by: David Schneider <dnschneid@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/usb_common.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/common/usb_common.c b/common/usb_common.c
index fb3ebe84e0..9ac17802d2 100644
--- a/common/usb_common.c
+++ b/common/usb_common.c
@@ -69,8 +69,11 @@ typec_current_t usb_get_typec_current_limit(enum tcpc_cc_polarity polarity,
enum tcpc_cc_voltage_status cc1, enum tcpc_cc_voltage_status cc2)
{
typec_current_t charge = 0;
- enum tcpc_cc_voltage_status cc = polarity ? cc2 : cc1;
- enum tcpc_cc_voltage_status cc_alt = polarity ? cc1 : cc2;
+ enum tcpc_cc_voltage_status cc;
+ enum tcpc_cc_voltage_status cc_alt;
+
+ cc = polarity_rm_dts(polarity) ? cc2 : cc1;
+ cc_alt = polarity_rm_dts(polarity) ? cc1 : cc2;
switch (cc) {
case TYPEC_CC_VOLT_RP_3_0:
@@ -110,16 +113,20 @@ enum tcpc_cc_polarity get_snk_polarity(enum tcpc_cc_voltage_status cc1,
* TYPEC_CC_VOLT_RP_1_5 > TYPEC_CC_VOLT_RP_DEF
* TYPEC_CC_VOLT_RP_DEF > TYPEC_CC_VOLT_OPEN
*/
- return cc2 > cc1;
+ if (cc_is_src_dbg_acc(cc1, cc2))
+ return (cc1 > cc2) ? POLARITY_CC1_DTS : POLARITY_CC2_DTS;
+
+ return (cc1 > cc2) ? POLARITY_CC1 : POLARITY_CC2;
}
enum tcpc_cc_polarity get_src_polarity(enum tcpc_cc_voltage_status cc1,
enum tcpc_cc_voltage_status cc2)
{
- if (cc_is_open(cc1, cc2))
+ if (cc_is_open(cc1, cc2) ||
+ cc_is_snk_dbg_acc(cc1, cc2))
return POLARITY_NONE;
- return cc1 != TYPEC_CC_VOLT_RD;
+ return (cc1 == TYPEC_CC_VOLT_RD) ? POLARITY_CC1 : POLARITY_CC2;
}
enum pd_cc_states pd_get_cc_state(