diff options
author | Denis Brockus <dbrockus@chromium.org> | 2020-01-27 09:45:58 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-01-30 17:45:27 +0000 |
commit | 7dec638eb577aaa3a00d0551d73c276b94ebacb2 (patch) | |
tree | 18bae7940876301320ce569984f2d4ee58dea091 /include | |
parent | 41614aba60ca77cd566b9bf29494aaf562225292 (diff) | |
download | chrome-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 'include')
-rw-r--r-- | include/usb_pd_tcpm.h | 44 |
1 files changed, 44 insertions, 0 deletions
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, @@ -104,6 +139,15 @@ static inline int cc_is_snk_dbg_acc(enum tcpc_cc_voltage_status cc1, } /** + * 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. */ static inline int cc_is_audio_acc(enum tcpc_cc_voltage_status cc1, |