summaryrefslogtreecommitdiff
path: root/driver/tcpm
diff options
context:
space:
mode:
authorDiana Z <dzigterman@chromium.org>2021-07-21 09:56:40 -0600
committerCommit Bot <commit-bot@chromium.org>2021-08-14 06:06:39 +0000
commitab1cdf1648d390619848f4f4f901b14aeee75244 (patch)
tree74b814ec98390eabb46c4a012adbc501c70e9df2 /driver/tcpm
parent80b43435ca89510e985481b725a470566fb65a05 (diff)
downloadchrome-ec-ab1cdf1648d390619848f4f4f901b14aeee75244.tar.gz
USB MUX: Generalize mux ACK
Currently, only the virtual mux driver uses the mux ACK feature, but the actual wait for the host command ACK is a part of the usb_mux general code. Generalize this mux ACK wait so it's available if needed in the future for more muxes. Additionally, moving this wait out of the mux set will allow us to lock the muxes intelligently between tasks, without keeping the muxes locked during the inactive ACK wait. BRANCH=None BUG=b:172222942,b:186777984 TEST=tast typec.Mode*.manual on voxel Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I61a043425a482cc6f3170548c888d91ec20c2a82 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3078411 Reviewed-by: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'driver/tcpm')
-rw-r--r--driver/tcpm/anx7447.c19
-rw-r--r--driver/tcpm/anx74xx.c9
-rw-r--r--driver/tcpm/anx7688.c6
-rw-r--r--driver/tcpm/ps8xxx.c6
-rw-r--r--driver/tcpm/tcpci.c6
5 files changed, 35 insertions, 11 deletions
diff --git a/driver/tcpm/anx7447.c b/driver/tcpm/anx7447.c
index 9458ee8c94..0367d4a78c 100644
--- a/driver/tcpm/anx7447.c
+++ b/driver/tcpm/anx7447.c
@@ -38,7 +38,8 @@ struct anx_usb_mux {
int state;
};
-static int anx7447_mux_set(const struct usb_mux *me, mux_state_t mux_state);
+static int anx7447_mux_set(const struct usb_mux *me, mux_state_t mux_state,
+ bool *ack_required);
static struct anx_state anx[CONFIG_USB_PD_PORT_MAX_COUNT];
static struct anx_usb_mux mux[CONFIG_USB_PD_PORT_MAX_COUNT];
@@ -290,6 +291,7 @@ static int anx7447_init(int port)
{
int rv, reg, i;
const struct usb_mux *me = &usb_muxes[port];
+ bool unused;
ASSERT(port < CONFIG_USB_PD_PORT_MAX_COUNT);
@@ -388,9 +390,13 @@ static int anx7447_init(int port)
while ((me != NULL) && (me->driver != &anx7447_usb_mux_driver))
me = me->next_mux;
+ /*
+ * Note that bypassing the usb_mux API is okay for internal driver calls
+ * since the task calling init already holds this port's mux lock.
+ */
if (me != NULL &&
!(me->flags & USB_MUX_FLAG_NOT_TCPC))
- rv = anx7447_mux_set(me, USB_PD_MUX_NONE);
+ rv = anx7447_mux_set(me, USB_PD_MUX_NONE, &unused);
#endif /* CONFIG_USB_PD_TCPM_MUX */
return rv;
@@ -496,6 +502,7 @@ void anx7447_tcpc_clear_hpd_status(int port)
static int anx7447_mux_init(const struct usb_mux *me)
{
int port = me->usb_port;
+ bool unused;
ASSERT(port < CONFIG_USB_PD_PORT_MAX_COUNT);
@@ -511,7 +518,7 @@ static int anx7447_mux_init(const struct usb_mux *me)
* USB_PD_MUX_DP_ENABLED) when reinitialized, we need to force
* initialize it to USB_PD_MUX_NONE
*/
- return anx7447_mux_set(me, USB_PD_MUX_NONE);
+ return anx7447_mux_set(me, USB_PD_MUX_NONE, &unused);
}
#ifdef CONFIG_USB_PD_TCPM_ANX7447_AUX_PU_PD
@@ -559,7 +566,8 @@ static inline void anx7447_configure_aux_src(const struct usb_mux *me,
*
* a2, a3, a10, a11, b2, b3, b10, b11 are pins on the USB-C connector.
*/
-static int anx7447_mux_set(const struct usb_mux *me, mux_state_t mux_state)
+static int anx7447_mux_set(const struct usb_mux *me, mux_state_t mux_state,
+ bool *ack_required)
{
int cc_direction;
mux_state_t mux_type;
@@ -567,6 +575,9 @@ static int anx7447_mux_set(const struct usb_mux *me, mux_state_t mux_state)
int rv;
int port = me->usb_port;
+ /* This driver does not use host command ACKs */
+ *ack_required = false;
+
cc_direction = mux_state & USB_PD_MUX_POLARITY_INVERTED;
mux_type = mux_state & USB_PD_MUX_DOCK;
CPRINTS("C%d mux_state = 0x%x, mux_type = 0x%x",
diff --git a/driver/tcpm/anx74xx.c b/driver/tcpm/anx74xx.c
index f45f7cd25e..8916fac17d 100644
--- a/driver/tcpm/anx74xx.c
+++ b/driver/tcpm/anx74xx.c
@@ -385,13 +385,17 @@ static int anx74xx_mux_aux_to_sbu(int port, int polarity, int enabled)
}
static int anx74xx_tcpm_mux_set(const struct usb_mux *me,
- mux_state_t mux_state)
+ mux_state_t mux_state,
+ bool *ack_required)
{
int ctrl5;
int ctrl1 = 0;
int rv;
int port = me->usb_port;
+ /* This driver does not use host command ACKs */
+ *ack_required = false;
+
if (!(mux_state & ~USB_PD_MUX_POLARITY_INVERTED)) {
anx[port].mux_state = mux_state;
return anx74xx_tcpm_mux_exit(port);
@@ -776,6 +780,7 @@ static int anx74xx_tcpm_set_polarity(int port, enum tcpc_cc_polarity polarity)
{
int reg, mux_state, rv = EC_SUCCESS;
const struct usb_mux *me = &usb_muxes[port];
+ bool unused;
rv |= tcpc_read(port, ANX74XX_REG_CC_SOFTWARE_CTRL, &reg);
if (polarity_rm_dts(polarity)) /* Inform ANX to use CC2 */
@@ -791,7 +796,7 @@ static int anx74xx_tcpm_set_polarity(int port, enum tcpc_cc_polarity polarity)
mux_state = anx[port].mux_state & ~USB_PD_MUX_POLARITY_INVERTED;
if (polarity_rm_dts(polarity))
mux_state |= USB_PD_MUX_POLARITY_INVERTED;
- anx74xx_tcpm_mux_set(me, mux_state);
+ anx74xx_tcpm_mux_set(me, mux_state, &unused);
#endif
return rv;
}
diff --git a/driver/tcpm/anx7688.c b/driver/tcpm/anx7688.c
index 9a2ed85de1..5e37352bc5 100644
--- a/driver/tcpm/anx7688.c
+++ b/driver/tcpm/anx7688.c
@@ -144,11 +144,15 @@ static void anx7688_tcpc_alert(int port)
anx7688_update_hpd_enable(port);
}
-static int anx7688_mux_set(const struct usb_mux *me, mux_state_t mux_state)
+static int anx7688_mux_set(const struct usb_mux *me, mux_state_t mux_state,
+ bool *ack_required)
{
int reg = 0;
int rv, polarity;
+ /* This driver does not use host command ACKs */
+ *ack_required = false;
+
rv = mux_read(me, TCPC_REG_CONFIG_STD_OUTPUT, &reg);
if (rv != EC_SUCCESS)
return rv;
diff --git a/driver/tcpm/ps8xxx.c b/driver/tcpm/ps8xxx.c
index 58fb109b3e..ce0a4a9c6a 100644
--- a/driver/tcpm/ps8xxx.c
+++ b/driver/tcpm/ps8xxx.c
@@ -886,9 +886,9 @@ void ps8xxx_wake_from_standby(const struct usb_mux *me)
msleep(10);
}
-static int ps8xxx_mux_set(const struct usb_mux *me, mux_state_t mux_state)
+static int ps8xxx_mux_set(const struct usb_mux *me, mux_state_t mux_state,
+ bool *ack_required)
{
-
if (product_id[me->usb_port] == PS8751_PRODUCT_ID &&
me->flags & USB_MUX_FLAG_NOT_TCPC) {
ps8xxx_wake_from_standby(me);
@@ -906,7 +906,7 @@ static int ps8xxx_mux_set(const struct usb_mux *me, mux_state_t mux_state)
TYPEC_CC_RD)));
}
- return tcpci_tcpm_mux_set(me, mux_state);
+ return tcpci_tcpm_mux_set(me, mux_state, ack_required);
}
static int ps8xxx_mux_get(const struct usb_mux *me, mux_state_t *mux_state)
diff --git a/driver/tcpm/tcpci.c b/driver/tcpm/tcpci.c
index 3bd5d1b5d0..d113d876ea 100644
--- a/driver/tcpm/tcpci.c
+++ b/driver/tcpm/tcpci.c
@@ -1515,11 +1515,15 @@ int tcpci_tcpm_mux_enter_low_power(const struct usb_mux *me)
return mux_write(me, TCPC_REG_COMMAND, TCPC_REG_COMMAND_I2CIDLE);
}
-int tcpci_tcpm_mux_set(const struct usb_mux *me, mux_state_t mux_state)
+int tcpci_tcpm_mux_set(const struct usb_mux *me, mux_state_t mux_state,
+ bool *ack_required)
{
int rv;
int reg = 0;
+ /* This driver does not use host command ACKs */
+ *ack_required = false;
+
/* Parameter is port only */
rv = mux_read(me, TCPC_REG_CONFIG_STD_OUTPUT, &reg);
if (rv != EC_SUCCESS)