summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWai-Hong Tam <waihong@google.com>2019-07-29 11:14:56 -0700
committerCommit Bot <commit-bot@chromium.org>2019-09-18 18:31:03 +0000
commita65af110097ebbc0368cf30be345f95762a6a0d9 (patch)
tree2ff1af04fececd02e91a4e9ab1319cdd997ceebc
parentecb74cc5610c835b32ccfabc7ff67a24eb3acb9b (diff)
downloadchrome-ec-a65af110097ebbc0368cf30be345f95762a6a0d9.tar.gz
servo_v4: Be a sink without PD comm when power charge-through detached
This CL changes the behavior of no charge-through happens but a user explicitly sets servo v4 as a source. It is changed from "sink with PD comm" to "sink without PD comm". BRANCH=servo BUG=b:138585164, b:135035317 TEST=Manual as the following console interaction: (Plug the power cable back to servo v4) > cc src > pd 1 state Port C1 CC1, Ena - Role: SRC-UFP State: SRC_READY, Flags: 0x415e > cc snk > pd 1 state Port C1 CC1, Dis - Role: SNK-UFP State: SNK_DISCOVERY, Flags: 0x0608 > cc pdsnk > pd 1 state Port C1 CC1, Ena - Role: SNK-UFP State: SNK_READY, Flags: 0x414e > cc src > pd 1 state Port C1 CC1, Ena - Role: SRC-UFP State: SRC_READY, Flags: 0x415e (Unplug the power cable from servo v4) > pd 1 state Port C1 CC1, Dis - Role: SNK-UFP State: SNK_DISCOVERY, Flags: 0x0608 (Plug the power cable back to servo v4) > pd 1 state Port C1 CC1, Ena - Role: SRC-UFP State: SRC_READY, Flags: 0x415e > cc pdsnk > pd 1 state Port C1 CC1, Ena - Role: SNK-UFP State: SNK_READY, Flags: 0x414e (Unplug the power cable from servo v4) > pd 1 state Port C1 CC1, Ena - Role: SNK-UFP State: SNK_READY, Flags: 0x414e (Plug the power cable back to servo v4) > pd 1 state Port C1 CC1, Ena - Role: SNK-UFP State: SNK_READY, Flags: 0x414e > cc snk > pd 1 state Port C1 CC1, Dis - Role: SNK-UFP State: SNK_DISCOVERY, Flags: 0x0608 (Unplug the power cable from servo v4) > pd 1 state Port C1 CC1, Dis - Role: SNK-UFP State: SNK_DISCOVERY, Flags: 0x0608 (Plug the power cable back to servo v4) > pd 1 state Port C1 CC1, Dis - Role: SNK-UFP State: SNK_DISCOVERY, Flags: 0x0608 Change-Id: Ia4b6f858a4b0e22d81efbff02df4d02f3dc04bc9 Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1724933 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> (cherry picked from commit 66bb7ba71db2a8c1233bd51d06e0ece93d89ce91) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1811460
-rw-r--r--board/servo_v4/usb_pd_policy.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/board/servo_v4/usb_pd_policy.c b/board/servo_v4/usb_pd_policy.c
index c9ce2db514..3c49eefeda 100644
--- a/board/servo_v4/usb_pd_policy.c
+++ b/board/servo_v4/usb_pd_policy.c
@@ -36,7 +36,7 @@
#define CONFIG_SET_CLEAR(c, set, clear) ((c | (set)) & ~(clear))
#define CONFIG_SRC(c) CONFIG_SET_CLEAR(c, \
CC_DISABLE_DTS | CC_ALLOW_SRC, \
- CC_ENABLE_DRP)
+ CC_ENABLE_DRP | CC_SNK_WITH_PD)
#define CONFIG_SNK(c) CONFIG_SET_CLEAR(c, \
CC_DISABLE_DTS, \
CC_ALLOW_SRC | CC_ENABLE_DRP | CC_SNK_WITH_PD)
@@ -45,10 +45,10 @@
CC_ALLOW_SRC | CC_ENABLE_DRP)
#define CONFIG_DRP(c) CONFIG_SET_CLEAR(c, \
CC_DISABLE_DTS | CC_ALLOW_SRC | CC_ENABLE_DRP, \
- 0)
+ CC_SNK_WITH_PD)
#define CONFIG_SRCDTS(c) CONFIG_SET_CLEAR(c, \
CC_ALLOW_SRC, \
- CC_ENABLE_DRP | CC_DISABLE_DTS)
+ CC_ENABLE_DRP | CC_DISABLE_DTS | CC_SNK_WITH_PD)
#define CONFIG_SNKDTS(c) CONFIG_SET_CLEAR(c, \
0, \
CC_ALLOW_SRC | CC_ENABLE_DRP | \
@@ -58,7 +58,7 @@
CC_ALLOW_SRC | CC_ENABLE_DRP | CC_DISABLE_DTS)
#define CONFIG_DRPDTS(c) CONFIG_SET_CLEAR(c, \
CC_ALLOW_SRC | CC_ENABLE_DRP, \
- CC_DISABLE_DTS)
+ CC_DISABLE_DTS | CC_SNK_WITH_PD)
/* Macros to apply Rd/Rp to CC lines */
#define DUT_ACTIVE_CC_SET(r, flags) \
@@ -198,6 +198,13 @@ static void dut_allow_charge(void)
*/
if (!(cc_config & CC_ENABLE_DRP))
pd_set_host_mode(DUT, 1);
+
+ /*
+ * Enable PD comm. The PD comm may be disabled during
+ * the power charge-through was detached.
+ */
+ pd_comm_enable(DUT, 1);
+
pd_update_contract(DUT);
}
}
@@ -232,6 +239,16 @@ static void board_manage_dut_port(void)
/* Mark as SNK only. */
pd_set_dual_role(DUT, PD_DRP_FORCE_SINK);
pd_set_host_mode(DUT, 0);
+
+ /*
+ * Disable PD comm. It matches the user expectation that
+ * unplugging the power charge-through makes servo v4 as
+ * a passive hub, without any PD support.
+ *
+ * There is an exception that servo v4 is explicitly set
+ * to have PD, like the "pnsnk" mode.
+ */
+ pd_comm_enable(DUT, cc_config & CC_SNK_WITH_PD ? 1 : 0);
} else {
/* Allow charge through after PD negotiate. */
hook_call_deferred(&dut_allow_charge_data, 2000 * MSEC);