From c33a78a3b1ccf4ff8f083f072636efe25809fce0 Mon Sep 17 00:00:00 2001 From: Alec Berg Date: Wed, 5 Nov 2014 14:09:18 -0800 Subject: [PATCH] pd: add print out when we receive SOP', SOP'' Add print when receive various SOP packets for debugging. BUG=none BRANCH=samus TEST=make buildall Change-Id: I574d0ed6338e880a9ec238f931fc299c22f3786a Signed-off-by: Alec Berg Reviewed-on: https://chromium-review.googlesource.com/227721 Reviewed-by: Vincent Palatin Reviewed-by: Todd Broch --- common/usb_pd_protocol.c | 15 ++++++++++++--- include/usb_pd.h | 1 + 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index d49e7a0041..12ea1f18de 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -121,6 +121,10 @@ static const uint8_t dec4b5b[] = { /* Start of Packet sequence : three Sync-1 K-codes, then one Sync-2 K-code */ #define PD_SOP (PD_SYNC1 | (PD_SYNC1<<5) | (PD_SYNC1<<10) | (PD_SYNC2<<15)) +#define PD_SOP_PRIME (PD_SYNC1 | (PD_SYNC1<<5) | \ + (PD_SYNC3<<10) | (PD_SYNC3<<15)) +#define PD_SOP_PRIME_PRIME (PD_SYNC1 | (PD_SYNC3<<5) | \ + (PD_SYNC1<<10) | (PD_SYNC3<<15)) /* Hard Reset sequence : three RST-1 K-codes, then one RST-2 K-code */ #define PD_HARD_RESET (PD_RST1 | (PD_RST1 << 5) |\ @@ -1050,10 +1054,15 @@ static int analyze_rx(int port, uint32_t *payload) /* Find the Start Of Packet sequence */ while (bit > 0) { bit = pd_dequeue_bits(port, bit, 20, &val); - if (val == PD_SOP) + if (val == PD_SOP) { break; - /* TODO: detect SOP with 1 error code */ - /* TODO: detect Hard reset */ + } else if (val == PD_SOP_PRIME) { + CPRINTF("SOP'\n"); + return -5; + } else if (val == PD_SOP_PRIME_PRIME) { + CPRINTF("SOP''\n"); + return -5; + } } if (bit < 0) { msg = "SOP"; diff --git a/include/usb_pd.h b/include/usb_pd.h index 1f6a4e97cb..0f43e0789f 100644 --- a/include/usb_pd.h +++ b/include/usb_pd.h @@ -603,6 +603,7 @@ enum pd_data_msg_type { /* K-codes for special symbols */ #define PD_SYNC1 0x18 #define PD_SYNC2 0x11 +#define PD_SYNC3 0x06 #define PD_RST1 0x07 #define PD_RST2 0x19 #define PD_EOP 0x0D