summaryrefslogtreecommitdiff
path: root/common/usb_pd_protocol.c
diff options
context:
space:
mode:
authorVijay Hiremath <vijay.p.hiremath@intel.com>2020-04-07 12:40:30 -0700
committerCommit Bot <commit-bot@chromium.org>2020-04-14 03:45:17 +0000
commitee4b7135b0b474447d0c087691b84a6995c28764 (patch)
tree86f0c355e1266f65f8930d78e941dda04d793cc1 /common/usb_pd_protocol.c
parent6328535c2e8350421412b02a5bc759cb97fec202 (diff)
downloadchrome-ec-ee4b7135b0b474447d0c087691b84a6995c28764.tar.gz
TCPMv1/v2: Move pd_prepare_sysjump() to common file
BUG=b:137493121 BRANCH=none TEST=make buildall -j Change-Id: I5123f26137d7590bcc00d86894eb981ac23d502a Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2140534 Reviewed-by: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'common/usb_pd_protocol.c')
-rw-r--r--common/usb_pd_protocol.c44
1 files changed, 12 insertions, 32 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c
index 4f500e5e91..3af420556c 100644
--- a/common/usb_pd_protocol.c
+++ b/common/usb_pd_protocol.c
@@ -161,11 +161,6 @@ static const uint8_t vdo_ver[] = {
#define VDO_VER(v) VDM_VER10
#endif
-#ifdef CONFIG_USB_PD_ALT_MODE_DFP
-/* Tracker for which task is waiting on sysjump prep to finish */
-static volatile task_id_t sysjump_task_waiting = TASK_ID_INVALID;
-#endif
-
static struct pd_protocol {
/* current port power role (SOURCE or SINK) */
enum pd_power_role power_role;
@@ -301,6 +296,16 @@ int pd_comm_is_enabled(int port)
#endif
}
+bool pd_alt_mode_capable(int port)
+{
+ /*
+ * PD is alternate mode capable only if PD communication is enabled and
+ * the port is not suspended.
+ */
+ return pd_comm_is_enabled(port) &&
+ !(pd[port].task_state == PD_STATE_SUSPENDED);
+}
+
static inline void set_state_timeout(int port,
uint64_t timeout,
enum pd_states timeout_state)
@@ -3062,8 +3067,7 @@ void pd_task(void *u)
#if defined(CONFIG_USB_PD_ALT_MODE_DFP)
if (evt & PD_EVENT_SYSJUMP) {
exit_supported_alt_mode(port);
- notify_sysjump_ready(&sysjump_task_waiting);
-
+ notify_sysjump_ready();
}
#endif
@@ -3843,8 +3847,7 @@ void pd_task(void *u)
if (evt & PD_EVENT_SYSJUMP)
/* Nothing to do for sysjump prep */
- notify_sysjump_ready(
- &sysjump_task_waiting);
+ notify_sysjump_ready();
#else
task_wait_event(-1);
#endif
@@ -4870,29 +4873,6 @@ DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, pd_chipset_shutdown, HOOK_PRIO_DEFAULT);
#endif /* CONFIG_USB_PD_DUAL_ROLE */
-#ifdef CONFIG_USB_PD_ALT_MODE_DFP
-void pd_prepare_sysjump(void)
-{
- int i;
-
- /* Exit modes before sysjump so we can cleanly enter again later */
- for (i = 0; i < board_get_usb_pd_port_count(); i++) {
- /*
- * We can't be in an alternate mode if PD comm is disabled or
- * the port is suspended, so no need to send the event
- */
- if (!pd_comm_is_enabled(i) ||
- pd[i].task_state == PD_STATE_SUSPENDED)
- continue;
-
- sysjump_task_waiting = task_get_current();
- task_set_event(PD_PORT_TO_TASK_ID(i), PD_EVENT_SYSJUMP, 0);
- task_wait_event_mask(TASK_EVENT_SYSJUMP_READY, -1);
- sysjump_task_waiting = TASK_ID_INVALID;
- }
-}
-#endif
-
#ifdef CONFIG_COMMON_RUNTIME
static void pd_control_resume(int port)