From 7dec638eb577aaa3a00d0551d73c276b94ebacb2 Mon Sep 17 00:00:00 2001 From: Denis Brockus Date: Mon, 27 Jan 2020 09:45:58 -0700 Subject: 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 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2022914 Tested-by: David Schneider Reviewed-by: Jett Rink --- include/usb_pd_tcpm.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'include/usb_pd_tcpm.h') diff --git a/include/usb_pd_tcpm.h b/include/usb_pd_tcpm.h index 9a4140afb4..97b0ec0864 100644 --- a/include/usb_pd_tcpm.h +++ b/include/usb_pd_tcpm.h @@ -50,11 +50,46 @@ enum tcpc_rp_value { }; enum tcpc_cc_polarity { + /* + * _NONE: either disconnected or connected to a SNK Debug + * Accessory + */ POLARITY_NONE = -1, + + /* + * _CCx: is used to indicate the polarity while not connected to + * a Debug Accessory. Only one CC line will assert a resistor and + * the other will be open. + */ POLARITY_CC1 = 0, POLARITY_CC2 = 1, + + /* + * CCx_DTS is used to indicate the polarity while connected to a + * SRC Debug Accessory. Assert resistors on both lines. + */ + POLARITY_CC1_DTS = 2, + POLARITY_CC2_DTS = 3, + + /* + * The current TCPC code relies on these specific POLARITY values. + * Adding in a check to verify if the list grows for any reason + * that this will give a hint that other places need to be + * adjusted. + */ + POLARITY_COUNT }; +/** + * Returns whether the polarity without the DTS extension + */ +static inline enum tcpc_cc_polarity polarity_rm_dts( + enum tcpc_cc_polarity polarity) +{ + BUILD_ASSERT(POLARITY_COUNT == 4); + return (polarity == POLARITY_NONE) ? polarity : polarity & BIT(0); +} + enum tcpm_transmit_type { TCPC_TX_SOP = 0, TCPC_TX_SOP_PRIME = 1, @@ -103,6 +138,15 @@ static inline int cc_is_snk_dbg_acc(enum tcpc_cc_voltage_status cc1, return cc1 == TYPEC_CC_VOLT_RD && cc2 == TYPEC_CC_VOLT_RD; } +/** + * Returns true if we detect the port partner is a src debug accessory. + */ +static inline int cc_is_src_dbg_acc(enum tcpc_cc_voltage_status cc1, + enum tcpc_cc_voltage_status cc2) +{ + return cc_is_rp(cc1) && cc_is_rp(cc2); +} + /** * Returns true if the port partner is an audio accessory. */ -- cgit v1.2.1