diff options
author | Keith Short <keithshort@chromium.org> | 2020-04-30 17:47:32 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-05-01 20:20:22 +0000 |
commit | ff7a100aaf125c95a7c88e70b409cb3e377ace43 (patch) | |
tree | 6890bf858deb74c24abc59623520fbaa7ec75e71 /driver | |
parent | 4f5972acaea79fadfb23302f47bbc4f331cb39ae (diff) | |
download | chrome-ec-ff7a100aaf125c95a7c88e70b409cb3e377ace43.tar.gz |
it83xx tcpc: Captured received SOP message type
Add support to the IT83xx TCPC driver to capture the received SOP
messaage type, matching the implementation of all other TCPC drivers.
This change also does a minor cleanup of the PD_HEADER_SOP macro to
ensure callers cannot overflow the field.
BUG=none
BRANCH=none
TEST=make buildall -j
Signed-off-by: Keith Short <keithshort@chromium.org>
Change-Id: I63d324761538c6fe1ae6cee9ad172ee052c474b4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2173303
Tested-by: Diana Z <dzigterman@chromium.org>
Reviewed-by: Diana Z <dzigterman@chromium.org>
Commit-Queue: Diana Z <dzigterman@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r-- | driver/tcpm/it83xx.c | 5 | ||||
-rw-r--r-- | driver/tcpm/it83xx_pd.h | 1 | ||||
-rw-r--r-- | driver/tcpm/tcpci.c | 4 |
3 files changed, 8 insertions, 2 deletions
diff --git a/driver/tcpm/it83xx.c b/driver/tcpm/it83xx.c index 8d48b68a00..360799061d 100644 --- a/driver/tcpm/it83xx.c +++ b/driver/tcpm/it83xx.c @@ -139,6 +139,11 @@ static int it83xx_tcpm_get_message_raw(int port, uint32_t *buf, int *head) /* check data message */ if (cnt) memcpy(buf, (uint32_t *)&IT83XX_USBPD_RDO0(port), cnt * 4); + + if (IS_ENABLED(CONFIG_USB_PD_DECODE_SOP)) { + int type = USBPD_REG_GET_SOP_TYPE_RX(IT83XX_USBPD_MRSR(port)); + *head |= PD_HEADER_SOP(type); + } /* * Note: clear RX done interrupt after get the data. * If clear this bit, USBPD receives next packet diff --git a/driver/tcpm/it83xx_pd.h b/driver/tcpm/it83xx_pd.h index 54c5ed3c84..bbfd881642 100644 --- a/driver/tcpm/it83xx_pd.h +++ b/driver/tcpm/it83xx_pd.h @@ -70,6 +70,7 @@ #define IT83XX_USBPD_MTSR1(p) REG8(IT83XX_USBPD_BASE(p)+0x1A) #define IT83XX_USBPD_VDMMCSR(p) REG8(IT83XX_USBPD_BASE(p)+0x1B) #define IT83XX_USBPD_MRSR(p) REG8(IT83XX_USBPD_BASE(p)+0x1C) +#define USBPD_REG_GET_SOP_TYPE_RX(mrsr) (((mrsr) >> 4) & 0x7) #define USBPD_REG_MASK_RX_MSG_VALID BIT(0) #define IT83XX_USBPD_PEFSMR(p) REG8(IT83XX_USBPD_BASE(p)+0x1D) #define IT83XX_USBPD_PES0R(p) REG8(IT83XX_USBPD_BASE(p)+0x1E) diff --git a/driver/tcpm/tcpci.c b/driver/tcpm/tcpci.c index 2ac4cf91f3..0205a757ea 100644 --- a/driver/tcpm/tcpci.c +++ b/driver/tcpm/tcpci.c @@ -673,7 +673,7 @@ static int tcpci_rev2_0_tcpm_get_message_raw(int port, uint32_t *payload, /* Encode message address in bits 31 to 28 */ *head &= 0x0000ffff; - *head |= PD_HEADER_SOP(frm & 7); + *head |= PD_HEADER_SOP(frm); if (rv == EC_SUCCESS && cnt > 0) { tcpc_xfer_unlocked(port, NULL, 0, (uint8_t *)payload, cnt, @@ -722,7 +722,7 @@ static int tcpci_rev1_0_tcpm_get_message_raw(int port, uint32_t *payload, #ifdef CONFIG_USB_PD_DECODE_SOP /* Encode message address in bits 31 to 28 */ *head &= 0x0000ffff; - *head |= PD_HEADER_SOP(frm & 7); + *head |= PD_HEADER_SOP(frm); #endif if (rv == EC_SUCCESS && cnt > 0) { tcpc_read_block(port, reg, (uint8_t *)payload, cnt); |