[PATCH v5 00/11] usb: dwc3: qcom: Add firmware-managed resource support for SA8255P

From: Faisal Hassan

Date: Mon Nov 23 2026 - 05:47:44 EST


On Qualcomm automotive SoCs such as SA8255P, the USB controller runs in
a Linux VM while the platform resources that the controller depends on
(clocks, interconnects, resets, regulators and the GDSC) are owned and
sequenced by firmware running in a separate VM:

+----------------+ SCMI +------------------+
| Linux VM | <------------------> | Firmware VM |
| | | |
| dwc3-qcom.c | | clocks |
| "power" PD |----------------------->| interconnects |
| "bus" PD |----------------------->| resets |
| | | regulators/GDSC |
+----------------+ +------------------+

Linux has no direct access to these resources; it can only vote for
two abstracted power domains exposed over the SCMI power-domain
protocol:

- "power": gates the power supply (GDSC) to the USB controller
- "bus": gates the clocks and interconnects used for data transfer

Register accesses through the controller require "power" to be voted
on; "bus" additionally requires "power". The vote policy implemented
in this series is:

- Enable order: power, then bus
- Disable order: bus, then power
- Runtime suspend/resume vote only "bus" -- "power" stays on so that
accesses that can legitimately happen while runtime suspended
keep working.
- System suspend/resume vote both domains.

The two domains are attached with PD_FLAG_NO_DEV_LINK because runtime
suspend and system suspend require different supplier states for the
same consumer, which a plain device-link cannot express; the driver
manages the runtime PM references for each attached domain explicitly
instead.

SA8255P also needs platform-specific handling on top of this. Automotive
platform requirements call for powering down the controller's GDSC and
entering VDDmin on the APPS side during system suspend, so the
controller loses all of its state, including the Qscratch programming,
regardless of whether wakeup is enabled. Runtime suspend does not remove
power. System resume therefore has to:

- reset the controller and have dwc3 core reinitialize it
(needs_full_reinit),
- reset the xHC, using the existing XHCI_RESET_ON_RESUME quirk, which
dwc3 can now request through a device property, and
- restore the VBUS override when the controller is not in host mode.

Dependencies: this series is based on usb-next plus
"usb: dwc3: qcom: Add support to skip phy management by USB core" [2]
from Krishna Kurapati (Acked-by: Thinh Nguyen, not yet applied), which
introduces the skip_phy_init property and the property array size used
here, so that patch needs to be applied first.

The PIPE_UTMI_CLK_SEL restore that earlier versions carried is dropped
in favour of "usb: dwc3: qcom: Restore UTMI PIPE clock on resume" [3]
from Filippo Falezza, which is still under review. That restore has to
run after the controller reset added in patch 7, as the reset returns
Qscratch to its defaults.

Patch overview:

Patch 1: Refactor dwc3_qcom_suspend()/dwc3_qcom_resume() to take a
pm_message_t instead of a bool, so the runtime-PM vs
system-PM path can be told apart with PMSG_IS_AUTO(), which
later patches rely on.
Patch 2: Disarm the wakeup interrupts when system suspend runs
without wakeup on a runtime-suspended host, as they would
otherwise stay armed as wakeup sources.
Patch 3: Track whether the wakeup interrupts are armed so enable and
disable stay balanced across runtime and system PM, and
stay disarmed if resume fails.
Patch 4: New devicetree binding, qcom,sa8255p-dwc3.yaml, requiring
"power"/"bus" power-domains and the USB PHYs for
firmware-managed platforms.
Patch 5: Teach xhci-plat to set XHCI_RESET_ON_RESUME from a device
property.
Patch 6: Add xhci_reset_on_resume to struct dwc3_properties and
forward it to xhci-plat.
Patch 7: Recover the controller after power loss in system suspend:
reset it on system resume, set needs_full_reinit and
xhci_reset_on_resume, and skip direct_complete so the
resume callback always runs. Replaces broken_suspend with
power_lost_in_suspend.
Patch 8: Restore the VBUS override after system resume.
Patch 9: Assert the controller reset on remove and probe failure.
Patch 10: Firmware-managed "power"/"bus" domain voting for SA8255P,
wired into probe/remove/suspend/resume, with the probe
error paths and the system-suspend-after-runtime-suspend
case keeping the votes balanced.
Patch 11: Enable the VBUS override at probe when the default role is
peripheral.

