Skip to content

usb: dwc3: Tensor G4 PHY-before-core glue, with system sleep (Pixel 9 Pro Fold) - #271

Closed
kdegeek wants to merge 3 commits into
derekross:omamobilefrom
kdegeek:zumapro-dwc3-glue
Closed

kdegeek wants to merge 3 commits into
derekross:omamobilefrom
kdegeek:zumapro-dwc3-glue

Conversation

@kdegeek

@kdegeek kdegeek commented Nov 18, 2026

Copy link
Copy Markdown

Is this the 9a's glue?

No. The Pixel 9a's &usb uses plain snps,dwc3 from zumapro.dtsi, and nothing on omamobile initialises the PHY before the core. dwc3-google.c is for Tensor G5 (Laguna), not G4. So this is its own PR, as asked on omarchy-mobile#203.

Evidence

Tested on a Pixel 9 Pro Fold (comet). The phone's daily kernel (7.3.0-rc6-omamobile-comet-rc2-cand21) binds 11210000.usb as google,zumapro-dwc3 at every boot, with dwc3-zumapro in the initramfs. That glue gives the phone its USB gadget, which is the only link while the phone is being brought up. The driver code is the same as in this branch; the only change here is the Kconfig symbol.

System sleep (commit 3), on the int-k9f and int-k9g integration kernels, 2026-11-01:

  • Before: pm_test devices failed at dwc3-zumapro 11210000.usb: failed to suspend: error -16, because the glue's suspend callback was an -EBUSY stub.
  • After: pm_test devices passes. Every device suspends and resumes, the gadget reconnects by itself, success 1, fail 0, and no storage or ACPM errors.
  • Then three real s2idle cycles on a 30 s RTC alarm (entry to exit 30.0, 30.0 and 29.9 s) and one power-key wake, with a fresh SSH login over the gadget after each.

What isn't established

Why comet needed the PHY initialised before the core while the 9a doesn't. The bring-up boots that lost USB were fixed together with two unrelated changes (symbol exports, and loading the mailbox driver before ACPM), so the glue's own effect was never isolated. One attended boot of comet with plain snps,dwc3 would settle it. If that boot works, commits 1 and 2 aren't needed. Commit 3's PHY reference would then belong in the core's own suspend path.

Commits

  1. dt-bindings: usb: snps,dwc3: Describe Tensor G4 peripheral glue: google,zumapro-dwc3, peripheral only, high speed, clocks bus_early/ref/ctrl, one USB2 PHY.
  2. usb: dwc3: Add Tensor G4 PHY-before-core glue: phy_init() under the enabled clocks before dwc3_core_probe(). Host and dual-role are rejected. New symbol CONFIG_USB_DWC3_ZUMAPRO.
  3. usb: dwc3: zumapro: Suspend and resume through the DWC3 core: uses the core's system sleep path, with an extra PHY power reference held across it.

Checks

tools/kernel-pr-check --build OUT --merge origin/omamobile HEAD: merges cleanly; prefixes, checkpatch --strict (0 warnings), policy, the W=1 build of dwc3-zumapro.c and dt_binding_check all pass, and every commit is signed off by its author. Also built with CONFIG_USB_DWC3_ZUMAPRO=m and W=1; every core symbol it uses is EXPORT_SYMBOL_GPL.

To use it, kernel/configs/omamobile.config needs CONFIG_USB_DWC3_ZUMAPRO=m (omarchy-mobile side), and the comet board needs compatible = "google,zumapro-dwc3" and clocks bus_early/ref/ctrl on &usb. That is a one-line board follow-up once both this PR and the comet DTS PR have merged.

🤖 Generated with Claude Code

The Pixel 9 Pro Fold (Tensor G4) runs its USB 2.0 gadget through a glue
driver that initialises the USB2 PHY before the DWC3 core's first
register access. Add its google,zumapro-dwc3 compatible: peripheral
only, high speed, three clocks (bus_early, ref, ctrl) and a single USB2
PHY. Existing snps,dwc3 users are unchanged.

