usb: dwc3: qcom: Keep USB 2.0 working in DisplayPort-only modes
Subsystems (5)
v4 cover usb: dwc3: qcom: Keep USB 2.0 working in DisplayPort-only modes
With a USB-C monitor in DisplayPort pin assignment C or E, the QMP USB3-DP combo PHY gives all four lanes to DisplayPort and keeps its USB PCS powered down. The USB 2.0 pair still works, and such monitors often have a USB 2.0 hub, but the dwc3 controller still runs from the USB3 PIPE clock. On Kaanapali the next xHCI reset in this state times out ("Host halt failed, -110"). USB stays lost until the cable is replugged. Commit f546912bcac6 ("phy: qcom: qmp-combo: Move pipe_clk on/off to common") keeps the pipe clock branch enabled. That is not enough here.
This series registers the dwc3 glue as a Type-C mode switch next to the PHY, so that it gets the mode (it does not route any signals). In DP-only modes it moves the controller to the UTMI clock, as "qcom,select-utmi-as-pipe-clk" does statically, before the PHY switches.
Peter Chen suggested on v2 that the PHY could notify the controller instead [1]. This series uses the existing Type-C mux framework:typec_mux_set() calls each mode switch linked from the connector in graph order, and the controller (HS port) comes before the PHY (SS port), so no new PHY-to-controller interface is needed. The cost is a "mode-switch" property on each controller node. If a notification from the PHY is preferred, the clock selection in patch 2 can be driven from it instead.
On Kaanapali the PHY becomes a mode switch with Balaji Kalkonda's DisplayPort series [2]. The controller side for that SoC is a DTS patch sent separately to the Qualcomm tree [3], and Tapas Rana has sent the same for Glymur [4]. Neither should be applied before patch 2: once the controller node has "mode-switch", pmic_glink_altmode defers its probe until dwc3-qcom registers the mux, which only patch 2 does.
Patch 2 is on top of Filippo Falezza's "usb: dwc3: qcom: Restore UTMI PIPE clock on resume" [5] and reads the selected clock back from QSCRATCH, which loses its contents in system suspend on SM7250. [5] is still under review; patch 2 will be rebased if it changes.
Patch 2 adds "depends on TYPEC || TYPEC=n" to USB_DWC3_QCOM, so with the arm64 defconfig (TYPEC=m) dwc3-qcom is built as a module. pmic_glink_altmode then probes later, and a monitor attached at boot depends on Yongxing Mou's "drm/bridge: aux-hpd-bridge: replay last HPD status on hpd_enable" [6] to be detected.
Tested on a Lenovo Y700 Gen 5 (TB323FU, Kaanapali) with the series backported to a v7.3-based tree that also has [2], [3] and [5], with a USB-C monitor that has an MST hub (two displays, DisplayPort over four lanes) and a USB 2.0 hub. On each of 5 plugs the controller switched to the UTMI clock 1-2 ms before the PHY switched, back to the PIPE clock on the next USB state, and the monitor's hub enumerated. After each of three s2idle cycles with the monitor attached, both displays and the hub came back. Plugging the monitor in during s2idle woke the tablet. The mode arrived after the glue had resumed and was applied right away, before the PHY switched (once with each clock selected beforehand); the path that applies a recorded state on resume was not hit. A USB-C hub with DisplayPort and USB 3 kept the PIPE clock, and a USB 3 stick on it ran at SuperSpeed.
Changes in v4:
- Patch 1: add Reviewed-by from Krzysztof
- Patch 2: mutex_lock()/mutex_unlock() where nothing returns early (Krzysztof)
- Patch 2: leave the probe code as it was apart from the new argument (Krzysztof)
- Rebase on next-20261118
- Link to v3: https://lore.kernel.org/all/[email protected]/
[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
[3] https://lore.kernel.org/all/[email protected]/
[4] https://lore.kernel.org/all/[email protected]/
[5] https://lore.kernel.org/all/[email protected]/
[6] https://lore.kernel.org/all/[email protected]/
Joonhoe Kim (2):
dt-bindings: usb: qcom,snps-dwc3: Add mode-switch
usb: dwc3: qcom: Use the UTMI clock as PIPE clock in DisplayPort-only
modes
.../bindings/usb/qcom,snps-dwc3.yaml | 5 + drivers/usb/dwc3/Kconfig | 1 + drivers/usb/dwc3/dwc3-qcom.c | 150 ++++++++++++++++-- 3 files changed, 143 insertions(+), 13 deletions(-)
base-commit: e8017d29067fd1310a65c3494ce1a1b492adbac6
prerequisite-patch-id: a793fca7329dac964c21459f8d7a8b003d36d84d
Signature · 1 line
2.53.0
PATCH v4 1/2 dt-bindings: usb: qcom,snps-dwc3: Add mode-switch
The QMP USB3-DP combo PHY stops the USB3 PIPE clock when a Type-C DisplayPort pin assignment gives it all four lanes for DisplayPort, while the controller can keep running its USB 2.0 port. The controller has to move to the UTMI clock before that happens, so it needs to know the Type-C mode. It does not route any signals itself.
The Type-C class passes the mode only to graph nodes that have the "mode-switch" property, so allow it on the controller node through usb-switch.yaml. Orientation and retimer switching do not apply to the controller.
---
v4:
- Add Reviewed-by from Krzysztof
v3:
- Drop the mode-switch line, the usb-switch.yaml reference allows it. Disallow orientation-switch and retimer-switch (Krzysztof)
- Say in the message that the controller does not route any signals v2:
- Use the common usb-switch schema instead of a local definition
Documentation/devicetree/bindings/usb/qcom,snps-dwc3.yaml | 5 +++++ 1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/usb/qcom,snps-dwc3.yaml +5 -0
@@ -158,6 +158,10 @@ properties: HS/FS/LS modes are supported. type: boolean + orientation-switch: false + + retimer-switch: false + wakeup-source: true required:
@@ -170,6 +174,7 @@ required: allOf: - $ref: snps,dwc3-common.yaml# + - $ref: /schemas/usb/usb-switch.yaml# - if: properties: compatible:
Signature · 1 line
2.53.0
PATCH v4 2/2 usb: dwc3: qcom: Use the UTMI clock as PIPE clock in DisplayPort-only modes
In reply to Joonhoe KimWith DisplayPort pin assignment C or E the QMP USB3-DP combo PHY gives all four lanes to DisplayPort and powers its USB PCS down. The controller can still run USB 2.0, e.g. for the hub of a USB-C monitor. Keeping the pipe clock branch enabled, as commit f546912bcac6 ("phy:
qcom: qmp-combo: Move pipe_clk on/off to common") does, is not enough on Kaanapali. The next xHCI reset in this mode times out ("Host halt failed, -110"), and USB stops working until the cable is replugged.
Register the glue as a Type-C mode switch when the node has the "mode-switch" property. Select the UTMI clock as PIPE clock in DP-only modes, as "qcom,select-utmi-as-pipe-clk" does statically. typec_mux_set() calls the switches in the order of the connector's ports. Port 0 (HS, the controller) comes before port 1 (SS, the PHY). So the controller switches before the PHY powers its USB side down.
The safe and USB states can come with the DisplayPort altmode, so only the modal states with the DisplayPort SVID count as DisplayPort. Pin assignment C or E always selects the UTMI clock. Go back to the PIPE clock when a USB state follows the safe state. A change from C/E to D/F while DisplayPort is active keeps the UTMI clock: the PHY may keep DP-only mode then, and the UTMI clock still runs USB 2.0 if it does not.
Read the selected clock back from QSCRATCH, as on some SoCs it loses its contents in system suspend.
The mux callback does not resume the glue. From the start of a runtime or system suspend until the core has resumed, the callback only records the state. The resume paths apply it before the core resumes, and again once the core has resumed or when the suspend fails.
The mux needs the Type-C class, so depend on TYPEC || TYPEC=n as PHY_QCOM_QMP_COMBO does, and do not register the mux without it. With the arm64 defconfig (TYPEC=m) this builds the glue, including dwc3-qcom-legacy, as a module.
---
v4:
- mutex_lock()/mutex_unlock() where nothing returns early (Krzysztof)
- Leave the probe code as it was apart from the new argument (Krzysztof) v3:
- Rebase on Filippo Falezza's "usb: dwc3: qcom: Restore UTMI PIPE clock on resume" and use its utmi_as_pipe_clk
- Compare with the clock selected in QSCRATCH, not a cached value
- Check the safe state before the altmode: the safe and USB states can come with the DisplayPort altmode (Sashiko)
- Always select the UTMI clock for pin assignment C or E (Sashiko)
- Do not resume the glue from the mux callback. From the start of a runtime or system suspend until the core has resumed, only record the state; apply it before and after the core resumes, and when the suspend fails (Sashiko)
- Leave the clock select alone on nodes without a mux
- Only record the state once remove has started
v2:
- Switch back to the PIPE clock from the mux callback, not on a role change (Sashiko)
- Keep dp_only while DisplayPort is active, as the PHY keeps its mode
- Defer the clock switch to resume while suspended for system sleep
- Depend on TYPEC || TYPEC=n, skip the mux without CONFIG_TYPEC (Sashiko)
drivers/usb/dwc3/Kconfig | 1 + drivers/usb/dwc3/dwc3-qcom.c | 150 ++++++++++++++++++++++++++++++++--- 2 files changed, 138 insertions(+), 13 deletions(-)
drivers/usb/dwc3/Kconfig +1 -0
@@ -132,6 +132,7 @@ config USB_DWC3_QCOM depends on ARCH_QCOM || COMPILE_TEST depends on EXTCON || !EXTCON depends on OF + depends on TYPEC || TYPEC=n default USB_DWC3 help Some Qualcomm SoCs use DesignWare Core IP for USB2/3
drivers/usb/dwc3/dwc3-qcom.c +137 -13
258 lines not on this page · raw message
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH v4 1/2] dt-bindings: usb: qcom,snps-dwc3: Add mode-switch
In reply to Joonhoe KimSashiko has reviewed this patch and found no issues.
Quoted 6 lines
The QMP USB3-DP combo PHY stops the USB3 PIPE clock when a Type-C DisplayPort pin assignment gives it all four lanes for DisplayPort, while the controller can keep running its USB 2.0 port. The controller has to move to the UTMI clock before that happens, so it needs to know the Type-C mode. It does not route any signals itself.
Quoted 7 lines
The Type-C class passes the mode only to graph nodes that have the "mode-switch" property, so allow it on the controller node through
usb-switch.yaml. Orientation and retimer switching do not apply to the controller.Reviewed-by Krzysztof Kozlowski <[email protected]>Signed-off-by Joonhoe Kim <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
[email protected]
AI reviewRe: [PATCH v4 2/2] usb: dwc3: qcom: Use the UTMI clock as PIPE clock in DisplayPort-only modes
In reply to Joonhoe KimSashiko has reviewed this patch and found no issues.
Quoted 15 lines
With DisplayPort pin assignment C or E the QMP USB3-DP combo PHY gives all four lanes to DisplayPort and powers its USB PCS down. The controller can still run USB 2.0, e.g. for the hub of a USB-C monitor. Keeping the pipe clock branch enabled, as commit
f546912bcac6("phy:
qcom: qmp-combo: Movepipe_clkon/off to common") does, is not enough on Kaanapali. The next xHCI reset in this mode times out ("Host halt failed, -110"), and USB stops working until the cable is replugged.Register the glue as a Type-C mode switch when the node has the "mode-switch" property. Select the UTMI clock as PIPE clock in DP-only modes, as "qcom,select-utmi-as-pipe-clk" does statically.
typec_mux_set()calls the switches in the order of the connector's ports. Port 0 (HS, the controller) comes before port 1 (SS, the PHY). So the controller switches before the PHY powers its USB side down.
Quoted 6 lines
[ ... ]
PHY_QCOM_QMP_COMBOdoes, and do not register the mux without it. With the arm64 defconfig (TYPEC=m) this builds the glue, including dwc3-qcom-legacy, as a module.Signed-off-by Joonhoe Kim <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Greg KH
maintainerRe: [PATCH v4 2/2] usb: dwc3: qcom: Use the UTMI clock as PIPE clock in DisplayPort-only modes
In reply to Joonhoe KimQuoted 106 lines · Joonhoe Kim
With DisplayPort pin assignment C or E the QMP USB3-DP combo PHY gives all four lanes to DisplayPort and powers its USB PCS down. The controller can still run USB 2.0, e.g. for the hub of a USB-C monitor. Keeping the pipe clock branch enabled, as commit
f546912bcac6("phy:
qcom: qmp-combo: Movepipe_clkon/off to common") does, is not enough on Kaanapali. The next xHCI reset in this mode times out ("Host halt failed, -110"), and USB stops working until the cable is replugged.Register the glue as a Type-C mode switch when the node has the "mode-switch" property. Select the UTMI clock as PIPE clock in DP-only modes, as "qcom,select-utmi-as-pipe-clk" does statically.
typec_mux_set()calls the switches in the order of the connector's ports. Port 0 (HS, the controller) comes before port 1 (SS, the PHY). So the controller switches before the PHY powers its USB side down.The safe and USB states can come with the DisplayPort altmode, so only the modal states with the DisplayPort SVID count as DisplayPort. Pin assignment C or E always selects the UTMI clock. Go back to the PIPE clock when a USB state follows the safe state. A change from C/E to D/F while DisplayPort is active keeps the UTMI clock: the PHY may keep DP-only mode then, and the UTMI clock still runs USB 2.0 if it does not.
Read the selected clock back from QSCRATCH, as on some SoCs it loses its contents in system suspend.
The mux callback does not resume the glue. From the start of a runtime or system suspend until the core has resumed, the callback only records the state. The resume paths apply it before the core resumes, and again once the core has resumed or when the suspend fails.
The mux needs the Type-C class, so depend on TYPEC || TYPEC=n as
PHY_QCOM_QMP_COMBOdoes, and do not register the mux without it. With the arm64 defconfig (TYPEC=m) this builds the glue, including dwc3-qcom-legacy, as a module.Signed-off-by Joonhoe Kim <[email protected]>---
v4:
- mutex_lock()/mutex_unlock() where nothing returns early (Krzysztof)
- Leave the probe code as it was apart from the new argument (Krzysztof) v3:
- Rebase on Filippo Falezza's "usb: dwc3: qcom: Restore UTMI PIPE clock on resume" and use itsutmi_as_pipe_clk
- Compare with the clock selected in QSCRATCH, not a cached value
- Check the safe state before the altmode: the safe and USB states can come with the DisplayPort altmode (Sashiko)
- Always select the UTMI clock for pin assignment C or E (Sashiko)
- Do not resume the glue from the mux callback. From the start of a runtime or system suspend until the core has resumed, only record the state; apply it before and after the core resumes, and when the suspend fails (Sashiko)
- Leave the clock select alone on nodes without a mux
- Only record the state once remove has started
v2:
- Switch back to the PIPE clock from the mux callback, not on a role change (Sashiko)
- Keepdp_onlywhile DisplayPort is active, as the PHY keeps its mode
- Defer the clock switch to resume while suspended for system sleep
- Depend on TYPEC || TYPEC=n, skip the mux withoutCONFIG_TYPEC(Sashiko)drivers/usb/dwc3/Kconfig | 1 + drivers/usb/dwc3/dwc3-qcom.c | 150 ++++++++++++++++++++++++++++++++--- 2 files changed, 138 insertions(+), 13 deletions(-)drivers/usb/dwc3/Kconfig +1
-0@@ -132,6 +132,7 @@ config USB_DWC3_QCOM depends on ARCH_QCOM || COMPILE_TEST depends on EXTCON || !EXTCON depends on OF + depends on TYPEC || TYPEC=n default USB_DWC3 help Some Qualcomm SoCs use DesignWare Core IP for USB2/3drivers/usb/dwc3/dwc3-qcom.c +10
-0@@ -19,6 +19,9 @@#include <linux/iopoll.h> #include <linux/usb/hcd.h> #include <linux/usb.h> +#include <linux/usb/typec_altmode.h> +#include <linux/usb/typec_dp.h> +#include <linux/usb/typec_mux.h> #include "core.h" #include "glue.h" @@ -82,6 +85,13 @@ struct dwc3_qcom {bool is_suspended;bool pm_suspended;bool utmi_as_pipe_clk; +bool dp_active; +bool dp_only; +bool mux_deferred; +bool mode_switch; +/* protects dp_active, dp_only and mux_deferred */ +struct mutex pipe_clk_lock; +struct typec_mux_dev *mux;struct icc_path *icc_path_ddr;struct icc_path *icc_path_apps;
drivers/usb/dwc3/dwc3-qcom.c static void dwc3_qcom_enable_interrupts(struct dwc3_qcom *qcom) · line 349
Quoted 5 lines
drivers/usb/dwc3/dwc3-qcom.c +1
-1@@ -336,16 +346,19 @@ static void dwc3_qcom_enable_interrupts(struct dwc3_qcom *qcom)dwc3_qcom_enable_port_interrupts (&qcom->ports[i]); } -static void dwc3_qcom_select_utmi_clk (struct dwc3_qcom *qcom) +static void dwc3_qcom_select_utmi_clk (struct dwc3_qcom *qcom,bool utmi)
What does that bool mean? That's going to be a pain, please make this 2 functions so you know what is happening when you call it.
Quoted 59 lines
drivers/usb/dwc3/dwc3-qcom.c +39
-3{ -/* Configure dwc3 to use UTMI clock as PIPE clock not present */ dwc3_qcom_setbits (qcom->qscratch_base,QSCRATCH_GENERAL_CFG ,PIPE_UTMI_CLK_DIS );usleep_range (100 ,1000 ); -dwc3_qcom_setbits (qcom->qscratch_base,QSCRATCH_GENERAL_CFG , -PIPE_UTMI_CLK_SEL |PIPE3_PHYSTATUS_SW ); +if (utmi) +dwc3_qcom_setbits (qcom->qscratch_base,QSCRATCH_GENERAL_CFG , +PIPE_UTMI_CLK_SEL |PIPE3_PHYSTATUS_SW ); +else +dwc3_qcom_clrbits (qcom->qscratch_base,QSCRATCH_GENERAL_CFG , +PIPE_UTMI_CLK_SEL |PIPE3_PHYSTATUS_SW );usleep_range (100 ,1000 );@@ -353,6 +366,39 @@ static void dwc3_qcom_select_utmi_clk(struct dwc3_qcom *qcom) PIPE_UTMI_CLK_DIS); } +static bool dwc3_qcom_utmi_clk_selected (struct dwc3_qcom *qcom) +{ +return readl (qcom->qscratch_base +QSCRATCH_GENERAL_CFG ) & +PIPE_UTMI_CLK_SEL ; +} + +static void dwc3_qcom_update_pipe_clk (struct dwc3_qcom *qcom) +{ +lockdep_assert_held (&qcom->pipe_clk_lock); + +if (qcom->mode_switch && !qcom->utmi_as_pipe_clk && + qcom->dp_only !=dwc3_qcom_utmi_clk_selected (qcom)) +dwc3_qcom_select_utmi_clk (qcom, qcom->dp_only); +} + +static void dwc3_qcom_defer_mux (struct dwc3_qcom *qcom) +{ +mutex_lock (&qcom->pipe_clk_lock); + qcom->mux_deferred = true; +mutex_unlock (&qcom->pipe_clk_lock); +} + +static void dwc3_qcom_undefer_mux (struct dwc3_qcom *qcom) +{ +guard (mutex)(&qcom->pipe_clk_lock); + +if (qcom->is_suspended) +return ; + + qcom->mux_deferred = false; +dwc3_qcom_update_pipe_clk (qcom); +} +static int dwc3_qcom_suspend (struct dwc3_qcom *qcom,bool wakeup) {u32 val;
drivers/usb/dwc3/dwc3-qcom.c static int dwc3_qcom_resume(struct dwc3_qcom *qcom, bool wakeup) · line 464
Quoted 7 lines
drivers/usb/dwc3/dwc3-qcom.c +3
-1@@ -413,7 +459,11 @@ static int dwc3_qcom_resume(struct dwc3_qcom *qcom, bool wakeup)* clock ("failed to enable ep0out"). */ if (qcom->utmi_as_pipe_clk) -dwc3_qcom_select_utmi_clk (qcom); +dwc3_qcom_select_utmi_clk (qcom, true); + +mutex_lock (&qcom->pipe_clk_lock);
Why no guard() use here?
Quoted 7 lines
drivers/usb/dwc3/dwc3-qcom.c +2
-0+dwc3_qcom_update_pipe_clk (qcom); +mutex_unlock (&qcom->pipe_clk_lock);/* Clear existing events from PHY related to L2 in/out */ for (i =0 ; i < qcom->num_ports; i++) {@@ -446,6 +496,54 @@ static irqreturn_t qcom_dwc3_resume_irq(int irq, void *data)return IRQ_HANDLED ;
drivers/usb/dwc3/dwc3-qcom.c static irqreturn_t qcom_dwc3_resume_irq(int irq, void *data) · line 506
Quoted 10 lines
drivers/usb/dwc3/dwc3-qcom.c +8
-0} +static int dwc3_qcom_mux_set (struct typec_mux_dev *mux, +struct typec_mux_state *state) +{ +struct dwc3_qcom *qcom =typec_mux_get_drvdata (mux); +bool dp = state->mode >=TYPEC_STATE_MODAL && state->alt && + state->alt->svid ==USB_TYPEC_DP_SID ; + +mutex_lock (&qcom->pipe_clk_lock);
guard()?
Re: [PATCH v4 2/2] usb: dwc3: qcom: Use the UTMI clock as PIPE clock in DisplayPort-only modes
From: Joonhoe Kim <[email protected]>
Quoted 5 lines · Greg KH
drivers/usb/dwc3/dwc3-qcom.c static void dwc3_qcom_enable_interrupts(struct dwc3_qcom *qcom) · line 349
Quoted 2 lines
drivers/usb/dwc3/dwc3-qcom.c +1
-1-static void dwc3_qcom_select_utmi_clk (struct dwc3_qcom *qcom) +static void dwc3_qcom_select_utmi_clk (struct dwc3_qcom *qcom,bool utmi)What does that bool mean? That's going to be a pain, please make this 2 functions so you know what is happening when you call it.
Will do in v5: dwc3_qcom_select_utmi_clk() stays as it is upstream, and a new dwc3_qcom_select_pipe_clk() goes back to the PIPE clock.
Quoted 3 lines
Review
Quoted 1 line
(quoted diff) +1
-0+ mutex_lock(&qcom->pipe_clk_lock);Why no
guard()use here?
v3 used guard() and scoped_guard() for this lock. Krzysztof preferred plain mutex_lock()/mutex_unlock() where nothing returns early [1], so I changed it in v4. I'll go back to guard() for this lock in v5, unless Krzysztof objects.
[1] https://lore.kernel.org/all/20261113-artificial-quixotic-firefly-84baef@quoll/
Thanks,
Joonhoe Kim
Quoted 14 lines · Joonhoe Kim
With a USB-C monitor in DisplayPort pin assignment C or E, the QMP USB3-DP combo PHY gives all four lanes to DisplayPort and keeps its USB PCS powered down. The USB 2.0 pair still works, and such monitors often have a USB 2.0 hub, but the dwc3 controller still runs from the USB3 PIPE clock. On Kaanapali the next xHCI reset in this state times out ("Host halt failed, -110"). USB stays lost until the cable is replugged. Commit
f546912bcac6("phy: qcom: qmp-combo: Movepipe_clkon/off to common") keeps the pipe clock branch enabled. That is not enough here.This series registers the dwc3 glue as a Type-C mode switch next to the PHY, so that it gets the mode (it does not route any signals). In DP-only modes it moves the controller to the UTMI clock, as "qcom,select-utmi-as-pipe-clk" does statically, before the PHY switches.
Quoted 8 lines
Peter Chen suggested on v2 that the PHY could notify the controller instead [1]. This series uses the existing Type-C mux framework:
typec_mux_set()calls each mode switch linked from the connector in graph order, and the controller (HS port) comes before the PHY (SS port), so no new PHY-to-controller interface is needed. The cost is a "mode-switch" property on each controller node. If a notification from the PHY is preferred, the clock selection in patch 2 can be driven from it instead.
Hi Joonhoe,
Thanks for explaining the trade-off in the cover letter, I may still prefer that the PHY notifies the controller is better, for the reasons below.
- The controller may not know well what the PHY really did or is going to do:
qmp_combo_typec_mux_set() has its own policy. It does not reconfigure while DP is powered on, and it skips the switch when the PHY is not initialized (drivers/phy/qualcomm/phy-qcom-qmp-combo.c):
if (qmp->qmpphy_mode != QMPPHY_MODE_USB3_ONLY && qmp->dp_powered_on) {
dev_dbg(qmp->dev, "typec_mux_set: DP PHY is still in use, delaying switch\n");
return 0;
}
/* The mux still receives Type-C events, even if all PHYs are uninitialized */
if (!qmp->init_count)
return 0;At above cases, no switch clock from PIPE to UMTI is needed. If qmp-combo calls the controller right before it tears the PHY down and again after it brings it up with the new mode, the controller does not add wrong or useless settings. It uses the UTMI clock while the PHY is being reconfigured, and goes back to the PIPE clock only if the new mode has USB3.
- Once DT ABI is added, it combines the kernel code with DTS. It needs to maintain both DT property (graph) and kernel code correctly, eg, it also depends on the layout at pmic-glink node. If using PHY notifies controller solution, it adapts for all related SoCs, and no dts dependencies.
Thinh, What's your opinion?
Peter
Quoted 65 lines
On Kaanapali the PHY becomes a mode switch with Balaji Kalkonda's DisplayPort series [2]. The controller side for that SoC is a DTS patch sent separately to the Qualcomm tree [3], and Tapas Rana has sent the same for Glymur [4]. Neither should be applied before patch 2: once the controller node has "mode-switch",
pmic_glink_altmodedefers its probe until dwc3-qcom registers the mux, which only patch 2 does.Patch 2 is on top of Filippo Falezza's "usb: dwc3: qcom: Restore UTMI PIPE clock on resume" [5] and reads the selected clock back from QSCRATCH, which loses its contents in system suspend on SM7250. [5] is still under review; patch 2 will be rebased if it changes.
Patch 2 adds "depends on TYPEC || TYPEC=n" to
USB_DWC3_QCOM, so with the arm64 defconfig (TYPEC=m) dwc3-qcom is built as a module.pmic_glink_altmodethen probes later, and a monitor attached at boot depends on Yongxing Mou's "drm/bridge: aux-hpd-bridge: replay last HPD status onhpd_enable" [6] to be detected.Tested on a Lenovo Y700 Gen 5 (TB323FU, Kaanapali) with the series backported to a v7.3-based tree that also has [2], [3] and [5], with a USB-C monitor that has an MST hub (two displays, DisplayPort over four lanes) and a USB 2.0 hub. On each of 5 plugs the controller switched to the UTMI clock 1-2 ms before the PHY switched, back to the PIPE clock on the next USB state, and the monitor's hub enumerated. After each of three s2idle cycles with the monitor attached, both displays and the hub came back. Plugging the monitor in during s2idle woke the tablet. The mode arrived after the glue had resumed and was applied right away, before the PHY switched (once with each clock selected beforehand); the path that applies a recorded state on resume was not hit. A USB-C hub with DisplayPort and USB 3 kept the PIPE clock, and a USB 3 stick on it ran at SuperSpeed.
Changes in v4:
- Patch 1: add Reviewed-by from Krzysztof
- Patch 2: mutex_lock()/mutex_unlock() where nothing returns early (Krzysztof)
- Patch 2: leave the probe code as it was apart from the new argument (Krzysztof)
- Rebase on next-20261118
- Link to v3: https://lore.kernel.org/all/[email protected]/[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
[3] https://lore.kernel.org/all/[email protected]/
[4] https://lore.kernel.org/all/[email protected]/
[5] https://lore.kernel.org/all/[email protected]/
[6] https://lore.kernel.org/all/[email protected]/Joonhoe Kim (2):
dt-bindings: usb: qcom,snps-dwc3: Add mode-switch
usb: dwc3: qcom: Use the UTMI clock as PIPE clock in DisplayPort-only
modes.../bindings/usb/qcom,snps-dwc3.yaml | 5 + drivers/usb/dwc3/Kconfig | 1 + drivers/usb/dwc3/dwc3-qcom.c | 150 ++++++++++++++++-- 3 files changed, 143 insertions(+), 13 deletions(-)base-commit:
e8017d29067fd1310a65c3494ce1a1b492adbac6
prerequisite-patch-id:a793fca7329dac964c21459f8d7a8b003d36d84dSignature · 1 line
2.53.0
Signature · 2 lines
Thanks, Peter Chen