Skip to contentSkip to conversation

phy: qcom: qmp-combo: Leave the USB PCS alone in DP-only mode

PATCH New Joonhoe Kim 1 participant 1 message Nov 3

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 phy: qcom: qmp-combo: Leave the USB PCS alone in DP-only mode

In DP-only mode (DisplayPort pin assignments C and E) all four lanes belong to the DisplayPort PHY and the USB PCS stays powered down. Three paths still touch the USB PCS in this state:

- The USB controller can exit and re-init its PHY in DP-only mode, e.g. across a system suspend that loses power. qmp_combo_usb_init() then programs the USB serdes, lane and PCS tables over the DisplayPort configuration and times out waiting for PHYSTATUS, and qmp_combo_usb_exit() resets and powers down a PCS that is not in use.
- qmp_combo_typec_switch_set() powers the USB PCS off and on when the orientation changes in DP-only mode, e.g. when a DP-only sink is plugged in the other way round while the mux is still in DP-only mode.
- qmp_combo_reconfigure_phy() powers the USB PCS off again when the port leaves DP-only mode.

Skip the USB PCS in these paths in DP-only mode. Keep the qmp_combo_com_init()/qmp_combo_com_exit() reference and usb_init_count, so that qmp_combo_reconfigure_phy() powers the USB PCS up when the port leaves DP-only mode.

The USB PIPE clock is not available in DP-only mode with or without this change. For USB, the only visible effect is that phy_init() no longer times out.

On a Lenovo Y700 Gen 5 (TB323FU, Kaanapali) with a USB-C monitor in pin assignment C, resume from s2idle fails with "phy initialization timed-out", the dwc3 resume returns -110 and USB stops working.

Fixes 896277138c13 ("phy: qcom: qmp-combo: register a typec mux to change the QMPPHY_MODE")
Fixes 89563a152973 ("phy: qualcomm: qmp-combo: Add preliminary USB4 support")

---
Changes in v3:
- Correct the last paragraph of the commit message. Drop the system
hang: it needed an out-of-tree dwc3 change [1].
- Say that the PIPE clock is missing in DP-only mode either way [2].
- Rebase on next-20261030. No code changes. Tested on v7.3 as in v2.
- Pick up Reviewed-by from Abel and Acked-by from Mani.
- Kernels without 89563a152973 need a variant that does not count the USB user in DP-only mode.
- v2: https://lore.kernel.org/all/[email protected]/

[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/

 drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 28 +++++++++++++++--------
 1 file changed, 18 insertions(+), 10 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-combo.c +18 -10
index 187f0cd11f6c..f1b565852caf 100644
@@ -4459,10 +4459,12 @@ static int qmp_combo_usb_init(struct phy *phy)
 	if (ret)
 		return ret;
 
-	ret = qmp_combo_usb_power_on(phy);
-	if (ret) {
-		qmp_combo_com_exit(qmp, false);
-		return ret;
+	if (qmp->qmpphy_mode != QMPPHY_MODE_DP_ONLY) {
+		ret = qmp_combo_usb_power_on(phy);
+		if (ret) {
+			qmp_combo_com_exit(qmp, false);
+			return ret;
+		}
 	}
 
 	qmp->usb_init_count++;
@@ -4484,9 +4486,11 @@ static int qmp_combo_usb_exit(struct phy *phy)
 		return 0;
 	}
 
-	ret = qmp_combo_usb_power_off(phy);
-	if (ret)
-		return ret;
+	if (qmp->qmpphy_mode != QMPPHY_MODE_DP_ONLY) {
+		ret = qmp_combo_usb_power_off(phy);
+		if (ret)
+			return ret;
+	}
 
 	ret = qmp_combo_com_exit(qmp, false);
 	if (ret)
@@ -4511,7 +4515,8 @@ static int qmp_combo_reconfigure_phy(struct qmp_combo *qmp, enum qmpphy_mode new
 	dev_dbg(qmp->dev, "qmp_combo_reconfigure_phy: switching from qmpphy mode %d to %d\n",
 		qmp->qmpphy_mode, new_mode);
 
-	if (qmp->usb_init_count || qmp->usb4_init_count)
+	if ((qmp->usb_init_count || qmp->usb4_init_count) &&
+	    qmp->qmpphy_mode != QMPPHY_MODE_DP_ONLY)
 		qmp_combo_usb_power_off(qmp->usb_phy);
 
 	if (qmp->dp_init_count)
@@ -5087,12 +5092,15 @@ static int qmp_combo_typec_switch_set(struct typec_switch_dev *sw,
 	qmp->orientation = orientation;
 
 	if (qmp->init_count) {
-		if (qmp->usb_init_count || qmp->usb4_init_count)
+		bool usb = (qmp->usb_init_count || qmp->usb4_init_count) &&
+			   qmp->qmpphy_mode != QMPPHY_MODE_DP_ONLY;
+
+		if (usb)
 			qmp_combo_usb_power_off(qmp->usb_phy);
 		qmp_combo_com_exit(qmp, true);
 
 		qmp_combo_com_init(qmp, true);
-		if (qmp->usb_init_count || qmp->usb4_init_count)
+		if (usb)
 			qmp_combo_usb_power_on(qmp->usb_phy);
 		if (qmp->dp_init_count)
 			cfg->dp_aux_init(qmp);

base-commit: 7649ba73f9e7e1e04d0b46213e39c79ae09dd55c

Signature · 1 line
2.43.0