summaryrefslogtreecommitdiff
path: root/driver/tcpm/it83xx.c
diff options
context:
space:
mode:
authorDino Li <Dino.Li@ite.com.tw>2018-07-13 14:53:57 +0800
committerchrome-bot <chrome-bot@chromium.org>2018-07-16 10:22:00 -0700
commit1247315ffe057bc546339c53171a23021ee4204f (patch)
tree7d1222e917c571bee346ad0fcfd5b68ff7b116d7 /driver/tcpm/it83xx.c
parent47de1e86750736f6e410e359b8f5980811be3556 (diff)
downloadchrome-ec-1247315ffe057bc546339c53171a23021ee4204f.tar.gz
tcpm: it83xx: IT8320 family compatibility
The bit7 and bit3 at UFPVDR register are reserved on BX version. But in DX version, these two bits are used to get the result of fast swap voltage comparing in UFP mode. So we change to mask three bits only. Add the support of two TX SOP type on the DX version. (Debug SOP' and Debug SOP'') On BX version, cc1/cc2 voltage detector function is enabled by bit1 or bit5 at register CCCSR. But on DX version, the bit1 will control both cc1 and cc2. So we create an option for this change. BUG=none BRANCH=none TEST=Plug USB-C power adapter and USB-C to hdmi adapter, both work. Change-Id: If881ef54145f211f7d48a971f56a6118487d9eed Signed-off-by: Dino Li <Dino.Li@ite.com.tw> Reviewed-on: https://chromium-review.googlesource.com/1119729 Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'driver/tcpm/it83xx.c')
-rw-r--r--driver/tcpm/it83xx.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/driver/tcpm/it83xx.c b/driver/tcpm/it83xx.c
index f34b9271f2..2a46c18cbf 100644
--- a/driver/tcpm/it83xx.c
+++ b/driver/tcpm/it83xx.c
@@ -57,9 +57,9 @@ static enum tcpc_cc_voltage_status it83xx_get_cc(
/* sink */
if (USBPD_GET_POWER_ROLE(port) == USBPD_POWER_ROLE_CONSUMER) {
if (cc_pin == USBPD_CC_PIN_1)
- ufp_volt = IT83XX_USBPD_UFPVDR(port) & 0xf;
+ ufp_volt = IT83XX_USBPD_UFPVDR(port) & 0x7;
else
- ufp_volt = (IT83XX_USBPD_UFPVDR(port) >> 4) & 0xf;
+ ufp_volt = (IT83XX_USBPD_UFPVDR(port) >> 4) & 0x7;
switch (ufp_volt) {
case USBPD_UFP_STATE_SNK_DEF:
@@ -138,9 +138,15 @@ static enum tcpc_transmit_complete it83xx_tx_data(
/* set message type */
IT83XX_USBPD_MTSR0(port) =
(IT83XX_USBPD_MTSR0(port) & ~0x1f) | (msg_type & 0xf);
- /* SOP type: bit[5:4] 00 SOP, 01 SOP', 10 SOP" */
+ /*
+ * SOP type bit[6~4]:
+ * on bx version and before:
+ * x00b=SOP, x01b=SOP', x10b=SOP", bit[6] is reserved.
+ * on dx version:
+ * 000b=SOP, 001b=SOP', 010b=SOP", 011b=Debug SOP', 100b=Debug SOP''.
+ */
IT83XX_USBPD_MTSR1(port) =
- (IT83XX_USBPD_MTSR1(port) & ~0x30) | ((type & 0x3) << 4);
+ (IT83XX_USBPD_MTSR1(port) & ~0x70) | ((type & 0x7) << 4);
/* bit7: transmit message is send to cable or not */
if (TCPC_TX_SOP == type)
IT83XX_USBPD_MTSR0(port) &= ~USBPD_REG_MASK_CABLE_ENABLE;
@@ -222,14 +228,12 @@ static void it83xx_enable_vconn(enum usbpd_port port, int enabled)
if (enabled) {
/* Disable unused CC to become VCONN */
if (cc_pin == USBPD_CC_PIN_1) {
- IT83XX_USBPD_CCCSR(port) =
- (IT83XX_USBPD_CCCSR(port) | 0xa0) & ~0xa;
+ IT83XX_USBPD_CCCSR(port) = USBPD_CC2_DISCONNECTED(port);
IT83XX_USBPD_CCPSR(port) = (IT83XX_USBPD_CCPSR(port)
& ~USBPD_REG_MASK_DISCONNECT_POWER_CC2)
| USBPD_REG_MASK_DISCONNECT_POWER_CC1;
} else {
- IT83XX_USBPD_CCCSR(port) =
- (IT83XX_USBPD_CCCSR(port) | 0xa) & ~0xa0;
+ IT83XX_USBPD_CCCSR(port) = USBPD_CC1_DISCONNECTED(port);
IT83XX_USBPD_CCPSR(port) = (IT83XX_USBPD_CCPSR(port)
& ~USBPD_REG_MASK_DISCONNECT_POWER_CC1)
| USBPD_REG_MASK_DISCONNECT_POWER_CC2;
@@ -490,6 +494,8 @@ static int it83xx_tcpm_transmit(int port,
case TCPC_TX_SOP:
case TCPC_TX_SOP_PRIME:
case TCPC_TX_SOP_PRIME_PRIME:
+ case TCPC_TX_SOP_DEBUG_PRIME:
+ case TCPC_TX_SOP_DEBUG_PRIME_PRIME:
status = it83xx_tx_data(port,
type,
PD_HEADER_TYPE(header),