Repository navigation
usb: apple: T8140 Type-C PHY and DWC3 for the J700 fixed hub (reworked, 12 patches) - #28
Merged
Merged
Conversation
The Type-C PHY of the T8140 (A18 Pro) differs from the T8122 PHY it is otherwise programmed like in two ways: there is no USB4/Thunderbolt controller behind it, and it carries a second eUSB2 PHY register bank, mapped separately from the usb2phy block, whose per-device defaults live in Apple's Device Tree and are copied into the node by the bootloader like the other tunables. Add a stand-alone apple,t8140-atcphy compatible, a sixth "usb2phy-reg" register region and apple,tunable-usb2phy-reg-dflt for those defaults. Both are limited to the T8140 compatible; the existing compatibles keep exactly five regions. The T8140 does not claim compatibility with apple,t8122-atcphy: a driver matching only the T8122 entry would program the PHY as USB4-capable and would not know about the eUSB2 bank. Assisted-by: LLM checkpatch dt_binding_check Co-authored-by: Claude Fable 5.1 <[email protected]> Signed-off-by: Ryan Murray <[email protected]>
Apple's J700 (MacBook Neo) has a VIA Labs VL122 two-port USB 2.0 hub permanently attached to the USB 2.0 root port of its Type-C USB controller. The hub's two downstream ports go to the high-speed pairs of the two Type-C connectors; only the rear connector also has SuperSpeed lanes, which bypass the hub. On Linux the hub enumerates as USB ID 2109:2122. Describe it with the generic USB hub binding, so that a board can wire the downstream ports to its connectors through the graph. The Type-C port controllers then find no USB role switch on their high-speed path, which is correct for a fixed hub: the controller behind it is a host regardless of what happens at the connectors. Add the schema to the T8140/J700 MAINTAINERS entry. Assisted-by: LLM checkpatch dt_binding_check Co-authored-by: Claude Fable 5.1 <[email protected]> Signed-off-by: Ryan Murray <[email protected]>
The T8140 (A18 Pro) has the same DWC3 controller and Apple-specific register region as the earlier SoCs, so its node is compatible with apple,t8103-dwc3. Add the SoC-specific entry to the list. Assisted-by: LLM checkpatch dt_binding_check Co-authored-by: Claude Fable 5.1 <[email protected]> Signed-off-by: Ryan Murray <[email protected]>
The glue defers dwc3_core_probe() to the first cable event, so it runs from the USB role switch callback and not from the glue's own probe. When it fails there, the glue device stays bound, and everything that dwc3_core_probe() acquired through devres before failing stays attached to the device, the request of the core register region included. The next cable event retries dwc3_core_probe() on the same struct and its devm_ioremap_resource() fails with -EBUSY on the region that is still requested, so the port never recovers without a rebind. Open a devres group around dwc3_core_probe() and release it when the probe fails. Zero the embedded struct dwc3 as well: dwc3_core_probe() initialises its locks, work items and lists, and the retry expects the zeroed struct it was given the first time. Based on the failed-probe cleanup in Eryk Wieliczko's dwc3-apple work for the T8132 (aurora-silicon, 2026). Eryk Wieliczko's Signed-off-by is outstanding. Fixes: 0ec946d ("usb: dwc3: Add Apple Silicon DWC3 glue layer driver") Assisted-by: LLM checkpatch sparse Co-authored-by: Claude Fable 5.1 <[email protected]> Signed-off-by: Ryan Murray <[email protected]>
The T8140 (A18 Pro) Type-C PHY is programmed like the T8122 one, with three differences that need SoC data of their own: - it has a second eUSB2 register bank, mapped separately from the usb2phy block, whose per-device defaults come from the ADT through the bootloader (apple,tunable-usb2phy-reg-dflt); - there is no USB4/Thunderbolt controller behind it, so it has no CIO lane tunables and cannot enter the TBT or USB4 modes; - its ADT has no common-a tunable entries, and the bootloader may leave out the SuperSpeed tunables altogether, in which case only USB2 can be used. Describe those in struct atcphy_hw and match apple,t8140-atcphy with it. Map the "usb2phy-reg" region, require its defaults and apply them after every USB2 PHY power-on, since the power-off path asserts the PHY resets. The 5 ms interval between the reset release and starting the link is the one the T8140 bring-up used for the eUSB2 repeater behind the PHY; it has not been narrowed down. Missing SuperSpeed tunables are recorded instead of failing the probe on this SoC, and the Type-C mux then refuses every mode that would run the uncalibrated lanes, so the port stays usable at USB2. TBT and USB4 are refused on a PHY without a USB4 controller. The T8140 DWC3 core also does not complete its initialisation against a parked PIPE unless the dummy PHY behind the mux is enabled explicitly (PIPEHANDLER_DUMMY_PHY_EN). Set it whenever the PIPE is parked on the dummy backend, only on SoCs without USB4: the earlier SoCs come up and run USB2-only with the bit clear and are left as they are. The eUSB2 sequencing follows the T8140 bring-up by the original author, who saw the fixed hub enumerate and run sustained transfers with it on a J700. This patch is compile-tested only. Assisted-by: LLM checkpatch sparse Co-authored-by: Claude Fable 5.1 <[email protected]> Signed-off-by: Ryan Murray <[email protected]>
The driver keeps a single flag, pipehandler_up, to remember that the PIPE mux has been routed to the USB3 or USB4 backend. That is enough to configure the PIPE once per mode, but it cannot tell which backend the mux is on, and it makes the dummy state a special case: a set_mode call in a USB2 mode always re-runs the dummy sequence, including its lock handshake, although the PIPE is on the dummy backend already. Record the backend the mux was last routed to instead, as the pipehandler state the mode table already uses. set_mode then returns early whenever the PIPE is already on the backend the current mode needs, which covers the repeated calls from the dwc3 glue and the xHCI core for every backend, and the USB4 configuration is still reached when the mux is parked. As before, the state is recorded even when the sequence fails, so a failed attempt is not retried on the next call. Parking the PIPE on the dummy backend is factored into one helper for the USB3 power-off and the DWC3 reset paths, which skips the sequence when the PIPE is parked already. The check in the Type-C mux callback that no mode change arrives with the PIPE routed to a live backend is kept. Assisted-by: LLM checkpatch sparse Co-authored-by: Claude Fable 5.1 <[email protected]> Signed-off-by: Ryan Murray <[email protected]>
On the J700 the USB2 pairs of the Type-C USB controller do not go to a connector: they go to a VIA VL122 hub on the board, whose downstream ports serve both Type-C connectors. The controller is a host whatever happens at the connectors, and there is no cable event that would bring the PHY out of its powered-off state before the controller starts. Today the PHY is powered off at probe and only ever powered on by a Type-C mode change, so such a controller never gets a working USB2 PHY. Detect the arrangement from the graph: the port is behind a fixed hub when the USB controller its USB3 port is linked to has an available "hub" child. For such a port: - bring the block up in USB2 mode at probe, while dwc3 is still held in reset, so that the common block, its clamps and the crossbar are set up the way a mode change sets them up; powering only the USB2 PHY later is not equivalent. The block is powered off again when a later probe step fails; - power the USB2 PHY on from the PHY's init callback: dwc3 asserts the reset that powers the USB2 PHY off before it initialises its PHYs, and nothing else would power it on again. When the whole block was powered off, because the USB3 PHY was, bring it back in the mode the Type-C mux last asked for, USB2 until a cable event says otherwise, so that a SuperSpeed device is not left at USB2 after the controller was re-initialised; - keep the block in USB2 when the connector goes to its safe state instead of powering it off underneath the running hub, which is what an unplug at the rear connector would otherwise do; - leave the common and AXI2AF tunables unapplied while it runs USB2 with the lanes off, as the T8140 bring-up did; the first SuperSpeed mode change applies the complete set. Ports whose USB2 pairs go to a connector see no change. The J700 sequence follows the original author's bring-up, which saw the hub enumerate and run sustained transfers. The graph-based detection and the rear-unplug behaviour are new and compile-tested only; a rear unplug during front-hub traffic is one of the boot checks owed. Assisted-by: LLM checkpatch sparse Co-authored-by: Claude Fable 5.1 <[email protected]> Signed-off-by: Ryan Murray <[email protected]>
The PIPE mux is normally routed from the USB3 PHY's set_mode callback, which dwc3 calls once per bring-up, after the Type-C mux has selected the mode. That works because a Type-C port controller changes the USB role on every cable event, so dwc3 is torn down and brought up again around each mode change, with the PIPE parked in between. A port behind a fixed hub has no role changes: the controller stays in host mode and dwc3 stays up. A cable at the rear connector still moves the PHY between USB2 and the SuperSpeed modes, but nothing routes the PIPE to the USB3 backend when a SuperSpeed device arrives, and nothing parks it before the lanes are reprogrammed when the device goes away. Remember from set_mode whether dwc3 is up in host mode, and clear that when the USB3 PHY is powered off or the dwc3 reset is asserted. On a fixed-hub port, the Type-C mux callback then does the PIPE work itself: it parks the PIPE before changing to a mode without a USB3 backend, and after a successful mode change it runs the host PIPE sequence when the new mode needs a different backend. Ports with a role switch keep the existing check that no mode change arrives with the PIPE routed to a live backend. The original author drove the same PIPE transitions from a role switch callback and saw the rear port train at 10 Gb/s in both orientations with the front hub in use. Driving them from the mux callback removes the dependency on the Type-C driver's call order; it is compile-tested only. Assisted-by: LLM checkpatch sparse Co-authored-by: Claude Fable 5.1 <[email protected]> Signed-off-by: Ryan Murray <[email protected]>
The glue sets the USB2 PHY's host or device mode before it releases the dwc3 reset, because the PHY has to be configured while it is still powered off. It does so through the handles that dwc3_core_probe() stores in struct dwc3, but the core probe is deferred to the first cable event, so on that first event the handles are still NULL and the call is a no-op: the first bring-up after boot runs with the PHY in whatever mode it was left in. The same handles are used for the USB3 PHY afterwards, and both calls ignore their return value. Look the two PHYs up in the glue's probe and use those handles. The lookup defers the glue until the PHY driver is bound, which the first cable event needed anyway, and the Type-C port controllers defer on the glue's role switch in turn, so everything is still in place before the first cable event. Warn when a set_mode call fails and continue as before: a USB3 PHY that cannot be routed leaves the port at USB2 rather than dead. Assisted-by: LLM checkpatch sparse Co-authored-by: Claude Fable 5.1 <[email protected]> Signed-off-by: Ryan Murray <[email protected]>
On the J700 the USB2 pairs of the Type-C USB controller go to a VIA VL122 hub on the board, whose two downstream ports serve the two Type-C connectors; only the rear connector also has SuperSpeed lanes, wired straight to the PHY. The device tree describes the hub as a "hub" child of the controller node with its ports linked to the connectors, so the Type-C port controllers find no USB role switch on their high-speed path and never drive the controller's role. Such a controller is a host whatever happens at the connectors, and the PHY provides USB2 for the hub from its own probe on. Bring the controller up in host mode at probe when it has an available hub child, instead of waiting for a cable event that never comes, and make the role switch callback a no-op for it. When the host bring-up fails after the core was probed, remove the core again, so that a later attempt does not start from an already probed core. The PHY follows the rear connector's Type-C mode changes on its own while the controller stays up, so a SuperSpeed device at the rear connector runs at SuperSpeed and a rear unplug leaves the front hub alone. Controllers without a hub child see no change. The original author ran the same fixed-hub host mode, keyed on a device tree property and with role-switch inputs for the connectors, and saw the hub and its devices enumerate on a J700. This version is compile-tested only. Assisted-by: LLM checkpatch sparse Co-authored-by: Claude Fable 5.1 <[email protected]> Signed-off-by: Ryan Murray <[email protected]>
dwc3_apple_init() does three things in a row: it configures the USB2 PHY, releases the reset and starts the core; it selects the role in the core and routes the USB3 PHY; and it starts xhci or the gadget. The first two are also what a system resume of a controller that stays in host mode across sleep needs, without the third, so split them into dwc3_apple_core_start() and dwc3_apple_set_role(). No functional change. The error paths keep their order: a core start failure asserts the reset, a host or gadget start failure exits the core first. Assisted-by: LLM checkpatch sparse Co-authored-by: Claude Fable 5.1 <[email protected]> Signed-off-by: Ryan Murray <[email protected]>
Controllers with a Type-C role switch are marked as syscore devices while a cable is connected, since commit 3b7f11e ("usb: dwc3-apple: preserve live ports across system sleep"): the glue owns the PHY and core as one unit and tears it down on the next role change, and system PM is kept away from it in between. A controller behind a fixed hub is always up and never sees a role change, and on the J700 its core does not keep its state across s2idle. Left untouched, it comes back with every xHCI command timing out ("Host halt failed, -110") and the whole USB tree disconnects; rebinding xhci-hcd fails the same way, which places the loss in the dwc3 core. Give the fixed-hub controller sleep callbacks instead of the syscore marking, following what dwc3_suspend_common() and dwc3_resume_common() do for the host role: suspend exits the core and asserts the reset; resume configures the USB2 PHY, releases the reset, initialises the core, restores the Apple-specific registers, PRTCAP and the USB3 PHY mode. The xHCI child stays registered throughout. It suspends before the glue and resumes after it, and then resets the re-initialised controller. Adding or removing the child from inside a PM callback is not an option, since that re-enters the PM core's device list. The sleeping core gets a state of its own, DWC3_APPLE_SUSPENDED, so that a role-switch query during sleep still reports host mode and a failed resume leaves the controller in a state that remove() can tear down without registering a second xHCI device. Because the PHY brings a fixed-hub port back in the mode the Type-C mux last selected, a SuperSpeed device that stayed plugged in at the rear connector is routed at SuperSpeed again after resume. No wakeup capability is declared: the AIC driver implements no irq_set_wake, so no interrupt on this SoC can be armed to end s2idle, and a wakeup path through a USB device cannot work yet. Once it can, the wake IRQ belongs on the xHCI device (dev_pm_set_wake_irq()) and a keep-powered branch like dwc3_suspend_common()'s belongs here. The observations above and the same exit-and-initialise sequence come from the J700 bring-up that preceded this series; this version is compile-tested only, and s2idle with a SuperSpeed device at the rear connector is one of the boot checks owed. Assisted-by: LLM checkpatch sparse Co-authored-by: Claude Fable 5.1 <[email protected]> Signed-off-by: Ryan Murray <[email protected]>
RyanTheTide
force-pushed
the
series/neo-j700-usb-20260926
branch
from
September 25, 2026 17:43
61d59a6 to
11585d9
Compare
RyanTheTide
marked this pull request as ready for review
September 25, 2026 17:44
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
usb: apple: T8140 Type-C PHY and DWC3 support for the J700's fixed hub
This replaces the four draft commits with a twelve-patch series, reworked per the
review. Compile- and schema-checked only; not run on hardware in this form (the
boot checks are listed at the end).
Hardware
The J700's Type-C USB controller does not wire its USB 2.0 pairs to a connector.
They go to a VIA Labs VL122 two-port USB 2.0 hub on the board (USB ID 2109:2122),
whose downstream ports serve the two Type-C connectors; only the back connector
also has SuperSpeed lanes, wired straight to the Type-C PHY. The controller is
therefore always a host, and the PHY has to provide USB 2.0 from probe on. The
T8140 PHY itself differs from the T8122 one it is otherwise programmed like: it
has no USB4/Thunderbolt controller behind it, and a second eUSB2 register bank
whose per-device defaults come from the ADT through the bootloader.
What changed against the draft
apple,t8140-atcphy(noapple,t8130-*, no falseapple,t8122-atcphyfallback), a sixth registerregion and
apple,tunable-usb2phy-reg-dfltlimited to it,apple,t8140-dwc3,and the hub as a
hub@1child of the controller (usb/vialab,vl122.yaml, perusb-hub.yaml) with its downstream ports linked to the connectors. The policyproperties (
apple,force-usb2-on,apple,force-usb2-host-preinit,apple,usb2-hub-always-on) and the virtual role inputs are gone. The Type-Cport controllers find no USB role switch on the hub path, which is right for a
fixed hub; they only drive the PHY's Type-C mux for the back connector's lanes.
(the PIPE state is tracked per backend instead of a single "up" flag),
PIPEHANDLER_DUMMY_PHY_ENis set only on SoCs without USB4, and PHYset_modefailures keep the base tolerance (warn, continue at USB2).
controller with an available
hubchild): it brings the block up in USB2 modeat probe, powers the USB2 PHY from its init callback after each dwc3 reset,
keeps the block in USB2 instead of powering it off under the hub when the back
connector's cable goes away, and routes the PIPE itself when the Type-C mode
changes while the controller stays in host mode.
on every Apple machine, where the USB2 PHY mode was set through a still-NULL
handle), brings a controller with a hub child up in host mode at probe with a
proper error path (
dwc3_core_remove()after a failed host start), and treatsrole-switch requests on it as no-ops.
DWC3_APPLE_SUSPENDEDstate and follows
dwc3_suspend_common()/dwc3_resume_common()for the hostrole, with xHCI staying registered. No wakeup capability is declared and no wake
IRQ is armed: the AIC driver implements no
irq_set_wake, so nothing on thisSoC can end s2idle yet; the message names where that support goes once AIC has
it.
dwc3_core_probe()(Fixes: 0ec946d32ef7) and the probe-time PHY lookup.credited with his Signed-off-by noted as outstanding; the in-tree sleep marking
is cited as commit 3b7f11e.
Patches
Checks
W=1 C=1(sparse) build ofatc.oanddwc3-apple.oat every commit: no warnings.checkpatch.pl --strict --codespell: clean apart from this tree'sAssisted-byformat note, the
Co-authored-bysignature note and the unresolvable commit idsin a .git-less run.
dt_binding_checkon the three schemas: clean.CHECK_DTBS=yont8140-j700,t6020-j414s,t8112-j413,t8103-j274andt8122-j613: no new warnings (the J700 DT gains its USB nodes in arm64: dts: apple: t8140/j700: keyboard, trackpad and USB-C topology (reworked, 5 patches) #30).Boot checks owed (J700 unless noted)
connector appears at 1-1.1 and transfers.
attached.
and the device trains at 10 Gb/s again (no wake source exists yet; use
pm_test=devicesor the power button).device, and a rebind of
dwc3-apple.The original author's observations on the draft (10 Gb/s in both orientations at
the back connector, sustained transfers through the front hub) were made with the
pre-rework code and are not tests of this series.
🤖 Generated with Claude Code