From f10da1149896c54bd95163d654e5f2bc4f3bd1f4 Mon Sep 17 00:00:00 2001 From: Patryk Duda Date: Wed, 2 Dec 2020 14:27:48 +0100 Subject: servo_v4/usb_pd_policy: Disable VBUS instead of power supply reset When running 'fakedisconnect' command on ServoV4, CC_DETACH bit is going to be set. Detach is done by calling pd_power_supply_reset() which disables VBUS (set DUT_CHG_EN to 0) and requests 5 volts from charger. Next step is disable PD communication by calling pd_comm_enable() and set RP to RP_RESERVED value (pd_set_rp_rd() function). Setting RP to RP_RESERVED (just disconnect all resistors on CC1 and CC2) actually is a trick to make PD_C1 task think that DUT is disconnected. TCPM stack checks voltage on CC lines and when voltage on active CC line indicates that we are open it changes state to SRC_DISCONNECTED. Changing state to SRC_DISCONNECTED triggers pd_power_supply_reset() which was already run in do_cc() function as a result of 'fakedisconnect' command. Calling this once again causes weird behaviour - communication issues and finally Hard Reset, eg: > fakedisconnect 100 1000 Fake disconnect for 1000 ms starting in 100 ms. C0 Req [1] 5000mV 3000mA [210.470350 CL: p0 s0 i500 v15000] [210.472703 PD TMOUT RX 1/1] RXERR1 Preamble C1 srcCAP>-1 C1 srcCAP>-1 C1 st14 SRC_DISCONNECTED [210.473835 PD TMOUT RX 467/1] RXERR0 Preamble C0 REQ>1 C0 st6 SNK_REQUESTED C0 st34 HARD_RESET_SEND C0 st35 HARD_RESET_EXECUTE C0 HARD RST TX Hard Reset in PD_C0 task can cause additional delay when C1 gets connected and DUT requests higher voltage. As a result DUT sends Hard Reset due to timeout. Hard Reset on port 1 causes PDTrySrc to fail because of timeout waiting for 'fakedisconnect' command. This was fixed by removing one voltage change request. In other words in do_cc() function we are not calling pd_power_supply_reset(), but disabling VBUS only. Eventually pd_power_supply_reset() will be called during transition to SRC_DISCONNECT state. BUG=b:162254118 BRANCH=none TEST=Run FAFT_PD test suite. All tests should pass except PDVbusRequest (depends on charger connected to ServoV4). TEST=Call 'fakedisconnect' command on ServoV4 console and check if there is no Hard Reset on port 0. Signed-off-by: Patryk Duda Change-Id: I657dd1ce2dc3a2f4914e975387eeebb037e1ada5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2569652 Reviewed-by: Jett Rink Reviewed-by: Diana Z --- board/servo_v4/usb_pd_policy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/board/servo_v4/usb_pd_policy.c b/board/servo_v4/usb_pd_policy.c index 0993cc472c..b90b8705f2 100644 --- a/board/servo_v4/usb_pd_policy.c +++ b/board/servo_v4/usb_pd_policy.c @@ -1037,7 +1037,7 @@ static void do_cc(int cc_config_new) if (cc_config_new != cc_config) { if (!(cc_config & CC_DETACH)) { /* Force detach */ - pd_power_supply_reset(DUT); + gpio_set_level(GPIO_DUT_CHG_EN, 0); /* Always set to 0 here so both CC lines are changed */ cc_config &= ~(CC_DISABLE_DTS & CC_ALLOW_SRC); -- cgit v1.2.1