summaryrefslogtreecommitdiff
path: root/driver/tcpm
diff options
context:
space:
mode:
authorJett Rink <jettrink@chromium.org>2018-04-23 10:42:42 -0600
committerchrome-bot <chrome-bot@chromium.org>2018-04-24 18:53:06 -0700
commit58f790b2c19cc95a07ac72fa4d7df1974619f785 (patch)
tree3d0cc230438a6541bb6b7fd5ea8d6cd52a17e259 /driver/tcpm
parentdc875f284fd9c152d337949cf486d8c072c8a9e6 (diff)
downloadchrome-ec-58f790b2c19cc95a07ac72fa4d7df1974619f785.tar.gz
mux: add mode for TCPCI mux that is not the TCPC
We need to use the PS8751 as the USB mux without configuring it as the TCPC. Add mode that allows passing in i2c port and address instead using tcpc_config_t values. BRANCH=none BUG=b:78341944 TEST=build using bip Change-Id: I45b420ef890dfa8c5e5052864b7a2bb66d8734d6 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1024486
Diffstat (limited to 'driver/tcpm')
-rw-r--r--driver/tcpm/tcpci.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/driver/tcpm/tcpci.c b/driver/tcpm/tcpci.c
index 96d6e5ba68..3c1234810f 100644
--- a/driver/tcpm/tcpci.c
+++ b/driver/tcpm/tcpci.c
@@ -496,13 +496,18 @@ int tcpci_tcpm_mux_init(int i2c_addr)
return EC_SUCCESS;
}
-int tcpci_tcpm_mux_set(int i2c_addr, mux_state_t mux_state)
+int tcpci_tcpm_mux_set(int i2c_port_addr, mux_state_t mux_state)
{
int reg = 0;
int rv;
- int port = i2c_addr; /* use port index in port_addr field */
-
- rv = tcpc_read(port, TCPC_REG_CONFIG_STD_OUTPUT, &reg);
+#ifdef CONFIG_USB_PD_TCPM_TCPCI_MUX_ONLY
+ int port = MUX_PORT(i2c_port_addr);
+ int addr = MUX_ADDR(i2c_port_addr);
+#else
+ int port = tcpc_config[i2c_port_addr].i2c_host_port;
+ int addr = tcpc_config[i2c_port_addr].i2c_slave_addr;
+#endif
+ rv = i2c_read8(port, addr, TCPC_REG_CONFIG_STD_OUTPUT, &reg);
if (rv != EC_SUCCESS)
return rv;
@@ -515,18 +520,24 @@ int tcpci_tcpm_mux_set(int i2c_addr, mux_state_t mux_state)
if (mux_state & MUX_POLARITY_INVERTED)
reg |= TCPC_REG_CONFIG_STD_OUTPUT_CONNECTOR_FLIPPED;
- return tcpc_write(port, TCPC_REG_CONFIG_STD_OUTPUT, reg);
+ return i2c_write8(port, addr, TCPC_REG_CONFIG_STD_OUTPUT, reg);
}
/* Reads control register and updates mux_state accordingly */
-int tcpci_tcpm_mux_get(int i2c_addr, mux_state_t *mux_state)
+int tcpci_tcpm_mux_get(int i2c_port_addr, mux_state_t *mux_state)
{
int reg = 0;
int rv;
- int port = i2c_addr; /* use port index in port_addr field */
+#ifdef CONFIG_USB_PD_TCPM_TCPCI_MUX_ONLY
+ int port = MUX_PORT(i2c_port_addr);
+ int addr = MUX_ADDR(i2c_port_addr);
+#else
+ int port = tcpc_config[i2c_port_addr].i2c_host_port;
+ int addr = tcpc_config[i2c_port_addr].i2c_slave_addr;
+#endif
*mux_state = 0;
- rv = tcpc_read(port, TCPC_REG_CONFIG_STD_OUTPUT, &reg);
+ rv = i2c_read8(port, addr, TCPC_REG_CONFIG_STD_OUTPUT, &reg);
if (rv != EC_SUCCESS)
return rv;