Testing:

Tested on SA8255P Ride, with usb_0 in peripheral mode and usb_1 in
host mode:
- usb_1: runtime suspend on device disconnect and resume on connect,
system suspend and resume with the controller active and while
runtime suspended, and 20x system suspend/resume
- usb_0: runtime suspend after unbinding the UDC, system suspend and
resume with the gadget bound and while runtime suspended (the host
re-enumerates the gadget), and 15x UDC unbind/bind

System suspend was run with pm_test=platform, so the SoC did not lose
power. Recovery after a real power loss and remote wakeup from system
suspend were not tested.

Changes in v5:
- Patch 1: moved to the start of the series; carries Acked-by from
Thinh and Reviewed-by from Krishna.
- Patch 2: new; disarm the wakeup interrupts in system suspend when
the device is not wakeup capable. [Peter]
- Patch 3: now follows patches 1 and 2. [Peter]
- Patch 4: no change; added Reviewed-by from Krzysztof.
- Patch 5: no change; added Reviewed-by from Peter.
- Patches 6-8: the v4 broken-suspend patch is split into the dwc3
xHCI-reset plumbing, the power-loss recovery (broken_suspend is
renamed power_lost_in_suspend, and the PIPE_UTMI_CLK_SEL restore is
dropped, see above) and the VBUS override restore. [Peter]
- Patch 9: new. The controller reset on remove and probe failure was
part of the firmware-managed patch and now applies to all
platforms. [Peter]
- Patch 10: attach the domains with devm_pm_domain_attach_list(), hide
the firmware-managed handling behind the resource enable/disable
helpers, return early from dwc3_qcom_interconnect_init(), and index
the domains with an enum. [Peter]
- Patch 11: program the VBUS override once, after the initial role
has been determined, instead of from the role-specific branches.
[Peter]
- Link to v4: https://lore.kernel.org/all/cover.1793212717.git.faisal.hassan@xxxxxxxxxxxxxxxx/

Changes in v4:
- Patch 3: addressed Krzysztof's review of the binding. [Krzysztof]
- Fixed the interrupts to exactly six, with the names listed in the
schema, instead of a variable count.
- Fixed phys to two entries, named usb2-phy and usb3-phy, and made
phys and phy-names required.
- Dropped the redundant minItems from power-domains and the
explicit "clocks/interconnects: false" properties.
- Kept "bus" as the second power domain name. Unlike the "perf"
domains used by other sa8255 bindings, which are SCMI performance
protocol domains with OPP levels, it is a plain SCMI power domain
that is only switched on and off. Noted this in the description.
- Updated the patch 3 commit message to match the binding. Rebased on
the latest usb-next; no other changes.
- Link to v3: https://lore.kernel.org/all/20261010053246.2991984-1-faisal.hassan@xxxxxxxxxxxxxxxx/

Changes in v3:
- Dropped the software node used to pass xhci-reset-on-resume from
dwc3-qcom to the dwc3 core, together with its probe/remove
handling. The flag is now a field in struct dwc3_properties
(xhci_reset_on_resume), set through the glue driver's probe data
and forwarded to xhci-plat by dwc3 host.c. This avoids the software
node lifetime problems that led to the revert of the earlier
approach. The old patch 5 is merged into the broken-suspend patch.
[Thinh]
- Renamed the flag to xhci_reset_on_resume and placed it with the
other quirk bits in struct dwc3. [Thinh]
- Depend on Krishna's skip-phy patch [2]; the property array in dwc3
host.c now has 9 slots (8 properties plus the terminator) to cover
all quirks that can be set together.
- Patch 1: changed approach. Instead of re-enabling the wakeup
interrupts when resume fails, track whether they are armed
(wakeup_irqs_armed) so enable/disable are idempotent, and always
disarm them on resume, not only for host mode with wakeup enabled.
On a failed resume they stay disarmed, since a level-triggered
wakeup line could otherwise keep firing.
- Patch 2: dropped the wakeup value derived from the PM message in
the resume path, as patch 1 now disarms the interrupts
unconditionally.
- Patch 3: interrupts were minItems 1/maxItems 6 and are now
minItems 5 with the names listed in the schema; added dma-coherent;
dropped the free-form descriptions of power-domains,
power-domain-names and resets.
- Patch 5: also set needs_full_reinit so dwc3 core re-initializes the
controller on system resume even in host mode with wakeup enabled;
restore Qscratch (PIPE_UTMI_CLK_SEL, VBUS_VALID) on every system
resume rather than depending on wakeup, only forcing VBUS_VALID
outside host mode, and never on runtime resume; skip
dwc3_pm_prepare() so the resume callback always runs.
- Patch 6: dwc3_qcom_domains_put() no longer returns an error: the
runtime PM usage count is dropped even when put_sync() fails, so
failures are only warned about and cannot unbalance the next vote.
System suspend of a runtime-suspended device now also drops the
"power" vote that runtime suspend keeps, so system resume stays
balanced. Probe error paths now assert the reset again. The
remove path is simplified accordingly.
- Patch 7: new.
- Link to v2: https://lore.kernel.org/all/20260903153827.3463313-1-faisal.hassan@xxxxxxxxxxxxxxxx/

