From 97934e4041040997bce215103b67e227aa806732 Mon Sep 17 00:00:00 2001 From: Alec Berg Date: Tue, 26 May 2015 18:06:06 -0700 Subject: [PATCH] pd: fix duplicate PD receive event on combined TCPM/TCPC Fix duplicate PD RX event when using combined TCPM/TCPC. Problem is that PD_EVENT_RX is already set in the phy layer in pd_rx_event when CC edges are detected. Therefore, we shouldn't set it again when the TCPC detects that receiving has started. BUG=none BRANCH=none TEST=test on samus. without this change we occasionally get a PD error and hard reset under certain timing circumstances due to the repeated event. with this change, those errors go away. Change-Id: If1034a549b75740f327e16810e81c9aa28d71b00 Signed-off-by: Alec Berg Reviewed-on: https://chromium-review.googlesource.com/273418 Reviewed-by: Vincent Palatin --- common/usb_pd_protocol.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index d8393f118c..35bb7c0dc6 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -2355,7 +2355,16 @@ void tcpc_alert(void) task_set_event(PD_PORT_TO_TASK_ID(i), PD_EVENT_CC, 0); } else if (status & TCPC_REG_ALERT1_RX_STATUS) { /* message received */ + /* + * If TCPC is compiled in, then we will have already + * received PD_EVENT_RX from phy layer in + * pd_rx_event(), so we don't need to set another + * event. If TCPC is not running on this MCU, then + * this needs to wake the PD task. + */ +#ifndef CONFIG_USB_PD_TCPC task_set_event(PD_PORT_TO_TASK_ID(i), PD_EVENT_RX, 0); +#endif } else if (status & TCPC_REG_ALERT1_RX_HARD_RST) { /* hard reset received */ execute_hard_reset(i);