Repository navigation
T6050: USB2 device mode on the Type-C combo PHY (on #2334) - #2423
Draft
RyanTheTide wants to merge 2 commits into
Draft
RyanTheTide wants to merge 2 commits into
RyanTheTide wants to merge 2 commits into
Conversation
The combo PHY refused every USB2 mode but host and had no .validate, so dwc3-apple, which now takes the device role only from a USB2 PHY that validates PHY_MODE_USB_DEVICE, kept every T6050 Type-C port host-only. The T6050 USB2 PHY is the USB2 block of the older ATC PHYs: its host start and stop sequences drive USBCTL, CTL and MISCTUNE bit for bit as atc.c does, and the ADT's atc-phy tunable-host and tunable-device are the same two tuples as on T8103, T6040 and T6041: USB2PHY_SIG bits 14:12 set for host and clear for device. atc.c selects the role with exactly those bits and, on every generation, forces VBUS detect and VBUS valid, since VBUS belongs to the port controller. Do the same here. combo_usb2_mode() accepts PHY_MODE_USB_DEVICE and latches the role. A USB2 start (the port's mode or the controller's power-up) applies the role right after the host tunable step, and a running PHY switches in place: device clears the host signature and forces VBUS valid, host re-applies the host tunable and sets it again. The controller's power-off returns the role to host, so a start without a controller session is the host start it was. .validate reports both roles. The USB3 side keeps refusing device mode with -EOPNOTSUPP before it touches the PIPE. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
A USB3 PHY that refuses PHY_MODE_USB_DEVICE with -EOPNOTSUPP leaves the PIPE on its dummy producer, and the gadget is offered at high speed. The T6050 Type-C PHY refuses device mode that way, before it touches the PIPE, but its errors were all treated as a failed PIPE handoff, so a device session on it failed. Take the high-speed path first for any such refusal. T8132 keeps failing: it refuses device mode while its SuperSpeed lanes are routed, which is not a PIPE left on its dummy producer. Host starts and every other error are handled as before. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
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.
Problem
With #2334, dwc3-apple takes the device role only when the USB2 PHY validates
PHY_MODE_USB_DEVICE. The T6050 Type-C combo PHY (drivers/phy/apple/atc-t6050-combo.h) has no.validateand refuses every USB2 mode except host. That leaves every M5 Pro/Max USB-C port (J714s, J716s, K114, K116 and the rest) host-only. A Mac on the other end of the cable cannot use the port as a USB gadget (NCM, ACM, mass storage).Change
Stacked on #2334 (base
usbgadget/t6040-device-mode).phy: apple: t6050: USB2 device mode on the Type-C combo PHY. The T6050 USB2 PHY is the USB2 block of the older ATC PHYs. Its host start and stop sequences drive
USBCTL,CTLandMISCTUNEexactly asatc.cdoes. The ADT'satc-phytunable-hostandtunable-deviceare the same two tuples on T8103, T6040, T6041 and T6050:USB2PHY_SIGbits 14:12 set for host and cleared for device.atc.cpicks the role with those bits and forces VBUS detect/valid on every generation. This PR does the same here:set_mode(DEVICE)latches the role..validatereports both roles.The USB3 side still refuses device mode with
-EOPNOTSUPP, before it touches the PIPE.usb: dwc3: apple: high-speed gadget on a T6050 port. A device-mode
-EOPNOTSUPPfrom the USB3 PHY already meant "PIPE left on its dummy producer, gadget at high speed" (T6040, from T6040: USB device mode on the USB-C ports (USB2), host-only decided by the PHY #2334). On T6050 every USB3 PHY error was instead treated as a failed PIPE handoff, which would fail the device start. The high-speed path now comes first. T8132 keeps failing, because its refusal means its SuperSpeed lanes are routed. Host starts are unchanged.A host session on T6050 does exactly what it did before: the role starts as host and the signature code is not run.
Testing
atc-t6050-dp.o,phy-apple-atc.oanddwc3-apple.o(clang 22, arm64, W=1) against a prepared kernel tree with this branch's sources and headers: 0 warnings, 0 errors, before and after. The modpost link step was not checked: the prepared tree is an older fleet kernel, and it fails identically before and after.checkpatch.pl --strict: clean.Still to run (owner of a J714s, J716s, K114 or K116, or any T6050)
Kernel with #2334 and this PR,
CONFIG_USB_DWC3_DUAL_ROLE=y, gadget configfs +f_ncmas modules. USB-C cable to any host (a Mac or a Linux PC).modprobe libcomposite usb_f_ncm, createg1with anncm.usb0function,echo $(ls /sys/class/udc | head -1) > UDC. Then reportcat /sys/class/udc/*/current_speed(high-speedexpected),dmesg | grep -iE 'dwc3|t6050|gadget'(expect "No USB3 device PHY: gadget at high speed") and the host's view (macOS: System Information USB, orlsusb -von Linux).iperf3 -son one side,iperf3 -c <peer> -t 20and-Rover the NCM link. Report both numbers.lsusb -t).echo freeze > /sys/power/state(s2idle) once with the gadget bound, then wake. The link must come back, and iperf3 must run again.Facts used (all public)
atc-phy0tunable-host = [0x0000000800000000, 0x0000700000007000]andtunable-device = [0x0000000800000000, 0x0000000000007000](reg 0 = USB2 PHY, offset 0x8, mask 0x7000, value 0x7000 or 0). The values are identical in the GravityLinux adt-collection dumps for J313 (T8103), J773s (T6040), J616c (T6041) and J873s (T6050).apple_t6050_usb2_host(CTL bit 3 SIDDQ cleared, bits 0 and 1 resets released, bit 2 APB_RESET_N set, MISCTUNE bits 29 and 30 cleared, USBCTL = 2 RUN) andapple_t6050_usb2_stopareatc_usb2_power_on/_offregister for register.atc.cdoes for both roles on every generation. T6040: USB device mode on the USB-C ports (USB2), host-only decided by the PHY #2334 found the same was needed for the T6040 device role. Here it is applied in the device role only, so host stays as it is.Risks for the reviewer
apple,tunable-usb2-host, the ADT'stunable_USB2PHY_HOSTexported by aura) is applied in device mode too, before the signature is cleared. If iBoot's tunable carries host-only fields beyond SIG, a device-specific tunable (tunable_USB2PHY_DEV, as T6040: USB device mode on the USB-C ports (USB2), host-only decided by the PHY #2334 did for T6040) would be the next step. That would need an ADT value from an owner, read withioreg -l -p IODeviceTree -n atc-phy0.atc.cdoes. If the T6050 PHY needs a stop/start around the switch, row 1 will show no connection on the host side.Assisted-by: LLM (Claude:Opus 5.5)