From 67f216975687ac7ab0569e1f4f07d5625be7b856 Mon Sep 17 00:00:00 2001 From: Jos Dehaes Date: Tue, 10 Nov 2026 15:14:23 +0100 Subject: [PATCH 01/11] arm64: dts: apple: t6041-j616c: give the external DCPs a text region The loader fills the M4 Max's external DCP firmware memory only from the three-region layout the M4 Pro uses: a text, a data and a heap placeholder (t6040-j616s-extdisp-mem-loader.dtsi). It points the text region at the internal DCP's TEXT, which the processors share, and fills the other two from the ADT. The J616c's HDMI and USB-C dcpext nodes describe only data and heap, so on a J614c the loader refuses both processors and the display gate keeps the external displays off: DCP: T6041: dcpext0 firmware memory refused; placeholder remains disabled DCP: T6041: dcpext1 firmware memory refused; placeholder remains disabled apple-t6041-display: /dcp@3a2e00000: no firmware memory, nothing enabled Add the text placeholder to both, as on the M4 Pro. The display gate only needs every region to be available asc-mem. Signed-off-by: Jos Dehaes Co-Authored-By: Claude Opus 5.5 --- arch/arm64/boot/dts/apple/t6041-j616c-hdmi.dtsi | 17 ++++++++++++++--- arch/arm64/boot/dts/apple/t6041-j616c-usbc.dtsi | 15 +++++++++++++-- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/arch/arm64/boot/dts/apple/t6041-j616c-hdmi.dtsi b/arch/arm64/boot/dts/apple/t6041-j616c-hdmi.dtsi index 7bf6baf4a2f11..b5770a86c9fed 100644 --- a/arch/arm64/boot/dts/apple/t6041-j616c-hdmi.dtsi +++ b/arch/arm64/boot/dts/apple/t6041-j616c-hdmi.dtsi @@ -5,7 +5,7 @@ * * Every node is disabled. No DISPEXT0 power domain is described: the chain * runs as iBoot leaves it powered. The boot loader fills dcpext0's firmware - * memory (the data and heap regions below; the text region is the internal + * memory (the regions below; it points the text region at the internal * DCP's), and the display gate (drivers/soc/apple/display-gate.c) then * enables the chain and adds dispext0's DART to the display subsystem's * iommus. @@ -17,6 +17,17 @@ }; reserved-memory { + /* + * The loader replaces this placeholder with the internal DCP's + * TEXT, which the external processors share, as on the M4 Pro. + */ + dcpext0_text: dcpext0-text { + compatible = "apple,asc-mem"; + reg = <0x0 0x0 0x0 0x4000>; + no-map; + status = "disabled"; + }; + dcpext0_data: dcpext0-data { compatible = "apple,asc-mem"; reg = <0x0 0x0 0x0 0x4000>; @@ -46,8 +57,8 @@ mux-control-names = "dp-xbar"; mux-index = <0>; apple,dptx-phy = <3>; - memory-region = <&dcpext0_data>, <&dcpext0_heap>; - memory-region-names = "data", "heap"; + memory-region = <&dcpext0_text>, <&dcpext0_data>, <&dcpext0_heap>; + memory-region-names = "text", "data", "heap"; }; &atcphy3 { diff --git a/arch/arm64/boot/dts/apple/t6041-j616c-usbc.dtsi b/arch/arm64/boot/dts/apple/t6041-j616c-usbc.dtsi index 35f6bfc990e8d..28acf941dc0db 100644 --- a/arch/arm64/boot/dts/apple/t6041-j616c-usbc.dtsi +++ b/arch/arm64/boot/dts/apple/t6041-j616c-usbc.dtsi @@ -15,6 +15,17 @@ }; reserved-memory { + /* + * The loader replaces this placeholder with the internal DCP's + * TEXT, which the external processors share, as on the M4 Pro. + */ + dcpext1_text: dcpext1-text { + compatible = "apple,asc-mem"; + reg = <0x0 0x0 0x0 0x4000>; + no-map; + status = "disabled"; + }; + dcpext1_data: dcpext1-data { compatible = "apple,asc-mem"; reg = <0x0 0x0 0x0 0x4000>; @@ -41,8 +52,8 @@ /* indexed by route */ apple,typec-dptx-phys = <0 1 2>; apple,typec-mux-indices = <2 2 2>; - memory-region = <&dcpext1_data>, <&dcpext1_heap>; - memory-region-names = "data", "heap"; + memory-region = <&dcpext1_text>, <&dcpext1_data>, <&dcpext1_heap>; + memory-region-names = "text", "data", "heap"; typec-routes { #address-cells = <1>; From 87449597e669b79c1797a973520cc540a9bdf710 Mon Sep 17 00:00:00 2001 From: Jos Dehaes Date: Tue, 10 Nov 2026 15:28:56 +0100 Subject: [PATCH 02/11] arm64: dts: apple: t6041-j614c-j616c: add DisplayPort and HDMI audio The M4 Max laptops have external displays but no audio for them: no SIO alias, no dpaudio controllers, and no DPA power domains, which only t6040-pmgr.dtsi describes. Their ADT has the M4 Pro's audio path (J614c read from the running machine): dcpext0's audio is dp-audio1 on SIO DMA channel 0x66 and dcpext1's is dp-audio2 on 0x68, and the PMGR has UART_P (0x1a0) and DPA_P (0x1a8) under SIO and DPA1 (0x238) and DPA2 (0x240) under DPA_P. Describe them as t6040-j616s-dpaudio.dtsi does: the four domains, the SIO alias the loader uses to reserve the SIO firmware and enable the SIO, the two dpaudio controllers and their links to dcpext0 and dcpext1, the SIO CPU domain's parents, and the SIO DART and mailbox. Signed-off-by: Jos Dehaes Co-Authored-By: Claude Opus 5.5 --- .../boot/dts/apple/t6041-j614c-j616c.dtsi | 133 ++++++++++++++++++ 1 file changed, 133 insertions(+) diff --git a/arch/arm64/boot/dts/apple/t6041-j614c-j616c.dtsi b/arch/arm64/boot/dts/apple/t6041-j614c-j616c.dtsi index fec641445c5d5..442fcbe3ddf3f 100644 --- a/arch/arm64/boot/dts/apple/t6041-j614c-j616c.dtsi +++ b/arch/arm64/boot/dts/apple/t6041-j614c-j616c.dtsi @@ -2543,3 +2543,136 @@ &ps_qspi { status = "okay"; }; + +/* + * DisplayPort/HDMI audio, as on the M4 Pro boards (t6040-j616s-dpaudio.dtsi). + * The J614c's ADT has the J616s's: dcpext0's audio is dp-audio1 (SIO DMA + * channel 0x66) and dcpext1's is dp-audio2 (0x68), and the PMGR has UART_P + * (0x1a0) and DPA_P (0x1a8) under SIO, and DPA1 (0x238) and DPA2 (0x240) + * under DPA_P. The SIO stays disabled here: the loader enables it once it has + * reserved the firmware iBoot loaded (it finds it by the alias). + */ +&pmgr { + ps_uart_p: power-controller@1a0 { + compatible = "apple,t6041-pmgr-pwrstate", "apple,t8103-pmgr-pwrstate"; + reg = <0x1a0 4>; + #power-domain-cells = <0>; + #reset-cells = <0>; + label = "uart_p"; + power-domains = <&ps_sio>; + }; + + ps_dpa_p: power-controller@1a8 { + compatible = "apple,t6041-pmgr-pwrstate", "apple,t8103-pmgr-pwrstate"; + reg = <0x1a8 4>; + #power-domain-cells = <0>; + #reset-cells = <0>; + label = "dpa_p"; + power-domains = <&ps_sio>; + apple,always-on; + }; + + ps_dpa1: power-controller@238 { + compatible = "apple,t6041-pmgr-pwrstate", "apple,t8103-pmgr-pwrstate"; + reg = <0x238 4>; + #power-domain-cells = <0>; + #reset-cells = <0>; + label = "dpa1"; + power-domains = <&ps_dpa_p>; + }; + + ps_dpa2: power-controller@240 { + compatible = "apple,t6041-pmgr-pwrstate", "apple,t8103-pmgr-pwrstate"; + reg = <0x240 4>; + #power-domain-cells = <0>; + #reset-cells = <0>; + label = "dpa2"; + power-domains = <&ps_dpa_p>; + }; +}; + +/ { + aliases { + sio = &sio; + }; + + dpaudio1: audio-controller-1 { + compatible = "apple,t6041-dpaudio", "apple,dpaudio"; + dmas = <&sio 0x66>; + dma-names = "tx"; + power-domains = <&ps_dpa1>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + dpaudio1_dcpext: endpoint { + remote-endpoint = <&dcpext0_audio>; + }; + }; + }; + }; + + dpaudio2: audio-controller-2 { + compatible = "apple,t6041-dpaudio", "apple,dpaudio"; + dmas = <&sio 0x68>; + dma-names = "tx"; + power-domains = <&ps_dpa2>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + dpaudio2_dcpext: endpoint { + remote-endpoint = <&dcpext1_audio>; + }; + }; + }; + }; +}; + +&dcpext0 { + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + dcpext0_audio: endpoint { + remote-endpoint = <&dpaudio1_dcpext>; + }; + }; + }; +}; + +&dcpext1 { + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + dcpext1_audio: endpoint { + remote-endpoint = <&dpaudio2_dcpext>; + }; + }; + }; +}; + +/* The SIO firmware drives the SPI, UART and DP audio shims: keep their parents on. */ +&ps_sio_cpu { + power-domains = <&ps_sio>, <&ps_spi_p>, <&ps_uart_p>, <&ps_dpa_p>; + status = "okay"; +}; + +&sio_dart { + status = "okay"; +}; + +&sio_mbox { + status = "okay"; +}; From 19af11724bf97036a90cd20ee7aa265b68a60ba7 Mon Sep 17 00:00:00 2001 From: Jos Dehaes Date: Tue, 10 Nov 2026 15:48:48 +0100 Subject: [PATCH 03/11] arm64: dts: apple: t6041-j614c-j616c: enable USB 3 on the USB-C ports The M4 Max laptops run their three USB-C ports at USB 2 only: the PHYs carry a hardcoded USB 2 tunable, the controllers are limited to high speed with only their USB 2 PHY, and nothing connects the connectors' SuperSpeed lanes. The left-front port's DisplayPort description adds a hardcoded set of ATC tunables for atcphy1. Their ADT has the M4 Pro's per-port ATC and controller tunables (atc-phy0..2, usb-drd0..2, J614c read from the running machine), which the loader copies into the PHY and controller nodes, as it does on the J614s. Describe the ports as the M4 Pro does: the controllers use both PHYs, the PHYs link to the connectors' SuperSpeed lanes and to the controllers, and the PHY mailboxes are on. Drop the hardcoded tunables, which the loader would otherwise duplicate. The HDMI PHY keeps its own. Signed-off-by: Jos Dehaes Co-Authored-By: Claude Opus 5.5 --- .../boot/dts/apple/t6041-j614c-j616c.dtsi | 146 +++++++++++--- .../boot/dts/apple/t6041-j616c-usbc.dtsi | 189 +----------------- 2 files changed, 116 insertions(+), 219 deletions(-) diff --git a/arch/arm64/boot/dts/apple/t6041-j614c-j616c.dtsi b/arch/arm64/boot/dts/apple/t6041-j614c-j616c.dtsi index ff5f0340e267a..3c7123151e129 100644 --- a/arch/arm64/boot/dts/apple/t6041-j614c-j616c.dtsi +++ b/arch/arm64/boot/dts/apple/t6041-j614c-j616c.dtsi @@ -1763,6 +1763,13 @@ remote-endpoint = <&dwc3_0_hs>; }; }; + + port@1 { + reg = <1>; + typec0_connector_ss: endpoint { + remote-endpoint = <&atcphy0_ss>; + }; + }; }; }; }; @@ -1803,6 +1810,13 @@ remote-endpoint = <&dwc3_1_hs>; }; }; + + port@1 { + reg = <1>; + typec1_connector_ss: endpoint { + remote-endpoint = <&atcphy1_ss>; + }; + }; }; }; }; @@ -1836,14 +1850,46 @@ remote-endpoint = <&dwc3_2_hs>; }; }; + + port@1 { + reg = <1>; + typec2_connector_ss: endpoint { + remote-endpoint = <&atcphy2_ss>; + }; + }; }; }; }; }; -/* The left-back port, USB 2 as the other two. */ +/* + * USB 3 on the three USB-C ports. The loader appends the PHY and controller + * tunables from the ADT, as on the M4 Pro, and disables a port it can't tune. + */ &atcphy0 { - apple,tunable-usb2-host = <0x8 0x7003 0x3>; + status = "okay"; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + atcphy0_ss: endpoint { + remote-endpoint = <&typec0_connector_ss>; + }; + }; + + port@1 { + reg = <1>; + atcphy0_usb3: endpoint { + remote-endpoint = <&dwc3_0_ss>; + }; + }; + }; +}; + +&atcphy0_mbox { status = "okay"; }; @@ -1856,15 +1902,6 @@ }; &dwc3_0 { - maximum-speed = "high-speed"; - phys = <&atcphy0 PHY_TYPE_USB2>; - phy-names = "usb2-phy"; - apple,tunable-gbl-host = <0x4 0x0001ef00 0x00002f00>, <0x1c 0x00000100 0x0>, - <0x2c 0x000a07ff 0x000800c8>, <0x100 0x02000100 0x02000100>, - <0x504 0x00001000 0x0>, <0x528 0xff0000ff 0x06000006>, - <0x52c 0xff0000ff 0x08000008>, <0x538 0x00000800 0x00000800>, - <0x580 0xffffffff 0x6f000006>; - apple,tunable-cfg-host = <0x20 0xff 0x1b>; status = "okay"; ports { @@ -1877,11 +1914,40 @@ remote-endpoint = <&typec0_connector_hs>; }; }; + + port@1 { + reg = <1>; + dwc3_0_ss: endpoint { + remote-endpoint = <&atcphy0_usb3>; + }; + }; }; }; &atcphy1 { - apple,tunable-usb2-host = <0x8 0x7003 0x3>; + status = "okay"; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + atcphy1_ss: endpoint { + remote-endpoint = <&typec1_connector_ss>; + }; + }; + + port@1 { + reg = <1>; + atcphy1_usb3: endpoint { + remote-endpoint = <&dwc3_1_ss>; + }; + }; + }; +}; + +&atcphy1_mbox { status = "okay"; }; @@ -1894,15 +1960,6 @@ }; &dwc3_1 { - maximum-speed = "high-speed"; - phys = <&atcphy1 PHY_TYPE_USB2>; - phy-names = "usb2-phy"; - apple,tunable-gbl-host = <0x4 0x0001ef00 0x00002f00>, <0x1c 0x00000100 0x0>, - <0x2c 0x000a07ff 0x000800c8>, <0x100 0x02000100 0x02000100>, - <0x504 0x00001000 0x0>, <0x528 0xff0000ff 0x06000006>, - <0x52c 0xff0000ff 0x08000008>, <0x538 0x00000800 0x00000800>, - <0x580 0xffffffff 0x6f000006>; - apple,tunable-cfg-host = <0x20 0xff 0x1b>; status = "okay"; ports { @@ -1915,11 +1972,40 @@ remote-endpoint = <&typec1_connector_hs>; }; }; + + port@1 { + reg = <1>; + dwc3_1_ss: endpoint { + remote-endpoint = <&atcphy1_usb3>; + }; + }; }; }; &atcphy2 { - apple,tunable-usb2-host = <0x8 0x7003 0x3>; + status = "okay"; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + atcphy2_ss: endpoint { + remote-endpoint = <&typec2_connector_ss>; + }; + }; + + port@1 { + reg = <1>; + atcphy2_usb3: endpoint { + remote-endpoint = <&dwc3_2_ss>; + }; + }; + }; +}; + +&atcphy2_mbox { status = "okay"; }; @@ -1932,15 +2018,6 @@ }; &dwc3_2 { - maximum-speed = "high-speed"; - phys = <&atcphy2 PHY_TYPE_USB2>; - phy-names = "usb2-phy"; - apple,tunable-gbl-host = <0x4 0x0001ef00 0x00002f00>, <0x1c 0x00000100 0x0>, - <0x2c 0x000a07ff 0x000800c8>, <0x100 0x02000100 0x02000100>, - <0x504 0x00001000 0x0>, <0x528 0xff0000ff 0x06000006>, - <0x52c 0xff0000ff 0x08000008>, <0x538 0x00000800 0x00000800>, - <0x580 0xffffffff 0x6f000006>; - apple,tunable-cfg-host = <0x20 0xff 0x1b>; status = "okay"; ports { @@ -1953,6 +2030,13 @@ remote-endpoint = <&typec2_connector_hs>; }; }; + + port@1 { + reg = <1>; + dwc3_2_ss: endpoint { + remote-endpoint = <&atcphy2_usb3>; + }; + }; }; }; diff --git a/arch/arm64/boot/dts/apple/t6041-j616c-usbc.dtsi b/arch/arm64/boot/dts/apple/t6041-j616c-usbc.dtsi index 35f6bfc990e8d..7ba659dc5d6a5 100644 --- a/arch/arm64/boot/dts/apple/t6041-j616c-usbc.dtsi +++ b/arch/arm64/boot/dts/apple/t6041-j616c-usbc.dtsi @@ -6,7 +6,7 @@ * dcpext1, its DARTs, mailbox, crossbar and Type-C route are disabled, as * for HDMI: the display gate enables them once the boot loader has filled * dcpext1's firmware memory. A disabled route is no mode switch, so typec1 - * then keeps USB2 and PD as before. + * then keeps USB and PD as before. */ / { @@ -64,13 +64,6 @@ &typec1 { ports { - port@1 { - reg = <1>; - typec1_connector_ss: endpoint { - remote-endpoint = <&atcphy1_ss>; - }; - }; - port@3 { reg = <3>; typec1_dcpext1: endpoint { @@ -83,184 +76,4 @@ &atcphy1 { mode-switch; orientation-switch; - - apple,tunable-axi2af = - <0x0 0x800000ff 0x8000001c>, - <0x4 0x80ff00ff 0x801b0003>, - <0x8 0x80ff00ff 0x801b0003>, - <0xc 0x80ff00ff 0x801b0005>, - <0x10 0x80ff00ff 0x801b0003>, - <0x14 0x80ff00ff 0x801b0003>, - <0x18 0x80ff00ff 0x801b0003>, - <0x1c 0x80ff00ff 0x801b0003>, - <0x20 0x800000ff 0x80000015>, - <0x24 0x800000ff 0x80000038>, - <0x28 0x80ff00ff 0x80380006>, - <0x2c 0x80ff00ff 0x80380006>, - <0x30 0x80ff00ff 0x80380006>, - <0x34 0x80ff00ff 0x80380006>, - <0x38 0x80ff00ff 0x80380006>, - <0x3c 0x80ff00ff 0x80380006>, - <0x40 0x800000ff 0x80000015>, - <0x44 0x800000ff 0x80000015>, - <0x48 0x800000ff 0x80000015>, - <0x100 0x000000ff 0x000000ff>, - <0x108 0xffff0006 0x00100000>, - <0x304 0x3f3f0000 0x04040000>, - <0x308 0x000fffff 0x00001681>, - <0x30c 0x000fffff 0x00001680>, - <0x310 0x70000fff 0x000001e0>, - <0x314 0xf0000fff 0x800001e0>, - <0x318 0x70000fff 0x000001e0>, - <0x31c 0xf0000fff 0x800001e0>, - <0x320 0x70000fff 0x000005a0>, - <0x324 0xf0000fff 0x800005a0>, - <0x328 0x70000fff 0x000005a0>, - <0x32c 0xf0000fff 0x800005a0>, - <0x330 0x70000fff 0x000005a0>, - <0x334 0xf0000fff 0x800005a0>, - <0x338 0x70000fff 0x000005a0>, - <0x33c 0x70000fff 0x000005a0>, - <0x340 0x70000fff 0x000005a0>, - <0x344 0x70000fff 0x000005a0>, - <0x348 0x70000fff 0x000005a0>, - <0x34c 0x70000fff 0x000005a0>, - <0x350 0x70000fff 0x000005a0>, - <0x358 0xffffffff 0x0000ffff>, - <0x35c 0xffffffff 0x0000ffff>, - <0x408 0xffff0020 0x00180020>, - <0x40c 0x000fffff 0x00001681>, - <0x410 0x000fffff 0x00001680>, - <0x414 0x70000fff 0x000001e0>, - <0x418 0x70000fff 0x000001e0>, - <0x41c 0x70000fff 0x000001e0>, - <0x420 0x70000fff 0x000001e0>, - <0x424 0x70000fff 0x000005a0>, - <0x428 0x70000fff 0x000005a0>, - <0x42c 0x70000fff 0x000005a0>, - <0x430 0x70000fff 0x000005a0>, - <0x434 0x70000fff 0x000005a0>, - <0x438 0x70000fff 0x000005a0>, - <0x43c 0x70000fff 0x000005a0>, - <0x440 0x70000fff 0x000005a0>, - <0x444 0x70000fff 0x000005a0>, - <0x448 0x70000fff 0x000005a0>, - <0x44c 0x70000fff 0x000005a0>, - <0x450 0x70000fff 0x000005a0>, - <0x454 0x70000fff 0x000005a0>, - <0x948 0x07ff07ff 0x00280000>, - <0xa48 0x07ff07ff 0x00400040>, - <0xb48 0x07ff07ff 0x00b8010e>, - <0xc48 0x07ff07ff 0x00400020>, - <0xd48 0x07ff07ff 0x008a008a>, - <0x1000 0xffffffff 0x7fffffff>, - <0x4008 0x00000001 0x00000001>, - <0x400c 0x00000001 0x00000001>, - <0x4014 0x00000001 0x00000001>, - <0x4018 0x00000001 0x00000000>, - <0x401c 0x00000001 0x00000001>; - apple,tunable-fabric = - <0x4 0x003f003f 0x00200020>, - <0xc 0x000000f1 0x000000a1>, - <0x10 0x0000801f 0x00000004>, - <0x18 0x003f003f 0x00200020>, - <0x20 0x000000f1 0x000000a1>, - <0x24 0x0000801f 0x00000004>, - <0x2c 0x00ff00ff 0x00960096>, - <0x34 0x000000f1 0x00000071>, - <0x38 0x0000801f 0x00000004>, - <0x40 0x0000003f 0x00000020>, - <0x48 0x0000801f 0x00000004>, - <0x50 0x007f007f 0x00450045>, - <0x58 0x0000801f 0x00000004>, - <0x60 0x0000003f 0x00000020>, - <0x68 0x0000801f 0x00000004>, - <0x70 0x00000001 0x00000001>, - <0x74 0x0000801f 0x00000004>, - <0x7c 0x007f007f 0x00400040>, - <0x80 0x000000f1 0x00000011>, - <0x84 0x00000001 0x00000001>, - <0x88 0x00000001 0x00000001>, - <0x8c 0x0000801f 0x00000004>, - <0x94 0x001f001f 0x00100010>, - <0x98 0x000000f1 0x00000011>, - <0x9c 0x0000801f 0x00000004>, - <0xa4 0x000000ff 0x000000e0>, - <0xa8 0x0000801f 0x00000004>, - <0xb0 0x0000003f 0x00000020>, - <0xb8 0x0000801f 0x00000004>, - <0xc0 0x0000003f 0x00000020>, - <0xc8 0x0000801f 0x00000004>, - <0xd0 0x001f001f 0x00100010>, - <0xd8 0x00000001 0x00000001>, - <0xdc 0x00000001 0x00000001>, - <0xe0 0x0000801f 0x00000004>, - <0xe8 0x0000000f 0x00000008>, - <0xec 0x0000801f 0x00000004>, - <0xf4 0xffffffff 0x01010101>, - <0xf8 0x0000801f 0x00000004>, - <0x100 0x00000001 0x00000001>, - <0x104 0x00000001 0x00000001>, - <0x108 0x0000801f 0x00000004>, - <0x110 0x0000801f 0x00000004>, - <0x118 0x0000801f 0x00000004>, - <0x120 0x00000001 0x00000001>, - <0x124 0x00000001 0x00000001>, - <0x128 0x0000801f 0x00000004>, - <0x130 0xffffffff 0x01010101>, - <0x134 0x0000801f 0x00000004>, - <0x13c 0x00000001 0x00000001>, - <0x140 0x00000001 0x00000001>, - <0x144 0x0000801f 0x00000004>, - <0x14c 0x00000001 0x00000001>, - <0x150 0x00000001 0x00000001>, - <0x154 0x0000801f 0x00000004>, - <0x15c 0x0000801f 0x00000004>, - <0x164 0xffffffff 0x01010101>, - <0x168 0x0000ffff 0x00000101>, - <0x16c 0x0000801f 0x00000004>, - <0x174 0x00000001 0x00000001>, - <0x178 0x00000001 0x00000001>, - <0x17c 0x0000801f 0x00000004>, - <0x184 0x00000001 0x00000001>, - <0x188 0x00000001 0x00000001>, - <0x18c 0x0000801f 0x00000004>; - apple,tunable-common-cfg = - <0x8 0x00000001 0x00000001>; - apple,tunable-axi2af-lioa = - <0x28 0x0000fe2f 0x00000000>, - <0x2c 0x00000007 0x00000000>, - <0x30 0x0000007f 0x00000000>, - <0x34 0x000000ff 0x00000000>, - <0x58 0x0000010b 0x00000000>; - apple,tunable-lane0 = - <0xd094 0x00080000 0x00080000>, - <0xd098 0x00080000 0x00080000>, - <0xd0a4 0x00800000 0x00800000>, - <0xd0a8 0x00200000 0x00200000>; - apple,tunable-lane1 = - <0x1d094 0x00080000 0x00080000>, - <0x1d098 0x00080000 0x00080000>, - <0x1d0a4 0x00800000 0x00800000>, - <0x1d0a8 0x00200000 0x00200000>; - apple,tunable-aus40cmn-shm = - <0xa04 0x0000007c 0x0000004c>; - apple,tunable-auspll = - <0x3224 0x00000c00 0x00000800>, - <0x3230 0x0000001f 0x0000000f>, - <0x3240 0x07d8007f 0x04000039>, - <0x32b0 0x0b800000 0x01800000>, - <0x32e8 0x00060001 0x00040001>, - <0x3338 0x0f800000 0x07800000>; - apple,tunable-cio4pll = - <0x3a30 0x0000001f 0x0000000f>, - <0x3a4c 0x0000fe7f 0x00004e1d>, - <0x3ab0 0x00700000 0x00300000>, - <0x3ae8 0x00060000 0x00020000>; - - port { - atcphy1_ss: endpoint { - remote-endpoint = <&typec1_connector_ss>; - }; - }; }; From 96958485f1e452233c5a5b31f17dbe318e32d529 Mon Sep 17 00:00:00 2001 From: Jos Dehaes Date: Tue, 10 Nov 2026 16:10:22 +0100 Subject: [PATCH 04/11] soc: apple: display-gate: leave the M4 Max ATC1 mailbox to the PHY The M4 Max USB-C display chain lists atcphy1's mailbox among the nodes it enables, and gives up on dcpext1 when any of them is already on. The mailbox is the PHY coprocessor's, which USB3 needs whatever the display does, so a device tree that runs the port at USB3 enables it and the gate then leaves the USB-C display off: apple-t6041-display: /mailbox@38b148000: already enabled, nothing changed Drop it from the chain, as the M4 Pro's leaves its ATC mailboxes out, and mark it enabled in the test fixture as the device tree does. Signed-off-by: Jos Dehaes Co-Authored-By: Claude Opus 5.5 --- drivers/soc/apple/display-gate.c | 6 ++++-- drivers/soc/apple/t6041-gate-test.dtso | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/soc/apple/display-gate.c b/drivers/soc/apple/display-gate.c index 73c56cc29ca21..430695747ea94 100644 --- a/drivers/soc/apple/display-gate.c +++ b/drivers/soc/apple/display-gate.c @@ -2993,8 +2993,10 @@ static const char *const t6041_max_hdmi_nodes[] = { }; static const char *const t6041_max_usbc_nodes[] = { - /* ATC1 mailbox and crossbar, DARTs, mailbox, route, dcpext1 */ - "/mailbox@38b148000", + /* + * ATC1 crossbar, DARTs, mailbox, route, dcpext1. The ATC1 mailbox is + * the PHY's, on for USB3 whatever the display does, as on the M4 Pro. + */ "/mux@38b24c000", "/iommu@602340000", "/iommu@602300000", diff --git a/drivers/soc/apple/t6041-gate-test.dtso b/drivers/soc/apple/t6041-gate-test.dtso index d12929a73c0c9..4b1ecc41439a5 100644 --- a/drivers/soc/apple/t6041-gate-test.dtso +++ b/drivers/soc/apple/t6041-gate-test.dtso @@ -116,7 +116,7 @@ }; mailbox@38b148000 { - status = "disabled"; + status = "okay"; }; mux@38b24c000 { From 6be59abe2c7bf1e24b2545ade8f540b51e86b2ce Mon Sep 17 00:00:00 2001 From: Roberto Dantas <7robertodantas@gmail.com> Date: Wed, 11 Nov 2026 09:20:32 -0300 Subject: [PATCH 05/11] arm64: dts: apple: t6041-j575c: describe the fourth back Type-C port The J575c has four back Thunderbolt ports, but the tree only describes ATC0-2. The fourth (ADT port-location back-left) is hpm3 on nub-spmi-a0 at 0x6 with interrupts 89/95/97, atc-phy3, usb-drd3 and dart-usb3. On the J614c/J616c ATC3 is the HDMI converter's fixed DP PHY, so there is no shared USB description of it; here it is a USB-C port like the other three. Add its PHY, PHY mailbox, DARTs and controller as t604x.dtsi has them for ATC2, at the ADT's ATC3 addresses (ATC2's plus 0x8000000) and interrupts (the controller and DART ones ATC2's plus 32, the PHY coprocessor's plus 10), the controller's usb-drd3 tables (the same as usb-drd0-2), and hpm3 with its connector. t604x-pmgr.dtsi leaves the ATC3 domains disabled for the J616c's display gate, so they are enabled here. Tested on a J575c: the port's PD controller, PHY and controller come up, and a USB hub and a USB stick behind it enumerate. Before, the port had power but no data. Assisted-by: LLM Signed-off-by: Roberto Dantas <7robertodantas@gmail.com> Co-Authored-By: Claude Opus 5.5 --- .../boot/dts/apple/t6041-j575c-atc3.dtsi | 161 ++++++++++++++++++ arch/arm64/boot/dts/apple/t6041-j575c.dts | 11 +- 2 files changed, 168 insertions(+), 4 deletions(-) create mode 100644 arch/arm64/boot/dts/apple/t6041-j575c-atc3.dtsi diff --git a/arch/arm64/boot/dts/apple/t6041-j575c-atc3.dtsi b/arch/arm64/boot/dts/apple/t6041-j575c-atc3.dtsi new file mode 100644 index 0000000000000..7f66ec53ff2e7 --- /dev/null +++ b/arch/arm64/boot/dts/apple/t6041-j575c-atc3.dtsi @@ -0,0 +1,161 @@ +// SPDX-License-Identifier: GPL-2.0+ OR MIT +/* + * The J575c's fourth back Type-C port (ADT port-location back-left): hpm3, + * atc-phy3, usb-drd3 and dart-usb3. On the J614c/J616c ATC3 is the HDMI + * converter's fixed DP PHY (t604x-extdisp.dtsi); here it is a USB-C port + * like ATC0-2, so it gets the same nodes as atcphy2/dwc3_2 in t604x.dtsi, at + * the ADT's ATC3 addresses (ATC2's plus 0x8000000) and interrupts. + */ + +/ { + atcphy3: phy@39aa90000 { + compatible = "apple,t6040-atcphy"; + reg = <0x3 0x9aa90000 0x0 0x4000>, + <0x3 0x9a800000 0x0 0x4000>, + <0x3 0x9aa84000 0x0 0x4000>, + <0x3 0x9b000000 0x0 0x30000>, + <0x3 0x9b200000 0x0 0x4000>, + <0x3 0x9b140000 0x0 0x4000>, + <0x3 0x9b0c0000 0x0 0x10000>, + <0x3 0x98000000 0x0 0x8000>, + <0x3 0x98020000 0x0 0x4000>, + <0x3 0x9b244000 0x0 0x4000>, + <0x3 0x9b250000 0x0 0x4000>; + reg-names = "bank0", "bank1", "pipehandler", "core", "cfg", "cpu", + "cpu-data", "axi2af", "axi2af-lioa", "fabric", "common-cfg"; + #phy-cells = <1>; + #reset-cells = <0>; + power-domains = <&ps_atc3_common_dp>; + mboxes = <&atcphy3_mbox>; + mbox-names = "phy-cpu"; + nonposted-mmio; + orientation-switch; + apple,tunable-usb2-host = <0x8 0x7003 0x3>; + }; + + atcphy3_mbox: mailbox@39b148000 { + compatible = "apple,t6041-asc-mailbox", "apple,asc-mailbox-v4"; + reg = <0x3 0x9b148000 0x0 0x4000>; + interrupt-parent = <&aic>; + interrupts = , + , + , + ; + interrupt-names = "send-empty", "send-not-empty", + "recv-empty", "recv-not-empty"; + #mbox-cells = <0>; + power-domains = <&ps_atc3_phymxwrap>; + }; + + dwc3_3_dart_0: iommu@39af00000 { + compatible = "apple,t6041-dart", "apple,t8110-dart"; + reg = <0x3 0x9af00000 0x0 0xc000>; + interrupt-parent = <&aic>; + interrupts = ; + power-domains = <&ps_atc3_usb>; + #iommu-cells = <1>; + }; + + dwc3_3_dart_1: iommu@39af80000 { + compatible = "apple,t6041-dart", "apple,t8110-dart"; + reg = <0x3 0x9af80000 0x0 0xc000>; + interrupt-parent = <&aic>; + interrupts = ; + power-domains = <&ps_atc3_usb>; + #iommu-cells = <1>; + }; + + dwc3_3: usb@39a280000 { + compatible = "apple,t6040-dwc3", "apple,t8103-dwc3"; + reg = <0x3 0x9a280000 0x0 0xcd00>, + <0x3 0x9a28cd00 0x0 0x3200>, + <0x3 0x9a200000 0x0 0x4000>; + reg-names = "dwc3-core", "dwc3-apple", "drd-cfg"; + interrupt-parent = <&aic>; + interrupts = ; + /* A role switch, as on ATC0-2 (see dwc3_2 in t604x.dtsi). */ + dr_mode = "otg"; + usb-role-switch; + role-switch-default-mode = "host"; + iommus = <&dwc3_3_dart_0 0>, <&dwc3_3_dart_1 1>; + power-domains = <&ps_atc3_usb>; + resets = <&atcphy3>; + phys = <&atcphy3 PHY_TYPE_USB2>; + phy-names = "usb2-phy"; + /* ADT /arm-io/usb-drd3, the same tables as usb-drd0-2 */ + apple,tunable-gbl-host = <0x4 0x0001ef00 0x00002f00>, <0x1c 0x00000100 0x0>, + <0x2c 0x000a07ff 0x000800c8>, <0x100 0x02000100 0x02000100>, + <0x504 0x00001000 0x0>, <0x528 0xff0000ff 0x06000006>, + <0x52c 0xff0000ff 0x08000008>, <0x538 0x00000800 0x00000800>, + <0x580 0xffffffff 0x6f000006>; + apple,tunable-cfg-host = <0x20 0xff 0x1b>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + dwc3_3_hs: endpoint { + remote-endpoint = <&typec3_connector_hs>; + }; + }; + }; + }; +}; + +/* ADT /arm-io/nub-spmi-a0/hpm3: reg 0x6, interrupts 89/95/97 */ +&nub_spmi_a0 { + hpm3: usb-pd@6 { + compatible = "apple,sn201202x"; + reg = <0x6 SPMI_USID>; + interrupts = <89 IRQ_TYPE_EDGE_RISING>, + <91 IRQ_TYPE_EDGE_RISING>, + <95 IRQ_TYPE_EDGE_RISING>, + <97 IRQ_TYPE_EDGE_RISING>; + interrupt-names = "irq", "select", "sleep", "wake"; + + typec3: connector { + compatible = "usb-c-connector"; + label = "USB-C Back 4"; + power-role = "dual"; + data-role = "dual"; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + typec3_connector_hs: endpoint { + remote-endpoint = <&dwc3_3_hs>; + }; + }; + }; + }; + }; +}; + +/* + * t604x-pmgr.dtsi leaves the ATC3 domains disabled: on the J614c/J616c the + * display gate enables them for the HDMI chain. Here they power a USB port. + */ +&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"; +}; diff --git a/arch/arm64/boot/dts/apple/t6041-j575c.dts b/arch/arm64/boot/dts/apple/t6041-j575c.dts index de0d491d90ca1..f5be5af9cab7d 100644 --- a/arch/arm64/boot/dts/apple/t6041-j575c.dts +++ b/arch/arm64/boot/dts/apple/t6041-j575c.dts @@ -456,9 +456,9 @@ }; /* - * guess: three of the four back Thunderbolt ports, with the J773s's PD - * controllers (nub-spmi-a0 0xc, 0xa and 0x8 for ATC0-2), at USB2 high speed - * as on the J616c. The fourth port (ATC3) is not described. + * Three of the four back Thunderbolt ports, with the J773s's PD controllers + * (nub-spmi-a0 0xc, 0xa and 0x8 for ATC0-2), at USB2 high speed as on the + * J616c. t6041-j575c-atc3.dtsi adds the fourth (hpm3 at 0x6, ATC3). */ &nub_spmi_a0 { status = "okay"; @@ -1049,7 +1049,10 @@ memory-region = <&aop_mmio_pmgr>; }; + +#include "t6041-j575c-atc3.dtsi" + /* * Not described: HDMI and the external display chains (unknown PHY routing - * on this board), the fourth back port and the SEP (no Touch ID sensor). + * on this board) and the SEP (no Touch ID sensor). */ From 41d3baa766cd4ece9e8b6a195632e565f02a28dd Mon Sep 17 00:00:00 2001 From: Roberto Dantas <7robertodantas@gmail.com> Date: Wed, 11 Nov 2026 09:20:57 -0300 Subject: [PATCH 06/11] arm64: dts: apple: t6041-j575c: enable USB3 on the back Type-C ports The back Type-C ports run at USB2 only. Describe USB3 on all four as t6040-j616s-usb3.dtsi does on the J616s: each PHY's tunables, the pipehandler table, the PHY coprocessor mailbox, the SuperSpeed endpoints between connector, PHY and controller, and the controller's USB3 tables with both PHYs. The values come from this machine's ADT (macOS 27.0.1): atc-phyN for the PHY tables and usb-drdN for the controller and pipehandler ones, converted as aura's kboot_atc.c does. The controller and pipehandler tables match the J616s's on all four ports; the PHYs differ in their per-port calibration (axi2af, aus40cmn-shm, and auspll on ATC2). Tested on a J575c (with the fourth port from the previous commit): - a USB 3.2 Gen 2 SSD at 10 Gb/s (uas) on ATC2; - a USB 3.2 Gen 1 stick behind a hub at 5 Gb/s (uas, 128 MB/s read) on ATC1 and ATC3; - the debug USB link on ATC0 keeps working. Not every connection trains at SuperSpeed yet: some devices only do in one plug orientation, and a device attached at boot sometimes stays at USB2 until it is plugged in again. Both fall back to USB2, as before. The board has Type-C retimers (ADT i2c6 uatcrt0..3), which have no driver yet, as on the J614/J616. Assisted-by: LLM Signed-off-by: Roberto Dantas <7robertodantas@gmail.com> Co-Authored-By: Claude Opus 5.5 --- .../boot/dts/apple/t6041-j575c-usb3.dtsi | 935 ++++++++++++++++++ arch/arm64/boot/dts/apple/t6041-j575c.dts | 6 +- 2 files changed, 939 insertions(+), 2 deletions(-) create mode 100644 arch/arm64/boot/dts/apple/t6041-j575c-usb3.dtsi diff --git a/arch/arm64/boot/dts/apple/t6041-j575c-usb3.dtsi b/arch/arm64/boot/dts/apple/t6041-j575c-usb3.dtsi new file mode 100644 index 0000000000000..9ccf9f996bed1 --- /dev/null +++ b/arch/arm64/boot/dts/apple/t6041-j575c-usb3.dtsi @@ -0,0 +1,935 @@ +// SPDX-License-Identifier: GPL-2.0+ OR MIT +/* + * USB3 on the J575c's four back Type-C ports (typec0-3), as on the J616s + * (t6040-j616s-usb3.dtsi): the atc-phyN tables AppleT6040TypeCPhy applies at + * every USB3 power-on, from this machine's ADT /arm-io/atc-phyN, relative to + * the PHY region each one targets, and the /arm-io/usb-drdN controller and + * pipehandler tables (the same on the four ports, and the J616s's). Entries + * are : new = (old & ~mask) | value. The PHYs differ in + * their per-port calibration (axi2af, aus40cmn-shm, and auspll on ATC2). + * Generated from the redacted ADT (macOS 27.0.1). + */ + +&atcphy0 { + apple,tunable-axi2af = + <0x0 0x800000ff 0x8000001d>, + <0x4 0x80ff00ff 0x801d0003>, + <0x8 0x80ff00ff 0x801d0003>, + <0xc 0x80ff00ff 0x801d0005>, + <0x10 0x80ff00ff 0x801d0003>, + <0x14 0x80ff00ff 0x801d0003>, + <0x18 0x80ff00ff 0x801d0003>, + <0x1c 0x80ff00ff 0x801d0003>, + <0x20 0x800000ff 0x80000016>, + <0x24 0x800000ff 0x8000003a>, + <0x28 0x80ff00ff 0x803a0006>, + <0x2c 0x80ff00ff 0x803a0006>, + <0x30 0x80ff00ff 0x803a0006>, + <0x34 0x80ff00ff 0x803a0006>, + <0x38 0x80ff00ff 0x803a0006>, + <0x3c 0x80ff00ff 0x803a0006>, + <0x40 0x800000ff 0x80000016>, + <0x44 0x800000ff 0x80000016>, + <0x48 0x800000ff 0x80000016>, + <0x100 0x000000ff 0x000000ff>, + <0x108 0xffff0006 0x00100000>, + <0x304 0x3f3f0000 0x04040000>, + <0x308 0x000fffff 0x00001681>, + <0x30c 0x000fffff 0x00001680>, + <0x310 0x70000fff 0x000001e0>, + <0x314 0xf0000fff 0x800001e0>, + <0x318 0x70000fff 0x000001e0>, + <0x31c 0xf0000fff 0x800001e0>, + <0x320 0x70000fff 0x000005a0>, + <0x324 0xf0000fff 0x800005a0>, + <0x328 0x70000fff 0x000005a0>, + <0x32c 0xf0000fff 0x800005a0>, + <0x330 0x70000fff 0x000005a0>, + <0x334 0xf0000fff 0x800005a0>, + <0x338 0x70000fff 0x000005a0>, + <0x33c 0x70000fff 0x000005a0>, + <0x340 0x70000fff 0x000005a0>, + <0x344 0x70000fff 0x000005a0>, + <0x348 0x70000fff 0x000005a0>, + <0x34c 0x70000fff 0x000005a0>, + <0x350 0x70000fff 0x000005a0>, + <0x358 0xffffffff 0x0000ffff>, + <0x35c 0xffffffff 0x0000ffff>, + <0x408 0xffff0020 0x00190020>, + <0x40c 0x000fffff 0x00001681>, + <0x410 0x000fffff 0x00001680>, + <0x414 0x70000fff 0x000001e0>, + <0x418 0x70000fff 0x000001e0>, + <0x41c 0x70000fff 0x000001e0>, + <0x420 0x70000fff 0x000001e0>, + <0x424 0x70000fff 0x000005a0>, + <0x428 0x70000fff 0x000005a0>, + <0x42c 0x70000fff 0x000005a0>, + <0x430 0x70000fff 0x000005a0>, + <0x434 0x70000fff 0x000005a0>, + <0x438 0x70000fff 0x000005a0>, + <0x43c 0x70000fff 0x000005a0>, + <0x440 0x70000fff 0x000005a0>, + <0x444 0x70000fff 0x000005a0>, + <0x448 0x70000fff 0x000005a0>, + <0x44c 0x70000fff 0x000005a0>, + <0x450 0x70000fff 0x000005a0>, + <0x454 0x70000fff 0x000005a0>, + <0x948 0x07ff07ff 0x00280000>, + <0xa48 0x07ff07ff 0x00400040>, + <0xb48 0x07ff07ff 0x00b8010e>, + <0xc48 0x07ff07ff 0x00400020>, + <0xd48 0x07ff07ff 0x008a008a>, + <0x1000 0xffffffff 0x7fffffff>, + <0x4008 0x00000001 0x00000001>, + <0x400c 0x00000001 0x00000001>, + <0x4014 0x00000001 0x00000001>, + <0x4018 0x00000001 0x00000000>, + <0x401c 0x00000001 0x00000001>; + apple,tunable-fabric = + <0x4 0x003f003f 0x00200020>, + <0xc 0x000000f1 0x000000a1>, + <0x10 0x0000801f 0x00000004>, + <0x18 0x003f003f 0x00200020>, + <0x20 0x000000f1 0x000000a1>, + <0x24 0x0000801f 0x00000004>, + <0x2c 0x00ff00ff 0x00960096>, + <0x34 0x000000f1 0x00000071>, + <0x38 0x0000801f 0x00000004>, + <0x40 0x0000003f 0x00000020>, + <0x48 0x0000801f 0x00000004>, + <0x50 0x007f007f 0x00450045>, + <0x58 0x0000801f 0x00000004>, + <0x60 0x0000003f 0x00000020>, + <0x68 0x0000801f 0x00000004>, + <0x70 0x00000001 0x00000001>, + <0x74 0x0000801f 0x00000004>, + <0x7c 0x007f007f 0x00400040>, + <0x80 0x000000f1 0x00000011>, + <0x84 0x00000001 0x00000001>, + <0x88 0x00000001 0x00000001>, + <0x8c 0x0000801f 0x00000004>, + <0x94 0x001f001f 0x00100010>, + <0x98 0x000000f1 0x00000011>, + <0x9c 0x0000801f 0x00000004>, + <0xa4 0x000000ff 0x000000e0>, + <0xa8 0x0000801f 0x00000004>, + <0xb0 0x0000003f 0x00000020>, + <0xb8 0x0000801f 0x00000004>, + <0xc0 0x0000003f 0x00000020>, + <0xc8 0x0000801f 0x00000004>, + <0xd0 0x001f001f 0x00100010>, + <0xd8 0x00000001 0x00000001>, + <0xdc 0x00000001 0x00000001>, + <0xe0 0x0000801f 0x00000004>, + <0xe8 0x0000000f 0x00000008>, + <0xec 0x0000801f 0x00000004>, + <0xf4 0xffffffff 0x01010101>, + <0xf8 0x0000801f 0x00000004>, + <0x100 0x00000001 0x00000001>, + <0x104 0x00000001 0x00000001>, + <0x108 0x0000801f 0x00000004>, + <0x110 0x0000801f 0x00000004>, + <0x118 0x0000801f 0x00000004>, + <0x120 0x00000001 0x00000001>, + <0x124 0x00000001 0x00000001>, + <0x128 0x0000801f 0x00000004>, + <0x130 0xffffffff 0x01010101>, + <0x134 0x0000801f 0x00000004>, + <0x13c 0x00000001 0x00000001>, + <0x140 0x00000001 0x00000001>, + <0x144 0x0000801f 0x00000004>, + <0x14c 0x00000001 0x00000001>, + <0x150 0x00000001 0x00000001>, + <0x154 0x0000801f 0x00000004>, + <0x15c 0x0000801f 0x00000004>, + <0x164 0xffffffff 0x01010101>, + <0x168 0x0000ffff 0x00000101>, + <0x16c 0x0000801f 0x00000004>, + <0x174 0x00000001 0x00000001>, + <0x178 0x00000001 0x00000001>, + <0x17c 0x0000801f 0x00000004>, + <0x184 0x00000001 0x00000001>, + <0x188 0x00000001 0x00000001>, + <0x18c 0x0000801f 0x00000004>; + apple,tunable-common-cfg = + <0x8 0x00000001 0x00000001>; + apple,tunable-axi2af-lioa = + <0x28 0x0000fe2f 0x00000000>, + <0x2c 0x00000007 0x00000000>, + <0x30 0x0000007f 0x00000000>, + <0x34 0x000000ff 0x00000000>, + <0x58 0x0000010b 0x00000000>; + apple,tunable-lane0 = + <0xd094 0x00080000 0x00080000>, + <0xd098 0x00080000 0x00080000>, + <0xd0a4 0x00800000 0x00800000>, + <0xd0a8 0x00200000 0x00200000>; + apple,tunable-lane1 = + <0x1d094 0x00080000 0x00080000>, + <0x1d098 0x00080000 0x00080000>, + <0x1d0a4 0x00800000 0x00800000>, + <0x1d0a8 0x00200000 0x00200000>; + apple,tunable-aus40cmn-shm = + <0xa04 0x0000007c 0x0000004c>; + apple,tunable-auspll = + <0x3224 0x00000c00 0x00000800>, + <0x3230 0x0000001f 0x0000000f>, + <0x3240 0x07d8007f 0x04000039>, + <0x32b0 0x0b800000 0x01800000>, + <0x32e8 0x00060001 0x00040001>, + <0x3338 0x0f800000 0x07800000>; + apple,tunable-cio4pll = + <0x3a30 0x0000001f 0x0000000f>, + <0x3a4c 0x0000fe7f 0x00004e1d>, + <0x3ab0 0x00700000 0x00300000>, + <0x3ae8 0x00060000 0x00020000>; + /* ADT /arm-io/usb-drd0 tunable_PIPE_HANDLER_DEFAULT */ + apple,tunable-pipehandler = <0x44 0x4 0x4>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + atcphy0_ss: endpoint { + remote-endpoint = <&typec0_connector_ss>; + }; + }; + + port@1 { + reg = <1>; + atcphy0_usb3: endpoint { + remote-endpoint = <&dwc3_0_ss>; + }; + }; + }; +}; + +&atcphy0_mbox { + status = "okay"; +}; + +&typec0 { + ports { + port@1 { + reg = <1>; + typec0_connector_ss: endpoint { + remote-endpoint = <&atcphy0_ss>; + }; + }; + }; +}; + +/* GCTL.PWRDNSCALE = 0xd as macOS's controller reset() sets it, after DRD_USB31_GBL_DEFAULT */ +&dwc3_0 { + /delete-property/ maximum-speed; + phys = <&atcphy0 PHY_TYPE_USB2>, <&atcphy0 PHY_TYPE_USB3>; + phy-names = "usb2-phy", "usb3-phy"; + apple,tunable-gbl-default = <0x64 0x2 0x0>, <0x10 0xfff80000 0x00680000>; + apple,tunable-dbg = <0x0 0x8 0x8>; + apple,tunable-link = <0x20 0x7ff00000 0x4e900000>, <0x24 0x001f8000 0x000b8000>, <0x60 0x0003ffff 0x00000600>; + + ports { + port@1 { + reg = <1>; + dwc3_0_ss: endpoint { + remote-endpoint = <&atcphy0_usb3>; + }; + }; + }; +}; + +&atcphy1 { + apple,tunable-axi2af = + <0x0 0x800000ff 0x8000001c>, + <0x4 0x80ff00ff 0x801b0003>, + <0x8 0x80ff00ff 0x801b0003>, + <0xc 0x80ff00ff 0x801b0005>, + <0x10 0x80ff00ff 0x801b0003>, + <0x14 0x80ff00ff 0x801b0003>, + <0x18 0x80ff00ff 0x801b0003>, + <0x1c 0x80ff00ff 0x801b0003>, + <0x20 0x800000ff 0x80000015>, + <0x24 0x800000ff 0x80000038>, + <0x28 0x80ff00ff 0x80380006>, + <0x2c 0x80ff00ff 0x80380006>, + <0x30 0x80ff00ff 0x80380006>, + <0x34 0x80ff00ff 0x80380006>, + <0x38 0x80ff00ff 0x80380006>, + <0x3c 0x80ff00ff 0x80380006>, + <0x40 0x800000ff 0x80000015>, + <0x44 0x800000ff 0x80000015>, + <0x48 0x800000ff 0x80000015>, + <0x100 0x000000ff 0x000000ff>, + <0x108 0xffff0006 0x00100000>, + <0x304 0x3f3f0000 0x04040000>, + <0x308 0x000fffff 0x00001681>, + <0x30c 0x000fffff 0x00001680>, + <0x310 0x70000fff 0x000001e0>, + <0x314 0xf0000fff 0x800001e0>, + <0x318 0x70000fff 0x000001e0>, + <0x31c 0xf0000fff 0x800001e0>, + <0x320 0x70000fff 0x000005a0>, + <0x324 0xf0000fff 0x800005a0>, + <0x328 0x70000fff 0x000005a0>, + <0x32c 0xf0000fff 0x800005a0>, + <0x330 0x70000fff 0x000005a0>, + <0x334 0xf0000fff 0x800005a0>, + <0x338 0x70000fff 0x000005a0>, + <0x33c 0x70000fff 0x000005a0>, + <0x340 0x70000fff 0x000005a0>, + <0x344 0x70000fff 0x000005a0>, + <0x348 0x70000fff 0x000005a0>, + <0x34c 0x70000fff 0x000005a0>, + <0x350 0x70000fff 0x000005a0>, + <0x358 0xffffffff 0x0000ffff>, + <0x35c 0xffffffff 0x0000ffff>, + <0x408 0xffff0020 0x00180020>, + <0x40c 0x000fffff 0x00001681>, + <0x410 0x000fffff 0x00001680>, + <0x414 0x70000fff 0x000001e0>, + <0x418 0x70000fff 0x000001e0>, + <0x41c 0x70000fff 0x000001e0>, + <0x420 0x70000fff 0x000001e0>, + <0x424 0x70000fff 0x000005a0>, + <0x428 0x70000fff 0x000005a0>, + <0x42c 0x70000fff 0x000005a0>, + <0x430 0x70000fff 0x000005a0>, + <0x434 0x70000fff 0x000005a0>, + <0x438 0x70000fff 0x000005a0>, + <0x43c 0x70000fff 0x000005a0>, + <0x440 0x70000fff 0x000005a0>, + <0x444 0x70000fff 0x000005a0>, + <0x448 0x70000fff 0x000005a0>, + <0x44c 0x70000fff 0x000005a0>, + <0x450 0x70000fff 0x000005a0>, + <0x454 0x70000fff 0x000005a0>, + <0x948 0x07ff07ff 0x00280000>, + <0xa48 0x07ff07ff 0x00400040>, + <0xb48 0x07ff07ff 0x00b8010e>, + <0xc48 0x07ff07ff 0x00400020>, + <0xd48 0x07ff07ff 0x008a008a>, + <0x1000 0xffffffff 0x7fffffff>, + <0x4008 0x00000001 0x00000001>, + <0x400c 0x00000001 0x00000001>, + <0x4014 0x00000001 0x00000001>, + <0x4018 0x00000001 0x00000000>, + <0x401c 0x00000001 0x00000001>; + apple,tunable-fabric = + <0x4 0x003f003f 0x00200020>, + <0xc 0x000000f1 0x000000a1>, + <0x10 0x0000801f 0x00000004>, + <0x18 0x003f003f 0x00200020>, + <0x20 0x000000f1 0x000000a1>, + <0x24 0x0000801f 0x00000004>, + <0x2c 0x00ff00ff 0x00960096>, + <0x34 0x000000f1 0x00000071>, + <0x38 0x0000801f 0x00000004>, + <0x40 0x0000003f 0x00000020>, + <0x48 0x0000801f 0x00000004>, + <0x50 0x007f007f 0x00450045>, + <0x58 0x0000801f 0x00000004>, + <0x60 0x0000003f 0x00000020>, + <0x68 0x0000801f 0x00000004>, + <0x70 0x00000001 0x00000001>, + <0x74 0x0000801f 0x00000004>, + <0x7c 0x007f007f 0x00400040>, + <0x80 0x000000f1 0x00000011>, + <0x84 0x00000001 0x00000001>, + <0x88 0x00000001 0x00000001>, + <0x8c 0x0000801f 0x00000004>, + <0x94 0x001f001f 0x00100010>, + <0x98 0x000000f1 0x00000011>, + <0x9c 0x0000801f 0x00000004>, + <0xa4 0x000000ff 0x000000e0>, + <0xa8 0x0000801f 0x00000004>, + <0xb0 0x0000003f 0x00000020>, + <0xb8 0x0000801f 0x00000004>, + <0xc0 0x0000003f 0x00000020>, + <0xc8 0x0000801f 0x00000004>, + <0xd0 0x001f001f 0x00100010>, + <0xd8 0x00000001 0x00000001>, + <0xdc 0x00000001 0x00000001>, + <0xe0 0x0000801f 0x00000004>, + <0xe8 0x0000000f 0x00000008>, + <0xec 0x0000801f 0x00000004>, + <0xf4 0xffffffff 0x01010101>, + <0xf8 0x0000801f 0x00000004>, + <0x100 0x00000001 0x00000001>, + <0x104 0x00000001 0x00000001>, + <0x108 0x0000801f 0x00000004>, + <0x110 0x0000801f 0x00000004>, + <0x118 0x0000801f 0x00000004>, + <0x120 0x00000001 0x00000001>, + <0x124 0x00000001 0x00000001>, + <0x128 0x0000801f 0x00000004>, + <0x130 0xffffffff 0x01010101>, + <0x134 0x0000801f 0x00000004>, + <0x13c 0x00000001 0x00000001>, + <0x140 0x00000001 0x00000001>, + <0x144 0x0000801f 0x00000004>, + <0x14c 0x00000001 0x00000001>, + <0x150 0x00000001 0x00000001>, + <0x154 0x0000801f 0x00000004>, + <0x15c 0x0000801f 0x00000004>, + <0x164 0xffffffff 0x01010101>, + <0x168 0x0000ffff 0x00000101>, + <0x16c 0x0000801f 0x00000004>, + <0x174 0x00000001 0x00000001>, + <0x178 0x00000001 0x00000001>, + <0x17c 0x0000801f 0x00000004>, + <0x184 0x00000001 0x00000001>, + <0x188 0x00000001 0x00000001>, + <0x18c 0x0000801f 0x00000004>; + apple,tunable-common-cfg = + <0x8 0x00000001 0x00000001>; + apple,tunable-axi2af-lioa = + <0x28 0x0000fe2f 0x00000000>, + <0x2c 0x00000007 0x00000000>, + <0x30 0x0000007f 0x00000000>, + <0x34 0x000000ff 0x00000000>, + <0x58 0x0000010b 0x00000000>; + apple,tunable-lane0 = + <0xd094 0x00080000 0x00080000>, + <0xd098 0x00080000 0x00080000>, + <0xd0a4 0x00800000 0x00800000>, + <0xd0a8 0x00200000 0x00200000>; + apple,tunable-lane1 = + <0x1d094 0x00080000 0x00080000>, + <0x1d098 0x00080000 0x00080000>, + <0x1d0a4 0x00800000 0x00800000>, + <0x1d0a8 0x00200000 0x00200000>; + apple,tunable-aus40cmn-shm = + <0xa04 0x0000007c 0x00000040>; + apple,tunable-auspll = + <0x3224 0x00000c00 0x00000800>, + <0x3230 0x0000001f 0x0000000f>, + <0x3240 0x07d8007f 0x04000039>, + <0x32b0 0x0b800000 0x01800000>, + <0x32e8 0x00060001 0x00040001>, + <0x3338 0x0f800000 0x07800000>; + apple,tunable-cio4pll = + <0x3a30 0x0000001f 0x0000000f>, + <0x3a4c 0x0000fe7f 0x00004e1d>, + <0x3ab0 0x00700000 0x00300000>, + <0x3ae8 0x00060000 0x00020000>; + /* ADT /arm-io/usb-drd1 tunable_PIPE_HANDLER_DEFAULT */ + apple,tunable-pipehandler = <0x44 0x4 0x4>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + atcphy1_ss: endpoint { + remote-endpoint = <&typec1_connector_ss>; + }; + }; + + port@1 { + reg = <1>; + atcphy1_usb3: endpoint { + remote-endpoint = <&dwc3_1_ss>; + }; + }; + }; +}; + +&atcphy1_mbox { + status = "okay"; +}; + +&typec1 { + ports { + port@1 { + reg = <1>; + typec1_connector_ss: endpoint { + remote-endpoint = <&atcphy1_ss>; + }; + }; + }; +}; + +/* GCTL.PWRDNSCALE = 0xd as macOS's controller reset() sets it, after DRD_USB31_GBL_DEFAULT */ +&dwc3_1 { + /delete-property/ maximum-speed; + phys = <&atcphy1 PHY_TYPE_USB2>, <&atcphy1 PHY_TYPE_USB3>; + phy-names = "usb2-phy", "usb3-phy"; + apple,tunable-gbl-default = <0x64 0x2 0x0>, <0x10 0xfff80000 0x00680000>; + apple,tunable-dbg = <0x0 0x8 0x8>; + apple,tunable-link = <0x20 0x7ff00000 0x4e900000>, <0x24 0x001f8000 0x000b8000>, <0x60 0x0003ffff 0x00000600>; + + ports { + port@1 { + reg = <1>; + dwc3_1_ss: endpoint { + remote-endpoint = <&atcphy1_usb3>; + }; + }; + }; +}; + +&atcphy2 { + apple,tunable-axi2af = + <0x0 0x800000ff 0x80000020>, + <0x4 0x80ff00ff 0x801f0003>, + <0x8 0x80ff00ff 0x801f0003>, + <0xc 0x80ff00ff 0x801f0005>, + <0x10 0x80ff00ff 0x801f0003>, + <0x14 0x80ff00ff 0x801f0003>, + <0x18 0x80ff00ff 0x801f0003>, + <0x1c 0x80ff00ff 0x801f0003>, + <0x20 0x800000ff 0x80000019>, + <0x24 0x800000ff 0x80000040>, + <0x28 0x80ff00ff 0x80400006>, + <0x2c 0x80ff00ff 0x80400006>, + <0x30 0x80ff00ff 0x80400006>, + <0x34 0x80ff00ff 0x80400006>, + <0x38 0x80ff00ff 0x80400006>, + <0x3c 0x80ff00ff 0x80400006>, + <0x40 0x800000ff 0x80000019>, + <0x44 0x800000ff 0x80000019>, + <0x48 0x800000ff 0x80000019>, + <0x100 0x000000ff 0x000000ff>, + <0x108 0xffff0006 0x00100000>, + <0x304 0x3f3f0000 0x04040000>, + <0x308 0x000fffff 0x00001681>, + <0x30c 0x000fffff 0x00001680>, + <0x310 0x70000fff 0x000001e0>, + <0x314 0xf0000fff 0x800001e0>, + <0x318 0x70000fff 0x000001e0>, + <0x31c 0xf0000fff 0x800001e0>, + <0x320 0x70000fff 0x000005a0>, + <0x324 0xf0000fff 0x800005a0>, + <0x328 0x70000fff 0x000005a0>, + <0x32c 0xf0000fff 0x800005a0>, + <0x330 0x70000fff 0x000005a0>, + <0x334 0xf0000fff 0x800005a0>, + <0x338 0x70000fff 0x000005a0>, + <0x33c 0x70000fff 0x000005a0>, + <0x340 0x70000fff 0x000005a0>, + <0x344 0x70000fff 0x000005a0>, + <0x348 0x70000fff 0x000005a0>, + <0x34c 0x70000fff 0x000005a0>, + <0x350 0x70000fff 0x000005a0>, + <0x358 0xffffffff 0x0000ffff>, + <0x35c 0xffffffff 0x0000ffff>, + <0x408 0xffff0020 0x001c0020>, + <0x40c 0x000fffff 0x00001681>, + <0x410 0x000fffff 0x00001680>, + <0x414 0x70000fff 0x000001e0>, + <0x418 0x70000fff 0x000001e0>, + <0x41c 0x70000fff 0x000001e0>, + <0x420 0x70000fff 0x000001e0>, + <0x424 0x70000fff 0x000005a0>, + <0x428 0x70000fff 0x000005a0>, + <0x42c 0x70000fff 0x000005a0>, + <0x430 0x70000fff 0x000005a0>, + <0x434 0x70000fff 0x000005a0>, + <0x438 0x70000fff 0x000005a0>, + <0x43c 0x70000fff 0x000005a0>, + <0x440 0x70000fff 0x000005a0>, + <0x444 0x70000fff 0x000005a0>, + <0x448 0x70000fff 0x000005a0>, + <0x44c 0x70000fff 0x000005a0>, + <0x450 0x70000fff 0x000005a0>, + <0x454 0x70000fff 0x000005a0>, + <0x948 0x07ff07ff 0x00280000>, + <0xa48 0x07ff07ff 0x00400040>, + <0xb48 0x07ff07ff 0x00b8010e>, + <0xc48 0x07ff07ff 0x00400020>, + <0xd48 0x07ff07ff 0x008a008a>, + <0x1000 0xffffffff 0x7fffffff>, + <0x4008 0x00000001 0x00000001>, + <0x400c 0x00000001 0x00000001>, + <0x4014 0x00000001 0x00000001>, + <0x4018 0x00000001 0x00000000>, + <0x401c 0x00000001 0x00000001>; + apple,tunable-fabric = + <0x4 0x003f003f 0x00200020>, + <0xc 0x000000f1 0x000000a1>, + <0x10 0x0000801f 0x00000004>, + <0x18 0x003f003f 0x00200020>, + <0x20 0x000000f1 0x000000a1>, + <0x24 0x0000801f 0x00000004>, + <0x2c 0x00ff00ff 0x00960096>, + <0x34 0x000000f1 0x00000071>, + <0x38 0x0000801f 0x00000004>, + <0x40 0x0000003f 0x00000020>, + <0x48 0x0000801f 0x00000004>, + <0x50 0x007f007f 0x00450045>, + <0x58 0x0000801f 0x00000004>, + <0x60 0x0000003f 0x00000020>, + <0x68 0x0000801f 0x00000004>, + <0x70 0x00000001 0x00000001>, + <0x74 0x0000801f 0x00000004>, + <0x7c 0x007f007f 0x00400040>, + <0x80 0x000000f1 0x00000011>, + <0x84 0x00000001 0x00000001>, + <0x88 0x00000001 0x00000001>, + <0x8c 0x0000801f 0x00000004>, + <0x94 0x001f001f 0x00100010>, + <0x98 0x000000f1 0x00000011>, + <0x9c 0x0000801f 0x00000004>, + <0xa4 0x000000ff 0x000000e0>, + <0xa8 0x0000801f 0x00000004>, + <0xb0 0x0000003f 0x00000020>, + <0xb8 0x0000801f 0x00000004>, + <0xc0 0x0000003f 0x00000020>, + <0xc8 0x0000801f 0x00000004>, + <0xd0 0x001f001f 0x00100010>, + <0xd8 0x00000001 0x00000001>, + <0xdc 0x00000001 0x00000001>, + <0xe0 0x0000801f 0x00000004>, + <0xe8 0x0000000f 0x00000008>, + <0xec 0x0000801f 0x00000004>, + <0xf4 0xffffffff 0x01010101>, + <0xf8 0x0000801f 0x00000004>, + <0x100 0x00000001 0x00000001>, + <0x104 0x00000001 0x00000001>, + <0x108 0x0000801f 0x00000004>, + <0x110 0x0000801f 0x00000004>, + <0x118 0x0000801f 0x00000004>, + <0x120 0x00000001 0x00000001>, + <0x124 0x00000001 0x00000001>, + <0x128 0x0000801f 0x00000004>, + <0x130 0xffffffff 0x01010101>, + <0x134 0x0000801f 0x00000004>, + <0x13c 0x00000001 0x00000001>, + <0x140 0x00000001 0x00000001>, + <0x144 0x0000801f 0x00000004>, + <0x14c 0x00000001 0x00000001>, + <0x150 0x00000001 0x00000001>, + <0x154 0x0000801f 0x00000004>, + <0x15c 0x0000801f 0x00000004>, + <0x164 0xffffffff 0x01010101>, + <0x168 0x0000ffff 0x00000101>, + <0x16c 0x0000801f 0x00000004>, + <0x174 0x00000001 0x00000001>, + <0x178 0x00000001 0x00000001>, + <0x17c 0x0000801f 0x00000004>, + <0x184 0x00000001 0x00000001>, + <0x188 0x00000001 0x00000001>, + <0x18c 0x0000801f 0x00000004>; + apple,tunable-common-cfg = + <0x8 0x00000001 0x00000001>; + apple,tunable-axi2af-lioa = + <0x28 0x0000fe2f 0x00000000>, + <0x2c 0x00000007 0x00000000>, + <0x30 0x0000007f 0x00000000>, + <0x34 0x000000ff 0x00000000>, + <0x58 0x0000010b 0x00000000>; + apple,tunable-lane0 = + <0xd094 0x00080000 0x00080000>, + <0xd098 0x00080000 0x00080000>, + <0xd0a4 0x00800000 0x00800000>, + <0xd0a8 0x00200000 0x00200000>; + apple,tunable-lane1 = + <0x1d094 0x00080000 0x00080000>, + <0x1d098 0x00080000 0x00080000>, + <0x1d0a4 0x00800000 0x00800000>, + <0x1d0a8 0x00200000 0x00200000>; + apple,tunable-aus40cmn-shm = + <0xa04 0x0000007c 0x00000048>; + apple,tunable-auspll = + <0x3224 0x00000c00 0x00000800>, + <0x3230 0x0000001f 0x0000000f>, + <0x3240 0x07d8007f 0x04000049>, + <0x32b0 0x0b800000 0x01800000>, + <0x32e8 0x00060001 0x00040001>, + <0x3338 0x0f800000 0x07800000>; + apple,tunable-cio4pll = + <0x3a30 0x0000001f 0x0000000f>, + <0x3a4c 0x0000fe7f 0x00004e1d>, + <0x3ab0 0x00700000 0x00300000>, + <0x3ae8 0x00060000 0x00020000>; + /* ADT /arm-io/usb-drd2 tunable_PIPE_HANDLER_DEFAULT */ + apple,tunable-pipehandler = <0x44 0x4 0x4>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + atcphy2_ss: endpoint { + remote-endpoint = <&typec2_connector_ss>; + }; + }; + + port@1 { + reg = <1>; + atcphy2_usb3: endpoint { + remote-endpoint = <&dwc3_2_ss>; + }; + }; + }; +}; + +&atcphy2_mbox { + status = "okay"; +}; + +&typec2 { + ports { + port@1 { + reg = <1>; + typec2_connector_ss: endpoint { + remote-endpoint = <&atcphy2_ss>; + }; + }; + }; +}; + +/* GCTL.PWRDNSCALE = 0xd as macOS's controller reset() sets it, after DRD_USB31_GBL_DEFAULT */ +&dwc3_2 { + /delete-property/ maximum-speed; + phys = <&atcphy2 PHY_TYPE_USB2>, <&atcphy2 PHY_TYPE_USB3>; + phy-names = "usb2-phy", "usb3-phy"; + apple,tunable-gbl-default = <0x64 0x2 0x0>, <0x10 0xfff80000 0x00680000>; + apple,tunable-dbg = <0x0 0x8 0x8>; + apple,tunable-link = <0x20 0x7ff00000 0x4e900000>, <0x24 0x001f8000 0x000b8000>, <0x60 0x0003ffff 0x00000600>; + + ports { + port@1 { + reg = <1>; + dwc3_2_ss: endpoint { + remote-endpoint = <&atcphy2_usb3>; + }; + }; + }; +}; + +&atcphy3 { + apple,tunable-axi2af = + <0x0 0x800000ff 0x80000025>, + <0x4 0x80ff00ff 0x80250003>, + <0x8 0x80ff00ff 0x80250003>, + <0xc 0x80ff00ff 0x80250005>, + <0x10 0x80ff00ff 0x80250003>, + <0x14 0x80ff00ff 0x80250003>, + <0x18 0x80ff00ff 0x80250003>, + <0x1c 0x80ff00ff 0x80250003>, + <0x20 0x800000ff 0x8000001e>, + <0x24 0x800000ff 0x8000004a>, + <0x28 0x80ff00ff 0x804a0006>, + <0x2c 0x80ff00ff 0x804a0006>, + <0x30 0x80ff00ff 0x804a0006>, + <0x34 0x80ff00ff 0x804a0006>, + <0x38 0x80ff00ff 0x804a0006>, + <0x3c 0x80ff00ff 0x804a0006>, + <0x40 0x800000ff 0x8000001e>, + <0x44 0x800000ff 0x8000001e>, + <0x48 0x800000ff 0x8000001e>, + <0x100 0x000000ff 0x000000ff>, + <0x108 0xffff0006 0x00100000>, + <0x304 0x3f3f0000 0x04040000>, + <0x308 0x000fffff 0x00001681>, + <0x30c 0x000fffff 0x00001680>, + <0x310 0x70000fff 0x000001e0>, + <0x314 0xf0000fff 0x800001e0>, + <0x318 0x70000fff 0x000001e0>, + <0x31c 0xf0000fff 0x800001e0>, + <0x320 0x70000fff 0x000005a0>, + <0x324 0xf0000fff 0x800005a0>, + <0x328 0x70000fff 0x000005a0>, + <0x32c 0xf0000fff 0x800005a0>, + <0x330 0x70000fff 0x000005a0>, + <0x334 0xf0000fff 0x800005a0>, + <0x338 0x70000fff 0x000005a0>, + <0x33c 0x70000fff 0x000005a0>, + <0x340 0x70000fff 0x000005a0>, + <0x344 0x70000fff 0x000005a0>, + <0x348 0x70000fff 0x000005a0>, + <0x34c 0x70000fff 0x000005a0>, + <0x350 0x70000fff 0x000005a0>, + <0x358 0xffffffff 0x0000ffff>, + <0x35c 0xffffffff 0x0000ffff>, + <0x408 0xffff0020 0x00210020>, + <0x40c 0x000fffff 0x00001681>, + <0x410 0x000fffff 0x00001680>, + <0x414 0x70000fff 0x000001e0>, + <0x418 0x70000fff 0x000001e0>, + <0x41c 0x70000fff 0x000001e0>, + <0x420 0x70000fff 0x000001e0>, + <0x424 0x70000fff 0x000005a0>, + <0x428 0x70000fff 0x000005a0>, + <0x42c 0x70000fff 0x000005a0>, + <0x430 0x70000fff 0x000005a0>, + <0x434 0x70000fff 0x000005a0>, + <0x438 0x70000fff 0x000005a0>, + <0x43c 0x70000fff 0x000005a0>, + <0x440 0x70000fff 0x000005a0>, + <0x444 0x70000fff 0x000005a0>, + <0x448 0x70000fff 0x000005a0>, + <0x44c 0x70000fff 0x000005a0>, + <0x450 0x70000fff 0x000005a0>, + <0x454 0x70000fff 0x000005a0>, + <0x948 0x07ff07ff 0x00280000>, + <0xa48 0x07ff07ff 0x00400040>, + <0xb48 0x07ff07ff 0x00b8010e>, + <0xc48 0x07ff07ff 0x00400020>, + <0xd48 0x07ff07ff 0x008a008a>, + <0x1000 0xffffffff 0x7fffffff>, + <0x4008 0x00000001 0x00000001>, + <0x400c 0x00000001 0x00000001>, + <0x4014 0x00000001 0x00000001>, + <0x4018 0x00000001 0x00000000>, + <0x401c 0x00000001 0x00000001>; + apple,tunable-fabric = + <0x4 0x003f003f 0x00200020>, + <0xc 0x000000f1 0x000000a1>, + <0x10 0x0000801f 0x00000004>, + <0x18 0x003f003f 0x00200020>, + <0x20 0x000000f1 0x000000a1>, + <0x24 0x0000801f 0x00000004>, + <0x2c 0x00ff00ff 0x00960096>, + <0x34 0x000000f1 0x00000071>, + <0x38 0x0000801f 0x00000004>, + <0x40 0x0000003f 0x00000020>, + <0x48 0x0000801f 0x00000004>, + <0x50 0x007f007f 0x00450045>, + <0x58 0x0000801f 0x00000004>, + <0x60 0x0000003f 0x00000020>, + <0x68 0x0000801f 0x00000004>, + <0x70 0x00000001 0x00000001>, + <0x74 0x0000801f 0x00000004>, + <0x7c 0x007f007f 0x00400040>, + <0x80 0x000000f1 0x00000011>, + <0x84 0x00000001 0x00000001>, + <0x88 0x00000001 0x00000001>, + <0x8c 0x0000801f 0x00000004>, + <0x94 0x001f001f 0x00100010>, + <0x98 0x000000f1 0x00000011>, + <0x9c 0x0000801f 0x00000004>, + <0xa4 0x000000ff 0x000000e0>, + <0xa8 0x0000801f 0x00000004>, + <0xb0 0x0000003f 0x00000020>, + <0xb8 0x0000801f 0x00000004>, + <0xc0 0x0000003f 0x00000020>, + <0xc8 0x0000801f 0x00000004>, + <0xd0 0x001f001f 0x00100010>, + <0xd8 0x00000001 0x00000001>, + <0xdc 0x00000001 0x00000001>, + <0xe0 0x0000801f 0x00000004>, + <0xe8 0x0000000f 0x00000008>, + <0xec 0x0000801f 0x00000004>, + <0xf4 0xffffffff 0x01010101>, + <0xf8 0x0000801f 0x00000004>, + <0x100 0x00000001 0x00000001>, + <0x104 0x00000001 0x00000001>, + <0x108 0x0000801f 0x00000004>, + <0x110 0x0000801f 0x00000004>, + <0x118 0x0000801f 0x00000004>, + <0x120 0x00000001 0x00000001>, + <0x124 0x00000001 0x00000001>, + <0x128 0x0000801f 0x00000004>, + <0x130 0xffffffff 0x01010101>, + <0x134 0x0000801f 0x00000004>, + <0x13c 0x00000001 0x00000001>, + <0x140 0x00000001 0x00000001>, + <0x144 0x0000801f 0x00000004>, + <0x14c 0x00000001 0x00000001>, + <0x150 0x00000001 0x00000001>, + <0x154 0x0000801f 0x00000004>, + <0x15c 0x0000801f 0x00000004>, + <0x164 0xffffffff 0x01010101>, + <0x168 0x0000ffff 0x00000101>, + <0x16c 0x0000801f 0x00000004>, + <0x174 0x00000001 0x00000001>, + <0x178 0x00000001 0x00000001>, + <0x17c 0x0000801f 0x00000004>, + <0x184 0x00000001 0x00000001>, + <0x188 0x00000001 0x00000001>, + <0x18c 0x0000801f 0x00000004>; + apple,tunable-common-cfg = + <0x8 0x00000001 0x00000001>; + apple,tunable-axi2af-lioa = + <0x28 0x0000fe2f 0x00000000>, + <0x2c 0x00000007 0x00000000>, + <0x30 0x0000007f 0x00000000>, + <0x34 0x000000ff 0x00000000>, + <0x58 0x0000010b 0x00000000>; + apple,tunable-lane0 = + <0xd094 0x00080000 0x00080000>, + <0xd098 0x00080000 0x00080000>, + <0xd0a4 0x00800000 0x00800000>, + <0xd0a8 0x00200000 0x00200000>; + apple,tunable-lane1 = + <0x1d094 0x00080000 0x00080000>, + <0x1d098 0x00080000 0x00080000>, + <0x1d0a4 0x00800000 0x00800000>, + <0x1d0a8 0x00200000 0x00200000>; + apple,tunable-aus40cmn-shm = + <0xa04 0x0000007c 0x0000004c>; + apple,tunable-auspll = + <0x3224 0x00000c00 0x00000800>, + <0x3230 0x0000001f 0x0000000f>, + <0x3240 0x07d8007f 0x04000059>, + <0x32b0 0x0b800000 0x01800000>, + <0x32e8 0x00060001 0x00040001>, + <0x3338 0x0f800000 0x07800000>; + apple,tunable-cio4pll = + <0x3a30 0x0000001f 0x0000000f>, + <0x3a4c 0x0000fe7f 0x00004e1d>, + <0x3ab0 0x00700000 0x00300000>, + <0x3ae8 0x00060000 0x00020000>; + /* ADT /arm-io/usb-drd3 tunable_PIPE_HANDLER_DEFAULT */ + apple,tunable-pipehandler = <0x44 0x4 0x4>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + atcphy3_ss: endpoint { + remote-endpoint = <&typec3_connector_ss>; + }; + }; + + port@1 { + reg = <1>; + atcphy3_usb3: endpoint { + remote-endpoint = <&dwc3_3_ss>; + }; + }; + }; +}; + +&atcphy3_mbox { + status = "okay"; +}; + +&typec3 { + ports { + port@1 { + reg = <1>; + typec3_connector_ss: endpoint { + remote-endpoint = <&atcphy3_ss>; + }; + }; + }; +}; + +/* GCTL.PWRDNSCALE = 0xd as macOS's controller reset() sets it, after DRD_USB31_GBL_DEFAULT */ +&dwc3_3 { + /delete-property/ maximum-speed; + phys = <&atcphy3 PHY_TYPE_USB2>, <&atcphy3 PHY_TYPE_USB3>; + phy-names = "usb2-phy", "usb3-phy"; + apple,tunable-gbl-default = <0x64 0x2 0x0>, <0x10 0xfff80000 0x00680000>; + apple,tunable-dbg = <0x0 0x8 0x8>; + apple,tunable-link = <0x20 0x7ff00000 0x4e900000>, <0x24 0x001f8000 0x000b8000>, <0x60 0x0003ffff 0x00000600>; + + ports { + port@1 { + reg = <1>; + dwc3_3_ss: endpoint { + remote-endpoint = <&atcphy3_usb3>; + }; + }; + }; +}; diff --git a/arch/arm64/boot/dts/apple/t6041-j575c.dts b/arch/arm64/boot/dts/apple/t6041-j575c.dts index f5be5af9cab7d..8f03eccdb23e2 100644 --- a/arch/arm64/boot/dts/apple/t6041-j575c.dts +++ b/arch/arm64/boot/dts/apple/t6041-j575c.dts @@ -457,8 +457,9 @@ /* * Three of the four back Thunderbolt ports, with the J773s's PD controllers - * (nub-spmi-a0 0xc, 0xa and 0x8 for ATC0-2), at USB2 high speed as on the - * J616c. t6041-j575c-atc3.dtsi adds the fourth (hpm3 at 0x6, ATC3). + * (nub-spmi-a0 0xc, 0xa and 0x8 for ATC0-2), as on the J616c. + * t6041-j575c-atc3.dtsi adds the fourth (hpm3 at 0x6, ATC3), and + * t6041-j575c-usb3.dtsi USB3 on all four. */ &nub_spmi_a0 { status = "okay"; @@ -1051,6 +1052,7 @@ #include "t6041-j575c-atc3.dtsi" +#include "t6041-j575c-usb3.dtsi" /* * Not described: HDMI and the external display chains (unknown PHY routing From b3304019e26acd75f4fb4079128fbe25ddc5117f Mon Sep 17 00:00:00 2001 From: Roberto Dantas <7robertodantas@gmail.com> Date: Wed, 11 Nov 2026 09:21:27 -0300 Subject: [PATCH 07/11] soc: apple: display-gate: enable the J575c's typec1 chain without its ATC mailbox The M4 Max external-display stages are the J616c's. Its typec1 chain starts with the ATC1 PHY's coprocessor mailbox, which the J616c's tree leaves disabled because that port has no USB3 there. The J575c's typec1 is also a USB3 port, so its tree enables that mailbox, as the M4 Pro boards do, and the stage would then refuse the whole chain as "already enabled". On the J575c, use the same chain without the mailbox. Nothing changes on the J614c and J616c. Tested on a J575c with the next commit: the gate enables dcp@602e00000's chain, and a monitor on typec1 (USB-C to HDMI adapter, pin assignment D) shows the console. Assisted-by: LLM Signed-off-by: Roberto Dantas <7robertodantas@gmail.com> Co-Authored-By: Claude Opus 5.5 --- drivers/soc/apple/display-gate.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/soc/apple/display-gate.c b/drivers/soc/apple/display-gate.c index 73c56cc29ca21..fb3928ebfcace 100644 --- a/drivers/soc/apple/display-gate.c +++ b/drivers/soc/apple/display-gate.c @@ -3008,13 +3008,29 @@ static const struct gate_staged t6041_max_stages[] = { { "/iommu@602300000", t6041_max_usbc_nodes, ARRAY_SIZE(t6041_max_usbc_nodes) }, }; +/* + * The J575c's typec1 chain. That port is also a USB3 port, so its device tree + * enables the ATC1 PHY's coprocessor mailbox, as the M4 Pro boards do: the + * mailbox is not part of the chain here, and the rest is the J616c's. + */ +static const struct gate_staged t6041_j575c_usbc = { + "/iommu@602300000", t6041_max_usbc_nodes + 1, ARRAY_SIZE(t6041_max_usbc_nodes) - 1, +}; + +static const struct gate_staged *t6041_max_stage(unsigned int i) +{ + if (i == 1 && of_machine_is_compatible("apple,j575c")) + return &t6041_j575c_usbc; + return &t6041_max_stages[i]; +} + /* Applied, they stay: the live tree refers to them. Only the KUnit test reverts them. */ static struct of_changeset t6041_max_cs[ARRAY_SIZE(t6041_max_stages)]; /* Enable every node of stage @i and put its display DART into the display subsystem's iommus. */ static int __init t6041_max_apply(unsigned int i, struct device_node *display) { - const struct gate_staged *st = &t6041_max_stages[i]; + const struct gate_staged *st = t6041_max_stage(i); struct of_changeset *cs = &t6041_max_cs[i]; struct device_node *np; unsigned int n; @@ -3067,7 +3083,7 @@ static void __init gate_t6041_max_run(void) return; } for (i = 0; i < ARRAY_SIZE(t6041_max_stages); i++) { - const struct gate_staged *st = &t6041_max_stages[i]; + const struct gate_staged *st = t6041_max_stage(i); const char *dcp = st->nodes[st->nr - 1]; if (!staged_ready(st)) From 08e57a0658f545a11465c655499e87668b3c8312 Mon Sep 17 00:00:00 2001 From: Roberto Dantas <7robertodantas@gmail.com> Date: Wed, 11 Nov 2026 09:21:58 -0300 Subject: [PATCH 08/11] arm64: dts: apple: t6041-j575c: describe USB-C DisplayPort on typec1 The J575c has no display output: iBoot lights neither HDMI nor a USB-C display, and leaves a 640x1136 dummy framebuffer. It does leave the external display processors powered with their firmware loaded (DISPEXT0-3 SYS/FE on, CPU hardware-gated, iop-dcpextN-nub segments present), as on the J616c, but there is no panel and no internal display handoff to enable the display subsystem. Describe the J616c's typec1 chain (dcpext1, the ATC1 crossbar and atcphy1 in DP alt mode, driven by hpm1) for the J575c's typec1, the back port next to the one at the right edge, with the firmware memory placeholders of t6040-j616s-extdisp-mem-loader.dtsi (text, data, heap), and the dcp/disp0 aliases the boot loader's handoff looks for. A boot loader that knows the J575c fills dcpext1's memory and enables the display subsystem; the display gate then enables the chain. Without one, the display stays off as before and the port keeps working as USB. ATC3 is the fourth back Type-C port, not the J616c's HDMI PHY, so t604x-extdisp.dtsi's ATC3 description is replaced by the port's own. Tested on a J575c with the aura J575c handoff: a USB-C to HDMI adapter (pin assignment D, two DP lanes beside USB3) on typec1 drives a 2560x1440 monitor with the Linux console from a cold boot and after a replug. With aura 1.0.0b8 (no J575c handoff) the gate logs "display subsystem not enabled" and nothing else changes. Not described yet: HDMI, which runs through the lpdptx PHY that has no T604x driver. Assisted-by: LLM Signed-off-by: Roberto Dantas <7robertodantas@gmail.com> Co-Authored-By: Claude Opus 5.5 --- .../boot/dts/apple/t6041-j575c-usbc.dtsi | 96 +++++++++++++++++++ arch/arm64/boot/dts/apple/t6041-j575c.dts | 36 ++++++- 2 files changed, 130 insertions(+), 2 deletions(-) create mode 100644 arch/arm64/boot/dts/apple/t6041-j575c-usbc.dtsi diff --git a/arch/arm64/boot/dts/apple/t6041-j575c-usbc.dtsi b/arch/arm64/boot/dts/apple/t6041-j575c-usbc.dtsi new file mode 100644 index 0000000000000..15afb8d2574ad --- /dev/null +++ b/arch/arm64/boot/dts/apple/t6041-j575c-usbc.dtsi @@ -0,0 +1,96 @@ +// SPDX-License-Identifier: GPL-2.0+ OR MIT +/* + * USB-C DisplayPort on the J575c's back-right-middle port (typec1): dcpext1, + * the ATC1 display crossbar and atcphy1 in DP alt mode, driven by hpm1. The + * same chain as the J616c's typec1 (t6041-j616c-usbc.dtsi). The adapters it + * was tested with negotiate pin assignment D, whose two DP lanes run on the + * USB3 PHY, so this needs t6041-j575c-usb3.dtsi. + * + * dcpext1, its DARTs, mailbox, crossbar and Type-C route are disabled: the + * display gate enables them once the boot loader has filled dcpext1's + * firmware memory. A disabled route is no mode switch, so typec1 then keeps + * USB2 and PD as before. + */ + +/ { + aliases { + dcpext1 = &dcpext1; + }; + + reserved-memory { + /* + * Filled by the boot loader from this boot's ADT + * /arm-io/dcpext1/iop-dcpext1-nub segment-ranges, as on the + * J616s (t6040-j616s-extdisp-mem-loader.dtsi): __TEXT, __DATA + * and the heap. + */ + dcpext1_text: dcpext1-text { + compatible = "apple,asc-mem"; + reg = <0x0 0x0 0x0 0x4000>; + no-map; + status = "disabled"; + }; + + dcpext1_data: dcpext1-data { + compatible = "apple,asc-mem"; + reg = <0x0 0x0 0x0 0x4000>; + no-map; + status = "disabled"; + }; + + dcpext1_heap: dcpext1-heap { + compatible = "apple,asc-mem"; + reg = <0x0 0x0 0x0 0x4000>; + no-map; + status = "disabled"; + }; + }; +}; + +&dcpext1 { + apple,iomfb-surfaces = <1 1 0 0>; + apple,connector-type = "USB-C"; + phys = <&atcphy1 PHY_TYPE_DP>; + phy-names = "typec1"; + mux-controls = <&atcphy1_xbar 0>; + mux-control-names = "typec1"; + /* indexed by route */ + apple,typec-dptx-phys = <0 1 2>; + apple,typec-mux-indices = <2 2 2>; + memory-region = <&dcpext1_text>, <&dcpext1_data>, <&dcpext1_heap>; + memory-region-names = "text", "data", "heap"; + + typec-routes { + #address-cells = <1>; + #size-cells = <0>; + + route@1 { + reg = <1>; + mode-switch; + status = "disabled"; + + port { + dcpext1_typec1: endpoint { + remote-endpoint = <&typec1_dcpext1>; + }; + }; + }; + }; +}; + +&typec1 { + ports { + port@3 { + reg = <3>; + typec1_dcpext1: endpoint { + remote-endpoint = <&dcpext1_typec1>; + }; + }; + }; +}; + +/* The DP mux of typec1 (the tunables and USB3 are in t6041-j575c-usb3.dtsi) */ +&atcphy1 { + mode-switch; + orientation-switch; +}; diff --git a/arch/arm64/boot/dts/apple/t6041-j575c.dts b/arch/arm64/boot/dts/apple/t6041-j575c.dts index 8f03eccdb23e2..1291bfa70e33b 100644 --- a/arch/arm64/boot/dts/apple/t6041-j575c.dts +++ b/arch/arm64/boot/dts/apple/t6041-j575c.dts @@ -31,6 +31,9 @@ ethernet0 = ðernet0; gpu = &gpu; aop = &aop; + dcp = &dcp; + disp0 = &display; + disp0-piodma = &disp0_piodma; }; chosen { @@ -1050,11 +1053,40 @@ memory-region = <&aop_mmio_pmgr>; }; +/* + * iBoot leaves the external display processors running with their firmware + * loaded. There is no panel, so the boot loader never hands the internal DCP + * over: it hands over each external processor's firmware memory on its own + * and then enables the display subsystem (found through the disp0 alias; dcp + * has to be there too), and the display gate enables the chains that have + * firmware memory. + */ +&display { + phandle = <&display>; +}; + +&disp0_piodma { + phandle = <&disp0_piodma>; +}; + +#include "t604x-extdisp.dtsi" + +/* + * Only typec1 carries an external display chain here. ATC3 is the fourth + * back Type-C port, not the J616c's HDMI PHY: drop that description, and + * t6041-j575c-atc3.dtsi describes the port instead. + */ +/delete-node/ &atcphy0_xbar; +/delete-node/ &atcphy2_xbar; +/delete-node/ &atcphy3_xbar; +/delete-node/ &atcphy3; +/delete-node/ &atcphy3_mbox; #include "t6041-j575c-atc3.dtsi" #include "t6041-j575c-usb3.dtsi" +#include "t6041-j575c-usbc.dtsi" /* - * Not described: HDMI and the external display chains (unknown PHY routing - * on this board) and the SEP (no Touch ID sensor). + * Not described: HDMI (dcpext0 through display-crossbar0 to the lpdptx PHY + * and a DP-to-HDMI converter on i2c8) and the SEP (no Touch ID sensor). */ From 48bf7a41d484887cc58dbcfa4eedcf641596d4f7 Mon Sep 17 00:00:00 2001 From: Dj <43033058+DjDeveloperr@users.noreply.github.com> Date: Wed, 11 Nov 2026 11:08:44 -0500 Subject: [PATCH 09/11] test: recognize deferred SEP policy-window unlock Backport the test-only correction from aurora-silicon/linux#1564. The cached ref-key unlock closure is dispatched through the real-root policy window after its definition. Validate that complete dispatch and reject unwrapped or extra invocation; retain call-site inventory and initrd rules. No production SEP, keybag or guard-policy changes. Assisted-by: LLM --- tools/aurora-sep/tests/test_policy_window.py | 53 ++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/tools/aurora-sep/tests/test_policy_window.py b/tools/aurora-sep/tests/test_policy_window.py index fda87d68a3f0c..d226e1d0f23da 100644 --- a/tools/aurora-sep/tests/test_policy_window.py +++ b/tools/aurora-sep/tests/test_policy_window.py @@ -73,6 +73,35 @@ def setUp(self): self.sbio = (APPLE / "sbio.rs").read_text() self.activate = function(self.sbio, "activate_touchid") + def assert_cached_refkey_window(self, body, at): + # A deferred closure's wrapper comes after its definition. Match its + # complete dispatch rather than accepting any later window in the fn. + # Preserve offsets while ignoring words in comments. + clean = re.sub(r"//[^\n]*|/\*.*?\*/", lambda m: " " * len(m[0]), + body, flags=re.S) + closure = re.search(r"\blet\s+(?Punlock)\s*=\s*\|\|\s*\{", clean) + self.assertIsNotNone(closure) + opening = closure.end() - 1 + depth, end = 1, opening + 1 + while depth and end < len(clean): + depth += (clean[end] == "{") - (clean[end] == "}") + end += 1 + self.assertEqual(depth, 0) + self.assertTrue(opening < at < end) + self.assertEqual(clean.count(PREPARE), 1) + # The initrd deliberately leaves the real root's window unused; its + # guarded store is read-only. Only that branch may call unlock directly. + dispatch = re.search( + r"\blet\s+unlocked\s*=\s*if\s+self\.keystore_only\.load\(Relaxed\)\s*" + r"\{\s*(?Punlock)\(\)\s*\}\s*else\s*" + r"\{\s*crate::xart_guard::policy_window\((?Punlock)\)\s*\};", + clean) + self.assertIsNotNone(dispatch) + self.assertGreater(dispatch.start(), end) + self.assertEqual( + [m.start() for m in re.finditer(r"\bunlock\b", clean)], + [closure.start("binding"), dispatch.start("initrd"), dispatch.start("root")]) + def test_touchid_designates_inside_the_window(self): at = self.activate.index(DESIGNATE) self.assertIn("crate::xart_guard::policy_window(", statement(self.activate, at)) @@ -87,6 +116,26 @@ def test_touchid_designates_a_keybag_that_already_existed(self): self.assertLess(recovered, self.activate.index(DESIGNATE)) self.assertNotIn("sks_provision_identity_keybag(", self.activate) + def test_cached_refkey_window_wraps_deferred_unlock(self): + body = function((APPLE / "refkey.rs").read_text(), "refkey_unseal_cached") + self.assert_cached_refkey_window(body, body.index(PREPARE)) + + def test_cached_refkey_rejects_unguarded_real_root_unlock(self): + body = function((APPLE / "refkey.rs").read_text(), "refkey_unseal_cached") + wrapped = "crate::xart_guard::policy_window(unlock)" + self.assertEqual(body.count(wrapped), 1) + body = body.replace(wrapped, "unlock()") + with self.assertRaises(AssertionError): + self.assert_cached_refkey_window(body, body.index(PREPARE)) + + def test_cached_refkey_rejects_extra_unguarded_unlock(self): + body = function((APPLE / "refkey.rs").read_text(), "refkey_unseal_cached") + dispatch = "let unlocked = if self.keystore_only.load(Relaxed)" + self.assertEqual(body.count(dispatch), 1) + body = body.replace(dispatch, "unlock();\n " + dispatch) + with self.assertRaises(AssertionError): + self.assert_cached_refkey_window(body, body.index(PREPARE)) + def test_no_other_path_designates_outside_a_window(self): # A new designate of an existing keybag needs the window too; add it # here once it runs in one. @@ -99,6 +148,9 @@ def test_no_other_path_designates_outside_a_window(self): self.assertTrue(callers) for f, outer, body, at in callers: with self.subTest(caller=outer): + if (f, outer) == ("refkey.rs", "refkey_unseal_cached"): + self.assert_cached_refkey_window(body, at) + continue before = body[:at] self.assertTrue("crate::xart_guard::policy_window(" in before or "crate::xart_guard::close_policy_window(" in before, @@ -107,3 +159,4 @@ def test_no_other_path_designates_outside_a_window(self): if __name__ == "__main__": unittest.main() + From 1e704a12a6164d0ea8d61ffd6b6ba290fb40cb12 Mon Sep 17 00:00:00 2001 From: Dj <43033058+DjDeveloperr@users.noreply.github.com> Date: Wed, 11 Nov 2026 11:54:57 -0500 Subject: [PATCH 10/11] test: remove the extra policy-window fixture EOF blank Whitespace only; preserve every assertion and negative control. Assisted-by: LLM --- tools/aurora-sep/tests/test_policy_window.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/aurora-sep/tests/test_policy_window.py b/tools/aurora-sep/tests/test_policy_window.py index d226e1d0f23da..8ae2a619e44ad 100644 --- a/tools/aurora-sep/tests/test_policy_window.py +++ b/tools/aurora-sep/tests/test_policy_window.py @@ -159,4 +159,3 @@ def test_no_other_path_designates_outside_a_window(self): if __name__ == "__main__": unittest.main() - From c1cb1cc2c5ed3a931d8f895d09a505d2f0b44f35 Mon Sep 17 00:00:00 2001 From: Dj <43033058+DjDeveloperr@users.noreply.github.com> Date: Wed, 11 Nov 2026 12:33:39 -0500 Subject: [PATCH 11/11] test: align policy-window check with merged PR #1561 Use the exact upstream test from ea10c4dba3be; supersede the duplicate local repair. Production source is unchanged. Signed-off-by: Diljit Singh --- tools/aurora-sep/tests/test_policy_window.py | 83 +++++++------------- 1 file changed, 28 insertions(+), 55 deletions(-) diff --git a/tools/aurora-sep/tests/test_policy_window.py b/tools/aurora-sep/tests/test_policy_window.py index 8ae2a619e44ad..d233b8c6ebd7a 100644 --- a/tools/aurora-sep/tests/test_policy_window.py +++ b/tools/aurora-sep/tests/test_policy_window.py @@ -73,35 +73,6 @@ def setUp(self): self.sbio = (APPLE / "sbio.rs").read_text() self.activate = function(self.sbio, "activate_touchid") - def assert_cached_refkey_window(self, body, at): - # A deferred closure's wrapper comes after its definition. Match its - # complete dispatch rather than accepting any later window in the fn. - # Preserve offsets while ignoring words in comments. - clean = re.sub(r"//[^\n]*|/\*.*?\*/", lambda m: " " * len(m[0]), - body, flags=re.S) - closure = re.search(r"\blet\s+(?Punlock)\s*=\s*\|\|\s*\{", clean) - self.assertIsNotNone(closure) - opening = closure.end() - 1 - depth, end = 1, opening + 1 - while depth and end < len(clean): - depth += (clean[end] == "{") - (clean[end] == "}") - end += 1 - self.assertEqual(depth, 0) - self.assertTrue(opening < at < end) - self.assertEqual(clean.count(PREPARE), 1) - # The initrd deliberately leaves the real root's window unused; its - # guarded store is read-only. Only that branch may call unlock directly. - dispatch = re.search( - r"\blet\s+unlocked\s*=\s*if\s+self\.keystore_only\.load\(Relaxed\)\s*" - r"\{\s*(?Punlock)\(\)\s*\}\s*else\s*" - r"\{\s*crate::xart_guard::policy_window\((?Punlock)\)\s*\};", - clean) - self.assertIsNotNone(dispatch) - self.assertGreater(dispatch.start(), end) - self.assertEqual( - [m.start() for m in re.finditer(r"\bunlock\b", clean)], - [closure.start("binding"), dispatch.start("initrd"), dispatch.start("root")]) - def test_touchid_designates_inside_the_window(self): at = self.activate.index(DESIGNATE) self.assertIn("crate::xart_guard::policy_window(", statement(self.activate, at)) @@ -116,26 +87,6 @@ def test_touchid_designates_a_keybag_that_already_existed(self): self.assertLess(recovered, self.activate.index(DESIGNATE)) self.assertNotIn("sks_provision_identity_keybag(", self.activate) - def test_cached_refkey_window_wraps_deferred_unlock(self): - body = function((APPLE / "refkey.rs").read_text(), "refkey_unseal_cached") - self.assert_cached_refkey_window(body, body.index(PREPARE)) - - def test_cached_refkey_rejects_unguarded_real_root_unlock(self): - body = function((APPLE / "refkey.rs").read_text(), "refkey_unseal_cached") - wrapped = "crate::xart_guard::policy_window(unlock)" - self.assertEqual(body.count(wrapped), 1) - body = body.replace(wrapped, "unlock()") - with self.assertRaises(AssertionError): - self.assert_cached_refkey_window(body, body.index(PREPARE)) - - def test_cached_refkey_rejects_extra_unguarded_unlock(self): - body = function((APPLE / "refkey.rs").read_text(), "refkey_unseal_cached") - dispatch = "let unlocked = if self.keystore_only.load(Relaxed)" - self.assertEqual(body.count(dispatch), 1) - body = body.replace(dispatch, "unlock();\n " + dispatch) - with self.assertRaises(AssertionError): - self.assert_cached_refkey_window(body, body.index(PREPARE)) - def test_no_other_path_designates_outside_a_window(self): # A new designate of an existing keybag needs the window too; add it # here once it runs in one. @@ -146,15 +97,37 @@ def test_no_other_path_designates_outside_a_window(self): # after a ref-key create has closed the window for the boot. callers = calls(PREPARE) self.assertTrue(callers) + deferred = 0 for f, outer, body, at in callers: with self.subTest(caller=outer): - if (f, outer) == ("refkey.rs", "refkey_unseal_cached"): - self.assert_cached_refkey_window(body, at) - continue before = body[:at] - self.assertTrue("crate::xart_guard::policy_window(" in before - or "crate::xart_guard::close_policy_window(" in before, - f"{f}: {outer}") + if ("crate::xart_guard::policy_window(" in before + or "crate::xart_guard::close_policy_window(" in before): + continue + # The call sits in a closure that is run later. + self.assertEqual((f, outer), ("refkey.rs", "refkey_unseal_cached")) + self.assertIn("let unlock = || {", before) + deferred += 1 + self.assert_unlock_runs_in_the_window_or_the_initrd(body[at:]) + self.assertEqual(deferred, 1) + + def assert_unlock_runs_in_the_window_or_the_initrd(self, after): + """`unlock` is run twice: in the window, or bare in the initrd. + + The trusted-key-only initrd attach (keystore_only) leaves the boot's + one window to the real root: "Do not consume the real root's one + policy window in the initrd". Its designate runs with the window + shut, where the guard lets no existing session record be rewritten. + """ + uses = re.findall(r"\bunlock\b(?!\s*=)", after) + self.assertEqual(len(uses), 2) + self.assertRegex( + after, + r"if self\.keystore_only\.load\(Relaxed\) \{\s*" + r"unlock\(\)\s*" + r"\} else \{\s*" + r"crate::xart_guard::policy_window\(unlock\)\s*" + r"\}") if __name__ == "__main__":