diff options
author | Duncan Laurie <dlaurie@google.com> | 2018-04-30 09:32:31 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-05-03 21:28:00 -0700 |
commit | d0d1ea3d46faa5c1141157fe9ef27967aafe85e0 (patch) | |
tree | 99462521b70360f8e48628b0e87de9e20e208e43 | |
parent | be54bb9a9c2be4ab926f7ca9bd4fe7303aea5c98 (diff) | |
download | chrome-ec-d0d1ea3d46faa5c1141157fe9ef27967aafe85e0.tar.gz |
usb_pd_protocol: Add PD_ROLE_DISCONNECTED for data role swaps
Add a state to indicate that a data role is actually disconnected and
notify the board-level data swap function with this state when a cable
is unplugged. This allows the board to clean up and restore any state
that may have been set up with a data role swap.
BUG=b:78308749
BRANCH=eve,poppy
TEST=manual on eve: plug in C-to-C cable, execute data swap on port 0
with 'pd 0 swap data' and ensure the OTG pins are asserted. Then unplug
the cable and ensure OTG pins are now deasserted.
Change-Id: I7d8fff22dd5836b4b5af54f0ede71ee1b6e40b5c
Signed-off-by: Duncan Laurie <dlaurie@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1035423
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
-rw-r--r-- | common/usb_pd_protocol.c | 5 | ||||
-rw-r--r-- | include/usb_pd.h | 5 |
2 files changed, 8 insertions, 2 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index 1d8b82f19d..180f353a4d 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -467,6 +467,11 @@ static inline void set_state(int port, enum pd_states next_state) #ifdef CONFIG_USB_PD_ALT_MODE_DFP pd_dfp_exit_mode(port, 0, 0); #endif + /* + * Indicate that the port is disconnected so the board + * can restore state from any previous data swap. + */ + pd_execute_data_swap(port, PD_ROLE_DISCONNECTED); #ifdef CONFIG_USBC_SS_MUX usb_mux_set(port, TYPEC_MUX_NONE, USB_SWITCH_DISCONNECT, pd[port].polarity); diff --git a/include/usb_pd.h b/include/usb_pd.h index acad78fb42..7cdc79c198 100644 --- a/include/usb_pd.h +++ b/include/usb_pd.h @@ -871,8 +871,9 @@ enum pd_data_msg_type { #define PD_ROLE_SINK 0 #define PD_ROLE_SOURCE 1 /* Data role */ -#define PD_ROLE_UFP 0 -#define PD_ROLE_DFP 1 +#define PD_ROLE_UFP 0 +#define PD_ROLE_DFP 1 +#define PD_ROLE_DISCONNECTED 2 /* Vconn role */ #define PD_ROLE_VCONN_OFF 0 #define PD_ROLE_VCONN_ON 1 |