diff options
author | Eric Herrmann <eherrmann@chromium.org> | 2021-03-09 11:03:33 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-05-05 11:30:55 +0000 |
commit | 984c6e145b834a276e8508f54f2d5171554ed41b (patch) | |
tree | 2a8cf78f8e3c5c42d29599cc35091bc98cafbf50 | |
parent | 6eea01ba062e10aa1d6b1c79375e5ed517ca52de (diff) | |
download | chrome-ec-984c6e145b834a276e8508f54f2d5171554ed41b.tar.gz |
Servo_v4/v4p1: Only read CC if a pull is applied
CC readings aren't valid if we aren't applying a pull to CC. This causes
some issues on platforms which use voltage clamp Rd implementations.
There is currently the intention to fake CC readings if we aren't
applying a pull, but it uses the CC_DETACH flag which doesn't directly
mirror the CC status, and we could be applying no CC pull even if
CC_DETACH isn't set.
Check more directly if we're applying CC pulls when getting the CC
status.
BUG=b:182173370
TEST=firmware_PDTrySrc on Voxel with servoV4
TEST=check that fakedisconnect as src and snk works on servoV4p1
BRANCH=None
Signed-off-by: Eric Herrmann <eherrmann@chromium.org>
Change-Id: Ie67c5c7a05add81aca1336caa7951d31f88c35fc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2745222
Reviewed-by: Nathan Kolluru <nkolluru@google.com>
Reviewed-by: Wai-Hong Tam <waihong@google.com>
(cherry picked from commit 304ac382935378e95ba1f37b98230d8219b18ac0)
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2873629
Commit-Queue: Zhuohao Lee <zhuohao@chromium.org>
Tested-by: Zhuohao Lee <zhuohao@chromium.org>
-rw-r--r-- | board/servo_v4/usb_pd_policy.c | 14 | ||||
-rw-r--r-- | board/servo_v4p1/usb_pd_policy.c | 12 |
2 files changed, 22 insertions, 4 deletions
diff --git a/board/servo_v4/usb_pd_policy.c b/board/servo_v4/usb_pd_policy.c index f995bc58bb..d0983cd39a 100644 --- a/board/servo_v4/usb_pd_policy.c +++ b/board/servo_v4/usb_pd_policy.c @@ -426,13 +426,22 @@ int pd_tcpc_cc_ra(int port, int cc_volt, int cc_sel) return ra; } +/* DUT CC readings aren't valid if we aren't applying CC pulls */ +bool cc_is_valid(void) +{ + if ((cc_config & CC_DETACH) || (cc_pull_stored == TYPEC_CC_OPEN) || + ((cc_pull_stored == TYPEC_CC_RP) && + (rp_value_stored == TYPEC_RP_RESERVED))) + return false; + return true; +} + int pd_adc_read(int port, int cc) { int mv; - if (port == 0) mv = adc_read_channel(cc ? ADC_CHG_CC2_PD : ADC_CHG_CC1_PD); - else if (!(cc_config & CC_DETACH)) { + else if (cc_is_valid()) { /* * In servo v4 hardware logic, both CC lines are wired directly * to DUT. When servo v4 as a snk, DUT may source Vconn to CC2 @@ -463,7 +472,6 @@ int pd_adc_read(int port, int cc) */ mv = 0; } - return mv; } diff --git a/board/servo_v4p1/usb_pd_policy.c b/board/servo_v4p1/usb_pd_policy.c index d00cc6e6b3..640adcd026 100644 --- a/board/servo_v4p1/usb_pd_policy.c +++ b/board/servo_v4p1/usb_pd_policy.c @@ -422,13 +422,23 @@ int pd_tcpc_cc_ra(int port, int cc_volt, int cc_sel) return ra; } +/* DUT CC readings aren't valid if we aren't applying CC pulls */ +bool cc_is_valid(void) +{ + if ((cc_config & CC_DETACH) || (cc_pull_stored == TYPEC_CC_OPEN) || + ((cc_pull_stored == TYPEC_CC_RP) && + (rp_value_stored == TYPEC_RP_RESERVED))) + return false; + return true; +} + int pd_adc_read(int port, int cc) { int mv = -1; if (port == CHG) mv = adc_read_channel(cc ? ADC_CHG_CC2_PD : ADC_CHG_CC1_PD); - else if (!(cc_config & CC_DETACH)) { + else if (cc_is_valid()) { /* * In servo v4 hardware logic, both CC lines are wired directly * to DUT. When servo v4 as a snk, DUT may source Vconn to CC2 |