diff options
author | Ayushee <ayushee.shah@intel.com> | 2020-03-11 10:10:22 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-03-12 23:19:14 +0000 |
commit | 7f3b64dd6abccf6fdb592eaf06901166cd2833bd (patch) | |
tree | 8a5c753fa53c43d313aacbcc5688f9b874f2dc79 /common/usb_pd_protocol.c | |
parent | 4d5a5e5ee9f2a33f1ee2ca8dbe1bf9b17e7f4b78 (diff) | |
download | chrome-ec-7f3b64dd6abccf6fdb592eaf06901166cd2833bd.tar.gz |
TCPMv1: Add common exit mode for all the alternate modes
When chipset is or transitioning to a new state or on sysjump, the SOC
re-negotiates to enter an alternate mode on booting up.
Added a common function which enables exiting the current supported
alternate mode, to avoid NACK from the port partner on reentry.
BUG=b:151169925
BRANCH=None
TEST=Tested on Volteer:
1. On connecting a DP dongle, able to enter into DP alternate mode
on reboot.
2. On connecting a Thunderbolt dock, able to enter into
Thunderbolt-Compatible mode on reboot.
Change-Id: Ie7ad5cee5d746691ada3e103beadf7c67667a5a3
Signed-off-by: Ayushee <ayushee.shah@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2094780
Reviewed-by: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'common/usb_pd_protocol.c')
-rw-r--r-- | common/usb_pd_protocol.c | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index eefba7ff25..bd3585d8fe 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -2330,33 +2330,39 @@ void pd_dev_get_rw_hash(int port, uint16_t *dev_id, uint8_t *rw_hash, memcpy(rw_hash, pd[port].dev_rw_hash, PD_RW_HASH_SIZE); } -#if defined(CONFIG_POWER_COMMON) || defined(CONFIG_USB_PD_ALT_MODE_DFP) -static void exit_dp_mode(int port) +__maybe_unused static void exit_supported_alt_mode(int port) { -#ifdef CONFIG_USB_PD_ALT_MODE_DFP - int opos = pd_alt_mode(port, USB_SID_DISPLAYPORT); + int i; - if (opos <= 0) + if (!IS_ENABLED(CONFIG_USB_PD_ALT_MODE_DFP)) return; - CPRINTS("C%d Exiting DP mode", port); - if (!pd_dfp_exit_mode(port, USB_SID_DISPLAYPORT, opos)) - return; - pd_send_vdm(port, USB_SID_DISPLAYPORT, - CMD_EXIT_MODE | VDO_OPOS(opos), NULL, 0); - pd_vdm_send_state_machine(port); - /* Have to wait for ACK */ -#endif /* CONFIG_USB_PD_ALT_MODE_DFP */ + for (i = 0; i < supported_modes_cnt; i++) { + int opos = pd_alt_mode(port, supported_modes[i].svid); + + if (opos > 0 && + pd_dfp_exit_mode(port, supported_modes[i].svid, opos)) { + CPRINTS("C%d Exiting ALT mode with SVID = 0x%x", port, + supported_modes[i].svid); + pd_send_vdm(port, supported_modes[i].svid, + CMD_EXIT_MODE | VDO_OPOS(opos), NULL, 0); + /* Wait for an ACK from port-partner */ + pd_vdm_send_state_machine(port); + } + } } -#endif /* CONFIG_POWER_COMMON */ #ifdef CONFIG_POWER_COMMON static void handle_new_power_state(int port) { - if (chipset_in_or_transitioning_to_state(CHIPSET_STATE_ANY_OFF)) - /* The SoC will negotiated DP mode again when it boots up */ - exit_dp_mode(port); + if (chipset_in_or_transitioning_to_state(CHIPSET_STATE_ANY_OFF)) { + /* + * The SoC will negotiate the alternate mode again when + * it boots up. + */ + exit_supported_alt_mode(port); + } /* Ensure mux is set properly after chipset transition */ set_usb_mux_with_current_data_role(port); } @@ -3093,7 +3099,7 @@ void pd_task(void *u) #if defined(CONFIG_USB_PD_ALT_MODE_DFP) if (evt & PD_EVENT_SYSJUMP) { - exit_dp_mode(port); + exit_supported_alt_mode(port); notify_sysjump_ready(&sysjump_task_waiting); } |