From 03f11f6549fd8a33ddf82aa7716997e27d636f23 Mon Sep 17 00:00:00 2001 From: Vincent Palatin Date: Fri, 18 Sep 2015 09:15:25 -0700 Subject: [PATCH] honeybuns: ensure we are always a data UFP The dock hub upstream port is wired to the type-C captive cable, so we can only be a data UFP : - ensure we reject data swap request to become a DFP (e.g. from dual role devices preferring to be a UFP such as Ryu) - swap to data UFP at startup (we will start as data DFP since we are a power source only). Signed-off-by: Vincent Palatin BRANCH=none BUG=none TEST=connect Honeybuns to Ryu and see Ryu becoming a power sink and a data DFP all the time. Change-Id: I876536451a327e04df0a81d8217ef19963d204b6 Reviewed-on: https://chromium-review.googlesource.com/300952 Commit-Ready: Vincent Palatin Tested-by: Vincent Palatin Reviewed-by: Alec Berg Reviewed-by: Scott Collyer --- board/honeybuns/usb_pd_policy.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/board/honeybuns/usb_pd_policy.c b/board/honeybuns/usb_pd_policy.c index 65c056f102..5ba1347106 100644 --- a/board/honeybuns/usb_pd_policy.c +++ b/board/honeybuns/usb_pd_policy.c @@ -139,8 +139,11 @@ int pd_check_power_swap(int port) int pd_check_data_swap(int port, int data_role) { - /* Always allow data swap */ - return 1; + /* + * Ensure we always are a UFP : + * Allow data swap if we are a DFP, otherwise don't allow. + */ + return (data_role == PD_ROLE_DFP) ? 1 : 0; } void pd_execute_data_swap(int port, int data_role) @@ -154,6 +157,9 @@ void pd_check_pr_role(int port, int pr_role, int flags) void pd_check_dr_role(int port, int dr_role, int flags) { + /* if the partner is a DRP (e.g. tablet), try to switch to UFP */ + if ((flags & PD_FLAGS_PARTNER_DR_DATA) && dr_role == PD_ROLE_DFP) + pd_request_data_swap(port); } int pd_alt_mode(int port, uint16_t svid)