From ec5614f1a6fbedbc797ac3fe8b84214e5246d6ec Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Fri, 20 Nov 2026 00:49:00 +1100 Subject: [PATCH 1/2] phy: apple: t6040: USB3 for a port wired to an on-board hub The Mac mini M4 Pro (J773s) has two front USB-C ports behind an on-board USB2/USB3 hub on ATC3, with no PD controller. This PHY brought USB3 up only for a plug orientation from a Type-C orientation switch. Without that switch it skipped the USB3 setup entirely and was then taken for a DP-only (HDMI converter) PHY. Recognise such a port the way dwc3-apple already does: a "hub" child on the controller that the PHY's USB3 graph port (port 1) links to. The PHY then takes the connection as fixed and runs USB3 on the lanes of a normal plug orientation, with no orientation switch. The ADT gives every connector-less ATC PHY plug orientation 1, as it does the laptops' HDMI converter PHYs, which already run unflipped. PHYs with an orientation switch, and those without a hub, are unchanged. Signed-off-by: Ryan Murray --- drivers/phy/apple/t6040-usb2.c | 55 ++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 13 deletions(-) diff --git a/drivers/phy/apple/t6040-usb2.c b/drivers/phy/apple/t6040-usb2.c index 50d82116aac2d..aed40eb3720b8 100644 --- a/drivers/phy/apple/t6040-usb2.c +++ b/drivers/phy/apple/t6040-usb2.c @@ -16,7 +16,9 @@ * stops the coprocessor and resets its RTKit state, and puts the PHY to * sleep, as macOS does on every detach: every attach boots the firmware again. * Without a plug orientation, or when the coprocessor does not come up, the - * PIPE stays on the dummy PHY and the port keeps working at USB2. + * PIPE stays on the dummy PHY and the port keeps working at USB2. A PHY wired + * to an on-board hub instead of a connector has no orientation switch: its + * lanes have the fixed orientation of t6040_usb3_fixed_hub(). * * The driver performs no ATC-register writes during probe. The power * sequences only cover the PHY: the host controller must be stopped before @@ -40,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -2209,6 +2212,28 @@ static bool t6040_map_regions(struct t6040_usb2_phy *tphy, struct platform_devic return tphy->regs[T6040_USB3_CORE] && tphy->regs[T6040_USB3_CFG]; } +/* + * Whether the PHY is wired to an on-board hub instead of a Type-C connector, + * as on the Mac mini's front ports: the board describes the hub as a child of + * the controller the PHY's USB3 port (graph port 1) is linked to, as it does + * for dwc3-apple. There is no port controller, so no orientation switch and + * no cable event, and the hub's SuperSpeed pair sits on the lanes of a plug + * in normal orientation: the ADT gives every such fixed ATC PHY plug + * orientation 1, as it does the laptops' HDMI converter PHYs, which run + * unflipped. + */ +static bool t6040_usb3_fixed_hub(struct device *dev) +{ + struct device_node *ep __free(device_node) = + of_graph_get_endpoint_by_regs(dev->of_node, 1, -1); + struct device_node *ctrl __free(device_node) = + ep ? of_graph_get_remote_port_parent(ep) : NULL; + struct device_node *hub __free(device_node) = + ctrl ? of_get_available_child_by_name(ctrl, "hub") : NULL; + + return hub; +} + /* * Everything USB3 needs from the device tree. A missing piece leaves the * port at USB2; only a mailbox that has not probed yet defers. @@ -2232,19 +2257,23 @@ static int t6040_usb3_probe(struct t6040_usb2_phy *tphy, struct platform_device phy_set_drvdata(tphy->usb3, tphy); init_completion(&tphy->app_reply); - if (!of_property_present(dev->of_node, "orientation-switch")) + if (of_property_present(dev->of_node, "orientation-switch")) { + /* + * Registered first: tipd waits for the switch the DT names, so the + * port keeps USB2, roles and PD even if a USB3 piece below is missing. + */ + sw = typec_switch_register(dev, &sw_desc); + if (IS_ERR(sw)) + return PTR_ERR(sw); + ret = devm_add_action_or_reset(dev, t6040_usb3_switch_unregister, sw); + if (ret) + return ret; + } else if (t6040_usb3_fixed_hub(dev)) { + /* Nothing ever sets it again: the lanes stay where the hub is. */ + tphy->orientation = TYPEC_ORIENTATION_NORMAL; + } else { return 0; - - /* - * Registered first: tipd waits for the switch the DT names, so the port - * keeps USB2, roles and PD even if a USB3 piece below is missing. - */ - sw = typec_switch_register(dev, &sw_desc); - if (IS_ERR(sw)) - return PTR_ERR(sw); - ret = devm_add_action_or_reset(dev, t6040_usb3_switch_unregister, sw); - if (ret) - return ret; + } for (i = 0; i < T6040_USB3_NR_REGIONS; i++) { if (!tphy->regs[i]) { From c78bc401151e7673a9f82419ebf559ab69f9c2fd Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Fri, 20 Nov 2026 00:49:00 +1100 Subject: [PATCH 2/2] arm64: dts: apple: t6040-j773s: enable the front USB-C ports The two front ports sit behind an on-board USB2/USB3 hub on ATC3, whose controller (ADT usb-drd3) is a fixed host. Enable atcphy3, its mailbox, the dwc3_3 DARTs and dwc3_3, and add: - the hub child on raw USB2 root port 1. It is the J773g's front hub: the ADT lists the same hub firmware (usb3hub-fw-gl3590, id 56) and the same hub port layout (usb-drd3-port-hs/-ss); - the link from the PHY's USB3 port to the controller's SuperSpeed port (raw port 2), by which the PHY finds the fixed hub; - the ATC3 power domains; - the hub's reset and SPI-flash output-enable lines (ADT usb3hub_rst 127, usb3hub_flash_oe 130), held high as the boot loader and macOS leave them, as on the J773g. The J614s, J616s and J616s-tether DTBs are unchanged. Signed-off-by: Ryan Murray --- .../boot/dts/apple/t6040-j773s-usb-front.dtsi | 88 +++++++++++++++++-- 1 file changed, 79 insertions(+), 9 deletions(-) diff --git a/arch/arm64/boot/dts/apple/t6040-j773s-usb-front.dtsi b/arch/arm64/boot/dts/apple/t6040-j773s-usb-front.dtsi index d4c2664675fa8..c9f789b01ef05 100644 --- a/arch/arm64/boot/dts/apple/t6040-j773s-usb-front.dtsi +++ b/arch/arm64/boot/dts/apple/t6040-j773s-usb-front.dtsi @@ -2,11 +2,17 @@ /* * The J773s's two front USB-C ports: an on-board USB2/USB3 hub behind ATC3, * whose controller (ADT usb-drd3) is a fixed host with no PD controller. - * The hub's firmware is on its own flash (ADT spi3 usb3hub-flash). + * The hub's firmware is on its own flash (ADT spi3 usb3hub-flash): the same + * hub as on the M4 Mac mini (J773g), with the same firmware id, on raw USB2 + * root port 1 and SuperSpeed root port 2 (ADT usb-drd3-port-hs/-ss). * - * Disabled until the T6040 PHY driver has a fixed-host mode: it brings USB3 - * up only for a Type-C plug orientation. Enabling this also takes the ATC3 - * power domains. Tunables are this ADT's atc-phy3 and usb-drd3 tables + * The hub child tells dwc3-apple the controller is a host from probe on, and + * the graph link from the PHY's USB3 port to the controller's SuperSpeed port + * is how the PHY finds that fixed hub: it then runs USB3 on the lanes of a + * normal plug orientation, as the ADT gives for atc-phy3, with no orientation + * switch. The hub's reset and SPI-flash output-enable lines (ADT + * usb3hub_rst, usb3hub_flash_oe) are AP GPIOs; the boot loader leaves both + * high, as macOS does. Tunables are this ADT's atc-phy3 and usb-drd3 tables * (macOS 26.6.2); DRD_USB31_GBL_DEFAULT is followed by the GCTL.PWRDNSCALE * entry the other ports use. */ @@ -211,7 +217,18 @@ <0x44 0x00000004 0x00000004>; apple,tunable-usb2-host = <0x8 0x00007003 0x00000003>; - status = "disabled"; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@1 { + reg = <1>; + atcphy3_usb3: endpoint { + remote-endpoint = <&dwc3_3_ss>; + }; + }; + }; }; atcphy3_mbox: mailbox@39b148000 { @@ -226,7 +243,6 @@ "recv-empty", "recv-not-empty"; #mbox-cells = <0>; power-domains = <&ps_atc3_phymxwrap>; - status = "disabled"; }; dwc3_3_dart_0: iommu@39af00000 { @@ -237,7 +253,6 @@ power-domains = <&ps_atc3_usb>; #iommu-cells = <1>; apple,dma-range = <0x100 0x4000 0x0 0xffff0000>; - status = "disabled"; }; dwc3_3_dart_1: iommu@39af80000 { @@ -248,7 +263,6 @@ power-domains = <&ps_atc3_usb>; #iommu-cells = <1>; apple,dma-range = <0x100 0x4000 0x0 0xffff0000>; - status = "disabled"; }; dwc3_3: usb@39a280000 { @@ -260,6 +274,8 @@ interrupt-parent = <&aic>; interrupts = ; dr_mode = "host"; + #address-cells = <1>; + #size-cells = <0>; iommus = <&dwc3_3_dart_0 0>, <&dwc3_3_dart_1 1>; power-domains = <&ps_atc3_usb>; resets = <&atcphy3>; @@ -288,6 +304,60 @@ apple,tunable-gbl-default = <0x64 0x00000002 0x00000000>, <0x10 0xfff80000 0x00680000>; - status = "disabled"; + + hub@1 { + compatible = "usb5ac,800b"; + reg = <1>; + }; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + /* Raw xHCI port 1 is USB2; raw port 2 is SuperSpeed. */ + port@2 { + reg = <2>; + dwc3_3_ss: endpoint { + remote-endpoint = <&atcphy3_usb3>; + }; + }; + }; + }; +}; + +&pinctrl { + usb3hub-flash-oe-hog { + gpio-hog; + gpios = <130 GPIO_ACTIVE_HIGH>; + output-high; + line-name = "usb3hub-flash-oe"; + }; + + usb3hub-reset-hog { + gpio-hog; + gpios = <127 GPIO_ACTIVE_HIGH>; + output-high; + line-name = "usb3hub-reset"; }; }; + +/* The ATC3 domains, which t604x-pmgr.dtsi leaves disabled. */ +&ps_atc3_common { + status = "okay"; +}; + +&ps_atc3_usb_aon { + status = "okay"; +}; + +&ps_atc3_usb { + status = "okay"; +}; + +&ps_atc3_phymxwrap { + status = "okay"; +}; + +&ps_atc3_common_dp { + status = "okay"; +};