summaryrefslogtreecommitdiff
path: root/driver
diff options
context:
space:
mode:
authorAyushee <ayushee.shah@intel.com>2019-06-20 22:53:18 -0700
committerCommit Bot <commit-bot@chromium.org>2019-08-16 06:32:49 +0000
commit91be7060d7694eedb53ce73b39bc7423a3814536 (patch)
tree4c236211331689195ee8c02854e6b0b6d63cbf83 /driver
parentd731e31bce43a8616bff235626bc69f71712bc7a (diff)
downloadchrome-ec-91be7060d7694eedb53ce73b39bc7423a3814536.tar.gz
usb_pd: Adding USB-C cable detection
When a discover identity command is sent with a SOP prime packet, the cable plug of an emark cable responds with the cable attribute. Added a structure pd_cable that stores the cable type and and resetting it when the cable is disconnected. Also added console command that gives the type of cable connected. Host(DFP) Cable Port-Partner(UFP) -------------------------EXPLICIT CONTRACT------------------------ Discover Identity SOP -----------------------------> request | <------------------------- Discover Identity response Discover Identity SOP' ---------> request | (If Emark Cable) <------------ Discover Identity SOP' | response Store cable type | (If Non-Emark Cable) <-------------- No response | Discover SVID SOP request ------------------------------------> (Rest of the PD flow) BUG=b:129990370 BRANCH=none TEST=Verified on dragonegg, able to get cable response Change-Id: I2536cf24d58f7ee5ff462b34fc32f69d7a200d41 Signed-off-by: Ayushee <ayushee.shah@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1707851 Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r--driver/tcpm/nct38xx.c3
-rw-r--r--driver/tcpm/tcpci.c11
-rw-r--r--driver/tcpm/tcpci.h3
3 files changed, 14 insertions, 3 deletions
diff --git a/driver/tcpm/nct38xx.c b/driver/tcpm/nct38xx.c
index 42925910de..ee8aeb58e6 100644
--- a/driver/tcpm/nct38xx.c
+++ b/driver/tcpm/nct38xx.c
@@ -260,7 +260,8 @@ int tcpci_nct38xx_transmit(int port, enum tcpm_transmit_type type,
rv = tcpc_write_block(port, TCPC_REG_TX_BYTE_CNT,
(const uint8_t *)txBuf, txBuf[0] + 1);
- rv = tcpc_write(port, TCPC_REG_TRANSMIT, TCPC_REG_TRANSMIT_SET(type));
+ rv = tcpc_write(port, TCPC_REG_TRANSMIT,
+ TCPC_REG_TRANSMIT_SET_WITH_RETRY(type));
return rv;
}
diff --git a/driver/tcpm/tcpci.c b/driver/tcpm/tcpci.c
index fb0faee0ce..712b2bea29 100644
--- a/driver/tcpm/tcpci.c
+++ b/driver/tcpm/tcpci.c
@@ -534,7 +534,16 @@ int tcpci_tcpm_transmit(int port, enum tcpm_transmit_type type,
return rv;
}
- return tcpc_write(port, TCPC_REG_TRANSMIT, TCPC_REG_TRANSMIT_SET(type));
+ /*
+ * On receiving a received message on SOP, protocol layer
+ * discards the pending SOP messages queued for transmission.
+ * But it doesn't do the same for SOP' message. So retry is
+ * assigned to 0 to avoid multiple transmission.
+ */
+ return tcpc_write(port, TCPC_REG_TRANSMIT,
+ (type == TCPC_TX_SOP_PRIME) ?
+ TCPC_REG_TRANSMIT_SET_WITHOUT_RETRY(type) :
+ TCPC_REG_TRANSMIT_SET_WITH_RETRY(type));
}
#ifndef CONFIG_USB_PD_TCPC_LOW_POWER
diff --git a/driver/tcpm/tcpci.h b/driver/tcpm/tcpci.h
index 9bec93e325..6db71e4161 100644
--- a/driver/tcpm/tcpci.h
+++ b/driver/tcpm/tcpci.h
@@ -116,8 +116,9 @@
#define TCPC_REG_RX_DATA 0x34 /* through 0x4f */
#define TCPC_REG_TRANSMIT 0x50
-#define TCPC_REG_TRANSMIT_SET(type) \
+#define TCPC_REG_TRANSMIT_SET_WITH_RETRY(type) \
(PD_RETRY_COUNT << 4 | (type))
+#define TCPC_REG_TRANSMIT_SET_WITHOUT_RETRY(type) (type)
#define TCPC_REG_TRANSMIT_RETRY(reg) (((reg) & 0x30) >> 4)
#define TCPC_REG_TRANSMIT_TYPE(reg) ((reg) & 0x7)