summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaveh Jalali <caveh@chromium.org>2022-08-09 02:54:32 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-08-12 21:15:25 +0000
commita0befd973ce613e65c474efd365a73eb54f1d911 (patch)
tree03145764d68a01c1be33b70b419f60d9c8393d63
parent6e832755e66110947f9dd29686163dc108ba40a6 (diff)
downloadchrome-ec-a0befd973ce613e65c474efd365a73eb54f1d911.tar.gz
drivers/usb_mux: Allow inverted polarity on muxes
This adds a feature for USB-C muxes to be inverted with respect to cable orientation. This effectively adds support for the case where CC1/CC2 are swapped. BRANCH=none BUG=b:240938782 TEST=USB3 and DP works on ghost MLB port with rest of patchset Change-Id: I1441810754078c51ff46f84106aa33e8eb813eb0 Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3818926 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Jack Rosenthal <jrosenth@chromium.org> Reviewed-by: Boris Mittelberg <bmbm@google.com>
-rw-r--r--driver/usb_mux/usb_mux.c4
-rw-r--r--include/usb_mux.h1
-rw-r--r--zephyr/include/dt-bindings/usbc_mux.h1
3 files changed, 6 insertions, 0 deletions
diff --git a/driver/usb_mux/usb_mux.c b/driver/usb_mux/usb_mux.c
index 723ad5711f..bde575bf7e 100644
--- a/driver/usb_mux/usb_mux.c
+++ b/driver/usb_mux/usb_mux.c
@@ -318,6 +318,10 @@ static int configure_mux(int port, int index, enum mux_config_type config,
if (mux_ptr->flags & USB_MUX_FLAG_SET_WITHOUT_FLIP)
lcl_state &= ~USB_PD_MUX_POLARITY_INVERTED;
+ if ((lcl_state != USB_PD_MUX_NONE) &&
+ (mux_ptr->flags & USB_MUX_FLAG_POLARITY_INVERTED))
+ lcl_state ^= USB_PD_MUX_POLARITY_INVERTED;
+
if (drv && drv->set) {
rv = drv->set(mux_ptr, lcl_state,
&ack_required);
diff --git a/include/usb_mux.h b/include/usb_mux.h
index 1d345b0b8f..d5683cc847 100644
--- a/include/usb_mux.h
+++ b/include/usb_mux.h
@@ -28,6 +28,7 @@
#define USB_MUX_FLAG_NOT_TCPC BIT(0) /* TCPC/MUX device used only as MUX */
#define USB_MUX_FLAG_SET_WITHOUT_FLIP BIT(1) /* SET should not flip */
#define USB_MUX_FLAG_RESETS_IN_G3 BIT(2) /* Mux chip will reset in G3 */
+#define USB_MUX_FLAG_POLARITY_INVERTED BIT(3) /* Mux polarity is inverted */
#endif /* CONFIG_ZEPHYR */
diff --git a/zephyr/include/dt-bindings/usbc_mux.h b/zephyr/include/dt-bindings/usbc_mux.h
index 8cfe38340f..61d528221c 100644
--- a/zephyr/include/dt-bindings/usbc_mux.h
+++ b/zephyr/include/dt-bindings/usbc_mux.h
@@ -14,5 +14,6 @@
#define USB_MUX_FLAG_NOT_TCPC BIT(0) /* TCPC/MUX device used only as MUX */
#define USB_MUX_FLAG_SET_WITHOUT_FLIP BIT(1) /* SET should not flip */
#define USB_MUX_FLAG_RESETS_IN_G3 BIT(2) /* Mux chip will reset in G3 */
+#define USB_MUX_FLAG_POLARITY_INVERTED BIT(3) /* Mux polarity is inverted */
#endif /* DT_BINDINGS_USBC_MUX_H_ */