Changes in v2:
- Reworked the resource model from OPP-based performance-state
voting to plain power-domain ON/OFF voting via "power" and "bus"
domains, addressing Bjorn's objection that OPP levels conflate
performance-state selection with power-state signaling. [Bjorn]
- Documented the PD_FLAG_NO_DEV_LINK rationale (asymmetric runtime
suspend vs system suspend supplier state) in the firmware-managed
patch.
- Validate the number of attached domains against what was
requested instead of assuming attach always returns exactly two.
- Fixed an unwind bug where a "bus" domain enable failure during
probe would return without dropping the "power" domain vote.
- Added the new qcom,sa8255p-dwc3.yaml binding.
- Terminated the broken-suspend software node's property array and
fixed a bug where the software-property walk in dwc3 core did not
continue past the first match.
- Fixed dwc3_qcom_resume()'s broken-suspend reset to only fire on
system resume, not runtime resume.
- Link to v1: https://lore.kernel.org/r/20251127-controller_scmi_upstream-v1-0-38bcca513c28@xxxxxxxxxxxxxxxx

[1] v2: https://lore.kernel.org/all/20260903153827.3463313-1-faisal.hassan@xxxxxxxxxxxxxxxx/
[2] https://lore.kernel.org/all/20260914-xhci-skip-phy-init-v1-1-9c46b31a5a39@xxxxxxxxxxxxxxxx/
[3] https://lore.kernel.org/all/20261027-dwc3-utmi-resume-v1-1-ca9f0aa65783@xxxxxxxxx/

Faisal Hassan (11):
usb: dwc3: qcom: Distinguish PM and runtime suspend/resume paths
usb: dwc3: qcom: Disarm wakeup IRQs on system suspend without wakeup
usb: dwc3: qcom: Keep wakeup IRQ enable/disable balanced on failed
resume
dt-bindings: usb: Add qcom,sa8255p-dwc3 for firmware-managed resources
usb: host: xhci-plat: Support XHCI_RESET_ON_RESUME via device property
usb: dwc3: Support resetting the xHCI host on system resume
usb: dwc3: qcom: Recover controller state after power loss in system
suspend
usb: dwc3: qcom: Restore VBUS override after system resume
usb: dwc3: qcom: Assert controller reset on remove and probe failure
usb: dwc3: qcom: Support firmware-managed resource states for power
management
usb: dwc3: qcom: Enable VBUS override at probe for default peripheral
role

.../bindings/usb/qcom,sa8255p-dwc3.yaml | 114 ++++++
drivers/usb/dwc3/core.c | 3 +
drivers/usb/dwc3/core.h | 3 +
drivers/usb/dwc3/dwc3-qcom.c | 355 ++++++++++++++++--
drivers/usb/dwc3/glue.h | 2 +
drivers/usb/dwc3/host.c | 5 +-
drivers/usb/host/xhci-plat.c | 3 +
7 files changed, 453 insertions(+), 32 deletions(-)
create mode 100644 Documentation/devicetree/bindings/usb/qcom,sa8255p-dwc3.yaml

--
2.34.1