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
This commit is contained in:
Jett Rink
2018-04-23 10:42:42 -06:00
committed by chrome-bot
parent dc875f284f
commit 58f790b2c1
3 changed files with 32 additions and 8 deletions

View File

@@ -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;

View File

@@ -2886,6 +2886,14 @@
*/
#undef CONFIG_USB_PD_TCPM_MUX
/*
* Use this option if any TCPC/MUX chip is only being used as a mux and the
* board's tcpc_config_t does not specify the chip. When this option is defined,
* all TPCPI mux drivers must use the MUX_PORT_AND_ADDR define to pack the port
* and address together.
*/
#undef CONFIG_USB_PD_TCPM_TCPCI_MUX_ONLY
/*
* The TCPM must know whether VBUS is present in order to make proper state
* transitions. In addition, charge_manager must know about VBUS presence in

View File

@@ -15,6 +15,11 @@
/* USB-C mux state */
typedef uint8_t mux_state_t;
/* Packing and Unpacking defines used with CONFIG_USB_PD_TCPM_TCPCI_MUX_ONLY */
#define MUX_PORT_AND_ADDR(port, addr) ((port << 8) | (addr & 0xFF))
#define MUX_PORT(port_addr) (port_addr >> 8)
#define MUX_ADDR(port_addr) (port_addr & 0xFF)
/* Mux state attributes */
/* TODO: Directly use USB_PD_MUX_* everywhere and remove these 3 defines */
#define MUX_USB_ENABLED USB_PD_MUX_USB_ENABLED