summaryrefslogtreecommitdiff
path: root/board/samus_pd/usb_pd_policy.c
diff options
context:
space:
mode:
authorAlec Berg <alecaberg@chromium.org>2014-07-08 16:48:17 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-07-14 23:06:55 +0000
commit8e29d9c2e80688e9ebfa8358d2c01ecff261bc92 (patch)
treeaef93e8dea5b73a4872e6f4b38f2bd939431b08b /board/samus_pd/usb_pd_policy.c
parent32e4f212b13ad38a6e72d6149b6714c48606afd7 (diff)
downloadchrome-ec-8e29d9c2e80688e9ebfa8358d2c01ecff261bc92.tar.gz
pd: support for dual-role port
Add support for toggling between source and sink as dual-role port. When transitioning to S0, we turn toggling on, when transitioning to S3, we turn toggling off but remain in the same PD state, and when transitioning to S5, we turn toggling off and force the PD role to a sink. Note, when toggling is off, the source disconnected state is allowed to transition to sink disconnected, but not vice versa. This means that if you go into S3 as a source, it will remain a source until the device is unplugged, at which point it will transition to a sink until the next transition to S0. The spec specifies: tDRP: 50ms - 100ms, Period a DRP shall complete a DFP to UFP and back dcDRP: 30% - 70%, Percent of time that a DRP shall advertise DFP tDRPHold: 100ms - 150ms, time to hold VBUS on after a DRP detects a UFP tDRPLock: 100ms - 150ms, time to stay in DFP after detecting loss of UFP This CL uses 40ms for time as a UFP (sink), 30ms for time as a DFP (source), and 120ms for hold and lock times. Also, if advertising as a DFP (source) and VBUS is detected, this automatically switches to a UFP (sink). BUG=chrome-os-partner:28782 BRANCH=none TEST=test on samus, make sure we are toggling between source and sink when disconnected. make sure plugging in zinger switches state machine through to sink_ready and make sure plugging in a USB switches to source_discovery. tested on a fruitpie by scoping the CC line and verifying the timing (except the hold time which I can't easily test). tested that dual role toggling is off in s3 and s5. also verified that going into s3 as a source keeps the port as a source and going into s5 switches it to a sink. Change-Id: I478634861f694164301d71359da35142ee7ebf75 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/207154 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'board/samus_pd/usb_pd_policy.c')
-rw-r--r--board/samus_pd/usb_pd_policy.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/board/samus_pd/usb_pd_policy.c b/board/samus_pd/usb_pd_policy.c
index 60f6e1c21f..8e05c7014a 100644
--- a/board/samus_pd/usb_pd_policy.c
+++ b/board/samus_pd/usb_pd_policy.c
@@ -161,6 +161,28 @@ int pd_power_negotiation_allowed(void)
return battery_ok;
}
+static void dual_role_on(void)
+{
+ pd_set_dual_role(PD_DRP_TOGGLE_ON);
+ CPRINTS("PCH -> S0, enable dual-role toggling");
+}
+DECLARE_HOOK(HOOK_CHIPSET_RESUME, dual_role_on, HOOK_PRIO_DEFAULT);
+
+static void dual_role_off(void)
+{
+ pd_set_dual_role(PD_DRP_TOGGLE_OFF);
+ CPRINTS("PCH -> S3, disable dual-role toggling");
+}
+DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, dual_role_off, HOOK_PRIO_DEFAULT);
+DECLARE_HOOK(HOOK_CHIPSET_STARTUP, dual_role_off, HOOK_PRIO_DEFAULT);
+
+static void dual_role_force_sink(void)
+{
+ pd_set_dual_role(PD_DRP_FORCE_SINK);
+ CPRINTS("PCH -> S5, force dual-role port to sink");
+}
+DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, dual_role_force_sink, HOOK_PRIO_DEFAULT);
+
static int command_ec_int(int argc, char **argv)
{
pd_send_ec_int();