summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Palatin <vpalatin@chromium.org>2014-05-01 14:56:05 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-05-02 22:01:57 +0000
commitd2c5e22944f7eeff4b6fd3c535c76fcbce25e22e (patch)
treecae1a624720977ec39cd6d1420d849b856e08ef2
parentb40a82bc45b26f12bdb6e8fd46f2519d22ff324c (diff)
downloadchrome-ec-d2c5e22944f7eeff4b6fd3c535c76fcbce25e22e.tar.gz
pd: more robust reception
Ensure that we finish reception if and only if we started it whatever other events happened. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chrome-os-partner:28332 TEST=Connect Zinger to Firefly, request higher voltage and ensure that Firefly was still getting the Pings after several hours. Change-Id: Ie99984aeb4c565be39d349457dbd2813203b3f5b Reviewed-on: https://chromium-review.googlesource.com/197946 Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--chip/stm32/usb_pd_phy.c6
-rw-r--r--common/usb_pd_protocol.c7
-rw-r--r--include/usb_pd.h7
3 files changed, 15 insertions, 5 deletions
diff --git a/chip/stm32/usb_pd_phy.c b/chip/stm32/usb_pd_phy.c
index 4417cd3f54..4a4e63b51b 100644
--- a/chip/stm32/usb_pd_phy.c
+++ b/chip/stm32/usb_pd_phy.c
@@ -349,6 +349,12 @@ void pd_rx_complete(void)
dma_disable(DMAC_TIM_RX);
}
+int pd_rx_started(void)
+{
+ /* is the sampling timer running ? */
+ return STM32_TIM_CR1(TIM_RX) & 1;
+}
+
void pd_rx_enable_monitoring(void)
{
/* clear comparator external interrupt */
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c
index af68874984..442cccce2d 100644
--- a/common/usb_pd_protocol.c
+++ b/common/usb_pd_protocol.c
@@ -631,7 +631,6 @@ void pd_task(void)
void *ctxt = pd_hw_init();
uint32_t payload[7];
int timeout = 10*MSEC;
- uint32_t evt;
int cc1_volt, cc2_volt;
int res;
@@ -644,9 +643,9 @@ void pd_task(void)
/* Verify board specific health status : current, voltages... */
pd_board_checks();
/* wait for next event/packet or timeout expiration */
- evt = task_wait_event(timeout);
+ task_wait_event(timeout);
/* incoming packet ? */
- if (evt & PD_EVENT_RX) {
+ if (pd_rx_started()) {
head = analyze_rx(payload);
pd_rx_complete();
if (head > 0)
@@ -795,8 +794,6 @@ static int command_pd(int argc, char **argv)
if (!strcasecmp(argv[1], "tx")) {
pd_task_state = PD_STATE_SNK_DISCOVERY;
task_wake(TASK_ID_PD);
- } else if (!strcasecmp(argv[1], "rx")) {
- pd_rx_event();
} else if (!strcasecmp(argv[1], "bist")) {
pd_task_state = PD_STATE_BIST;
task_wake(TASK_ID_PD);
diff --git a/include/usb_pd.h b/include/usb_pd.h
index e11d712800..84d98dff9b 100644
--- a/include/usb_pd.h
+++ b/include/usb_pd.h
@@ -255,6 +255,13 @@ void pd_start_tx(void *ctxt, int polarity, int bit_len);
*/
void pd_tx_done(int polarity);
+/**
+ * Check whether the PD reception is started.
+ *
+ * @return true if the reception is on-going.
+ */
+int pd_rx_started(void);
+
/* Callback when the hardware has detected an incoming packet */
void pd_rx_event(void);
/* Start sampling the CC line for reception */