Assisted-by: LLM
Signed-off-by: Nate Crawford <nate@kdegeek.com>
The DWC3 core reads GSNPSID before it initialises its generic PHYs. On
Tensor, a read of the link while the USB2 PHY is isolated or in reset
can hang. Initialise the USB2 PHY under the three enabled clocks before
handing over to dwc3_core_probe(), and hold that reference until
removal; the core balances its own. Host and dual-role modes need their
own power sequencing and are rejected.

The probe structure follows dwc3-generic-plat. It gets its own Kconfig
symbol, USB_DWC3_ZUMAPRO.

The Pixel 9 Pro Fold (comet) brings up its USB gadget, and with it its
only link during bring-up, through this glue on its daily v7.3-rc6 based
kernel. The Pixel 9a, the same SoC, binds plain snps,dwc3; why comet
needed the PHY first was not isolated: the bring-up boots that lost USB
were fixed together with two unrelated changes. System sleep is added
by the next patch.

Assisted-by: LLM
Signed-off-by: Nate Crawford <nate@kdegeek.com>
The glue refused system sleep with -EBUSY, so every suspend attempt on
the Pixel 9 Pro Fold failed at 11210000.usb ("failed to suspend: error
-16"), even at the PM core's "devices" test level.

Use the generic DWC3 system sleep path, as dwc3-generic-plat does, but
keep the inherited clocks on and hold an extra PHY power reference over
the sleep. The usbdrd PHY's last power_off isolates the link, and
dwc3_core_init() reads core registers (dwc3_phy_setup()) before it
powers the PHY again; the probe comment already records that such a
read can hang on Tensor. With the extra reference the core is re-inited
against the same initialised, powered PHY that it found at probe. In
peripheral mode the core soft-disconnects the gadget on suspend and
reconnects on resume.

Tested on a Pixel 9 Pro Fold with a v7.3-rc6 based kernel: pm_test
"devices" passes, every device suspends and resumes, the USB gadget
comes back and the host reconnects, with no storage or ACPM errors.
Before this change the same test failed at 11210000.usb with -EBUSY.
Three real suspend-to-idle cycles on a 30 s RTC alarm and one
power-key wake then passed, with SSH over the gadget back after each.

Assisted-by: LLM
Signed-off-by: Nate Crawford <nate@kdegeek.com>
@derekross

Copy link
Copy Markdown
Owner

Thanks, Nate, and thank you especially for the "What isn't established" section: it is the most useful part of the description, and it is where I'd like to start.

The driver is cleanly separated: a new file, a new compatible and a new Kconfig symbol, so no phone on omamobile changes until a board uses it. The gate passes here (clean merge, sign-offs, checkpatch --strict with 0 warnings, W=1), and I ran the binding through dtschema by hand since our container skips it: the file and its example validate, and the 9a's, the 7 Pro's and the 6 Pro's DTBs read the same against your schema as against the base's. CI is waiting for my approval; I'll approve it.

Before it merges, though, I think the published tree already has an answer to the problem this glue works around, and I'd like to know whether comet needs anything more:

  1. The same hazard, solved twice already for this SoC family. The DWC3 core does read its registers before phy_init(). On the Pixel 8 Pro that froze the phone at every rebind, and the cause turned out to be the link left in reset by the PHY's exit, not the isolation: da56cbe9ff2f ("phy: exynos5-usbdrd: release the Exynos 2200 link reset at exit") fixed it in the PHY, and zumapro uses those ops. And the Pixel 9a's &usb in zumapro-tegu.dts is plain snps,dwc3 with a fourth clock, CLK_GOUT_HSI0_USB_SUBCTL as subctl, because "the PHY turns that clock off in suspend, and the core touches those registers before it initialises the PHY again". That is the PHY's own clock, the one a held phy_init() keeps running. The 9a suspends and resumes with that node. My guess is that your bring-up tree was missing one of these two when USB was lost, and the glue stood in for it.

    So could you run the boot you describe, on a kernel built from omamobile, with &usb exactly as the 9a has it (plain snps,dwc3, the four clocks, dr_mode = "peripheral", both PHYs enabled)? Then pm_test devices once and one real s2idle cycle. Please run it attended, with the kernel log streaming to the laptop before the boot. Your slot B is marked, so if the link doesn't come up the phone won't fall back by itself: it's fastboot by the buttons and your saved slot B set. If it works, we close this and arm64: dts: exynos: google: Add the Pixel 9 Pro Fold (comet) #273 enables USB the 9a's way, which also means the board draft can be booted as it stands. If it doesn't, please put where it stops into commit 2's message, and the three points below apply.

  2. Runtime PM. dwc3_core_probe() enables runtime PM on the device, and dwc3-generic-plat.c wires the core's three runtime callbacks; the glue wires none. If anything ever sets power/control to auto, the PM core marks the controller suspended without asking anyone, and the gadget's interrupt handler then parks every event and disables its interrupt waiting for a resume that does nothing. On a phone whose only link is that gadget I'd rather it couldn't happen: please hold a runtime PM reference from probe to remove, with a comment, or wire the callbacks with the same PHY reference your sleep path holds.

  3. The binding. It fixes dr_mode to peripheral and maximum-speed to high-speed, which are the driver's limits and not the hardware's, and it names the third clock ctrl, where zumapro.dtsi has bus_early, ref and suspend (and the 9a adds subctl). The driver only counts the clocks, so the names can be the SoC's. As written, a board that only changes the compatible fails dtbs_check (I fed it such a node: "'ctrl' was expected"), so the follow-up wouldn't be the one line the description expects. Which clock is ctrl on your tree?

  4. Commits 2 and 3. Commit 2 adds a suspend callback that returns -EBUSY and commit 3 replaces it. We merge kernel pull requests commit by commit, so please fold 3 into 2.

One small thing: the Kconfig entry wants depends on OF.

@derekross derekross left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI has run on this head and passes: clean merge onto today's omamobile, sign-offs, prefixes, checkpatch --strict, a W=1 build of dwc3-zumapro.c, and dt_binding_check on snps,dwc3.yaml, which is the check I had run by hand. The one skipped line is "device trees: none touched": CI validates no board against the changed schema when a pull request touches no device tree, so for the 9a, the 7 Pro and the 6 Pro that still rests on my hand run.

Nothing in my comment above changes: the boot with the 9a's plain snps,dwc3 node is still the next step, and it decides whether the other three points matter.

@kdegeek

kdegeek commented Nov 18, 2026

Copy link
Copy Markdown
Author

Derek,

The plain node works on comet. On 2026-11-18 I booted our running kernel (7.3.0-rc6-omamobile-comet-rc2-cand21, which has omamobile's dwc3 core and USB PHY code) with one change to the device tree: usb@11210000 set up the 9a way. The compatible is snps,dwc3 alone, with the four HSI0 clocks named bus_early, ref, suspend and subctl (CLK_GOUT_HSI0_USB_SUBCTL). Nothing else in the tree changed.

  • Bind: 11210000.usb bound to dwc3 directly, and the gadget came up 0.49 s into boot. The UDC read state=configured, so the host the phone was plugged into enumerated it. (dwc3_zumapro was loaded from the image, but nothing bound to it.)
  • pm_test devices (s2idle): rc=0, and the UDC was still configured afterwards.
  • One real s2idle cycle with an RTC wake: suspend entry at 143.26 s, exit at 184.64 s, rc=0. suspend_stats success went from 1 to 2, with no failures and no last_failed_dev. The UDC was still configured after the resume.
  • No dwc3 error, failure or timeout, no SError and no internal error in the kernel log from boot to the end of the test.

That run was a kexec, so the controller started from the state the previous kernel left it in, not from ABL's. The same day, I also cold-booted the exact board DTB from #273 through ABL. dwc3 bound 11210000.usb directly, the gadget was up 3.17 s into boot, and the host configured it. There was no glue module. The details are on #273.

On the module: I put the missing binder down to the old images carrying only dwc3-exynos.ko. These runs had dwc3.ko in the image, which is all the plain node needs.

So I'm withdrawing the glue and closing this PR. USB is enabled in #273 the 9a's way, with the node above. CONFIG_USB_DWC3_ZUMAPRO, dwc3-zumapro in INITRAMFS_MODULES and the README lines go from omarchy-mobile#203 as well.

@kdegeek kdegeek closed this Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants