summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJameson Thies <jthies@google.com>2023-05-12 17:09:36 +0000
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-05-12 23:16:19 +0000
commit98406285eb79141babdae0710cc24b9d9dde9db9 (patch)
tree77e42997055bed77ebe36b1f28cffd436d95f446
parenta609efecf170b1b7cb9e393e237fe75c20fb2a90 (diff)
downloadchrome-ec-98406285eb79141babdae0710cc24b9d9dde9db9.tar.gz
USB Mux: Use polarity in safe mode
Currently, a handful of drivers look for the mux_state to be equal to USB_PD_MUX_SAFE_MODE when handling safe mode. This check requires that the polarity information be cleared before sending the mux_state to any drivers to correctly handle the safe state. But the same mux_state is sent to the kernel, which relies on polarity information from the EC when setting USB-C switches. This CL updates the retimer, tcpm and usb_mux drivers which check for mux_state to equal USB_PD_MUX_SAFE_MODE to instead only look for the safe mode bit to be set. This allows those drivers to function the same way in safe mode regardless of polarity information. It also updates usb_mux.c to preserve the polarity bit when sending mux_state to drivers in safe_state. LOW_COVERAGE_REASON=20 of the changed drivers have no emulators BUG=b:279733113 TEST=make -j buildall, confirmed that no remaining drivers check for mux state to equal USB_PD_MUX_SAFE_MODE. Checked on redrix that we are able to drive a monitor with inverted and normal polarity after losing Try.SRC. Change-Id: Ifc89d0ba1da0975436f93be102fadf725a5b8566 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4527219 Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Tested-by: Jameson Thies <jthies@google.com> Commit-Queue: Jameson Thies <jthies@google.com>
-rw-r--r--driver/retimer/anx7483.c2
-rw-r--r--driver/retimer/nb7v904m.c2
-rw-r--r--driver/retimer/pi3dpx1207.c2
-rw-r--r--driver/retimer/ps8802.c2
-rw-r--r--driver/retimer/ps8818.c2
-rw-r--r--driver/retimer/tusb544.c2
-rw-r--r--driver/tcpm/anx7447.c2
-rw-r--r--driver/tcpm/anx74xx.c2
-rw-r--r--driver/tcpm/anx7688.c2
-rw-r--r--driver/tcpm/ps8xxx.c2
-rw-r--r--driver/tcpm/tcpci.c2
-rw-r--r--driver/usb_mux/amd_fp5.c2
-rw-r--r--driver/usb_mux/amd_fp6.c2
-rw-r--r--driver/usb_mux/anx3443.c2
-rw-r--r--driver/usb_mux/anx7440.c2
-rw-r--r--driver/usb_mux/anx7451.c2
-rw-r--r--driver/usb_mux/it5205.c2
-rw-r--r--driver/usb_mux/pi3usb3x532.c2
-rw-r--r--driver/usb_mux/ps8740.c2
-rw-r--r--driver/usb_mux/ps8743.c2
-rw-r--r--driver/usb_mux/ps8822.c2
-rw-r--r--driver/usb_mux/tusb1064.c2
-rw-r--r--driver/usb_mux/usb_mux.c3
23 files changed, 23 insertions, 24 deletions
diff --git a/driver/retimer/anx7483.c b/driver/retimer/anx7483.c
index 4b07848b9e..b4532ee12c 100644
--- a/driver/retimer/anx7483.c
+++ b/driver/retimer/anx7483.c
@@ -232,7 +232,7 @@ test_export_static int anx7483_set(const struct usb_mux *me,
*ack_required = false;
/* This driver treats safe mode as none */
- if (mux_state == USB_PD_MUX_SAFE_MODE)
+ if (mux_state & USB_PD_MUX_SAFE_MODE)
mux_state = USB_PD_MUX_NONE;
/*
diff --git a/driver/retimer/nb7v904m.c b/driver/retimer/nb7v904m.c
index 2990a906b5..18fdf3b2ba 100644
--- a/driver/retimer/nb7v904m.c
+++ b/driver/retimer/nb7v904m.c
@@ -154,7 +154,7 @@ static int nb7v904m_set_mux(const struct usb_mux *me, mux_state_t mux_state,
*ack_required = false;
/* This driver treats safe mode as none */
- if (mux_state == USB_PD_MUX_SAFE_MODE)
+ if (mux_state & USB_PD_MUX_SAFE_MODE)
mux_state = USB_PD_MUX_NONE;
/* Turn off redriver if it's not needed at all. */
diff --git a/driver/retimer/pi3dpx1207.c b/driver/retimer/pi3dpx1207.c
index e40f269e3b..4a4c180f8c 100644
--- a/driver/retimer/pi3dpx1207.c
+++ b/driver/retimer/pi3dpx1207.c
@@ -102,7 +102,7 @@ static int pi3dpx1207_set_mux(const struct usb_mux *me, mux_state_t mux_state,
*ack_required = false;
/* This driver treats safe mode as none */
- if (mux_state == USB_PD_MUX_SAFE_MODE)
+ if (mux_state & USB_PD_MUX_SAFE_MODE)
mux_state = USB_PD_MUX_NONE;
/* USB */
diff --git a/driver/retimer/ps8802.c b/driver/retimer/ps8802.c
index e2d93a25b4..24ad0f290f 100644
--- a/driver/retimer/ps8802.c
+++ b/driver/retimer/ps8802.c
@@ -189,7 +189,7 @@ static int ps8802_set_mux(const struct usb_mux *me, mux_state_t mux_state,
*ack_required = false;
/* This driver treats safe mode as none */
- if (mux_state == USB_PD_MUX_SAFE_MODE)
+ if (mux_state & USB_PD_MUX_SAFE_MODE)
mux_state = USB_PD_MUX_NONE;
if (chipset_in_state(CHIPSET_STATE_HARD_OFF))
diff --git a/driver/retimer/ps8818.c b/driver/retimer/ps8818.c
index dff1b33a64..1f17146476 100644
--- a/driver/retimer/ps8818.c
+++ b/driver/retimer/ps8818.c
@@ -90,7 +90,7 @@ static int ps8818_set_mux(const struct usb_mux *me, mux_state_t mux_state,
*ack_required = false;
/* This driver treats safe mode as none */
- if (mux_state == USB_PD_MUX_SAFE_MODE)
+ if (mux_state & USB_PD_MUX_SAFE_MODE)
mux_state = USB_PD_MUX_NONE;
if (chipset_in_state(CHIPSET_STATE_HARD_OFF))
diff --git a/driver/retimer/tusb544.c b/driver/retimer/tusb544.c
index c2d617c3be..8bac6cedd6 100644
--- a/driver/retimer/tusb544.c
+++ b/driver/retimer/tusb544.c
@@ -61,7 +61,7 @@ static int tusb544_set_mux(const struct usb_mux *me, mux_state_t mux_state,
*ack_required = false;
/* This driver treats safe mode as none */
- if (mux_state == USB_PD_MUX_SAFE_MODE)
+ if (mux_state & USB_PD_MUX_SAFE_MODE)
mux_state = USB_PD_MUX_NONE;
if (mux_state == USB_PD_MUX_NONE)
diff --git a/driver/tcpm/anx7447.c b/driver/tcpm/anx7447.c
index 79f08ee655..4760596eae 100644
--- a/driver/tcpm/anx7447.c
+++ b/driver/tcpm/anx7447.c
@@ -664,7 +664,7 @@ static int anx7447_mux_set(const struct usb_mux *me, mux_state_t mux_state,
*ack_required = false;
/* This driver treats safe mode as none */
- if (mux_state == USB_PD_MUX_SAFE_MODE)
+ if (mux_state & USB_PD_MUX_SAFE_MODE)
mux_state = USB_PD_MUX_NONE;
cc_direction = mux_state & USB_PD_MUX_POLARITY_INVERTED;
diff --git a/driver/tcpm/anx74xx.c b/driver/tcpm/anx74xx.c
index e6ad23c25a..9e3a975754 100644
--- a/driver/tcpm/anx74xx.c
+++ b/driver/tcpm/anx74xx.c
@@ -400,7 +400,7 @@ static int anx74xx_tcpm_mux_set(const struct usb_mux *me, mux_state_t mux_state,
*ack_required = false;
/* This driver treats safe mode as none */
- if (mux_state == USB_PD_MUX_SAFE_MODE)
+ if (mux_state & USB_PD_MUX_SAFE_MODE)
mux_state = USB_PD_MUX_NONE;
if (!(mux_state & ~USB_PD_MUX_POLARITY_INVERTED)) {
diff --git a/driver/tcpm/anx7688.c b/driver/tcpm/anx7688.c
index 6ad8a16ff4..277edd0217 100644
--- a/driver/tcpm/anx7688.c
+++ b/driver/tcpm/anx7688.c
@@ -154,7 +154,7 @@ static int anx7688_mux_set(const struct usb_mux *me, mux_state_t mux_state,
*ack_required = false;
/* This driver treats safe mode as none */
- if (mux_state == USB_PD_MUX_SAFE_MODE)
+ if (mux_state & USB_PD_MUX_SAFE_MODE)
mux_state = USB_PD_MUX_NONE;
rv = mux_read(me, TCPC_REG_CONFIG_STD_OUTPUT, &reg);
diff --git a/driver/tcpm/ps8xxx.c b/driver/tcpm/ps8xxx.c
index 9eb3b40b2b..0818b328bf 100644
--- a/driver/tcpm/ps8xxx.c
+++ b/driver/tcpm/ps8xxx.c
@@ -1118,7 +1118,7 @@ static int ps8xxx_mux_set(const struct usb_mux *me, mux_state_t mux_state,
bool *ack_required)
{
/* This driver treats safe mode as none */
- if (mux_state == USB_PD_MUX_SAFE_MODE)
+ if (mux_state & USB_PD_MUX_SAFE_MODE)
mux_state = USB_PD_MUX_NONE;
if (product_id[me->usb_port] == PS8751_PRODUCT_ID &&
diff --git a/driver/tcpm/tcpci.c b/driver/tcpm/tcpci.c
index b78cfbb74c..ffadcab8c0 100644
--- a/driver/tcpm/tcpci.c
+++ b/driver/tcpm/tcpci.c
@@ -1635,7 +1635,7 @@ int tcpci_tcpm_mux_set(const struct usb_mux *me, mux_state_t mux_state,
*ack_required = false;
/* This driver treats safe mode as none */
- if (mux_state == USB_PD_MUX_SAFE_MODE)
+ if (mux_state & USB_PD_MUX_SAFE_MODE)
mux_state = USB_PD_MUX_NONE;
/* Parameter is port only */
diff --git a/driver/usb_mux/amd_fp5.c b/driver/usb_mux/amd_fp5.c
index ca042b0fa0..b5aa6d2669 100644
--- a/driver/usb_mux/amd_fp5.c
+++ b/driver/usb_mux/amd_fp5.c
@@ -50,7 +50,7 @@ static int amd_fp5_set_mux(const struct usb_mux *me, mux_state_t mux_state,
*ack_required = false;
/* This driver treats safe mode as none */
- if (mux_state == USB_PD_MUX_SAFE_MODE)
+ if (mux_state & USB_PD_MUX_SAFE_MODE)
mux_state = USB_PD_MUX_NONE;
saved_mux_state[me->usb_port] = mux_state;
diff --git a/driver/usb_mux/amd_fp6.c b/driver/usb_mux/amd_fp6.c
index a776a696f7..ff3b6eacb8 100644
--- a/driver/usb_mux/amd_fp6.c
+++ b/driver/usb_mux/amd_fp6.c
@@ -142,7 +142,7 @@ static int amd_fp6_set_mux(const struct usb_mux *me, mux_state_t mux_state,
*ack_required = false;
/* This driver treats safe mode as none */
- if (mux_state == USB_PD_MUX_SAFE_MODE)
+ if (mux_state & USB_PD_MUX_SAFE_MODE)
mux_state = USB_PD_MUX_NONE;
if (mux_state == USB_PD_MUX_NONE)
diff --git a/driver/usb_mux/anx3443.c b/driver/usb_mux/anx3443.c
index f3b0b08afd..e8c2621a54 100644
--- a/driver/usb_mux/anx3443.c
+++ b/driver/usb_mux/anx3443.c
@@ -97,7 +97,7 @@ static int anx3443_set_mux(const struct usb_mux *me, mux_state_t mux_state,
*ack_required = false;
/* This driver treats safe mode as none */
- if (mux_state == USB_PD_MUX_SAFE_MODE)
+ if (mux_state & USB_PD_MUX_SAFE_MODE)
mux_state = USB_PD_MUX_NONE;
saved_mux_state[me->usb_port].mux_state = mux_state;
diff --git a/driver/usb_mux/anx7440.c b/driver/usb_mux/anx7440.c
index 456eaaa407..5a80487e05 100644
--- a/driver/usb_mux/anx7440.c
+++ b/driver/usb_mux/anx7440.c
@@ -69,7 +69,7 @@ static int anx7440_set_mux(const struct usb_mux *me, mux_state_t mux_state,
*ack_required = false;
/* This driver treats safe mode as none */
- if (mux_state == USB_PD_MUX_SAFE_MODE)
+ if (mux_state & USB_PD_MUX_SAFE_MODE)
mux_state = USB_PD_MUX_NONE;
res = anx7440_read(me, ANX7440_REG_CHIP_CTRL, &reg);
diff --git a/driver/usb_mux/anx7451.c b/driver/usb_mux/anx7451.c
index b974128740..127f0b8e67 100644
--- a/driver/usb_mux/anx7451.c
+++ b/driver/usb_mux/anx7451.c
@@ -97,7 +97,7 @@ static int anx7451_set_mux(const struct usb_mux *me, mux_state_t mux_state,
*ack_required = false;
/* This driver treats safe mode as none */
- if (mux_state == USB_PD_MUX_SAFE_MODE)
+ if (mux_state & USB_PD_MUX_SAFE_MODE)
mux_state = USB_PD_MUX_NONE;
/*
diff --git a/driver/usb_mux/it5205.c b/driver/usb_mux/it5205.c
index de3d950c86..a773a51d0e 100644
--- a/driver/usb_mux/it5205.c
+++ b/driver/usb_mux/it5205.c
@@ -100,7 +100,7 @@ static int it5205_set_mux(const struct usb_mux *me, mux_state_t mux_state,
*ack_required = false;
/* This driver treats safe mode as none */
- if (mux_state == USB_PD_MUX_SAFE_MODE)
+ if (mux_state & USB_PD_MUX_SAFE_MODE)
mux_state = USB_PD_MUX_NONE;
switch (mux_state & MUX_STATE_DP_USB_MASK) {
diff --git a/driver/usb_mux/pi3usb3x532.c b/driver/usb_mux/pi3usb3x532.c
index 54eff928b7..42d13ca835 100644
--- a/driver/usb_mux/pi3usb3x532.c
+++ b/driver/usb_mux/pi3usb3x532.c
@@ -89,7 +89,7 @@ static int pi3usb3x532_set_mux(const struct usb_mux *me, mux_state_t mux_state,
*ack_required = false;
/* This driver treats safe mode as none */
- if (mux_state == USB_PD_MUX_SAFE_MODE)
+ if (mux_state & USB_PD_MUX_SAFE_MODE)
mux_state = USB_PD_MUX_NONE;
if (mux_state & USB_PD_MUX_USB_ENABLED)
diff --git a/driver/usb_mux/ps8740.c b/driver/usb_mux/ps8740.c
index 557c4f1976..2b412ac35a 100644
--- a/driver/usb_mux/ps8740.c
+++ b/driver/usb_mux/ps8740.c
@@ -77,7 +77,7 @@ static int ps8740_set_mux(const struct usb_mux *me, mux_state_t mux_state,
*ack_required = false;
/* This driver treats safe mode as none */
- if (mux_state == USB_PD_MUX_SAFE_MODE)
+ if (mux_state & USB_PD_MUX_SAFE_MODE)
mux_state = USB_PD_MUX_NONE;
if (mux_state & USB_PD_MUX_USB_ENABLED)
diff --git a/driver/usb_mux/ps8743.c b/driver/usb_mux/ps8743.c
index 86f0a7f9b2..6c123bb50c 100644
--- a/driver/usb_mux/ps8743.c
+++ b/driver/usb_mux/ps8743.c
@@ -126,7 +126,7 @@ static int ps8743_set_mux(const struct usb_mux *me, mux_state_t mux_state,
*ack_required = false;
/* This driver treats safe mode as none */
- if (mux_state == USB_PD_MUX_SAFE_MODE)
+ if (mux_state & USB_PD_MUX_SAFE_MODE)
mux_state = USB_PD_MUX_NONE;
if (mux_state & USB_PD_MUX_USB_ENABLED)
diff --git a/driver/usb_mux/ps8822.c b/driver/usb_mux/ps8822.c
index d3ea76965d..97d1158f99 100644
--- a/driver/usb_mux/ps8822.c
+++ b/driver/usb_mux/ps8822.c
@@ -84,7 +84,7 @@ static int ps8822_set_mux(const struct usb_mux *me, mux_state_t mux_state,
*ack_required = false;
/* This driver treats safe mode as none */
- if (mux_state == USB_PD_MUX_SAFE_MODE)
+ if (mux_state & USB_PD_MUX_SAFE_MODE)
mux_state = USB_PD_MUX_NONE;
rv = ps8822_read(me, PS8822_REG_PAGE0, PS8822_REG_MODE, &reg);
diff --git a/driver/usb_mux/tusb1064.c b/driver/usb_mux/tusb1064.c
index 9dc25d0d01..266e36a2eb 100644
--- a/driver/usb_mux/tusb1064.c
+++ b/driver/usb_mux/tusb1064.c
@@ -97,7 +97,7 @@ int tusb1064_set_mux(const struct usb_mux *me, mux_state_t mux_state,
int mask;
/* This driver treats safe mode as none */
- if (mux_state == USB_PD_MUX_SAFE_MODE)
+ if (mux_state & USB_PD_MUX_SAFE_MODE)
mux_state = USB_PD_MUX_NONE;
rv = tusb1064_read(me, TUSB1064_REG_GENERAL, &reg);
diff --git a/driver/usb_mux/usb_mux.c b/driver/usb_mux/usb_mux.c
index 334b7f2f2d..ceabe7f8c8 100644
--- a/driver/usb_mux/usb_mux.c
+++ b/driver/usb_mux/usb_mux.c
@@ -514,8 +514,7 @@ static void perform_mux_set(int port, int index, mux_state_t mux_mode,
return;
/* Configure superspeed lanes */
- mux_state = ((mux_mode != USB_PD_MUX_NONE) &&
- (mux_mode != USB_PD_MUX_SAFE_MODE) && polarity) ?
+ mux_state = ((mux_mode != USB_PD_MUX_NONE) && polarity) ?
mux_mode | USB_PD_MUX_POLARITY_INVERTED :
mux_mode;