From d743da074c6c55746daa32d656cc820ad9be46ba Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Tue, 17 Nov 2026 14:31:49 +0100 Subject: [PATCH 1/5] dt-bindings: apple: describe T8142 USB4 and PCIe-C Allow the five ACIO register windows, LSTX GPIO and router firmware tunables used by T8142. Describe its native PCIe-C compatible and require the shared MSI vector base. Include the T8142 pinctrl fallback chain used by the AOP LSTX pin. Signed-off-by: Thomas Glanzmann --- .../devicetree/bindings/pci/apple,pcie.yaml | 3 +++ .../thunderbolt/apple,t8103-usb4-acio.yaml | 27 +++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/pci/apple,pcie.yaml b/Documentation/devicetree/bindings/pci/apple,pcie.yaml index a9fd4822fd127..06405f7179fe8 100644 --- a/Documentation/devicetree/bindings/pci/apple,pcie.yaml +++ b/Documentation/devicetree/bindings/pci/apple,pcie.yaml @@ -101,6 +101,7 @@ properties: - const: apple,t8103-pciec - const: apple,t6000-pciec - const: apple,t6050-pciec + - const: apple,t8142-pciec - items: - const: apple,t8132-pciec - const: apple,t8122-pciec @@ -374,6 +375,7 @@ allOf: contains: enum: - apple,t8132-pciec + - apple,t8142-pciec - apple,t6040-pciec then: required: @@ -501,6 +503,7 @@ allOf: - apple,t6000-pciec - apple,t6040-pciec - apple,t6050-pciec + - apple,t8142-pciec then: properties: reg: diff --git a/Documentation/devicetree/bindings/thunderbolt/apple,t8103-usb4-acio.yaml b/Documentation/devicetree/bindings/thunderbolt/apple,t8103-usb4-acio.yaml index 01592811223d2..29c64e3b3c33e 100644 --- a/Documentation/devicetree/bindings/thunderbolt/apple,t8103-usb4-acio.yaml +++ b/Documentation/devicetree/bindings/thunderbolt/apple,t8103-usb4-acio.yaml @@ -52,8 +52,8 @@ properties: PCIe adapter configuration space of the USB4 router. Present where the root complex exposes the adapter separately, so that the tunnel can be configured before a PCIe-C link is brought up. - - description: MxWrap co-processor control registers, on T8132 and T6050 - - description: PCIe router AP firmware registers, on T6050 + - description: MxWrap co-processor control registers, on T8132, T8142 and T6050 + - description: PCIe router AP firmware registers, on T8142 and T6050 reg-names: oneOf: @@ -253,6 +253,7 @@ allOf: enum: - apple,t6040-usb4-acio - apple,t8132-usb4-acio + - apple,t8142-usb4-acio then: properties: reg: @@ -267,6 +268,7 @@ allOf: - apple,t6040-usb4-acio - apple,t6050-usb4-acio - apple,t8132-usb4-acio + - apple,t8142-usb4-acio then: properties: pinctrl-names: @@ -309,7 +311,28 @@ allOf: properties: power-domains: maxItems: 4 + - if: + properties: + compatible: + not: + contains: + enum: + - apple,t6050-usb4-acio + - apple,t8142-usb4-acio + then: + properties: apple,tunable-router-ap-fw: false + - if: + properties: + compatible: + contains: + const: apple,t8142-usb4-acio + then: + properties: + reg: + minItems: 5 + reg-names: + minItems: 5 additionalProperties: false From 56cecd6de9229ee56b37e57e4e7fe65083b4cf12 Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Tue, 17 Nov 2026 14:31:49 +0100 Subject: [PATCH 2/5] PCI: apple: support T8142 PCIe-C MSI slices T8142 uses the Intr2AXI controller layout but its three-cell AIC interrupt specifier and MSI window differ from T6050. Match it natively. This allows a tunnelled NVMe controller to allocate working MSI-X interrupts. For T8132 and T8142 the slice is checked against the device tree alone. msi-ranges names the AIC input of global vector apple,msi-vector-base in a linear window, so the window's AIC base is msi-ranges minus apple,msi-vector-base, and the slice is checked by its shape: an edge-rising SPI, 32 vectors, 32-aligned, above the internal port's vectors and inside the 8-bit map target. This replaces T8132's table of ECAM apertures and its AIC base 1506 behind a machine check. The T8132 trees give 1602 - 0x60 = 1634 - 0x80 = 1506, and every J813 PCIe node gives 1741. Signed-off-by: Thomas Glanzmann --- drivers/pci/controller/pcie-apple.c | 53 ++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 16 deletions(-) diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c index 8e20a36cc575e..35f984f4eace5 100644 --- a/drivers/pci/controller/pcie-apple.c +++ b/drivers/pci/controller/pcie-apple.c @@ -473,6 +473,22 @@ static const struct hw_info t6050_pciec_hw = { .mps_timers = true, }; +/* T8142 shares this register layout, with its own three-cell AIC MSI slice. */ +static const struct hw_info t8142_pciec_hw = { + .port_msiaddr = PORT_MSIADDR, + .port_msiaddr_hi = PORT_MSIADDR + 4, + .port_perst = PORT_PERST, + .port_rid2sid = PORT_RID2SID, + .port_msimap = PORT_T602X_MSIMAP, + .port_tunctrl = PORT_T6050_TUNCTRL, + .max_rid2sid = 256, + .tunneled = true, + .tunnel_intr2axi = true, + .no_port_reset = true, + .msimap_by_vector = true, + .mps_timers = true, +}; + static const struct of_device_id apple_pcie_of_match[]; /** @@ -3384,8 +3400,25 @@ static int apple_msi_init(struct apple_pcie *pcie) * 32-vector slice. Keep endpoint MSI data local, and route its table * entry to the corresponding shared-window vector. */ - if (pcie->hw == &t8122_pciec_hw || pcie->hw == &t8132_pciec_hw || - pcie->hw == &t6040_pciec_hw) { + if (pcie->hw == &t8132_pciec_hw || pcie->hw == &t8142_pciec_hw) { + /* + * msi-ranges names the AIC input of global vector + * apple,msi-vector-base in a linear window, so the slice is + * checked by its shape only: an edge-rising SPI, 32 vectors, + * 32-aligned, above the internal port's vectors and inside the + * 8-bit map target. + */ + if (args.args_count != 3 || args.args[0] != 0 || + args.args[2] != IRQ_TYPE_EDGE_RISING || + of_property_read_u32(to_of_node(fwnode), + "apple,msi-vector-base", + &pcie->msi_vector_base) || + args.args[1] < pcie->msi_vector_base || + !apple_t6030_msi_slice_valid(pcie->msi_vector_base, + pcie->nvecs, args.args[1], + args.args[1] - pcie->msi_vector_base)) + goto invalid_slice; + } else if (pcie->hw == &t8122_pciec_hw || pcie->hw == &t6040_pciec_hw) { struct resource ecam; u32 expected_base, aic_base; @@ -3422,19 +3455,6 @@ static int apple_msi_init(struct apple_pcie *pcie) default: goto invalid_slice; } - } else if (of_machine_is_compatible("apple,t8132")) { - aic_base = 1506; - switch (ecam.start) { - /* The internal port's bridges own vectors 0..95. */ - case 0x1c50000000ULL: - expected_base = 0x60; - break; - case 0x1c60000000ULL: - expected_base = 0x80; - break; - default: - goto invalid_slice; - } } else { goto invalid_slice; } @@ -3468,7 +3488,7 @@ static int apple_msi_init(struct apple_pcie *pcie) /* Keep map targets within the supported 8-bit range. */ if ((pcie->hw == &t8122_pciec_hw || pcie->hw == &t8132_pciec_hw || - pcie->hw == &t6040_pciec_hw) && + pcie->hw == &t6040_pciec_hw || pcie->hw == &t8142_pciec_hw) && (!pcie->nvecs || pcie->nvecs > 256 || pcie->msi_vector_base > FIELD_MAX(PORT_MSIMAP_TARGET) + 1 - pcie->nvecs)) { @@ -7484,6 +7504,7 @@ static const struct dev_pm_ops apple_pcie_pm_ops = { static const struct of_device_id apple_pcie_of_match[] = { { .compatible = "apple,t6040-pciec", .data = &t6040_pciec_hw }, { .compatible = "apple,t6050-pciec", .data = &t6050_pciec_hw }, + { .compatible = "apple,t8142-pciec", .data = &t8142_pciec_hw }, { .compatible = "apple,t8132-pciec", .data = &t8132_pciec_hw }, { .compatible = "apple,t8122-pciec", .data = &t8122_pciec_hw }, { .compatible = "apple,t8112-pciec", .data = &t8112_pciec_hw }, From caf9ba025e07b4923277967993a23b82445ebc1a Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Tue, 17 Nov 2026 14:31:49 +0100 Subject: [PATCH 3/5] thunderbolt: apple: support T8142 router startup and deep sleep Use the qualified MxWrap startup sequence: CIO reset leaves the CPU running, then RTKit readiness precedes the LSTX handoff. Admit native T8142 PCIe-C hosts without a T6050 fallback. Keep DP IN disabled. Deep sleep removes CIO power. Remove idle NVMe hierarchies before stopping the router and request fresh cable state on resume. Refuse sleep when a disk is open or another endpoint driver cannot be removed safely. Extend the production-C admission tests with native T8142 and a negative control. The T8142 behaviours are named flags of its match data (sleep_removes_domains, restart_on_wake, phy_shared_with_dwc3), so a later SoC that behaves the same sets them instead of extending a comparison. Signed-off-by: Thomas Glanzmann --- drivers/thunderbolt/apple.c | 52 +++++++++++--- tools/asahi/pciec-policy-tests.py | 111 ++++++++++++++++++++++++++++-- 2 files changed, 151 insertions(+), 12 deletions(-) diff --git a/drivers/thunderbolt/apple.c b/drivers/thunderbolt/apple.c index ac8e1a4205098..013f259b35c16 100644 --- a/drivers/thunderbolt/apple.c +++ b/drivers/thunderbolt/apple.c @@ -171,6 +171,15 @@ struct apple_cio_hw { bool gen4_link_recovery; /* Leave the host router's TMU to its firmware; host TMU constants. */ bool host_tmu; + /* Deep sleep removes the CIO domains, including an attached router. */ + bool sleep_removes_domains; + /* Start the router again at once after a wake. */ + bool restart_on_wake; + /* + * The PHY is shared with DWC3: release PCIe, or refuse the sleep, + * before DWC3's default-priority PM notifier queues its PHY shutdown. + */ + bool phy_shared_with_dwc3; const struct apple_dpin_policy *dp; }; @@ -206,9 +215,22 @@ static const struct apple_cio_hw apple_cio_t8132_hw = { .dp = &apple_dpin_m4, }; -/* Type 7 uses its existing ready-state check and has no qualified DP route. */ +/* + * T8142 has a Type 7 router with an MxWrap CPU already running after CIO + * reset. Hand LSTX to firmware only after RTKit is ready. DP IN is not yet + * qualified; the connector's DisplayPort alternate mode is independent. + */ static const struct apple_cio_hw apple_cio_t8142_hw = { + .mxwrap = true, .type7 = true, + .lstx_explicit = true, + .skip_run = true, + .lstx_after_boot = true, + .strict_fw_ready = true, + .no_host_clx = true, + .sleep_removes_domains = true, + .restart_on_wake = true, + .phy_shared_with_dwc3 = true, .dp = &apple_dpin_disabled, }; @@ -1308,7 +1330,8 @@ static bool apple_cio_pciec_eligible(const struct device_node *np) return of_device_is_compatible(np, "apple,t6040-pciec") || of_device_is_compatible(np, "apple,t8103-pciec") || of_device_is_compatible(np, "apple,t6000-pciec") || - of_device_is_compatible(np, "apple,t6050-pciec"); + of_device_is_compatible(np, "apple,t6050-pciec") || + of_device_is_compatible(np, "apple,t8142-pciec"); } static bool @@ -3994,6 +4017,12 @@ static bool apple_cio_t6050_sleep(struct apple_cio *acio) apple_sleep_v27_late() && !pm_suspend_default_s2idle(); } +/* Deep sleep removes the CIO domains, including an attached router. */ +static bool apple_cio_sleep_removes_domains(struct apple_cio *acio) +{ + return acio->hw->sleep_removes_domains && !pm_suspend_default_s2idle(); +} + /* The longest the displays behind a port may take to go before its router does. */ #define APPLE_CIO_SLEEP_DP_RELEASE_MS 3000 @@ -4096,7 +4125,8 @@ static int apple_cio_sleep_teardown(struct apple_cio *acio) scoped_guard(mutex, &acio->pcie_tunnel_lock) { if (READ_ONCE(acio->pcie_tunnel_requested) || acio->pcie_tunnel_populated) { struct platform_device *pcie; - int mode = READ_ONCE(t6050_sleep_pcie); + bool t8142 = apple_cio_sleep_removes_domains(acio); + int mode = t8142 ? 1 : READ_ONCE(t6050_sleep_pcie); int ret = 0; /* @@ -4105,7 +4135,7 @@ static int apple_cio_sleep_teardown(struct apple_cio *acio) * still carries them: only NVMe controllers, whose driver touches no * notifier chain on removal, and by default only with no disk in use. */ - if (!mode || !apple_cio_t6050_sleep(acio)) + if (!mode || (!t8142 && !apple_cio_t6050_sleep(acio))) return 0; pcie = apple_cio_find_pcie_tunnel(acio); if (pcie) { @@ -4116,7 +4146,8 @@ static int apple_cio_sleep_teardown(struct apple_cio *acio) dev_warn(acio->dev, "PCIe devices behind this port stay for the sleep (%d): the port is not powered off\n", ret); - return 0; + /* T8142 cannot retain this port through deep sleep. */ + return t8142 ? ret : 0; } } acio->pcie_tunnel_stopping = true; @@ -4125,7 +4156,7 @@ static int apple_cio_sleep_teardown(struct apple_cio *acio) dev_info(acio->dev, "powering off port for system sleep (cable info 0x%x)\n", acio->current_cable_info); t6050 = apple_cio_t6050_sleep(acio); - if (t6050) { + if (t6050 || apple_cio_sleep_removes_domains(acio)) { u64 activity; /* With no NHI the answer is "yes": then nothing is expected back. */ @@ -4193,7 +4224,7 @@ static void apple_cio_sleep_restart_work(struct work_struct *work) /* Is this port powered off for the sleep about to start? Asked at PM_SUSPEND_PREPARE. */ static bool apple_cio_sleep_tears_down(struct apple_cio *acio) { - if (READ_ONCE(s2idle_teardown)) + if (READ_ONCE(s2idle_teardown) || apple_cio_sleep_removes_domains(acio)) return true; /* A port whose router sleeps in place keeps its tunnels: its NHI owns the sleep. */ return apple_cio_t6050_sleep(acio) && !READ_ONCE(acio->sleep_in_place); @@ -4220,7 +4251,7 @@ static int apple_cio_pm_notify(struct notifier_block *nb, unsigned long event, apple_cio_sleep_close_owed(acio); /* Before tasks freeze: tearing down the NHI needs unfrozen work. */ if (tears_down) { - /* Only the displays' release refuses, with the port as it was. */ + /* Refuse before powering off a port that cannot be released. */ ret = apple_cio_sleep_teardown(acio); if (ret) return notifier_from_errno(ret); @@ -4235,6 +4266,8 @@ static int apple_cio_pm_notify(struct notifier_block *nb, unsigned long event, } owed = acio->sleep_restart_owed; early = acio->sleep_aborted_early; + if (acio->hw->restart_on_wake) + delay = 0; /* TEST: macOS starts the router again straight after the wake. */ if (acio->sleep_t6050) { acio->sleep_t6050 = false; @@ -4714,6 +4747,9 @@ static int apple_cio_probe(struct platform_device *pdev) } acio->pm_notifier.notifier_call = apple_cio_pm_notify; + /* Before DWC3's default-priority notifier queues its PHY shutdown. */ + if (acio->hw->phy_shared_with_dwc3) + acio->pm_notifier.priority = 40; register_pm_notifier(&acio->pm_notifier); /* Before the notifiers of the default priority, after the port controllers' (30). */ acio->pm_notifier_dp.notifier_call = apple_cio_dp_pm_notify; diff --git a/tools/asahi/pciec-policy-tests.py b/tools/asahi/pciec-policy-tests.py index a5a8fb96e143d..9441119a26e93 100644 --- a/tools/asahi/pciec-policy-tests.py +++ b/tools/asahi/pciec-policy-tests.py @@ -100,10 +100,11 @@ def function(source, name): int main(void) { struct device_node dart = { .tunables = true }; - const char *intr2axi[] = { "apple,t8112-pciec", "apple,t6000-pciec" }; - for (unsigned int i = 0; i < 2; i++) { + const char *intr2axi[] = { "apple,t8112-pciec", "apple,t6000-pciec", + "apple,t8142-pciec" }; + for (unsigned int i = 0; i < 3; i++) { /* M2 must win over its T8103 fallback, without a board allowlist. */ - struct device_node host = { .compat = { intr2axi[i], "apple,t8103-pciec" }, + struct device_node host = { .compat = { intr2axi[i], i < 2 ? "apple,t8103-pciec" : NULL }, .status = -1, .dart = &dart }; const struct of_device_id *id = of_match_node(apple_pcie_of_match, &host); assert(id && ((const struct hw_info *)id->data)->tunnel_intr2axi); @@ -132,12 +133,112 @@ def function(source, name): expect(®ular, false, false); regular.compat[0] = "apple,unknown-pciec"; expect(®ular, false, false); - puts("PASS: M1, M1 Pro, M2, firmware handoff, missing DART and DT opt-in"); + puts("PASS: M1, M1 Pro, M2, native T8142, firmware handoff, missing DART and DT opt-in"); return 0; } ''' +def pm_registration(source, start, end): + first = source.index(start) + return source[first:source.index(end, first) + len(end)] + + +PM_FIXTURE = r''' +#include +#include +#include +struct notifier_block { int (*notifier_call)(void); int priority; }; +struct apple_cio_hw { bool phy_shared_with_dwc3; }; +struct apple_cio { const struct apple_cio_hw *hw; struct notifier_block pm_notifier; }; +struct dwc3_apple { struct notifier_block pm_nb; }; +static const struct apple_cio_hw apple_cio_t8142_hw = { .phy_shared_with_dwc3 = true }; +static struct notifier_block *chain[2]; +static int count; +static bool busy, phy_off, pci_off; +static int register_pm_notifier(struct notifier_block *nb) +{ + int i = count++; + assert(count <= 2); + while (i && chain[i - 1]->priority < nb->priority) { + chain[i] = chain[i - 1]; + i--; + } + chain[i] = nb; + return 0; +} +static int apple_cio_pm_notify(void) +{ + /* An open disk must be rejected while its PCIe link still works. */ + assert(!phy_off); + if (busy) + return 1; + pci_off = true; + return 0; +} +static int dwc3_apple_pm_notify(void) +{ + assert(pci_off); + phy_off = true; + return 0; +} +static void add_cio(struct apple_cio *acio) +{ + /* ACIO_REGISTRATION */ +} +static void add_dwc(struct dwc3_apple *appledwc) +{ + int ret; + /* DWC_REGISTRATION */ + assert(!ret); +} +int main(void) +{ + struct apple_cio acio = { .hw = &apple_cio_t8142_hw }; + struct dwc3_apple dwc = { 0 }; + /* DWC3 probes first on J813. Equal priority reproduces the failure. */ + add_dwc(&dwc); + add_cio(&acio); + for (int open = 0; open < 2; open++) { + busy = open; + phy_off = pci_off = false; + for (int i = 0; i < count; i++) + if (chain[i]->notifier_call()) + break; + assert(phy_off == !busy && pci_off == !busy); + } + puts("PASS: T8142 refuses an open disk before PHY shutdown; idle PCIe stops first"); + return 0; +} +''' + + +def test_pm_order(out, acio): + dwc = (ROOT / 'drivers/usb/dwc3/dwc3-apple.c').read_text() + code = PM_FIXTURE.replace('/* ACIO_REGISTRATION */', pm_registration( + acio, 'acio->pm_notifier.notifier_call = apple_cio_pm_notify;', + 'register_pm_notifier(&acio->pm_notifier);')) + code = code.replace('/* DWC_REGISTRATION */', pm_registration( + dwc, 'appledwc->pm_nb.notifier_call = dwc3_apple_pm_notify;', + 'ret = register_pm_notifier(&appledwc->pm_nb);')) + mutation = code.replace('acio->pm_notifier.priority = 40;', + 'acio->pm_notifier.priority = 0;') + assert mutation != code + for name, body in [('pm-order', code), ('phy-before-pcie', mutation)]: + source, binary = out / (name + '.c'), out / name + source.write_text(body) + subprocess.run(['cc', '-std=gnu11', '-Wall', '-Werror', str(source), + '-o', str(binary)], check=True) + run = subprocess.run([str(binary)], capture_output=True, text=True) + (out / (name + '.log')).write_text(run.stdout + run.stderr) + if name == 'pm-order': + assert run.returncode == 0, run.stderr + print(run.stdout, end='') + else: + assert run.returncode < 0 and 'Assertion' in run.stderr + print('PASS negative control:', name) + + def main(): parser = argparse.ArgumentParser() parser.add_argument('--out', type=Path) @@ -155,8 +256,10 @@ def main(): with tempfile.TemporaryDirectory(prefix='pciec-policy-') as tmp: out = args.out or Path(tmp) out.mkdir(parents=True, exist_ok=True) + test_pm_order(out, acio) cases = {'production': code, 'm2-fallback': code.replace('{ .compatible = "apple,t8112-pciec",\t.data = &t8112_pciec_hw },', ''), + 't8142-admission': code.replace('of_device_is_compatible(np, \"apple,t8142-pciec\")', 'false'), 'dart-bypass': code.replace('tunables = of_property_present(iommu_spec.np, "apple,tunable");', 'tunables = true;')} for name, body in cases.items(): source = out / (name + '.c') From 13483df0aa7f364a0c3e1c183dc7f2853976c5e0 Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Tue, 17 Nov 2026 14:31:49 +0100 Subject: [PATCH 4/5] arm64: dts: apple: enable the J813 rear USB4 port Describe ACIO1, its mailbox and LSTX pin, and the PCIe-C tunnel. Populate both DARTs under their powered parents. Use connector port 4 so the existing DisplayPort alternate-mode route can retain port 3. Name the PCIe-C tunable alias usb4-1-pcie, as t6040-usb4.dtsi does; aura looks it up under that spelling since aurora-silicon/aura#302. Signed-off-by: Thomas Glanzmann --- .../arm64/boot/dts/apple/t8142-j813-usb4.dtsi | 314 ++++++++++++++++++ arch/arm64/boot/dts/apple/t8142-j813.dts | 2 + 2 files changed, 316 insertions(+) create mode 100644 arch/arm64/boot/dts/apple/t8142-j813-usb4.dtsi diff --git a/arch/arm64/boot/dts/apple/t8142-j813-usb4.dtsi b/arch/arm64/boot/dts/apple/t8142-j813-usb4.dtsi new file mode 100644 index 0000000000000..a0107a4613eed --- /dev/null +++ b/arch/arm64/boot/dts/apple/t8142-j813-usb4.dtsi @@ -0,0 +1,314 @@ +// SPDX-License-Identifier: GPL-2.0+ OR MIT +/* J813 rear USB-C port: the ACIO1 router and its PCIe-C tunnel. */ + +/ { + aliases { + + usb4-1-acio = &acio1; + + usb4-1-pcie-adapter = &acio1; + + usb4-1-nhi = &acio1_nhi; + + /* aura copies the PCIe-C tunables here (needs aura#302). */ + usb4-1-pcie = &apciec1; + }; +}; + +&pmgr { + + ps_atc1_pcie: power-controller@3d8 { + compatible = "apple,t8142-pmgr-pwrstate", "apple,t8103-pmgr-pwrstate"; + reg = <0x3d8 4>; + #power-domain-cells = <0>; + #reset-cells = <0>; + power-domains = <&ps_atc1_common>, <&ps_atc1_usb_aon>; + label = "atc1-pcie"; + }; + + ps_atc1_cio: power-controller@3e0 { + compatible = "apple,t8142-pmgr-pwrstate", "apple,t8103-pmgr-pwrstate"; + reg = <0x3e0 4>; + #power-domain-cells = <0>; + #reset-cells = <0>; + power-domains = <&ps_atc1_common>; + label = "atc1-cio"; + }; + + ps_atc1_cio_pcie: power-controller@4e8 { + compatible = "apple,t8142-pmgr-pwrstate", "apple,t8103-pmgr-pwrstate"; + reg = <0x4e8 4>; + #power-domain-cells = <0>; + #reset-cells = <0>; + power-domains = <&ps_atc1_cio>; + label = "atc1-cio-pcie"; + }; + + ps_atc1_cio_usb: power-controller@4f0 { + compatible = "apple,t8142-pmgr-pwrstate", "apple,t8103-pmgr-pwrstate"; + reg = <0x4f0 4>; + #power-domain-cells = <0>; + #reset-cells = <0>; + power-domains = <&ps_atc1_cio>; + label = "atc1-cio-usb"; + }; +}; + +/* Populate these DARTs only after their parent is powered and configured. */ +/delete-node/ &acio1_dart; +/delete-node/ &pciec1_dart; + +&{/soc} { + + cio_reset: reset-controller@380780000 { + compatible = "apple,t8142-cio-reset"; + reg = <0x3 0x80780000 0x0 0x4000>; + #reset-cells = <1>; + }; + + pinctrl_aop: pinctrl@390824000 { + compatible = "apple,t8142-pinctrl", "apple,t8140-pinctrl", "apple,t8103-pinctrl"; + reg = <0x3 0x90824000 0x0 0x4000>; + gpio-controller; + #gpio-cells = <2>; + gpio-ranges = <&pinctrl_aop 0 0 77>; + apple,npins = <77>; + + /* Only LSTX pin 21 is ours; the AOP owns the rest of this bank. */ + gpio-reserved-ranges = <0 21>, <22 55>; + interrupt-controller; + #interrupt-cells = <2>; + interrupts = , + , + , + ; + apple,irq-group-base = <3>; + + acio1_lstx_pins: acio1-lstx-pins { + pinmux = <0x10015>; + }; + }; + + acio1_mbox: mailbox@409108000 { + compatible = "apple,t8142-asc-mailbox", "apple,asc-mailbox-v4"; + reg = <0x4 0x09108000 0x0 0x4000>; + interrupts = , + , + , + ; + interrupt-names = "send-empty", "send-not-empty", + "recv-empty", "recv-not-empty"; + #mbox-cells = <0>; + }; + + /* acio@ avoids the bootloader's legacy cio@ register-index fixup. */ + acio1: acio@409ac0000 { + compatible = "apple,t8142-usb4-acio"; + reg = <0x4 0x09ac0000 0x0 0xc000>, + <0x4 0x09080000 0x0 0x26000>, + <0x4 0x09e44000 0x0 0x4000>, + <0x4 0x09100000 0x0 0x4000>, + <0x4 0x09c80000 0x0 0x4000>; + reg-names = "rc", "sram", "pcie-adapter", "cpu", "router-ap-fw"; + mboxes = <&acio1_mbox>; + resets = <&cio_reset 1>; + + power-domains = <&ps_atc1_cio>, <&ps_atc1_cio_pcie>, + <&ps_atc1_cio_usb>, <&ps_atc1_pcie>; + thunderbolt-switch; + apple,pcie-tunnel = <&acio1_pcie_tunnel>; + + pinctrl-0 = <&acio1_lstx_pins>; + pinctrl-names = "lstx"; + lstx-gpios = <&pinctrl_aop 21 GPIO_ACTIVE_HIGH>; + + /* Other router tunables are supplied by the bootloader. */ + apple,tunable-router-ap-fw = <0x8 0xff2 0x482>; + + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x4 0x09000000 0x1000000>; + nonposted-mmio; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@1 { + reg = <1>; + acio1_tbt: endpoint { + remote-endpoint = <&typec1_usb4>; + }; + }; + }; + + acio1_dart: iommu@a80000 { + compatible = "apple,t8142-dart", "apple,t8110-dart"; + reg = <0xa80000 0xc000>; + interrupts = ; + power-domains = <&ps_atc1_cio>; + #iommu-cells = <1>; + apple,dma-range = <0x100 0x4000 0x0 0xffff0000>; + apple,bypass-sids = <15>; + apple,full-error-reporting; + apple,ctc-flush; + + /* ACIO DART tunables are not supplied by the bootloader. */ + apple,tunable = <0x20c 0x80000121 0x80000121>, + <0x220 0xf0f 0xf0f>, + <0x224 0xffff 0x909>, + <0x300 0x1f31 0x1>, + <0x308 0x3ffffffc 0x10000000>, + <0x310 0x3ffffffc 0x3ffffffc>, + <0x800 0xf003f 0x10000>, + <0x804 0xf003f 0x10002>, + <0x808 0xf003f 0x10004>, + <0x80c 0xf003f 0x20006>, + <0x810 0xf003f 0x2000a>, + <0x814 0xf003f 0x2000e>, + <0x818 0xf003f 0x20012>, + <0x81c 0xf003f 0x20016>, + <0x820 0xf003f 0x2001a>, + <0x824 0xf003f 0x2001e>, + <0x828 0xf003f 0x20022>, + <0x82c 0xf003f 0x20026>, + <0x830 0xf003f 0x2002a>, + <0x834 0xf003f 0x2002e>, + <0x838 0xf003f 0x20032>, + <0x83c 0xf003f 0x10036>; + }; + + acio1_nhi: nhi@f00000 { + compatible = "apple,t8142-usb4-nhi"; + reg = <0xf00000 0x100000>; + reg-names = "nhi"; + interrupts = , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + ; + interrupt-names = "txring0", "txring1", "txring2", "txring3", + "txring4", "txring5", "txring6", "txring7", + "txring8", "txring9", "txring10", "txring11", + "rxring0", "rxring1", "rxring2", "rxring3", + "rxring4", "rxring5", "rxring6", "rxring7", + "rxring8", "rxring9", "rxring10", "rxring11"; + + iommus = <&acio1_dart 0>, <&acio1_dart 1>, <&acio1_dart 2>, + <&acio1_dart 3>, <&acio1_dart 4>, <&acio1_dart 5>, + <&acio1_dart 6>, <&acio1_dart 7>, <&acio1_dart 8>, + <&acio1_dart 9>, <&acio1_dart 10>, <&acio1_dart 11>, + <&acio1_dart 16>, <&acio1_dart 17>, <&acio1_dart 18>, + <&acio1_dart 19>, <&acio1_dart 20>, <&acio1_dart 21>, + <&acio1_dart 22>, <&acio1_dart 23>, <&acio1_dart 24>, + <&acio1_dart 25>, <&acio1_dart 26>, <&acio1_dart 27>; + + /* Filled by the bootloader. */ + apple,thunderbolt-drom = [00]; + }; + }; +}; + +/ { + acio1_pcie_tunnel: pcie-tunnel-1 { + #address-cells = <2>; + #size-cells = <2>; + ranges; + nonposted-mmio; + + pciec1_dart: iommu@40c000000 { + compatible = "apple,t8142-dart", "apple,t8110-dart"; + reg = <0x4 0x0c000000 0x0 0xc000>; + interrupts = ; + power-domains = <&ps_atc1_pcie>; + #iommu-cells = <1>; + apple,bypass-sids = <253 255>; + apple,full-error-reporting; + apple,ctc-flush; + }; + + apciec1: pcie@1c60000000 { + compatible = "apple,t8142-pciec"; + device_type = "pci"; + reg = <0x1c 0x60000000 0x0 0x10000000>, + <0x4 0x0c034000 0x0 0x4000>, + <0x4 0x0c020000 0x0 0x8000>, + <0x4 0x0c038000 0x0 0x4000>, + <0x4 0x0c060000 0x0 0x4000>, + <0x4 0x0c02c000 0x0 0x4000>, + <0x4 0x0c028000 0x0 0x4000>; + reg-names = "config", "rc", "port0", "fabric", "debug", "ltssm", "intr2axi"; + interrupts = ; + power-domains = <&ps_atc1_pcie>; + + apple,pciec-kernel-init; + + msi-controller; + msi-parent = <&apciec1>; + msi-ranges = <&aic AIC_IRQ 1869 IRQ_TYPE_EDGE_RISING 32>; + apple,msi-vector-base = <128>; + + iommu-map = <0x0 &pciec1_dart 0x0 0x40>; + iommu-map-mask = <0x3f>; + + linux,pci-domain = <2>; + + bus-range = <0x0 0x7f>; + #address-cells = <3>; + #size-cells = <2>; + + ranges = <0x43000000 0xc 0x0 0xc 0x0 0x2 0x0>, + <0x02000000 0x0 0x00100000 0xe 0x00100000 0x0 0x3ff00000>, + <0x42000000 0x0 0x40000000 0xe 0x40000000 0x0 0x40000000>; + + apciec1_port: pci@0,0 { + device_type = "pci"; + reg = <0x0 0x0 0x0 0x0 0x0>; + external-facing; + + #address-cells = <3>; + #size-cells = <2>; + ranges; + + interrupt-controller; + #interrupt-cells = <1>; + interrupt-map-mask = <0 0 0 7>; + interrupt-map = <0 0 0 1 &apciec1_port 0 0 0 0>, + <0 0 0 2 &apciec1_port 0 0 0 1>, + <0 0 0 3 &apciec1_port 0 0 0 2>, + <0 0 0 4 &apciec1_port 0 0 0 3>; + }; + }; + }; +}; + +/* Port 3 is reserved for the board's DisplayPort alternate-mode route. */ +&typec1 { + ports { + port@4 { + reg = <4>; + typec1_usb4: endpoint { + remote-endpoint = <&acio1_tbt>; + }; + }; + }; +}; diff --git a/arch/arm64/boot/dts/apple/t8142-j813.dts b/arch/arm64/boot/dts/apple/t8142-j813.dts index fe9e3b8ce77db..4b3ce1a391ce1 100644 --- a/arch/arm64/boot/dts/apple/t8142-j813.dts +++ b/arch/arm64/boot/dts/apple/t8142-j813.dts @@ -405,3 +405,5 @@ "shared-l2", "gfx-data", "gfx1-data", "fw-data", "fw-text"; }; + +#include "t8142-j813-usb4.dtsi" From f6ed2df61ae926454e6abafa15503ff29ff119a4 Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Thu, 19 Nov 2026 08:50:09 +0100 Subject: [PATCH 5/5] arm64: dts: apple: enable the J813 front USB4 port Only the rear port's ACIO1 router and PCIe-C tunnel are described. The front connector's PD controller enters USB4 by itself when a USB4 device is attached (DATA_STATUS bit 23), and nothing in the kernel takes the link over: a USB4 NVMe enclosure that works on the rear port shows up neither as USB4 nor as USB on the front port. Describe ACIO0 like ACIO1, with the values of the ADT acio0, acio-cpu0, dart-acio0, apciec0 and dart-apciec0 nodes: router 0x401ac0000, mailbox 0x401108000, PCIe-C 0x404000000 with ECAM 0x1c50000000 and its MSI slice at vector 96 (AIC 1837), CIO reset 0, LSTX AOP pin 19 and the ATC0 power states 0x3c8, 0x3d0, 0x4d8 and 0x4e0. The bootloader fills the tunables and the DROM through the usb4-0-* aliases, as for the rear port. Signed-off-by: Thomas Glanzmann --- .../arm64/boot/dts/apple/t8142-j813-usb4.dtsi | 282 +++++++++++++++++- 1 file changed, 278 insertions(+), 4 deletions(-) diff --git a/arch/arm64/boot/dts/apple/t8142-j813-usb4.dtsi b/arch/arm64/boot/dts/apple/t8142-j813-usb4.dtsi index a0107a4613eed..c9d726ef5dbb2 100644 --- a/arch/arm64/boot/dts/apple/t8142-j813-usb4.dtsi +++ b/arch/arm64/boot/dts/apple/t8142-j813-usb4.dtsi @@ -1,9 +1,21 @@ // SPDX-License-Identifier: GPL-2.0+ OR MIT -/* J813 rear USB-C port: the ACIO1 router and its PCIe-C tunnel. */ +/* + * J813 USB-C ports: the ACIO0 (front) and ACIO1 (rear) routers and their + * PCIe-C tunnels. + */ / { aliases { + usb4-0-acio = &acio0; + + usb4-0-pcie-adapter = &acio0; + + usb4-0-nhi = &acio0_nhi; + + /* aura copies the PCIe-C tunables here (needs aura#302). */ + usb4-0-pcie = &apciec0; + usb4-1-acio = &acio1; usb4-1-pcie-adapter = &acio1; @@ -17,6 +29,24 @@ &pmgr { + ps_atc0_pcie: power-controller@3c8 { + compatible = "apple,t8142-pmgr-pwrstate", "apple,t8103-pmgr-pwrstate"; + reg = <0x3c8 4>; + #power-domain-cells = <0>; + #reset-cells = <0>; + power-domains = <&ps_atc0_common>, <&ps_atc0_usb_aon>; + label = "atc0-pcie"; + }; + + ps_atc0_cio: power-controller@3d0 { + compatible = "apple,t8142-pmgr-pwrstate", "apple,t8103-pmgr-pwrstate"; + reg = <0x3d0 4>; + #power-domain-cells = <0>; + #reset-cells = <0>; + power-domains = <&ps_atc0_common>; + label = "atc0-cio"; + }; + ps_atc1_pcie: power-controller@3d8 { compatible = "apple,t8142-pmgr-pwrstate", "apple,t8103-pmgr-pwrstate"; reg = <0x3d8 4>; @@ -35,6 +65,24 @@ label = "atc1-cio"; }; + ps_atc0_cio_pcie: power-controller@4d8 { + compatible = "apple,t8142-pmgr-pwrstate", "apple,t8103-pmgr-pwrstate"; + reg = <0x4d8 4>; + #power-domain-cells = <0>; + #reset-cells = <0>; + power-domains = <&ps_atc0_cio>; + label = "atc0-cio-pcie"; + }; + + ps_atc0_cio_usb: power-controller@4e0 { + compatible = "apple,t8142-pmgr-pwrstate", "apple,t8103-pmgr-pwrstate"; + reg = <0x4e0 4>; + #power-domain-cells = <0>; + #reset-cells = <0>; + power-domains = <&ps_atc0_cio>; + label = "atc0-cio-usb"; + }; + ps_atc1_cio_pcie: power-controller@4e8 { compatible = "apple,t8142-pmgr-pwrstate", "apple,t8103-pmgr-pwrstate"; reg = <0x4e8 4>; @@ -55,6 +103,8 @@ }; /* Populate these DARTs only after their parent is powered and configured. */ +/delete-node/ &acio0_dart; +/delete-node/ &pciec0_dart; /delete-node/ &acio1_dart; /delete-node/ &pciec1_dart; @@ -74,8 +124,8 @@ gpio-ranges = <&pinctrl_aop 0 0 77>; apple,npins = <77>; - /* Only LSTX pin 21 is ours; the AOP owns the rest of this bank. */ - gpio-reserved-ranges = <0 21>, <22 55>; + /* Only LSTX pins 19 and 21 are ours; the AOP owns the rest of this bank. */ + gpio-reserved-ranges = <0 19>, <20 1>, <22 55>; interrupt-controller; #interrupt-cells = <2>; interrupts = , @@ -84,11 +134,153 @@ ; apple,irq-group-base = <3>; + acio0_lstx_pins: acio0-lstx-pins { + pinmux = <0x10013>; + }; + acio1_lstx_pins: acio1-lstx-pins { pinmux = <0x10015>; }; }; + acio0_mbox: mailbox@401108000 { + compatible = "apple,t8142-asc-mailbox", "apple,asc-mailbox-v4"; + reg = <0x4 0x01108000 0x0 0x4000>; + interrupts = , + , + , + ; + interrupt-names = "send-empty", "send-not-empty", + "recv-empty", "recv-not-empty"; + #mbox-cells = <0>; + }; + + /* acio@ avoids the bootloader's legacy cio@ register-index fixup. */ + acio0: acio@401ac0000 { + compatible = "apple,t8142-usb4-acio"; + reg = <0x4 0x01ac0000 0x0 0xc000>, + <0x4 0x01080000 0x0 0x26000>, + <0x4 0x01e44000 0x0 0x4000>, + <0x4 0x01100000 0x0 0x4000>, + <0x4 0x01c80000 0x0 0x4000>; + reg-names = "rc", "sram", "pcie-adapter", "cpu", "router-ap-fw"; + mboxes = <&acio0_mbox>; + resets = <&cio_reset 0>; + + power-domains = <&ps_atc0_cio>, <&ps_atc0_cio_pcie>, + <&ps_atc0_cio_usb>, <&ps_atc0_pcie>; + thunderbolt-switch; + apple,pcie-tunnel = <&acio0_pcie_tunnel>; + + pinctrl-0 = <&acio0_lstx_pins>; + pinctrl-names = "lstx"; + lstx-gpios = <&pinctrl_aop 19 GPIO_ACTIVE_HIGH>; + + /* Other router tunables are supplied by the bootloader. */ + apple,tunable-router-ap-fw = <0x8 0xff2 0x482>; + + #address-cells = <1>; + #size-cells = <1>; + ranges = <0x0 0x4 0x01000000 0x1000000>; + nonposted-mmio; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@1 { + reg = <1>; + acio0_tbt: endpoint { + remote-endpoint = <&typec0_usb4>; + }; + }; + }; + + acio0_dart: iommu@a80000 { + compatible = "apple,t8142-dart", "apple,t8110-dart"; + reg = <0xa80000 0xc000>; + interrupts = ; + power-domains = <&ps_atc0_cio>; + #iommu-cells = <1>; + apple,dma-range = <0x100 0x4000 0x0 0xffff0000>; + apple,bypass-sids = <15>; + apple,full-error-reporting; + apple,ctc-flush; + + /* ACIO DART tunables are not supplied by the bootloader. */ + apple,tunable = <0x20c 0x80000121 0x80000121>, + <0x220 0xf0f 0xf0f>, + <0x224 0xffff 0x909>, + <0x300 0x1f31 0x1>, + <0x308 0x3ffffffc 0x10000000>, + <0x310 0x3ffffffc 0x3ffffffc>, + <0x800 0xf003f 0x10000>, + <0x804 0xf003f 0x10002>, + <0x808 0xf003f 0x10004>, + <0x80c 0xf003f 0x20006>, + <0x810 0xf003f 0x2000a>, + <0x814 0xf003f 0x2000e>, + <0x818 0xf003f 0x20012>, + <0x81c 0xf003f 0x20016>, + <0x820 0xf003f 0x2001a>, + <0x824 0xf003f 0x2001e>, + <0x828 0xf003f 0x20022>, + <0x82c 0xf003f 0x20026>, + <0x830 0xf003f 0x2002a>, + <0x834 0xf003f 0x2002e>, + <0x838 0xf003f 0x20032>, + <0x83c 0xf003f 0x10036>; + }; + + acio0_nhi: nhi@f00000 { + compatible = "apple,t8142-usb4-nhi"; + reg = <0xf00000 0x100000>; + reg-names = "nhi"; + interrupts = , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + , + ; + interrupt-names = "txring0", "txring1", "txring2", "txring3", + "txring4", "txring5", "txring6", "txring7", + "txring8", "txring9", "txring10", "txring11", + "rxring0", "rxring1", "rxring2", "rxring3", + "rxring4", "rxring5", "rxring6", "rxring7", + "rxring8", "rxring9", "rxring10", "rxring11"; + + iommus = <&acio0_dart 0>, <&acio0_dart 1>, <&acio0_dart 2>, + <&acio0_dart 3>, <&acio0_dart 4>, <&acio0_dart 5>, + <&acio0_dart 6>, <&acio0_dart 7>, <&acio0_dart 8>, + <&acio0_dart 9>, <&acio0_dart 10>, <&acio0_dart 11>, + <&acio0_dart 16>, <&acio0_dart 17>, <&acio0_dart 18>, + <&acio0_dart 19>, <&acio0_dart 20>, <&acio0_dart 21>, + <&acio0_dart 22>, <&acio0_dart 23>, <&acio0_dart 24>, + <&acio0_dart 25>, <&acio0_dart 26>, <&acio0_dart 27>; + + /* Filled by the bootloader. */ + apple,thunderbolt-drom = [00]; + }; + }; + acio1_mbox: mailbox@409108000 { compatible = "apple,t8142-asc-mailbox", "apple,asc-mailbox-v4"; reg = <0x4 0x09108000 0x0 0x4000>; @@ -229,6 +421,77 @@ }; / { + acio0_pcie_tunnel: pcie-tunnel-0 { + #address-cells = <2>; + #size-cells = <2>; + ranges; + nonposted-mmio; + + pciec0_dart: iommu@404000000 { + compatible = "apple,t8142-dart", "apple,t8110-dart"; + reg = <0x4 0x04000000 0x0 0xc000>; + interrupts = ; + power-domains = <&ps_atc0_pcie>; + #iommu-cells = <1>; + apple,bypass-sids = <253 255>; + apple,full-error-reporting; + apple,ctc-flush; + }; + + apciec0: pcie@1c50000000 { + compatible = "apple,t8142-pciec"; + device_type = "pci"; + reg = <0x1c 0x50000000 0x0 0x10000000>, + <0x4 0x04034000 0x0 0x4000>, + <0x4 0x04020000 0x0 0x8000>, + <0x4 0x04038000 0x0 0x4000>, + <0x4 0x04060000 0x0 0x4000>, + <0x4 0x0402c000 0x0 0x4000>, + <0x4 0x04028000 0x0 0x4000>; + reg-names = "config", "rc", "port0", "fabric", "debug", "ltssm", "intr2axi"; + interrupts = ; + power-domains = <&ps_atc0_pcie>; + + apple,pciec-kernel-init; + + msi-controller; + msi-parent = <&apciec0>; + msi-ranges = <&aic AIC_IRQ 1837 IRQ_TYPE_EDGE_RISING 32>; + apple,msi-vector-base = <96>; + + iommu-map = <0x0 &pciec0_dart 0x0 0x40>; + iommu-map-mask = <0x3f>; + + linux,pci-domain = <1>; + + bus-range = <0x0 0x7f>; + #address-cells = <3>; + #size-cells = <2>; + + ranges = <0x43000000 0x8 0x0 0x8 0x0 0x2 0x0>, + <0x02000000 0x0 0x00100000 0xa 0x00100000 0x0 0x3ff00000>, + <0x42000000 0x0 0x40000000 0xa 0x40000000 0x0 0x40000000>; + + apciec0_port: pci@0,0 { + device_type = "pci"; + reg = <0x0 0x0 0x0 0x0 0x0>; + external-facing; + + #address-cells = <3>; + #size-cells = <2>; + ranges; + + interrupt-controller; + #interrupt-cells = <1>; + interrupt-map-mask = <0 0 0 7>; + interrupt-map = <0 0 0 1 &apciec0_port 0 0 0 0>, + <0 0 0 2 &apciec0_port 0 0 0 1>, + <0 0 0 3 &apciec0_port 0 0 0 2>, + <0 0 0 4 &apciec0_port 0 0 0 3>; + }; + }; + }; + acio1_pcie_tunnel: pcie-tunnel-1 { #address-cells = <2>; #size-cells = <2>; @@ -301,7 +564,18 @@ }; }; -/* Port 3 is reserved for the board's DisplayPort alternate-mode route. */ +/* Port 3 of each connector is the board's DisplayPort alternate-mode route. */ +&typec0 { + ports { + port@4 { + reg = <4>; + typec0_usb4: endpoint { + remote-endpoint = <&acio0_tbt>; + }; + }; + }; +}; + &typec1 { ports { port@4 {