From 50d8d75faa478e0714bf2c2d6494bf8b59036f8a Mon Sep 17 00:00:00 2001 From: Joshua Warren <816217+joshuaswarren@users.noreply.github.com> Date: Thu, 12 Nov 2026 18:09:54 -0600 Subject: [PATCH 01/31] spmi: apple: take interrupts on generation 4 controllers Generation 4 (t8142, t6050) had its interrupt refused at probe. macOS's trace (reported by Dj on the Aurora M5 Pro thread) acks peripheral sources 0..255 per bit in words from +0x600, with the controller fault source 263 at +0x620 bit 7. On K114c the PMIC RTC alarm sets +0x600 bit 2 (read-only probe, alarm armed 20 s out). Take the mask and ack bank offsets from the hw table (gen1 unchanged, shared with a host check in spmi-apple-irq.h). Generation 4 has no mask bank we could find (no word in 0x20..0x7f or 0x500..0x6ff toggles), so sources are masked in the cache only. Commands stay polled: the RX notification is not wired for gen 4. Tested: host check of the register math; compile only, not booted. Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com> --- drivers/spmi/spmi-apple-controller.c | 63 +++++++++++++++---------- drivers/spmi/spmi-apple-irq-host-test.c | 42 +++++++++++++++++ drivers/spmi/spmi-apple-irq.h | 37 +++++++++++++++ 3 files changed, 116 insertions(+), 26 deletions(-) create mode 100644 drivers/spmi/spmi-apple-irq-host-test.c create mode 100644 drivers/spmi/spmi-apple-irq.h diff --git a/drivers/spmi/spmi-apple-controller.c b/drivers/spmi/spmi-apple-controller.c index c5f8829cfeb45..7ecbf636dc16e 100644 --- a/drivers/spmi/spmi-apple-controller.c +++ b/drivers/spmi/spmi-apple-controller.c @@ -32,14 +32,14 @@ #include #include +#include "spmi-apple-irq.h" + /* SPMI Controller Registers */ #define SPMI_STATUS_REG 0 #define SPMI_CMD_REG 0x4 #define SPMI_RSP_REG 0x8 #define SPMI_ACT_REG 0xa4 -#define SPMI_IRQ_MASK_BASE 0x20 -#define SPMI_IRQ_ACK_BASE 0x60 /* * Peripheral interrupts come first. The RX FIFO notification sits right * after them, followed by the controller's own fault interrupts, so the @@ -61,8 +61,6 @@ * reply FIFO. macOS acks the controller's fault interrupt (source 263, after the 256 * peripheral sources; ack words from 0x600) and empties the queue when the controller starts. */ -#define SPMI_GEN4_IRQ_ACK_BASE 0x600 -#define SPMI_GEN4_FAULT_IRQ (SPMI_MAX_PERIPHERAL_IRQS + 7) #define SPMI_FAULT_QUEUE_MAX 64 /* More than the reply FIFO holds: the bound of a recovery's read-out. */ #define SPMI_GEN4_REPLY_DRAIN_MAX 64 @@ -77,6 +75,8 @@ struct apple_spmi_hw { u32 rx_empty; bool legacy_irqs; u32 num_irqs; + u32 irq_mask; + u32 irq_ack; }; static const struct apple_spmi_hw apple_spmi_gen1 = { @@ -86,6 +86,8 @@ static const struct apple_spmi_hw apple_spmi_gen1 = { .rx_empty = SPMI_RX_FIFO_EMPTY, .legacy_irqs = true, .num_irqs = 256, + .irq_mask = APPLE_SPMI_GEN1_IRQ_MASK, + .irq_ack = APPLE_SPMI_GEN1_IRQ_ACK, }; /* M1 Pro, Max and Ultra: 192 peripheral interrupts, notification at 192 */ @@ -96,6 +98,8 @@ static const struct apple_spmi_hw apple_spmi_t6000 = { .rx_empty = SPMI_RX_FIFO_EMPTY, .legacy_irqs = true, .num_irqs = 192, + .irq_mask = APPLE_SPMI_GEN1_IRQ_MASK, + .irq_ack = APPLE_SPMI_GEN1_IRQ_ACK, }; static const struct apple_spmi_hw apple_spmi_gen4 = { @@ -103,6 +107,9 @@ static const struct apple_spmi_hw apple_spmi_gen4 = { .command = 0x210, .reply = 0x220, .rx_empty = BIT(30), + .num_irqs = 256, + .irq_mask = APPLE_SPMI_GEN4_IRQ_MASK, + .irq_ack = APPLE_SPMI_GEN4_IRQ_ACK, }; struct apple_spmi { @@ -125,23 +132,26 @@ struct apple_spmi { static void apple_spmi_irq_ack_raw(struct apple_spmi *spmi, u32 irq) { - u32 __iomem *reg = spmi->regs + SPMI_IRQ_ACK_BASE + (irq / 32) * 4; + u32 __iomem *reg = spmi->regs + spmi->hw->irq_ack + (irq / 32) * 4; writel(BIT(irq % 32), reg); } static void apple_spmi_irq_mask_raw(struct apple_spmi *spmi, u32 irq) { - u32 __iomem *reg = spmi->regs + SPMI_IRQ_MASK_BASE + (irq / 32) * 4; + u32 __iomem *reg = spmi->regs + spmi->hw->irq_mask + (irq / 32) * 4; - writel(readl(reg) & ~BIT(irq % 32), reg); + /* Generation 4 has no mask bank found: sources are masked in irq_mask_cache only. */ + if (spmi->hw->irq_mask) + writel(readl(reg) & ~BIT(irq % 32), reg); } static void apple_spmi_irq_unmask_raw(struct apple_spmi *spmi, u32 irq) { - u32 __iomem *reg = spmi->regs + SPMI_IRQ_MASK_BASE + (irq / 32) * 4; + u32 __iomem *reg = spmi->regs + spmi->hw->irq_mask + (irq / 32) * 4; - writel(readl(reg) | BIT(irq % 32), reg); + if (spmi->hw->irq_mask) + writel(readl(reg) | BIT(irq % 32), reg); } static void apple_spmi_irq_ack(struct irq_data *d) @@ -181,8 +191,8 @@ static inline u32 apple_spmi_pack_cmd(u8 opc, u8 sid, u16 param) /* Ack the fault interrupt, then pop and log every queued fault record */ static void apple_spmi_drain_faults(struct device *dev, struct apple_spmi *spmi) { - void __iomem *ack = spmi->regs + SPMI_GEN4_IRQ_ACK_BASE + (SPMI_GEN4_FAULT_IRQ / 32) * 4; - u32 bit = BIT(SPMI_GEN4_FAULT_IRQ % 32), fault; + void __iomem *ack = spmi->regs + APPLE_SPMI_GEN4_IRQ_ACK + (APPLE_SPMI_GEN4_FAULT_IRQ / 32) * 4; + u32 bit = BIT(APPLE_SPMI_GEN4_FAULT_IRQ % 32), fault; int i; if (!spmi->faults) @@ -513,7 +523,7 @@ static void apple_spmi_irq_handler(struct irq_desc *desc) unsigned long val, offset, bit; chained_irq_enter(chip, desc); - val = readl(spmi->regs + SPMI_IRQ_ACK_BASE + (notify / 32) * 4); + val = readl(spmi->regs + spmi->hw->irq_ack + (notify / 32) * 4); raw_pending |= !!val; if (val & BIT(notify % 32)) { apple_spmi_irq_ack_raw(spmi, notify); @@ -522,14 +532,14 @@ static void apple_spmi_irq_handler(struct irq_desc *desc) } /* Other queues' responses, such as the sleep's own commands at the debug link's cut. */ if (val & ~BIT(notify % 32)) { - writel(val & ~BIT(notify % 32), spmi->regs + SPMI_IRQ_ACK_BASE + (notify / 32) * 4); + writel(val & ~BIT(notify % 32), spmi->regs + spmi->hw->irq_ack + (notify / 32) * 4); handled = true; } for (offset = 0; offset < notify / 8; offset += sizeof(val)) { unsigned long stray; - val = readq(spmi->regs + SPMI_IRQ_ACK_BASE + offset); + val = readq(spmi->regs + spmi->hw->irq_ack + offset); raw_pending |= !!val; /* * After a real sleep, sources no driver uses come up pending (on the Neo the @@ -540,8 +550,8 @@ static void apple_spmi_irq_handler(struct irq_desc *desc) */ stray = val & ~spmi->irq_used[offset / sizeof(val)]; if (stray) { - writel(lower_32_bits(stray), spmi->regs + SPMI_IRQ_ACK_BASE + offset); - writel(upper_32_bits(stray), spmi->regs + SPMI_IRQ_ACK_BASE + offset + 4); + writel(lower_32_bits(stray), spmi->regs + spmi->hw->irq_ack + offset); + writel(upper_32_bits(stray), spmi->regs + spmi->hw->irq_ack + offset + 4); handled = true; } if (val & spmi->irq_used[offset / sizeof(val)] & @@ -571,7 +581,7 @@ static void apple_spmi_irq_handler(struct irq_desc *desc) * unmasked, or it fires again for what was just cleared. */ if (handled) - readl(spmi->regs + SPMI_IRQ_ACK_BASE); + readl(spmi->regs + spmi->hw->irq_ack); chained_irq_exit(chip, desc); } @@ -580,7 +590,8 @@ static void apple_spmi_teardown_irq(void *data) struct apple_spmi *spmi = data; for (size_t offset = 0; offset < (spmi->hw->num_irqs + 32) / 8; offset += 4) - writel(0, spmi->regs + SPMI_IRQ_MASK_BASE + offset); + if (spmi->hw->irq_mask) + writel(0, spmi->regs + spmi->hw->irq_mask + offset); synchronize_irq(spmi->irq); irq_set_chained_handler_and_data(spmi->irq, NULL, NULL); @@ -600,8 +611,9 @@ static int apple_spmi_init_irq(struct platform_device *pdev, raw_spin_lock_init(&spmi->irq_mask_lock); for (size_t offset = 0; offset < (spmi->hw->num_irqs + 32) / 8; offset += 4) { - writel(0, spmi->regs + SPMI_IRQ_MASK_BASE + offset); - writel(U32_MAX, spmi->regs + SPMI_IRQ_ACK_BASE + offset); + if (spmi->hw->irq_mask) + writel(0, spmi->regs + spmi->hw->irq_mask + offset); + writel(U32_MAX, spmi->regs + spmi->hw->irq_ack + offset); } spmi->irqd = devm_irq_domain_instantiate(&pdev->dev, &info); @@ -613,8 +625,10 @@ static int apple_spmi_init_irq(struct platform_device *pdev, return ret; irq_set_chained_handler_and_data(spmi->irq, apple_spmi_irq_handler, spmi); - apple_spmi_irq_unmask_raw(spmi, spmi->hw->num_irqs); - spmi->notify_irq = true; + if (spmi->hw->legacy_irqs) { + apple_spmi_irq_unmask_raw(spmi, spmi->hw->num_irqs); + spmi->notify_irq = true; + } return 0; } @@ -662,7 +676,7 @@ static int apple_spmi_resume_noirq(struct device *dev) if (pm_resume_via_firmware()) { bitmap_to_arr32(words, spmi->irq_mask_cache, spmi->hw->num_irqs); for (i = 0; i < spmi->hw->num_irqs / 32; i++) - writel(words[i], spmi->regs + SPMI_IRQ_MASK_BASE + i * 4); + writel(words[i], spmi->regs + spmi->hw->irq_mask + i * 4); } apple_spmi_irq_ack_raw(spmi, spmi->hw->num_irqs); apple_spmi_irq_unmask_raw(spmi, spmi->hw->num_irqs); @@ -715,9 +729,6 @@ static int apple_spmi_probe(struct platform_device *pdev) if (spmi->irq < 0 && spmi->irq != -ENXIO) return spmi->irq; if (spmi->irq >= 0) { - if (!spmi->hw->legacy_irqs) - return dev_err_probe(&pdev->dev, -EOPNOTSUPP, - "Generation 4 interrupt layout is not supported\n"); ret = apple_spmi_init_irq(pdev, spmi, spmi->irq); if (ret) return ret; diff --git a/drivers/spmi/spmi-apple-irq-host-test.c b/drivers/spmi/spmi-apple-irq-host-test.c new file mode 100644 index 0000000000000..89dbbacfedfb2 --- /dev/null +++ b/drivers/spmi/spmi-apple-irq-host-test.c @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Host check for the Apple SPMI interrupt register layout (not built by kbuild): + * cc -Wall -Werror -o /tmp/spmi-irq-test drivers/spmi/spmi-apple-irq-host-test.c && /tmp/spmi-irq-test + * + * The expected values are the layouts measured on hardware or traced from macOS: + * generation 1 (T8103/T6000): mask words from 0x20, ack/pending words from 0x60; + * generation 4 (T8142/T6050): ack/pending words from 0x600, source n in bit n % 32 + * of word n / 32, the controller's fault source 263 acked at 0x620 bit 7. + */ +#include +#include +#include + +typedef uint32_t u32; +#define BIT(n) (1U << (n)) + +#include "spmi-apple-irq.h" + +int main(void) +{ + /* generation 1 */ + assert(apple_spmi_irq_reg(APPLE_SPMI_GEN1_IRQ_MASK, 3) == 0x20); + assert(apple_spmi_irq_reg(APPLE_SPMI_GEN1_IRQ_ACK, 3) == 0x60); + assert(apple_spmi_irq_reg(APPLE_SPMI_GEN1_IRQ_ACK, 40) == 0x64); + assert(apple_spmi_irq_bit(40) == BIT(8)); + + /* generation 4: the PMU alarm source seen on K114c, the hpm2 wake bit macOS acks, the fault source */ + assert(apple_spmi_irq_reg(APPLE_SPMI_GEN4_IRQ_ACK, 2) == 0x600); + assert(apple_spmi_irq_bit(2) == BIT(2)); + assert(apple_spmi_irq_reg(APPLE_SPMI_GEN4_IRQ_ACK, 19) == 0x600); + assert(apple_spmi_irq_bit(19) == BIT(19)); + assert(apple_spmi_irq_reg(APPLE_SPMI_GEN4_IRQ_ACK, APPLE_SPMI_GEN4_FAULT_IRQ) == 0x620); + assert(apple_spmi_irq_bit(APPLE_SPMI_GEN4_FAULT_IRQ) == BIT(7)); + /* no hardware mask bank for gen 4 */ + assert(APPLE_SPMI_GEN4_IRQ_MASK == 0); + /* the last peripheral source is in word 7 */ + assert(apple_spmi_irq_reg(APPLE_SPMI_GEN4_IRQ_ACK, 255) == 0x61c); + + puts("spmi-apple-irq host check: ok"); + return 0; +} diff --git a/drivers/spmi/spmi-apple-irq.h b/drivers/spmi/spmi-apple-irq.h new file mode 100644 index 0000000000000..dce85d2d65ae2 --- /dev/null +++ b/drivers/spmi/spmi-apple-irq.h @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Apple SPMI controller interrupt register layout, shared with the host check + * (spmi-apple-irq-host-test.c). + * + * Peripheral sources 0..255 come first, then the RX FIFO notification (256) and + * the controller's own fault sources. Source n sits in bit n % 32 of word n / 32 + * of both the mask bank and the ack/pending bank. + */ +#ifndef _SPMI_APPLE_IRQ_H +#define _SPMI_APPLE_IRQ_H + +/* Generation 1 (T8103, T6000) */ +#define APPLE_SPMI_GEN1_IRQ_MASK 0x20 +#define APPLE_SPMI_GEN1_IRQ_ACK 0x60 + +/* + * Generation 4 (T8142, T6050): ack and pending words from 0x600, the fault source + * 263 acked at 0x620 bit 7 (traced from macOS under the hypervisor). The mask bank + * is not found; see APPLE_SPMI_GEN4_IRQ_MASK. + */ +#define APPLE_SPMI_GEN4_IRQ_ACK 0x600 +#define APPLE_SPMI_GEN4_FAULT_IRQ (256 + 7) +/* No mask bank found by toggling every word in 0x20..0x7f and 0x500..0x6ff (K114c): 0 = soft mask only */ +#define APPLE_SPMI_GEN4_IRQ_MASK 0 + +static inline u32 apple_spmi_irq_reg(u32 base, u32 irq) +{ + return base + (irq / 32) * 4; +} + +static inline u32 apple_spmi_irq_bit(u32 irq) +{ + return BIT(irq % 32); +} + +#endif /* _SPMI_APPLE_IRQ_H */ From 47a85b996907e5f57f2ed1b4e42cd00b2355ba61 Mon Sep 17 00:00:00 2001 From: Joshua Warren <816217+joshuaswarren@users.noreply.github.com> Date: Fri, 13 Nov 2026 01:23:27 +0000 Subject: [PATCH 02/31] spmi: apple: use the generation 4 mask bank at +0x400 Probe on K114c: +0x400..0x41c toggle and restore (8 words), +0x420 does not, matching the +0x600 ack bank 0x200 above (Dj, seq 713, from write offsets in a macOS trace). The alarm latches +0x600 bit 2 once the PMIC alarm mask byte 0x200e is 0 (as rtc-macsmc writes it) and a write of 4 to +0x600 clears it (measured). Whether the +0x400 bit gates the AIC line is not measured. Drop the cache-only masking for gen 4. On a firmware resume re-apply the runtime mask, since a firmware sleep entry writes the mask bank itself. Host check extended; compile only, not booted. Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com> --- drivers/spmi/spmi-apple-controller.c | 24 ++++++++++++++---------- drivers/spmi/spmi-apple-irq-host-test.c | 7 +++++-- drivers/spmi/spmi-apple-irq.h | 6 +++--- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/drivers/spmi/spmi-apple-controller.c b/drivers/spmi/spmi-apple-controller.c index 7ecbf636dc16e..a7f2e1b32d7ba 100644 --- a/drivers/spmi/spmi-apple-controller.c +++ b/drivers/spmi/spmi-apple-controller.c @@ -141,17 +141,14 @@ static void apple_spmi_irq_mask_raw(struct apple_spmi *spmi, u32 irq) { u32 __iomem *reg = spmi->regs + spmi->hw->irq_mask + (irq / 32) * 4; - /* Generation 4 has no mask bank found: sources are masked in irq_mask_cache only. */ - if (spmi->hw->irq_mask) - writel(readl(reg) & ~BIT(irq % 32), reg); + writel(readl(reg) & ~BIT(irq % 32), reg); } static void apple_spmi_irq_unmask_raw(struct apple_spmi *spmi, u32 irq) { u32 __iomem *reg = spmi->regs + spmi->hw->irq_mask + (irq / 32) * 4; - if (spmi->hw->irq_mask) - writel(readl(reg) | BIT(irq % 32), reg); + writel(readl(reg) | BIT(irq % 32), reg); } static void apple_spmi_irq_ack(struct irq_data *d) @@ -590,8 +587,7 @@ static void apple_spmi_teardown_irq(void *data) struct apple_spmi *spmi = data; for (size_t offset = 0; offset < (spmi->hw->num_irqs + 32) / 8; offset += 4) - if (spmi->hw->irq_mask) - writel(0, spmi->regs + spmi->hw->irq_mask + offset); + writel(0, spmi->regs + spmi->hw->irq_mask + offset); synchronize_irq(spmi->irq); irq_set_chained_handler_and_data(spmi->irq, NULL, NULL); @@ -611,8 +607,7 @@ static int apple_spmi_init_irq(struct platform_device *pdev, raw_spin_lock_init(&spmi->irq_mask_lock); for (size_t offset = 0; offset < (spmi->hw->num_irqs + 32) / 8; offset += 4) { - if (spmi->hw->irq_mask) - writel(0, spmi->regs + spmi->hw->irq_mask + offset); + writel(0, spmi->regs + spmi->hw->irq_mask + offset); writel(U32_MAX, spmi->regs + spmi->hw->irq_ack + offset); } @@ -667,8 +662,17 @@ static int apple_spmi_resume_noirq(struct device *dev) unsigned long flags; size_t i; - if (!spmi->notify_parked) + if (!spmi->notify_parked) { + /* Gen 4 never parks the notification, but a firmware sleep entry writes the mask bank itself. */ + if (spmi->hw->legacy_irqs || !spmi->irqd || !pm_resume_via_firmware()) + return 0; + raw_spin_lock_irqsave(&spmi->irq_mask_lock, flags); + bitmap_to_arr32(words, spmi->irq_mask_cache, spmi->hw->num_irqs); + for (i = 0; i < spmi->hw->num_irqs / 32; i++) + writel(words[i], spmi->regs + spmi->hw->irq_mask + i * 4); + raw_spin_unlock_irqrestore(&spmi->irq_mask_lock, flags); return 0; + } guard(mutex)(&spmi->fifo_lock); raw_spin_lock_irqsave(&spmi->irq_mask_lock, flags); diff --git a/drivers/spmi/spmi-apple-irq-host-test.c b/drivers/spmi/spmi-apple-irq-host-test.c index 89dbbacfedfb2..5ab780d73bc05 100644 --- a/drivers/spmi/spmi-apple-irq-host-test.c +++ b/drivers/spmi/spmi-apple-irq-host-test.c @@ -32,8 +32,11 @@ int main(void) assert(apple_spmi_irq_bit(19) == BIT(19)); assert(apple_spmi_irq_reg(APPLE_SPMI_GEN4_IRQ_ACK, APPLE_SPMI_GEN4_FAULT_IRQ) == 0x620); assert(apple_spmi_irq_bit(APPLE_SPMI_GEN4_FAULT_IRQ) == BIT(7)); - /* no hardware mask bank for gen 4 */ - assert(APPLE_SPMI_GEN4_IRQ_MASK == 0); + /* gen 4 mask bank (measured on K114c, Dj's HV trace writes +0x420), mirrors the ack bank */ + assert(APPLE_SPMI_GEN4_IRQ_MASK == 0x400); + assert(apple_spmi_irq_reg(APPLE_SPMI_GEN4_IRQ_MASK, 2) == 0x400); + assert(apple_spmi_irq_reg(APPLE_SPMI_GEN4_IRQ_MASK, 263) == 0x420); + assert(APPLE_SPMI_GEN4_IRQ_ACK - APPLE_SPMI_GEN4_IRQ_MASK == 0x200); /* the last peripheral source is in word 7 */ assert(apple_spmi_irq_reg(APPLE_SPMI_GEN4_IRQ_ACK, 255) == 0x61c); diff --git a/drivers/spmi/spmi-apple-irq.h b/drivers/spmi/spmi-apple-irq.h index dce85d2d65ae2..d43dfa1c606cb 100644 --- a/drivers/spmi/spmi-apple-irq.h +++ b/drivers/spmi/spmi-apple-irq.h @@ -17,12 +17,12 @@ /* * Generation 4 (T8142, T6050): ack and pending words from 0x600, the fault source * 263 acked at 0x620 bit 7 (traced from macOS under the hypervisor). The mask bank - * is not found; see APPLE_SPMI_GEN4_IRQ_MASK. + * is at 0x400 (see APPLE_SPMI_GEN4_IRQ_MASK). */ #define APPLE_SPMI_GEN4_IRQ_ACK 0x600 #define APPLE_SPMI_GEN4_FAULT_IRQ (256 + 7) -/* No mask bank found by toggling every word in 0x20..0x7f and 0x500..0x6ff (K114c): 0 = soft mask only */ -#define APPLE_SPMI_GEN4_IRQ_MASK 0 +/* Mask bank mirrors the ack bank 0x200 below; +0x400..0x41c toggle on K114c, +0x420 does not. */ +#define APPLE_SPMI_GEN4_IRQ_MASK 0x400 static inline u32 apple_spmi_irq_reg(u32 base, u32 irq) { From 217257994425530a5c1d18069b6cea64ee2ac158 Mon Sep 17 00:00:00 2001 From: Joshua Warren <816217+joshuaswarren@users.noreply.github.com> Date: Thu, 19 Nov 2026 12:07:56 -0600 Subject: [PATCH 03/31] spmi: apple: read the fault queue before the shared ack, limit gen4 mask writes Both open code points from review: The controller's fault source (263, word 0x620 bit 7 on gen4) shares its ack word with the notification word the handler reads first, and the stray-source path acked it directly: queued fault records were lost. Drain the queue before the bit is acked, in both the notification-word path and the readq stray path. gen4 has no notification source, and the word at +0x420 does not behave as a mask bank, so the init and teardown loops now write only the num_irqs / 32 mask words on gen4 (the legacy controllers keep the extra notification word). The host-test file is dropped: kbuild never built it and it checked constants against themselves. Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com> --- drivers/spmi/spmi-apple-controller.c | 27 +++++++++++++-- drivers/spmi/spmi-apple-irq-host-test.c | 45 ------------------------- drivers/spmi/spmi-apple-irq.h | 3 +- 3 files changed, 26 insertions(+), 49 deletions(-) delete mode 100644 drivers/spmi/spmi-apple-irq-host-test.c diff --git a/drivers/spmi/spmi-apple-controller.c b/drivers/spmi/spmi-apple-controller.c index a7f2e1b32d7ba..1237ac856ac55 100644 --- a/drivers/spmi/spmi-apple-controller.c +++ b/drivers/spmi/spmi-apple-controller.c @@ -116,6 +116,7 @@ struct apple_spmi { void __iomem *regs; void __iomem *faults; unsigned int nfaults; + struct device *dev; const struct apple_spmi_hw *hw; struct mutex fifo_lock; struct completion fifo_rx; @@ -521,6 +522,17 @@ static void apple_spmi_irq_handler(struct irq_desc *desc) chained_irq_enter(chip, desc); val = readl(spmi->regs + spmi->hw->irq_ack + (notify / 32) * 4); + /* + * On gen4 the controller's own fault source shares this last ack word + * (0x620, bit 7). Its queued records must be read before the source is + * acked, or drain_faults() never sees them. + */ + if (!spmi->hw->legacy_irqs && spmi->faults && + (val & BIT(APPLE_SPMI_GEN4_FAULT_IRQ % 32))) { + apple_spmi_drain_faults(spmi->dev, spmi); + val &= ~BIT(APPLE_SPMI_GEN4_FAULT_IRQ % 32); + handled = true; + } raw_pending |= !!val; if (val & BIT(notify % 32)) { apple_spmi_irq_ack_raw(spmi, notify); @@ -546,6 +558,14 @@ static void apple_spmi_irq_handler(struct irq_desc *desc) * pending for its unmask: it isn't a bad interrupt either. */ stray = val & ~spmi->irq_used[offset / sizeof(val)]; + if (stray && !spmi->hw->legacy_irqs && spmi->faults && + offset == (APPLE_SPMI_GEN4_FAULT_IRQ / 32) * sizeof(val) && + (stray & BIT(APPLE_SPMI_GEN4_FAULT_IRQ % 32))) { + /* Same rule as above: read the queued records first. */ + apple_spmi_drain_faults(spmi->dev, spmi); + stray &= ~BIT(APPLE_SPMI_GEN4_FAULT_IRQ % 32); + handled = true; + } if (stray) { writel(lower_32_bits(stray), spmi->regs + spmi->hw->irq_ack + offset); writel(upper_32_bits(stray), spmi->regs + spmi->hw->irq_ack + offset + 4); @@ -586,7 +606,8 @@ static void apple_spmi_teardown_irq(void *data) { struct apple_spmi *spmi = data; - for (size_t offset = 0; offset < (spmi->hw->num_irqs + 32) / 8; offset += 4) + for (size_t offset = 0; offset < spmi->hw->num_irqs / 8 + (spmi->hw->legacy_irqs ? 4 : 0); + offset += 4) writel(0, spmi->regs + spmi->hw->irq_mask + offset); synchronize_irq(spmi->irq); @@ -606,7 +627,8 @@ static int apple_spmi_init_irq(struct platform_device *pdev, raw_spin_lock_init(&spmi->irq_mask_lock); - for (size_t offset = 0; offset < (spmi->hw->num_irqs + 32) / 8; offset += 4) { + for (size_t offset = 0; offset < spmi->hw->num_irqs / 8 + (spmi->hw->legacy_irqs ? 4 : 0); + offset += 4) { writel(0, spmi->regs + spmi->hw->irq_mask + offset); writel(U32_MAX, spmi->regs + spmi->hw->irq_ack + offset); } @@ -705,6 +727,7 @@ static int apple_spmi_probe(struct platform_device *pdev) return -ENOMEM; spmi = spmi_controller_get_drvdata(ctrl); + spmi->dev = &pdev->dev; spmi->hw = device_get_match_data(&pdev->dev); if (!spmi->hw) return -EINVAL; diff --git a/drivers/spmi/spmi-apple-irq-host-test.c b/drivers/spmi/spmi-apple-irq-host-test.c deleted file mode 100644 index 5ab780d73bc05..0000000000000 --- a/drivers/spmi/spmi-apple-irq-host-test.c +++ /dev/null @@ -1,45 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * Host check for the Apple SPMI interrupt register layout (not built by kbuild): - * cc -Wall -Werror -o /tmp/spmi-irq-test drivers/spmi/spmi-apple-irq-host-test.c && /tmp/spmi-irq-test - * - * The expected values are the layouts measured on hardware or traced from macOS: - * generation 1 (T8103/T6000): mask words from 0x20, ack/pending words from 0x60; - * generation 4 (T8142/T6050): ack/pending words from 0x600, source n in bit n % 32 - * of word n / 32, the controller's fault source 263 acked at 0x620 bit 7. - */ -#include -#include -#include - -typedef uint32_t u32; -#define BIT(n) (1U << (n)) - -#include "spmi-apple-irq.h" - -int main(void) -{ - /* generation 1 */ - assert(apple_spmi_irq_reg(APPLE_SPMI_GEN1_IRQ_MASK, 3) == 0x20); - assert(apple_spmi_irq_reg(APPLE_SPMI_GEN1_IRQ_ACK, 3) == 0x60); - assert(apple_spmi_irq_reg(APPLE_SPMI_GEN1_IRQ_ACK, 40) == 0x64); - assert(apple_spmi_irq_bit(40) == BIT(8)); - - /* generation 4: the PMU alarm source seen on K114c, the hpm2 wake bit macOS acks, the fault source */ - assert(apple_spmi_irq_reg(APPLE_SPMI_GEN4_IRQ_ACK, 2) == 0x600); - assert(apple_spmi_irq_bit(2) == BIT(2)); - assert(apple_spmi_irq_reg(APPLE_SPMI_GEN4_IRQ_ACK, 19) == 0x600); - assert(apple_spmi_irq_bit(19) == BIT(19)); - assert(apple_spmi_irq_reg(APPLE_SPMI_GEN4_IRQ_ACK, APPLE_SPMI_GEN4_FAULT_IRQ) == 0x620); - assert(apple_spmi_irq_bit(APPLE_SPMI_GEN4_FAULT_IRQ) == BIT(7)); - /* gen 4 mask bank (measured on K114c, Dj's HV trace writes +0x420), mirrors the ack bank */ - assert(APPLE_SPMI_GEN4_IRQ_MASK == 0x400); - assert(apple_spmi_irq_reg(APPLE_SPMI_GEN4_IRQ_MASK, 2) == 0x400); - assert(apple_spmi_irq_reg(APPLE_SPMI_GEN4_IRQ_MASK, 263) == 0x420); - assert(APPLE_SPMI_GEN4_IRQ_ACK - APPLE_SPMI_GEN4_IRQ_MASK == 0x200); - /* the last peripheral source is in word 7 */ - assert(apple_spmi_irq_reg(APPLE_SPMI_GEN4_IRQ_ACK, 255) == 0x61c); - - puts("spmi-apple-irq host check: ok"); - return 0; -} diff --git a/drivers/spmi/spmi-apple-irq.h b/drivers/spmi/spmi-apple-irq.h index d43dfa1c606cb..4134ef37ff369 100644 --- a/drivers/spmi/spmi-apple-irq.h +++ b/drivers/spmi/spmi-apple-irq.h @@ -1,7 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0 */ /* - * Apple SPMI controller interrupt register layout, shared with the host check - * (spmi-apple-irq-host-test.c). + * Apple SPMI controller interrupt register layout. * * Peripheral sources 0..255 come first, then the RX FIFO notification (256) and * the controller's own fault sources. Source n sits in bit n % 32 of word n / 32 From 7297cb87900409735bd095d12085419db920ec3e Mon Sep 17 00:00:00 2001 From: Joshua Warren <816217+joshuaswarren@users.noreply.github.com> Date: Thu, 19 Nov 2026 18:27:53 -0600 Subject: [PATCH 04/31] spmi: apple: drop the unreachable fault drain in the stray-queue loop The stray-queue loop visits ack words 0 to 3 (bytes 0 to 24), while the gen4 fault source lives in word 8 (0x620), which the chained handler already reads and drains before acking. The hunk also compared a word index against byte offsets. It could never fire; remove it. Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com> --- drivers/spmi/spmi-apple-controller.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/spmi/spmi-apple-controller.c b/drivers/spmi/spmi-apple-controller.c index 1237ac856ac55..bdabe697859b1 100644 --- a/drivers/spmi/spmi-apple-controller.c +++ b/drivers/spmi/spmi-apple-controller.c @@ -558,14 +558,6 @@ static void apple_spmi_irq_handler(struct irq_desc *desc) * pending for its unmask: it isn't a bad interrupt either. */ stray = val & ~spmi->irq_used[offset / sizeof(val)]; - if (stray && !spmi->hw->legacy_irqs && spmi->faults && - offset == (APPLE_SPMI_GEN4_FAULT_IRQ / 32) * sizeof(val) && - (stray & BIT(APPLE_SPMI_GEN4_FAULT_IRQ % 32))) { - /* Same rule as above: read the queued records first. */ - apple_spmi_drain_faults(spmi->dev, spmi); - stray &= ~BIT(APPLE_SPMI_GEN4_FAULT_IRQ % 32); - handled = true; - } if (stray) { writel(lower_32_bits(stray), spmi->regs + spmi->hw->irq_ack + offset); writel(upper_32_bits(stray), spmi->regs + spmi->hw->irq_ack + offset + 4); From c805637e0cf8ca95caa1a275a09e717ec636458a Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Thu, 19 Nov 2026 23:50:54 +0100 Subject: [PATCH 05/31] dt-bindings: usb: apple,sn201202x: add the T8152 controllers The USB-C PD controllers behind the J873g's (T8152) SPMI controller at 0x308908000 answer as the T8132 ones do: no register-selection interrupt, so a selection is polled, and the payload length of the selected register is read from register 0x1f. Their event, sleep and wake sources are interrupts 11/17/19, 37/43/45 and 63/69/71 of that controller. Add apple,t8152-sn201202x with apple,t8132-sn201202x as fallback, so that the T8132 interrupt layout (irq, sleep, wake) applies. Signed-off-by: Thomas Glanzmann --- .../devicetree/bindings/usb/apple,sn201202x.yaml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/usb/apple,sn201202x.yaml b/Documentation/devicetree/bindings/usb/apple,sn201202x.yaml index cc82767a25a51..84ae1f7bf0880 100644 --- a/Documentation/devicetree/bindings/usb/apple,sn201202x.yaml +++ b/Documentation/devicetree/bindings/usb/apple,sn201202x.yaml @@ -18,7 +18,9 @@ description: | The controller can be polled when interrupt resources are not supplied. T8132 omits the register-selection interrupt, so selection is polled while - event, standby and wakeup notifications use interrupts. + event, standby and wakeup notifications use interrupts. The T8152 + controllers work as the T8132 ones do: no register-selection interrupt, and + the payload length of a selected register in register 0x1f. properties: compatible: @@ -27,6 +29,10 @@ properties: - items: - const: apple,t8132-sn201202x - const: apple,sn201202x + - items: + - const: apple,t8152-sn201202x + - const: apple,t8132-sn201202x + - const: apple,sn201202x reg: maxItems: 1 From bdb6c539491f308c09e85aa2c1c9e368487cf6cb Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Thu, 19 Nov 2026 23:52:00 +0100 Subject: [PATCH 06/31] dt-bindings: display: apple,t8152-dcp-iboot: describe the USB-C ports as Type-C mode switches A T8152 DCP drives the rear USB-C port whose PD controller reports a DisplayPort sink. So far the DCP read the controllers itself, through apple,usb-pd. The controllers belong to the USB Type-C port driver instead, which passes the DisplayPort alt mode state of a port to the Type-C mode switches its connector's graph leads to. Describe one display switch per port, shared by the DCPs: the port's usb-c node in the shared ports node (the one apple,usb-c-ports refers to) is the mode switch, with an endpoint at the display port (port@3) of the port's usb-c-connector. The DCPs already share these nodes for the port's PHY registers and tunables, and each port has one owner at a time. One switch per DCP instead would fill the three mode switches a connector's port driver looks at (fwnode_typec_mux_get() collects the matches into a three-entry array and stops at the third endpoint without an error), and leave out the port's ATC PHY, which needs one for USB4. Drop apple,usb-pd, which nothing reads any more. Signed-off-by: Thomas Glanzmann --- .../display/apple,t8152-dcp-iboot.yaml | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/Documentation/devicetree/bindings/display/apple,t8152-dcp-iboot.yaml b/Documentation/devicetree/bindings/display/apple,t8152-dcp-iboot.yaml index 6fbdaba2d17a4..cc7ea1045a323 100644 --- a/Documentation/devicetree/bindings/display/apple,t8152-dcp-iboot.yaml +++ b/Documentation/devicetree/bindings/display/apple,t8152-dcp-iboot.yaml @@ -169,12 +169,6 @@ properties: The converter drives the HDMI hot-plug detect line only while it is powered. - apple,usb-pd: - $ref: /schemas/types.yaml#/definitions/phandle - description: - The USB-C port's PD controller (SPMI), polled for the DisplayPort alt - mode connection and the plug orientation. - hpd-gpios: maxItems: 1 description: @@ -243,20 +237,30 @@ patternProperties: apple,dfp-endpoint: $ref: /schemas/types.yaml#/definitions/uint32 description: The ATC's display-crossbar0 DFP endpoint (ATC instance). - apple,usb-pd: - $ref: /schemas/types.yaml#/definitions/phandle - description: The port's PD controller (SPMI). apple,tunable-pre: $ref: /schemas/types.yaml#/definitions/uint32-matrix description: As the node's apple,tunable-pre, for this port's PHY. apple,tunable-post: $ref: /schemas/types.yaml#/definitions/uint32-matrix description: As the node's apple,tunable-post, for this port's PHY. + mode-switch: + type: boolean + description: + The port's display switch, one per port and shared by all DCPs + that can drive it. The port controller sets the port's + DisplayPort alt mode state, pin assignment and HPD on it; the plug + orientation is the Type-C port's. + port: + $ref: /schemas/graph.yaml#/properties/port + description: + Connects to the display port (port@3) of the port's + usb-c-connector. + dependencies: + mode-switch: [ port ] required: - reg - reg-names - apple,dfp-endpoint - - apple,usb-pd required: - compatible @@ -311,7 +315,13 @@ examples: <0x3 0x03a13a00 0x0 0xc0>; reg-names = "atc", "atc-ps", "atc-psd"; apple,dfp-endpoint = <3>; - apple,usb-pd = <&hpm3>; + mode-switch; + + port { + endpoint { + remote-endpoint = <&typec3_display>; + }; + }; }; }; }; From 6cf0ccf5aab2f2bd96970d59f51cf593d2d8a152 Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Thu, 19 Nov 2026 23:56:10 +0100 Subject: [PATCH 07/31] drm/apple: take the T8152 USB-C display state from the Type-C ports The T8152 DCPs found a USB-C display by reading the rear ports' PD controllers over SPMI every 250 ms (t8152_pd.c): plug and orientation from STATUS (0x1a), DisplayPort connection, pin assignment and HPD from DATA_STATUS (0x5f), through the controllers' register window (select at 0x00, length at 0x1f, data from 0x20). With tipd bound to the same controllers, tipd failed to read its events while the display path polled. The controllers belong to tipd now. Take the state from the Type-C class instead: one Type-C mode switch per rear port, the port's usb-c node in the shared ports node, with an endpoint at the display port of the port's connector. tipd sets the port's mode on it. The switch records whether the port is in DisplayPort alt mode with HPD high, the lanes of the pin assignment (two for B, D and F, which share the cable with USB 3) and the plug orientation of the Type-C port, once, next to the port claims of t8152_atc.c, and tells every DCP that drives USB-C to look at the ports. The port claim and the PHY, crossbar and DPTX handling of t8152_atc.c and iboot_drm.c stay as they were. One switch per port, not one per DCP: a connector's port driver takes three mode switches at most (TYPEC_MUX_MAX_DEVS; fwnode_connection_find_matches() stops at the third endpoint and returns success). A switch per DCP would fill all three on every J873g rear connector, and the port's ATC PHY, which needs one for USB4, would never be called. A HPD pulse is not a new sink. Without a video stream, an EV2780 drops HPD for about 160 ms every 4.7 s; the PD controller reports it after the fact, and tipd passes it on as HPD low and then high. Connecting the sink anew on each pulse kept its link from coming up (link faults, one lane, then a standby link trained at RBR whose mode list lacked the enabled mode, so the next DPMS on failed atomic check). The 250 ms poll never saw these pulses. A switch event is looked at 100 ms later, which takes such a low and high together, and only a changed plug (orientation, lanes) or a sink that leaves DP alt mode with its partner is a new connection. dcp-fabric.c's route layer itself does not fit these DCPs: it switches a DP PHY and the display crossbar through their drivers and connects the sink through the DCP's IOMFB DPTX service, while the iBoot interface DCPs program the ATC PHY and the crossbar themselves and connect through their own DPTX port service. Their switches only record the state, in t8152_typec.c. The 250 ms work now only re-arms while a DCP can take the shared HDMI port, whose HPD line has no interrupt. The PD controller reset that made a sink which stopped answering AUX enter DP alt mode again (a cold reset, "Gaid", then system power state S0, "SSPS") is gone: the controller is tipd's, and tipd puts it into S0 whenever it sets the controller up. What remains is the DisplayPort side, at most once a minute: release the link and connect the port's sink again. HPD changes now reach the display path as they happen. The first DCP that probes registers the switches, ahead of everything else in its probe, and they stay until the driver is unloaded: tipd keeps the switch it found, and must not wait for a DCP that cannot start. Their parent is a faux device of their own ("t8152-typec"), not that DCP, so unbinding a DCP leaves no switch under an unbound device. A switch that cannot be registered is disabled in the live tree, so that tipd goes on without it; the driver keeps that changeset and reverts it at unload. Signed-off-by: Thomas Glanzmann --- drivers/gpu/drm/apple/Kconfig | 5 +- drivers/gpu/drm/apple/Makefile | 2 +- drivers/gpu/drm/apple/dcp.c | 6 +- drivers/gpu/drm/apple/iboot_drm.c | 77 +++++--- drivers/gpu/drm/apple/iomfb_iboot.c | 11 +- drivers/gpu/drm/apple/iomfb_iboot.h | 13 +- drivers/gpu/drm/apple/t8152_atc.c | 15 +- drivers/gpu/drm/apple/t8152_display.h | 31 +-- drivers/gpu/drm/apple/t8152_pd.c | 211 -------------------- drivers/gpu/drm/apple/t8152_typec.c | 264 ++++++++++++++++++++++++++ 10 files changed, 359 insertions(+), 276 deletions(-) delete mode 100644 drivers/gpu/drm/apple/t8152_pd.c create mode 100644 drivers/gpu/drm/apple/t8152_typec.c diff --git a/drivers/gpu/drm/apple/Kconfig b/drivers/gpu/drm/apple/Kconfig index 876ebbd58605e..aae90f8de5825 100644 --- a/drivers/gpu/drm/apple/Kconfig +++ b/drivers/gpu/drm/apple/Kconfig @@ -78,7 +78,7 @@ config DRM_APPLE_DCP_T8132 config DRM_APPLE_DCP_T8152 bool "Mac mini M6 (J873g) displays" depends on DRM_APPLE - depends on SPMI=y || SPMI=DRM_APPLE + depends on TYPEC depends on MFD_MACSMC=y || MFD_MACSMC=DRM_APPLE select APERTURE_HELPERS help @@ -86,7 +86,8 @@ config DRM_APPLE_DCP_T8152 coprocessors of the T8152 Mac mini (J873g) through their firmware's iBoot interface: the HDMI port, whose DisplayPort-to-HDMI converter is powered through the SMC, and displays on the rear USB-C ports, - whose PD controllers are polled over SPMI. + whose DisplayPort alt mode the USB Type-C port driver of their PD + controllers reports (TYPEC_SN201202X). The boot loader hands each coprocessor over, running or quiesced, with the AFK endpoints it left running. The adopted sessions cannot diff --git a/drivers/gpu/drm/apple/Makefile b/drivers/gpu/drm/apple/Makefile index e6752d0f28516..c040f80df8e80 100644 --- a/drivers/gpu/drm/apple/Makefile +++ b/drivers/gpu/drm/apple/Makefile @@ -19,7 +19,7 @@ appledrm-y += iomfb_v26_6_desktop.o appledrm-y += iomfb_v14_7.o iomfb_v14_7_link.o appledrm-$(CONFIG_DRM_APPLE_DCP_T8132) += iomfb_m4.o t8132_ext_drm.o appledrm-$(CONFIG_DRM_APPLE_DCP_T8152) += t8152_atc.o t8152_aux.o t8152_dptx.o -appledrm-$(CONFIG_DRM_APPLE_DCP_T8152) += t8152_hdmi.o t8152_pd.o +appledrm-$(CONFIG_DRM_APPLE_DCP_T8152) += t8152_hdmi.o t8152_typec.o appledrm-$(CONFIG_DRM_APPLE_DCP_T8152) += iomfb_iboot.o iboot_drm.o appledrm-y += iomfb_h17p.o appledrm-$(CONFIG_DRM_APPLE_KUNIT_TEST) += iomfb_h17p_test.o parser_test.o diff --git a/drivers/gpu/drm/apple/dcp.c b/drivers/gpu/drm/apple/dcp.c index 396b62c988ecb..b0b1255045fd5 100644 --- a/drivers/gpu/drm/apple/dcp.c +++ b/drivers/gpu/drm/apple/dcp.c @@ -7938,8 +7938,11 @@ static int dcp_platform_probe(struct platform_device *pdev) void *group; int ret; - if (hw->firmware_compat == DCP_FIRMWARE_IBOOT) + if (hw->firmware_compat == DCP_FIRMWARE_IBOOT) { + /* The port controllers wait for the USB-C display switches. */ + t8152_typec_register(dev); return dcp_platform_probe_iboot(pdev); + } /* t6041_dcpext=0: stay off the external processors' hardware. */ if (of_device_is_compatible(dev->of_node, "apple,t6041-dcpext") && @@ -10249,6 +10252,7 @@ int __init dcp_register(void) void dcp_unregister(void) { platform_driver_unregister(&apple_platform_driver); + t8152_typec_unregister(); } #if IS_ENABLED(CONFIG_DRM_APPLE_DISPLAY_KUNIT_TEST) diff --git a/drivers/gpu/drm/apple/iboot_drm.c b/drivers/gpu/drm/apple/iboot_drm.c index c0b3bd2311962..46b9fae499254 100644 --- a/drivers/gpu/drm/apple/iboot_drm.c +++ b/drivers/gpu/drm/apple/iboot_drm.c @@ -369,10 +369,10 @@ iboot_connector_detect(struct drm_connector *connector, bool force) dev_info(dcp->dev, "sink %s\n", hpd ? "plugged" : "unplugged"); disp->hpd = hpd; /* - * USB-C: the DPTX port's HPD follows the PD controller, and a - * new plug may come the other way round. + * USB-C: the DPTX port's HPD follows the port's Type-C state, + * and a new plug may come the other way round. */ - if (disp->pd) { + if (disp->usbc) { if (!hpd || ib->powered) { iboot_cancel_swap_locked(ib); if (t8152_dptx_disconnect(disp, 0)) @@ -408,11 +408,11 @@ iboot_connector_detect(struct drm_connector *connector, bool force) dev_err(dcp->dev, "no modes from the new sink\n"); ib->nr_tmodes = 0; ib->nr_cmodes = 0; - /* A sleeping EIZO may need a fresh DP alt mode entry. */ - if (disp->pd && !disp->on_hdmi && - time_after(jiffies, ib->pd_reset_time + 60 * HZ)) { - ib->pd_reset_time = jiffies; - schedule_work(&ib->pd_reset_work); + /* A sleeping EIZO may need its link started anew. */ + if (disp->usbc && !disp->on_hdmi && + time_after(jiffies, ib->relink_time + 60 * HZ)) { + ib->relink_time = jiffies; + schedule_work(&ib->relink_work); } } /* @@ -724,16 +724,17 @@ static int iboot_set_mode_locked(struct dcp_iboot *ib, dev_err(ib->dcp->dev, "set_mode failed: %d\n", ret); /* * USB-C: a sink that no longer answers AUX (seen after the - * monitor's deep sleep) comes back with a fresh DP alt mode - * entry; the plug that follows sets the mode again. At most - * once a minute, so a dead sink does not loop. + * monitor's deep sleep) is connected anew: its link is + * released, and the plug that follows starts the PHY cold + * and sets the mode again. At most once a minute, so a dead + * sink does not loop. */ - if (ib->disp.pd && !ib->disp.on_hdmi && - time_after(jiffies, ib->pd_reset_time + 60 * HZ)) { + if (ib->disp.usbc && !ib->disp.on_hdmi && + time_after(jiffies, ib->relink_time + 60 * HZ)) { ib->cur_mode = *t; ib->mode_failed = true; - ib->pd_reset_time = jiffies; - schedule_work(&ib->pd_reset_work); + ib->relink_time = jiffies; + schedule_work(&ib->relink_work); } return ret; } @@ -944,14 +945,18 @@ static const struct drm_mode_config_funcs iboot_mode_config_funcs = { .atomic_commit = drm_atomic_helper_commit, }; -static void iboot_pd_reset_work(struct work_struct *work) +/* + * Release the link of a USB-C sink that does not answer, and have the port's + * sink plugged again: the port's Type-C state still shows it, so the next + * look at the ports connects it as a new one. + */ +static void iboot_relink_work(struct work_struct *work) { - struct dcp_iboot *ib = container_of(work, struct dcp_iboot, pd_reset_work); + struct dcp_iboot *ib = container_of(work, struct dcp_iboot, relink_work); struct t8152_display *disp = &ib->disp; int ret; - dev_info(ib->dcp->dev, "USB-C sink does not answer, entering DP alt mode again\n"); - /* The reset may finish between polls. Release the old link explicitly. */ + dev_info(ib->dcp->dev, "USB-C sink does not answer, connecting it again\n"); mutex_lock(&ib->lock); iboot_cancel_swap_locked(ib); ret = t8152_dptx_disconnect(disp, 0); @@ -968,13 +973,9 @@ static void iboot_pd_reset_work(struct work_struct *work) return; } disp->hpd = 0; - ret = t8152_pd_reconnect(disp); mutex_unlock(&ib->lock); - if (ret) { - dev_err(ib->dcp->dev, "DP alt mode entry failed: %d\n", ret); - return; - } drm_kms_helper_hotplug_event(&ib->drm); + dcp_iboot_hpd_event(ib); } static void iboot_hpd_work(struct work_struct *work) @@ -985,11 +986,27 @@ static void iboot_hpd_work(struct work_struct *work) if (!READ_ONCE(ib->ready)) return; drm_helper_hpd_irq_event(&ib->drm); - if (READ_ONCE(ib->ready)) + /* + * USB-C changes come from the ports' display switches. The HDMI port's + * HPD line has no interrupt: poll it while this DCP can take the port. + */ + if (READ_ONCE(ib->ready) && ib->disp.hdmi_port) queue_delayed_work(system_freezable_wq, &ib->hpd_work, msecs_to_jiffies(250)); } +/* + * A USB-C port's Type-C state changed: look at the ports shortly. A HPD pulse + * the port driver learns of after the fact comes as HPD low and high at once; + * the delay takes both together. + */ +void dcp_iboot_hpd_event(struct dcp_iboot *ib) +{ + if (READ_ONCE(ib->ready)) + mod_delayed_work(system_freezable_wq, &ib->hpd_work, + msecs_to_jiffies(100)); +} + void dcp_iboot_kms_stop(struct dcp_iboot *ib) { if (!ib->kms_work_ready) @@ -998,7 +1015,7 @@ void dcp_iboot_kms_stop(struct dcp_iboot *ib) cancel_delayed_work_sync(&ib->hpd_work); hrtimer_cancel(&ib->swap_timer); cancel_work_sync(&ib->swap_work); - cancel_work_sync(&ib->pd_reset_work); + cancel_work_sync(&ib->relink_work); } static void iboot_swap_stop(void *data) @@ -1014,7 +1031,7 @@ int dcp_iboot_kms_init(struct dcp_iboot *ib) ib->pending = -1; INIT_WORK(&ib->swap_work, iboot_swap_work); - INIT_WORK(&ib->pd_reset_work, iboot_pd_reset_work); + INIT_WORK(&ib->relink_work, iboot_relink_work); INIT_DELAYED_WORK(&ib->hpd_work, iboot_hpd_work); hrtimer_setup(&ib->swap_timer, iboot_swap_timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS); @@ -1031,7 +1048,7 @@ int dcp_iboot_kms_init(struct dcp_iboot *ib) ret = drmm_mode_config_init(drm); if (ret) return ret; - ib->pd_reset_time = jiffies - 61 * HZ; + ib->relink_time = jiffies - 61 * HZ; drm->mode_config.min_width = 320; drm->mode_config.min_height = 240; @@ -1067,10 +1084,10 @@ int dcp_iboot_kms_init(struct dcp_iboot *ib) if (ret) return ret; drm_connector_helper_add(&ib->connector, &iboot_connector_helper); - if (ib->disp.hpd_gpio || ib->disp.pd) + if (ib->disp.hpd_gpio || ib->disp.usbc) ib->connector.polled = DRM_CONNECTOR_POLL_CONNECT | DRM_CONNECTOR_POLL_DISCONNECT; - if (ib->disp.pd) + if (ib->disp.usbc) ib->connector.polled = DRM_CONNECTOR_POLL_HPD; ret = drm_connector_attach_encoder(&ib->connector, &ib->encoder); if (ret) diff --git a/drivers/gpu/drm/apple/iomfb_iboot.c b/drivers/gpu/drm/apple/iomfb_iboot.c index 757b122dc8e42..df308b133a39a 100644 --- a/drivers/gpu/drm/apple/iomfb_iboot.c +++ b/drivers/gpu/drm/apple/iomfb_iboot.c @@ -625,7 +625,7 @@ static int dcp_iboot_start(struct dcp_iboot *ib) &t8152_dptx_port_ops, 2); if (ret) return dev_err_probe(dev, ret, "no DPTX port service\n"); - if (disp->pd) { + if (disp->usbc) { ret = t8152_dptx_disconnect(disp, 0); if (ret) return dev_err_probe(dev, ret, "cannot release inherited DP link\n"); @@ -635,7 +635,7 @@ static int dcp_iboot_start(struct dcp_iboot *ib) * USB-C negotiation can outlive probe or fail while a monitor sleeps. * Register the connector first; the hotplug path owns all USB-C links. */ - if (disp->pd) + if (disp->usbc) sink = false; if (sink) { ret = t8152_dptx_connect(disp, 0); @@ -698,9 +698,9 @@ static int dcp_iboot_start(struct dcp_iboot *ib) if (ret) return ret; WRITE_ONCE(ib->ready, true); - if (disp->hpd_gpio || disp->pd) + if (disp->hpd_gpio || disp->usbc) drmm_kms_helper_poll_init(&ib->drm); - if (disp->pd) + if (disp->usbc) queue_delayed_work(system_freezable_wq, &ib->hpd_work, msecs_to_jiffies(250)); drm_client_setup(&ib->drm, NULL); @@ -801,6 +801,9 @@ int dcp_iboot_probe(struct apple_dcp *dcp) dev_warn(dev, "live session not recorded; its DMA stays allocated\n"); WRITE_ONCE(dcp->retain_dma, true); } + /* The device stays bound from here on: follow the USB-C ports. */ + if (t8152_typec_init(disp)) + dev_err(dev, "USB-C ports not followed, no USB-C display\n"); if (ret) dev_err(dev, "cannot adopt the DCP: %d\n", ret); else diff --git a/drivers/gpu/drm/apple/iomfb_iboot.h b/drivers/gpu/drm/apple/iomfb_iboot.h index 9c2268604b017..bddeeedc198d5 100644 --- a/drivers/gpu/drm/apple/iomfb_iboot.h +++ b/drivers/gpu/drm/apple/iomfb_iboot.h @@ -94,9 +94,9 @@ struct dcp_iboot { bool mode_set; /* SET_MODE of cur_mode failed; the next plug sets it again */ bool mode_failed; - /* USB-C: re-enter DP alt mode when the sink stopped answering */ - struct work_struct pd_reset_work; - unsigned long pd_reset_time; + /* USB-C: connect the sink anew when it stopped answering */ + struct work_struct relink_work; + unsigned long relink_time; /* * The DPAV video interface started: SET_MODE again, or the * firmware's idle power off timer takes the link down 30 s later. @@ -116,6 +116,10 @@ static inline struct dcp_iboot *to_dcp_iboot(struct drm_device *drm) } #if IS_ENABLED(CONFIG_DRM_APPLE_DCP_T8152) +/* t8152_typec.c */ +void t8152_typec_register(struct device *dev); +void t8152_typec_unregister(void); + /* iomfb_iboot.c */ int dcp_iboot_probe(struct apple_dcp *dcp); void dcp_iboot_remove(struct apple_dcp *dcp); @@ -131,7 +135,10 @@ int dcp_iboot_set_boot_mode(struct dcp_iboot *ib); void dcp_iboot_update_edid(struct dcp_iboot *ib); void dcp_iboot_reset_mode(struct dcp_iboot *ib); void dcp_iboot_av_started(struct dcp_iboot *ib); +void dcp_iboot_hpd_event(struct dcp_iboot *ib); #else +static inline void t8152_typec_register(struct device *dev) { } +static inline void t8152_typec_unregister(void) { } static inline int dcp_iboot_probe(struct apple_dcp *dcp) { return -ENODEV; } static inline void dcp_iboot_remove(struct apple_dcp *dcp) { } #endif diff --git a/drivers/gpu/drm/apple/t8152_atc.c b/drivers/gpu/drm/apple/t8152_atc.c index ce4b6a84602de..b2d018d4e636e 100644 --- a/drivers/gpu/drm/apple/t8152_atc.c +++ b/drivers/gpu/drm/apple/t8152_atc.c @@ -13,7 +13,7 @@ * set up the lanes again), drive settings, the DCP -> ATCn/DFP0 crossbar * route, and with the display off or unplugged a full power down and a cold * start. A DCP drives one USB-C port at a time: the one it claims from the - * shared ports while polling their PD controllers. + * shared ports once their Type-C state shows a sink (t8152_typec.c). */ #include @@ -53,7 +53,6 @@ struct t8152_atc_port { unsigned int index; /* ATC instance */ /* display crossbar DFP endpoint of this ATC */ u32 dfp; - struct spmi_device *pd; /* AP DisplayPort AUX controller aux0 (shared), for the EDID */ struct t8152_aux *aux; /* PMGR power states of the four ATC dependencies */ @@ -692,7 +691,9 @@ static int atc_detect(struct t8152_display *disp, bool *flipped) atc->next = atc->cur; /* Keep a monitor on its controller, including while userspace blanks it. */ if (atc_owner[atc->cur->index] == disp->dev) { - ret = t8152_pd_sink(atc->cur->pd, flipped, &atc->cur->next_lanes); + ret = t8152_typec_sink(disp, atc->cur->index, flipped, + &atc->cur->next_lanes); + /* The plug changed: a new sink */ if (ret > 0 && (atc->cur->swap != *flipped || atc->cur->lanes != atc->cur->next_lanes)) disp->hpd = 0; @@ -706,7 +707,7 @@ static int atc_detect(struct t8152_display *disp, bool *flipped) struct t8152_atc_port *port = &atc->port[i]; if (atc_owner[port->index] || - t8152_pd_sink(port->pd, flipped, &port->next_lanes) <= 0) + t8152_typec_sink(disp, port->index, flipped, &port->next_lanes) <= 0) continue; atc_owner[port->index] = disp->dev; atc->next = port; @@ -739,7 +740,6 @@ static void atc_select(struct t8152_display *disp) dev_info(disp->dev, "USB-C display on ATC%u now, was ATC%u\n", port->index, atc->cur->index); atc->cur = port; - disp->pd = port->pd; disp->dcp_output = port->dfp; } @@ -796,9 +796,6 @@ static int atc_port_init(struct t8152_display *disp, struct t8152_atc *atc, port->psd = atc_map(disp, np, "atc-psd"); if (!port->base || !port->ps || !port->psd) return -ENOMEM; - port->pd = t8152_pd_get(np); - if (IS_ERR_OR_NULL(port->pd)) - return port->pd ? PTR_ERR(port->pd) : -ENODEV; /* The node without ports is ATC3's (J873g back-right). */ port->dfp = 3; of_property_read_u32(np, "apple,dfp-endpoint", &port->dfp); @@ -916,7 +913,7 @@ int t8152_atc_init(struct t8152_display *disp) atc->next = atc->cur; disp->phy = &atc_ops; disp->phy_priv = atc; - disp->pd = atc->cur->pd; + disp->usbc = true; disp->dcp_output = atc->cur->dfp; dev_info(disp->dev, "USB-C display on ATC%u (%u ports)\n", atc->cur->index, atc->nports); diff --git a/drivers/gpu/drm/apple/t8152_display.h b/drivers/gpu/drm/apple/t8152_display.h index b26baf6b04924..f4aa562fb3810 100644 --- a/drivers/gpu/drm/apple/t8152_display.h +++ b/drivers/gpu/drm/apple/t8152_display.h @@ -4,15 +4,15 @@ * that no subsystem driver covers yet: the ATC PHYs' DisplayPort lanes and * their display crossbar route (t8152_atc.c), the HDMI port's dedicated * DisplayPort PHY and PS190 converter (t8152_hdmi.c), the AP's DisplayPort - * AUX controllers that read the sink's EDID (t8152_aux.c), the rear USB-C - * ports' ACE3 PD controllers (t8152_pd.c), and the DPTX port service the - * DCP firmware calls into for the PHY (t8152_dptx.c). + * AUX controllers that read the sink's EDID (t8152_aux.c), and the DPTX port + * service the DCP firmware calls into for the PHY (t8152_dptx.c). The rear + * USB-C ports' DisplayPort alt mode state comes from their Type-C port + * driver, through the ports' shared display switches (t8152_typec.c). * - * Interim: the ATC DisplayPort mode moves to drivers/phy/apple/atc.c, the - * ACE3 controllers to tipd, and the choice of port with DP alt mode to the - * Type-C route layer of dcp-fabric.c, each in its own change. Until then - * these files program the registers themselves, for the iBoot interface - * DCPs of iomfb_iboot.c alone. + * Interim: the ATC DisplayPort mode moves to drivers/phy/apple/atc.c and the + * choice of port with DP alt mode to the Type-C route layer of dcp-fabric.c, + * each in its own change. Until then these files program the registers + * themselves, for the iBoot interface DCPs of iomfb_iboot.c alone. */ #ifndef __APPLE_T8152_DISPLAY_H__ #define __APPLE_T8152_DISPLAY_H__ @@ -24,9 +24,9 @@ struct apple_epic_service_ops; struct device; struct device_node; struct gpio_desc; -struct spmi_device; struct t8152_display; struct t8152_hdmi; +struct t8152_typec; /* SET_DRIVE_SETTINGS and GET_DRIVE_SETTINGS records, one per lane */ struct t8152_drive_settings { @@ -90,8 +90,9 @@ struct t8152_display { /* optional sink HPD line (HDMI), polled; the last level seen */ struct gpio_desc *hpd_gpio; int hpd; - /* USB-C: the PD controller of the port in use */ - struct spmi_device *pd; + /* USB-C: plug and HPD come from the ports' display switches */ + bool usbc; + struct t8152_typec *typec; /* HDMI PHY: DCPEXT0's, or the main DCP's on an HDMI-only boot */ bool hdmi; /* @@ -126,10 +127,10 @@ int t8152_aux_init(struct t8152_display *disp, struct t8152_aux *aux); int t8152_aux_read_edid(struct t8152_display *disp, struct t8152_aux *aux, u8 *buf, size_t size); -/* t8152_pd.c */ -struct spmi_device *t8152_pd_get(struct device_node *np); -int t8152_pd_sink(struct spmi_device *pd, bool *flipped, u32 *lanes); -int t8152_pd_reconnect(struct t8152_display *disp); +/* t8152_typec.c, see also iomfb_iboot.h */ +int t8152_typec_init(struct t8152_display *disp); +int t8152_typec_sink(struct t8152_display *disp, u32 index, bool *flipped, + u32 *lanes); /* t8152_dptx.c */ extern const struct apple_epic_service_ops t8152_dptx_port_ops; diff --git a/drivers/gpu/drm/apple/t8152_pd.c b/drivers/gpu/drm/apple/t8152_pd.c deleted file mode 100644 index 8c514d17d69d2..0000000000000 --- a/drivers/gpu/drm/apple/t8152_pd.c +++ /dev/null @@ -1,211 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only OR MIT -/* - * USB-C plug state from the rear ports' ACE3 PD controllers over SPMI, for - * the USB-C displays' hotplug: the DP alt mode connection, its pin - * assignment and the plug orientation. Logical registers are read through a - * window: select with a register-zero write, wait for the busy bit to - * clear, read the size at 0x1f and the data from 0x20. - * - * Interim, until tipd owns these controllers and reports DP alt mode to the - * Type-C route layer of dcp-fabric.c: tipd and this share the SPMI devices, - * serialized by the device lock. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "t8152_display.h" - -#define ACE3_SELECT 0x00 -#define ACE3_SELECT_BUSY BIT(7) -#define ACE3_SIZE 0x1f -#define ACE3_DATA 0x20 -#define ACE3_BURST 16 - -#define ACE3_REG_CMD1 0x08 -#define ACE3_REG_DATA1 0x09 -#define ACE3_REG_STATUS 0x1a -#define ACE3_REG_POWER_STATE 0x20 -#define ACE3_REG_DATA_STATUS 0x5f - -#define STATUS_PLUG_PRESENT BIT(0) -#define STATUS_UPSIDE_DOWN BIT(4) -#define DATA_DP_CONNECTION BIT(8) -#define DATA_HPD_LEVEL BIT(15) /* CD321x, as tipd */ - -static int ace3_read(struct spmi_device *sdev, u8 reg, u8 *buf, size_t len) -{ - u8 sel, size; - int ret, err = 0; - - ret = spmi_register_zero_write(sdev, reg); - if (ret) - return ret; - ret = read_poll_timeout(spmi_ext_register_read, err, - err || !(sel & ACE3_SELECT_BUSY), 50, 20000, - false, sdev, ACE3_SELECT, &sel, 1); - if (ret || err) - return ret ?: err; - ret = spmi_ext_register_read(sdev, ACE3_SIZE, &size, 1); - if (ret) - return ret; - if (size < len) - return -EIO; - for (size_t done = 0; done < len; done += ACE3_BURST) { - ret = spmi_ext_register_read(sdev, ACE3_DATA + done, buf + done, - min_t(size_t, len - done, ACE3_BURST)); - if (ret) - return ret; - } - return 0; -} - -static int ace3_select(struct spmi_device *sdev, u8 reg) -{ - u8 sel; - int ret, err = 0; - - ret = spmi_register_zero_write(sdev, reg); - if (ret) - return ret; - ret = read_poll_timeout(spmi_ext_register_read, err, - err || !(sel & ACE3_SELECT_BUSY), 50, 20000, - false, sdev, ACE3_SELECT, &sel, 1); - return ret ?: err; -} - -static int ace3_write(struct spmi_device *sdev, u8 reg, const u8 *buf, - size_t len) -{ - int ret = ace3_select(sdev, reg); - - return ret ?: spmi_ext_register_write(sdev, ACE3_DATA, (u8 *)buf, len); -} - -/* A 4CC command with an optional data byte; 0 once the controller took it. */ -static int ace3_cmd(struct spmi_device *sdev, const char *cmd, int data) -{ - u8 val[4]; - int ret; - - ret = spmi_command_wakeup(sdev); - if (ret) - return ret; - if (data >= 0) { - u8 d = data; - - ret = ace3_write(sdev, ACE3_REG_DATA1, &d, 1); - if (ret) - return ret; - } - ret = ace3_write(sdev, ACE3_REG_CMD1, cmd, 4); - if (ret) - return ret; - for (int i = 0; i < 1000; i++) { - ret = ace3_read(sdev, ACE3_REG_CMD1, val, sizeof(val)); - if (ret) - return ret; - if (!memcmp(val, "!CMD", 4)) - return -EIO; - if (!memcmp(val, "\0\0\0\0", 4)) - return 0; - usleep_range(1000, 2000); - } - return -ETIMEDOUT; -} - -/* - * Leave and enter DP alt mode again, as unplugging and plugging the cable - * does: reset the controller (Gaid), then power the port up again once it - * takes commands (SSPS 0). A sink that stopped answering AUX after a - * monitor's deep sleep comes back this way. - */ -int t8152_pd_reconnect(struct t8152_display *disp) -{ - struct spmi_device *pd = disp->pd; - int ret; - - device_lock(&pd->dev); - /* Gaid resets the controller before it can report completion. */ - ret = spmi_command_wakeup(pd); - if (!ret) - ret = ace3_write(pd, ACE3_REG_CMD1, "Gaid", 4); - if (ret) - goto out; - /* - * The controller restarts: on the J873g ports its mode register read - * "BOOT" about 22 ms after Gaid, it acknowledged no SPMI command from - * about 215 ms on, and it read "APP " and took SSPS again after about - * 290 ms. Polling it through that gap only gets NACKs, which the SPMI - * controller logs as errors, and nothing signals the restart's end. - * So SSPS is first sent 500 ms after Gaid, and every 500 ms after that - * for a controller that takes longer. - */ - for (int i = 0; i < 60; i++) { - msleep(500); - ret = ace3_cmd(pd, "SSPS", 0); - if (!ret) - break; - } -out: - device_unlock(&pd->dev); - return ret; -} - -/* 1 with a DisplayPort sink in DP alt mode and HPD high, 0 without. */ -int t8152_pd_sink(struct spmi_device *pd, bool *flipped, u32 *lanes) -{ - u8 status[4], data[4], power; - int ret; - - /* Serialize the logical register window with the USB4 port monitor. */ - device_lock(&pd->dev); - /* Without a plug the controller sleeps and ignores selects. */ - ret = spmi_command_wakeup(pd); - if (ret) - goto out; - ret = ace3_read(pd, ACE3_REG_POWER_STATE, &power, sizeof(power)); - if (ret) - goto out; - /* Register access alone does not enable the alt-mode policy engine. */ - if (power) { - ret = ace3_cmd(pd, "SSPS", 0); - if (ret) - goto out; - } - ret = ace3_read(pd, ACE3_REG_STATUS, status, sizeof(status)); - if (!ret) - ret = ace3_read(pd, ACE3_REG_DATA_STATUS, data, sizeof(data)); - if (ret) - goto out; - *flipped = status[0] & STATUS_UPSIDE_DOWN; - /* Pin D/F shares the cable with USB3; C/E uses all four DP lanes. */ - *lanes = get_unaligned_le32(data) & BIT(5) ? 2 : 4; - /* The sink answers AUX once it raised HPD, not at alt mode entry. */ - ret = (status[0] & STATUS_PLUG_PRESENT) && - (get_unaligned_le32(data) & DATA_DP_CONNECTION) && - (get_unaligned_le32(data) & DATA_HPD_LEVEL); -out: - device_unlock(&pd->dev); - return ret; -} - -/* The PD controller @np's apple,usb-pd points at, NULL without one. */ -struct spmi_device *t8152_pd_get(struct device_node *np) -{ - struct device_node *pd_np = of_parse_phandle(np, "apple,usb-pd", 0); - struct spmi_device *pd; - - if (!pd_np) - return NULL; - /* Holds a reference for the lifetime of the (retained) device. */ - pd = spmi_find_device_by_of_node(pd_np); - of_node_put(pd_np); - return pd ?: ERR_PTR(-EPROBE_DEFER); -} diff --git a/drivers/gpu/drm/apple/t8152_typec.c b/drivers/gpu/drm/apple/t8152_typec.c new file mode 100644 index 0000000000000..afae7b2546d60 --- /dev/null +++ b/drivers/gpu/drm/apple/t8152_typec.c @@ -0,0 +1,264 @@ +// SPDX-License-Identifier: GPL-2.0-only OR MIT +/* + * The rear USB-C ports' DisplayPort alt mode, from the USB Type-C port + * driver that owns their PD controllers. Each port has one Type-C mode + * switch for the display path, shared by all DCPs: the port's usb-c node in + * the shared ports node (apple,usb-c-ports), whose endpoint is at the display + * port of the port's connector. The Type-C class looks at three mode switches + * of a connector at most, and the port's PHY needs one as well, so there is + * no room for one per DCP. + * + * The first DCP that probes registers the switches, and they stay until the + * driver is unloaded: the port driver keeps using a switch it found, and + * must not wait for a DCP that cannot start. A switch records what the + * display path reads (DisplayPort alt mode with HPD high, the lanes of the + * pin assignment, the plug orientation) and has every DCP that drives USB-C + * look at its ports; t8152_atc.c claims a port for one of them. + * + * The switches are dcp-fabric.c's in the device tree only. Its route layer + * switches a DP PHY and the display crossbar through their own drivers and + * connects the sink through the DCP's IOMFB DPTX service; these DCPs program + * the ATC PHY and the crossbar themselves and connect through the iBoot + * interface's DPTX port service, so their switches record the state alone. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "iomfb_iboot.h" +#include "t8152_display.h" + +/* The ATC instances, as the display crossbar's DFP endpoints number them */ +#define T8152_TYPEC_PORTS 4 + +struct t8152_typec_port { + struct typec_mux_dev *mux; + /* below under t8152_typec_lock */ + bool sink; + bool flipped; + u32 lanes; +}; + +/* A DCP that drives USB-C, told about the ports' changes */ +struct t8152_typec { + struct list_head node; + struct t8152_display *disp; +}; + +/* Registers the switches, once */ +static DEFINE_MUTEX(t8152_typec_register_lock); +/* Below under t8152_typec_register_lock: the switches' parent, which no DCP binding owns */ +static struct faux_device *t8152_typec_owner; +/* The status changesets of ports whose switch could not be registered */ +struct t8152_typec_disabled { + struct list_head node; + struct of_changeset cs; +}; + +static LIST_HEAD(t8152_typec_disabled_ports); +/* The ports' state, written by the port driver, and the DCPs that read it */ +static DEFINE_SPINLOCK(t8152_typec_lock); +static struct t8152_typec_port t8152_typec_ports[T8152_TYPEC_PORTS]; +static LIST_HEAD(t8152_typec_displays); + +static int t8152_typec_set(struct typec_mux_dev *mux, struct typec_mux_state *state) +{ + struct t8152_typec_port *port = typec_mux_get_drvdata(mux); + struct typec_displayport_data *dp = NULL; + struct t8152_typec *typec; + bool flipped = false; + u32 lanes = 4; + + if (state->alt && state->alt->svid == USB_TYPEC_DP_SID && + state->mode >= TYPEC_DP_STATE_A && state->mode <= TYPEC_DP_STATE_F) { + dp = state->data; + flipped = typec_altmode_get_orientation(state->alt) == + TYPEC_ORIENTATION_REVERSE; + /* B, D and F share the cable with USB 3: two DisplayPort lanes */ + if (state->mode == TYPEC_DP_STATE_B || state->mode == TYPEC_DP_STATE_D || + state->mode == TYPEC_DP_STATE_F) + lanes = 2; + } + + guard(spinlock)(&t8152_typec_lock); + /* The sink answers AUX once it raised HPD, not at alt mode entry. */ + port->sink = dp && (dp->status & DP_STATUS_HPD_STATE); + port->flipped = flipped; + port->lanes = lanes; + list_for_each_entry(typec, &t8152_typec_displays, node) + dcp_iboot_hpd_event(container_of(typec->disp, struct dcp_iboot, disp)); + return 0; +} + +/* + * 1 with a DisplayPort sink on the port of ATC @index (DP alt mode, HPD + * high), 0 without. + * + * A HPD pulse that ends before the DCP looks is not a new sink: an EV2780 + * without a video stream drops HPD for about 160 ms every few seconds, and + * connecting it anew each time kept its link from coming up. A sink that is + * really unplugged leaves DP alt mode with its partner. + */ +int t8152_typec_sink(struct t8152_display *disp, u32 index, bool *flipped, + u32 *lanes) +{ + struct t8152_typec_port *port; + + if (!disp->typec || index >= T8152_TYPEC_PORTS) + return 0; + port = &t8152_typec_ports[index]; + guard(spinlock)(&t8152_typec_lock); + if (!port->mux || !port->sink) + return 0; + *flipped = port->flipped; + *lanes = port->lanes; + return 1; +} + +static int t8152_typec_port_register(struct device *dev, struct device_node *np) +{ + struct typec_mux_desc desc = {}; + struct t8152_typec_port *port; + struct typec_mux_dev *mux; + u32 index; + int ret; + + ret = of_property_read_u32(np, "apple,dfp-endpoint", &index); + if (ret || index >= T8152_TYPEC_PORTS) + return dev_err_probe(dev, ret ?: -EINVAL, "%pOF: invalid port\n", np); + port = &t8152_typec_ports[index]; + if (port->mux) + return 0; + desc.fwnode = of_fwnode_handle(np); + desc.set = t8152_typec_set; + desc.drvdata = port; + desc.name = kasprintf(GFP_KERNEL, "dcp-usb-c%u", index); + if (!desc.name) + return -ENOMEM; + port->lanes = 4; + /* Under the shared owner, not @dev: the switch outlives any DCP's binding. */ + mux = typec_mux_register(&t8152_typec_owner->dev, &desc); + kfree(desc.name); + if (IS_ERR(mux)) + return dev_err_probe(dev, PTR_ERR(mux), "%pOF: switch not registered\n", np); + scoped_guard(spinlock, &t8152_typec_lock) + port->mux = mux; + return 0; +} + +/* + * A switch that cannot be registered: the port driver goes on without it. + * The changeset stays applied until the driver unloads, which reverts it. + */ +static void t8152_typec_port_disable(struct device *dev, struct device_node *np) +{ + struct t8152_typec_disabled *d = kzalloc(sizeof(*d), GFP_KERNEL); + + if (!d) + return; + of_changeset_init(&d->cs); + if (!of_changeset_update_prop_string(&d->cs, np, "status", "disabled") && + !of_changeset_apply(&d->cs)) { + list_add(&d->node, &t8152_typec_disabled_ports); + return; + } + dev_err(dev, "%pOF: could not disable the display switch\n", np); + of_changeset_destroy(&d->cs); + kfree(d); +} + +/* + * Register the display switches of the USB-C ports the DCP @dev can drive, + * unless another DCP did. Called first in the DCP's probe, so that the port + * driver, which waits for them, never waits for a DCP that cannot start. + */ +void t8152_typec_register(struct device *dev) +{ + struct device_node *ports __free(device_node) = + of_parse_phandle(dev->of_node, "apple,usb-c-ports", 0); + struct device_node *np = ports ?: dev->of_node; + + guard(mutex)(&t8152_typec_register_lock); + if (!t8152_typec_owner) { + t8152_typec_owner = faux_device_create("t8152-typec", NULL, NULL); + if (!t8152_typec_owner) { + dev_err(dev, "no owner for the USB-C display switches\n"); + return; + } + } + for_each_available_child_of_node_scoped(np, child) { + if (of_property_present(child, "mode-switch") && + t8152_typec_port_register(dev, child)) + t8152_typec_port_disable(dev, child); + } +} + +/* At driver unload, once no DCP is bound */ +void t8152_typec_unregister(void) +{ + guard(mutex)(&t8152_typec_register_lock); + for (unsigned int i = 0; i < T8152_TYPEC_PORTS; i++) { + struct typec_mux_dev *mux = t8152_typec_ports[i].mux; + + if (!mux) + continue; + scoped_guard(spinlock, &t8152_typec_lock) + t8152_typec_ports[i].mux = NULL; + typec_mux_unregister(mux); + } + while (!list_empty(&t8152_typec_disabled_ports)) { + struct t8152_typec_disabled *d = + list_first_entry(&t8152_typec_disabled_ports, typeof(*d), node); + + list_del(&d->node); + /* A changeset that cannot be reverted is still part of the tree: keep it */ + if (of_changeset_revert(&d->cs)) + continue; + of_changeset_destroy(&d->cs); + kfree(d); + } + if (t8152_typec_owner) { + faux_device_destroy(t8152_typec_owner); + t8152_typec_owner = NULL; + } +} + +static void t8152_typec_leave(void *data) +{ + struct t8152_typec *typec = data; + + scoped_guard(spinlock, &t8152_typec_lock) + list_del(&typec->node); +} + +/* + * Have the DCP see the USB-C ports' display state from now on: call this + * once the DCP stays bound. Without it, the DCP sees no USB-C sink. + */ +int t8152_typec_init(struct t8152_display *disp) +{ + struct t8152_typec *typec; + int ret; + + typec = devm_kzalloc(disp->dev, sizeof(*typec), GFP_KERNEL); + if (!typec) + return -ENOMEM; + typec->disp = disp; + scoped_guard(spinlock, &t8152_typec_lock) + list_add_tail(&typec->node, &t8152_typec_displays); + ret = devm_add_action_or_reset(disp->dev, t8152_typec_leave, typec); + if (ret) + return ret; + disp->typec = typec; + return 0; +} From f9ad98d1d5d604ef3c4535e9fa397c08c130c9d1 Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Thu, 19 Nov 2026 23:57:58 +0100 Subject: [PATCH 08/31] arm64: dts: apple: t8152-j873g: hand the rear USB-C PD controllers to tipd The PD controllers of the three rear USB-C ports were described for the display path alone, which read them over SPMI itself. Describe them for tipd, which owns them from now on, and the display path takes their DisplayPort alt mode state from the Type-C class: - the controllers as apple,t8152-sn201202x, with the T8132 fallback: tipd's SPMI transport then polls the register selection and reads the payload length from register 0x1f, as these controllers need; - the SPMI controller (AIC 682) as the interrupt controller of their event, sleep and wake sources: 11/17/19 (back-middle), 37/43/45 (back-left) and 63/69/71 (back-right), rising edge, as in the ADT. In a test with the compatibles and interrupts alone, tipd bound all three, took its events by interrupt, and both display partners showed DisplayPort alt mode active; - a usb-c-connector per controller, whose display port (port@3) leads to the port's usb-c node in the main DCP's shared ports node, the port's one display switch for all three DCPs. The USB port (port@0) stays unlinked: the USB data path is not changed here. The DCP's usb-c nodes lose apple,usb-pd, which nothing reads any more. Signed-off-by: Thomas Glanzmann --- arch/arm64/boot/dts/apple/t8152-j873-dcp.dtsi | 134 +++++++++++++++++- 1 file changed, 128 insertions(+), 6 deletions(-) diff --git a/arch/arm64/boot/dts/apple/t8152-j873-dcp.dtsi b/arch/arm64/boot/dts/apple/t8152-j873-dcp.dtsi index 8263f1c68634b..2cc188ea99d91 100644 --- a/arch/arm64/boot/dts/apple/t8152-j873-dcp.dtsi +++ b/arch/arm64/boot/dts/apple/t8152-j873-dcp.dtsi @@ -100,29 +100,124 @@ /* * ADT /arm-io/nub-spmi-a0 (gen 4): the USB-C PD controllers of * the three rear ports, each of which can carry the USB-C display. + * Their event, sleep and wake sources are interrupts of this + * controller (the ADT's), its own line is AIC 682. A connector's + * display port leads to the port's display switch, which all + * DCPs share. */ nub_spmi_a0: spmi@308908000 { compatible = "apple,t8152-spmi", "apple,t8142-spmi"; reg = <0x3 0x08908000 0x0 0x4000>; + interrupt-parent = <&aic>; + interrupts = ; + interrupt-controller; + #interrupt-cells = <2>; #address-cells = <2>; #size-cells = <0>; /* back-middle */ hpm0: usb-pd@c { - compatible = "apple,sn201202x"; + compatible = "apple,t8152-sn201202x", "apple,t8132-sn201202x", + "apple,sn201202x"; reg = <0xc SPMI_USID>; + interrupts = <11 IRQ_TYPE_EDGE_RISING>, + <17 IRQ_TYPE_EDGE_RISING>, + <19 IRQ_TYPE_EDGE_RISING>; + interrupt-names = "irq", "sleep", "wake"; + + typec0: connector { + compatible = "usb-c-connector"; + label = "USB-C Back-middle"; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + /* USB: not linked to its controller yet */ + port@0 { + reg = <0>; + }; + + /* DisplayPort: the DCPs' display switch */ + port@3 { + reg = <3>; + + typec0_display: endpoint { + remote-endpoint = <&display_typec0>; + }; + }; + }; + }; }; /* back-left */ hpm1: usb-pd@a { - compatible = "apple,sn201202x"; + compatible = "apple,t8152-sn201202x", "apple,t8132-sn201202x", + "apple,sn201202x"; reg = <0xa SPMI_USID>; + interrupts = <37 IRQ_TYPE_EDGE_RISING>, + <43 IRQ_TYPE_EDGE_RISING>, + <45 IRQ_TYPE_EDGE_RISING>; + interrupt-names = "irq", "sleep", "wake"; + + typec1: connector { + compatible = "usb-c-connector"; + label = "USB-C Back-left"; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + /* USB: not linked to its controller yet */ + port@0 { + reg = <0>; + }; + + /* DisplayPort: the DCPs' display switch */ + port@3 { + reg = <3>; + + typec1_display: endpoint { + remote-endpoint = <&display_typec1>; + }; + }; + }; + }; }; /* back-right */ hpm3: usb-pd@8 { - compatible = "apple,sn201202x"; + compatible = "apple,t8152-sn201202x", "apple,t8132-sn201202x", + "apple,sn201202x"; reg = <0x8 SPMI_USID>; + interrupts = <63 IRQ_TYPE_EDGE_RISING>, + <69 IRQ_TYPE_EDGE_RISING>, + <71 IRQ_TYPE_EDGE_RISING>; + interrupt-names = "irq", "sleep", "wake"; + + typec3: connector { + compatible = "usb-c-connector"; + label = "USB-C Back-right"; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + /* USB: not linked to its controller yet */ + port@0 { + reg = <0>; + }; + + /* DisplayPort: the DCPs' display switch */ + port@3 { + reg = <3>; + + typec3_display: endpoint { + remote-endpoint = <&display_typec3>; + }; + }; + }; + }; }; }; @@ -182,6 +277,7 @@ * USB-C back-middle: ADT atc-phy0. PS: the ATC's DP_0, DP_1 and * USB_AON power states (+0, +0x20, +0x100), PSD: its common * domain. Tunables before and after the lane crossbar setup. + * The node is also the port's display switch for all DCPs. */ usb-c@403000000 { reg = <0x4 0x03000000 0x0 0x84000>, @@ -189,7 +285,8 @@ <0x3 0x03a13700 0x0 0xc0>; reg-names = "atc", "atc-ps", "atc-psd"; apple,dfp-endpoint = <0>; - apple,usb-pd = <&hpm0>; + /* The DCPs' display switch of the port */ + mode-switch; apple,tunable-pre = /* ACIOPHY_CMN_DFLT */ <0x00800 0x00fc0000 0x00fc0000>, @@ -279,12 +376,19 @@ <0x00ebc 0x0000007f 0x0000005a>, /* ASDC_AUX_SHM_DFLT */ <0x02308 0x000000fc 0x00000084>; + + port { + display_typec0: endpoint { + remote-endpoint = <&typec0_display>; + }; + }; }; /* * USB-C back-left: ADT atc-phy1. PS: the ATC's DP_0, DP_1 and * USB_AON power states (+0, +0x20, +0x100), PSD: its common * domain. Tunables before and after the lane crossbar setup. + * The node is also the port's display switch for all DCPs. */ usb-c@40b000000 { reg = <0x4 0x0b000000 0x0 0x84000>, @@ -292,7 +396,8 @@ <0x3 0x03a13800 0x0 0xc0>; reg-names = "atc", "atc-ps", "atc-psd"; apple,dfp-endpoint = <1>; - apple,usb-pd = <&hpm1>; + /* The DCPs' display switch of the port */ + mode-switch; apple,tunable-pre = /* ACIOPHY_CMN_DFLT */ <0x00800 0x00fc0000 0x00fc0000>, @@ -382,12 +487,19 @@ <0x00ebc 0x0000007f 0x0000005a>, /* ASDC_AUX_SHM_DFLT */ <0x02308 0x000000fc 0x00000084>; + + port { + display_typec1: endpoint { + remote-endpoint = <&typec1_display>; + }; + }; }; /* * USB-C back-right: ADT atc-phy3. PS: the ATC's DP_0, DP_1 and * USB_AON power states (+0, +0x20, +0x100), PSD: its common * domain. Tunables before and after the lane crossbar setup. + * The node is also the port's display switch for all DCPs. */ usb-c@413000000 { reg = <0x4 0x13000000 0x0 0x84000>, @@ -395,7 +507,8 @@ <0x3 0x03a13a00 0x0 0xc0>; reg-names = "atc", "atc-ps", "atc-psd"; apple,dfp-endpoint = <3>; - apple,usb-pd = <&hpm3>; + /* The DCPs' display switch of the port */ + mode-switch; apple,tunable-pre = /* ACIOPHY_CMN_DFLT */ <0x00800 0x00fc0000 0x00fc0000>, @@ -485,7 +598,14 @@ <0x00ebc 0x0000007f 0x0000005a>, /* ASDC_AUX_SHM_DFLT */ <0x02308 0x000000fc 0x00000084>; + + port { + display_typec3: endpoint { + remote-endpoint = <&typec3_display>; + }; + }; }; + }; /* @@ -563,6 +683,7 @@ iommus = <&dispext0_dart 0>; dma-coherent; }; + }; dcpext1_mbox: mailbox@316020700 { @@ -591,6 +712,7 @@ iommus = <&dispext1_dart 0>; dma-coherent; }; + }; }; From 264d1fded1d8e2224335e19f53a2fb8f5d7b4d35 Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Thu, 19 Nov 2026 22:14:28 +0100 Subject: [PATCH 09/31] dt-bindings: phy: apple,atcphy: add the T8152 fixed-USB3 PHY The two front USB-C ports of the Mac mini (2026, J873g) sit behind an on-board USB3 hub. The hub's SuperSpeed lanes are wired to the Type-C PHY of the SoC's ATC2 directly, without a Type-C mux or port controller in between, so that PHY only ever runs one fixed USB3 configuration. Describe the T8152 variant in that role, with a boolean apple,fixed-usb3 that marks such a port: the PHY runs USB3 on lane 0 from probe on, ignores mux and orientation changes and provides only the USB3 PHY of its controller. The controller's USB2 side and reset stay with the bootloader, so the T8152 PHY has no #reset-cells and no Type-C switch properties. The PHY is described by its core and pipehandler banks. On T8152 the core bank also holds the USB controller's DARTs, and the PHY's power and reset block sits behind them. It needs four power domains, listed in the order they are powered up: the ATC's USB_AON power state, its common PSD service and its COMMON_DP_0 and COMMON_DP_1 power states. The other variants keep their single power domain and #reset-cells. Signed-off-by: Thomas Glanzmann --- .../devicetree/bindings/phy/apple,atcphy.yaml | 142 ++++++++++++++---- 1 file changed, 114 insertions(+), 28 deletions(-) diff --git a/Documentation/devicetree/bindings/phy/apple,atcphy.yaml b/Documentation/devicetree/bindings/phy/apple,atcphy.yaml index 41ecaccc8a0ae..783f6732fae3a 100644 --- a/Documentation/devicetree/bindings/phy/apple,atcphy.yaml +++ b/Documentation/devicetree/bindings/phy/apple,atcphy.yaml @@ -40,6 +40,13 @@ description: > DisplayPort also requires separate bootloader-provided calibration lists for that bank and the common configuration in the lpdptx region. + The T8152 variant is supported as the USB3 PHY of a fixed-USB3 port only, + see apple,fixed-usb3. It is described by its core and pipehandler banks; the + core bank also holds the USB controller's DARTs. Its power domains are the + ATC's PMGR power states and PSD service the PHY needs, in the order they are + powered up. Lane 0 is powered up and the crossbar set between the common-a + tunables and the others. + allOf: - $ref: /schemas/usb/usb-switch.yaml# - if: @@ -122,32 +129,78 @@ allOf: required: - power-domains else: - properties: - reg: - minItems: 5 - items: - - description: Common controls for all PHYs (USB2/3/4, DisplayPort, TBT) - - description: DisplayPort Alternate Mode PHY specific controls - - description: Type-C PHY AXI to Apple Fabric interconnect controls - - description: USB2 PHY specific controls - - description: USB3 PIPE interface controls - - description: Secondary eUSB2 PHY register bank (T8140) - - description: - Power and hibernation control of the USB controller the PHY - serves (T8140). The PHY drives that controller's reset and - takes it through hibernation for a system sleep. - reg-names: - minItems: 5 - items: - - const: core - - const: lpdptx - - const: axi2af - - const: usb2phy - - const: pipehandler - - const: usb2phy-reg - - const: pwrctl - required: - - power-domains + if: + properties: + compatible: + contains: + const: apple,t8152-atcphy + then: + properties: + reg: + items: + - description: + PHY core with its power and reset block, which also holds + the USB controller's DARTs + - description: USB3 PIPE interface controls + reg-names: + items: + - const: core + - const: pipehandler + power-domains: + items: + - description: The ATC's USB_AON power state + - description: The ATC's common PSD service + - description: The ATC's COMMON_DP_0 power state + - description: The ATC's COMMON_DP_1 power state + required: + - power-domains + else: + properties: + reg: + minItems: 5 + items: + - description: Common controls for all PHYs (USB2/3/4, DisplayPort, TBT) + - description: DisplayPort Alternate Mode PHY specific controls + - description: Type-C PHY AXI to Apple Fabric interconnect controls + - description: USB2 PHY specific controls + - description: USB3 PIPE interface controls + - description: Secondary eUSB2 PHY register bank (T8140) + - description: + Power and hibernation control of the USB controller the PHY + serves (T8140). The PHY drives that controller's reset and + takes it through hibernation for a system sleep. + reg-names: + minItems: 5 + items: + - const: core + - const: lpdptx + - const: axi2af + - const: usb2phy + - const: pipehandler + - const: usb2phy-reg + - const: pwrctl + required: + - power-domains + - if: + properties: + compatible: + contains: + const: apple,t8152-atcphy + then: + properties: + "#reset-cells": false + mode-switch: false + orientation-switch: false + ports: false + required: + - apple,fixed-usb3 + else: + properties: + apple,fixed-usb3: false + power-domains: + maxItems: 1 + required: + - "#reset-cells" - if: properties: compatible: @@ -234,6 +287,7 @@ allOf: - apple,t8122-atcphy - apple,t6030-atcphy - apple,t6031-atcphy + - apple,t8152-atcphy then: required: - orientation-switch @@ -275,6 +329,7 @@ properties: - const: apple,t8132-atcphy - const: apple,t8140-atcphy - const: apple,t8142-atcphy + - const: apple,t8152-atcphy reg: minItems: 1 @@ -294,7 +349,8 @@ properties: orientation-switch: true power-domains: - maxItems: 1 + minItems: 1 + maxItems: 4 phys: maxItems: 1 @@ -323,6 +379,15 @@ properties: $ref: /schemas/graph.yaml#/properties/port description: Incoming endpoint from the USB4/Thunderbolt controller. + apple,fixed-usb3: + type: boolean + description: > + T8152 only, and required there. The port's SuperSpeed lanes go straight + to a USB3 device or hub, with no Type-C mux in between, so the PHY runs + USB3 on lane 0 from probe on and ignores mux and orientation changes. It + provides only the USB3 PHY of its USB controller, which is a host, and + leaves the controller's USB2 side and reset to the bootloader. + apple,dp-alt-mode: type: boolean description: > @@ -521,7 +586,6 @@ required: - reg - reg-names - "#phy-cells" - - "#reset-cells" additionalProperties: false @@ -622,3 +686,25 @@ examples: }; }; }; + + - | + soc { + #address-cells = <2>; + #size-cells = <2>; + + phy@383000000 { + compatible = "apple,t8152-atcphy"; + reg = <0x3 0x83000000 0x0 0x84000>, + <0x3 0x82414000 0x0 0x4000>; + reg-names = "core", "pipehandler"; + + #phy-cells = <1>; + apple,fixed-usb3; + power-domains = <&ps_atc2_usb_aon>, <&ps_atc2_common>, + <&ps_atc2_common_dp_0>, <&ps_atc2_common_dp_1>; + + apple,tunable-common-a = <0x00800 0x00fc0000 0x00fc0000>; + apple,tunable-common-b = <0x6c004 0x003f003f 0x00200020>; + apple,tunable-lane0-usb = <0x082d8 0xf0000000 0x70000000>; + }; + }; From 43558edcc32ed71a6a3ae0336da8499a4793a67c Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Thu, 19 Nov 2026 22:14:45 +0100 Subject: [PATCH 10/31] phy: apple: atc: add T8152 for a fixed-USB3 port The J873g front ports reach their on-board USB3 hub through ATC2's Type-C PHY, wired to the hub without a Type-C mux. So far the hub ran at USB2 only: the bootloader leaves the PHY powered down and the PIPE on the controller's dummy PHY. Support the T8152 PHY in that role in the shared ATC driver. T8152 shares the T8142 generation's power and reset block, tunables and PIPE handler, with a different layout: the USB controller's DARTs sit at 0x20000 and 0x40000 of the ATC window, so the power and reset block follows at 0x60000, its lane swap is bit 1 there, and the reset the power-up releases first is a separate always-on sync reset at 0x60030. The crossbar is at 0x4c and the USB3 mode's existing setting, USB3+DP with single PMA 0x008, gives the value 0x110; there is no lane mode register to program. Describe this in the match data, with zero for the layout of the other SoCs, and leave the power-up and power-down, the tunables, the crossbar and the PIPE switch to the existing code. What remains T8152 code: - Lane 0 is powered up on its own after the common-a tunables (LFPS receivers, sleep, clamp, AHB reset) and down again with the PHY. Without it the lane registers stay in AHB reset, drop the lane tunables and the PHY never reports PIPE PhyStatus. The crossbar is set right after, before the remaining tunables, as in the T8152 sequence. - While the PIPE moves to the PHY, the BIST overrides hold lane 0's PIPE reset and power-down, stepping from P2 to P3, and the non-selected PHY override is released under them. The T8152 PIPE handler takes the lock request but does not acknowledge it: with the controller out of reset, no acknowledge came within 150 ms in either direction, while the PIPE moved to USB3 and back to the dummy PHY under the request. So T8152 changes the PIPE under the request without waiting for the acknowledge; otherwise every USB3 start fails. A fixed-USB3 port, apple,fixed-usb3, is a host by construction. Probe maps only the core and PIPE windows, the core without claiming it as it holds the DARTs, powers the PHY's power domains in the order they are listed and brings the PHY up in USB3. It registers only the USB3 PHY: no reset controller, Type-C mux or switch, as the controller's reset and USB2 side stay with the bootloader. The PIPE is routed when the controller powers the USB3 PHY on, after its core reset, which also sets the PHY up again after a power-off. If that fails the host starts with its PIPE parked, so the hub keeps USB2. The T8152 register sequence is the one of the earlier standalone driver, with which the hub enumerated at 10 Gb/s. The other SoCs keep their register accesses: the new layout fields are zero for them, and the new code runs for T8152 or a fixed-USB3 port only. KUnit cases check the T8152 crossbar, lane and power block accesses. Signed-off-by: Thomas Glanzmann --- drivers/phy/apple/atc-test.c | 113 +++++ drivers/phy/apple/atc.c | 455 ++++++++++++++++-- tools/asahi/atc-usb3-tests.py | 7 +- .../selftests/drivers/apple/atc-t8132-usb3.py | 9 +- .../selftests/drivers/gpu/apple-dcp/common.py | 12 + .../drivers/gpu/apple-dcp/dwc3/mocks.c | 8 +- .../drivers/gpu/apple-dcp/lifecycle.py | 4 +- .../selftests/drivers/gpu/apple-dcp/phy.py | 24 +- 8 files changed, 577 insertions(+), 55 deletions(-) diff --git a/drivers/phy/apple/atc-test.c b/drivers/phy/apple/atc-test.c index 09eec7f9d6185..a34e19b1ab432 100644 --- a/drivers/phy/apple/atc-test.c +++ b/drivers/phy/apple/atc-test.c @@ -1450,3 +1450,116 @@ static struct kunit_suite atcphy_t8132_pm_test_suite = { }; kunit_test_suite(atcphy_t8132_pm_test_suite); + +#define ATCPHY_TEST_T8152_LANE0_UP \ + (ACIOPHY_T8152_AON_LANE_SLEEP_SMALL | ACIOPHY_T8152_AON_LANE_SLEEP_BIG | \ + ACIOPHY_T8152_AON_LANE_AHB_RESET_N) + +/* + * A T8152 fixed-USB3 PHY over zeroed memory in place of its ATC window, up to + * the sync reset. Its USB controller's DARTs sit at the T8103 offsets of the + * power and reset block: mark those words to see that nothing writes them. + */ +static struct apple_atcphy *atcphy_test_alloc_t8152(struct kunit *test) +{ + struct apple_atcphy *atcphy = atcphy_test_alloc_dev(test, false); + void *core = kunit_kzalloc(test, ATCPHY_T8152_SYNC_RESET + 4, GFP_KERNEL); + + KUNIT_ASSERT_NOT_NULL(test, core); + atcphy->regs.core = (__force void __iomem *)core; + atcphy->hw = &atcphy_hw_t8152; + atcphy->fixed_usb3 = true; + writel(0xdeadbeef, atcphy->regs.core + ATCPHY_POWER_CTRL); + writel(0xdeadbeef, atcphy->regs.core + ATCPHY_MISC); + + return atcphy; +} + +static void atcphy_test_t8152_untouched(struct kunit *test, struct apple_atcphy *atcphy) +{ + KUNIT_EXPECT_EQ(test, readl(atcphy->regs.core + ATCPHY_POWER_CTRL), 0xdeadbeefU); + KUNIT_EXPECT_EQ(test, readl(atcphy->regs.core + ATCPHY_MISC), 0xdeadbeefU); +} + +/* USB3: lane 0 powered up, crossbar 0x110, no lane mode register, lane swap bit 1 */ +static void atcphy_test_t8152_lanes(struct kunit *test) +{ + struct apple_atcphy *atcphy = atcphy_test_alloc_t8152(test); + void __iomem *core = atcphy->regs.core; + + writel(ACIOPHY_T8152_AON_LANE_CLAMP_EN, core + ACIOPHY_T8152_AON_LANE0); + writel(ATCPHY_T8152_MISC_LANE_SWAP, core + ATCPHY_T8152_CFG_OFFSET + ATCPHY_MISC); + + atcphy_lanes_up_t8152(atcphy, APPLE_ATCPHY_MODE_USB3); + KUNIT_EXPECT_EQ(test, readl(core + ACIOPHY_T8152_AON_LANE0), ATCPHY_TEST_T8152_LANE0_UP); + KUNIT_EXPECT_EQ(test, readl(core + ACIOPHY_T8152_AON_SLEEP_CTRL2), + ACIOPHY_T8152_AON_SLEEP_CTRL2_RXA_LFPS_SMALL_LN0 | + ACIOPHY_T8152_AON_SLEEP_CTRL2_RXA_LFPS_BIG_LN0); + KUNIT_EXPECT_EQ(test, readl(core + ACIOPHY_CROSSBAR_T8103), 0x110U); + + KUNIT_EXPECT_EQ(test, atcphy_configure_lanes(atcphy, APPLE_ATCPHY_MODE_USB3), 0); + KUNIT_EXPECT_EQ(test, readl(core + ACIOPHY_CROSSBAR_T8103), 0x110U); + KUNIT_EXPECT_EQ(test, readl(core + ACIOPHY_LANE_MODE_T8103), 0U); + KUNIT_EXPECT_EQ(test, readl(core + ATCPHY_T8152_CFG_OFFSET + ATCPHY_MISC), 0U); + atcphy_test_t8152_untouched(test, atcphy); +} + +/* Power-up and power-down go to the block at 0x60000 and the sync reset at 0x60030 */ +static void atcphy_test_t8152_power(struct kunit *test) +{ + struct apple_atcphy *atcphy = atcphy_test_alloc_t8152(test); + void __iomem *core = atcphy->regs.core; + u32 ctrl = ATCPHY_T8152_CFG_OFFSET + ATCPHY_POWER_CTRL; + u32 stat = ATCPHY_T8152_CFG_OFFSET + ATCPHY_POWER_STAT; + + writel(ATCPHY_POWER_CLAMP_EN, core + ctrl); + writel(ATCPHY_POWER_SLEEP_SMALL | ATCPHY_POWER_SLEEP_BIG, core + stat); + KUNIT_EXPECT_EQ(test, atcphy_power_on(atcphy), 0); + KUNIT_EXPECT_EQ(test, readl(core + ctrl), ATCPHY_POWER_SLEEP_SMALL | + ATCPHY_POWER_SLEEP_BIG | ATCPHY_POWER_APB_RESET_N); + KUNIT_EXPECT_EQ(test, readl(core + ATCPHY_T8152_SYNC_RESET), ATCPHY_MISC_RESET_N); + atcphy_test_t8152_untouched(test, atcphy); + + writel(ATCPHY_TEST_T8152_LANE0_UP, core + ACIOPHY_T8152_AON_LANE0); + writel(0, core + stat); + KUNIT_EXPECT_EQ(test, atcphy_power_off(atcphy), 0); + KUNIT_EXPECT_EQ(test, readl(core + ctrl), ATCPHY_POWER_CLAMP_EN); + KUNIT_EXPECT_EQ(test, readl(core + ATCPHY_T8152_SYNC_RESET), 0U); + KUNIT_EXPECT_EQ(test, readl(core + ACIOPHY_T8152_AON_LANE0), + ACIOPHY_T8152_AON_LANE_CLAMP_EN); + atcphy_test_t8152_untouched(test, atcphy); +} + +/* + * The T8152 PIPE handler does not acknowledge the lock: the request is made + * and the PIPE changes under it without waiting. Its release then finds the + * acknowledge clear at once. + */ +static void atcphy_test_t8152_pipe_lock(struct kunit *test) +{ + struct apple_atcphy *atcphy = atcphy_test_alloc_t8152(test); + void *pipehandler = kunit_kzalloc(test, PIPEHANDLER_NONSELECTED_OVERRIDE + 4, + GFP_KERNEL); + + KUNIT_ASSERT_NOT_NULL(test, pipehandler); + atcphy->regs.pipehandler = (__force void __iomem *)pipehandler; + KUNIT_EXPECT_EQ(test, atcphy_pipehandler_lock(atcphy), 0); + KUNIT_EXPECT_EQ(test, readl(atcphy->regs.pipehandler + PIPEHANDLER_LOCK_REQ), + PIPEHANDLER_LOCK_EN); + KUNIT_EXPECT_EQ(test, atcphy_pipehandler_unlock(atcphy), 0); + KUNIT_EXPECT_EQ(test, readl(atcphy->regs.pipehandler + PIPEHANDLER_LOCK_REQ), 0U); +} + +static struct kunit_case atcphy_t8152_test_cases[] = { + KUNIT_CASE(atcphy_test_t8152_lanes), + KUNIT_CASE(atcphy_test_t8152_power), + KUNIT_CASE(atcphy_test_t8152_pipe_lock), + {} +}; + +static struct kunit_suite atcphy_t8152_test_suite = { + .name = "phy-apple-atc-t8152", + .test_cases = atcphy_t8152_test_cases, +}; + +kunit_test_suite(atcphy_t8152_test_suite); diff --git a/drivers/phy/apple/atc.c b/drivers/phy/apple/atc.c index 34d3aa12b8f4c..347d2a4d6ec03 100644 --- a/drivers/phy/apple/atc.c +++ b/drivers/phy/apple/atc.c @@ -249,6 +249,44 @@ enum atcphy_lane_mode { #define ACIOPHY_BIST_MAC_USBPHY_CFG_OV2_LN0_RESET_N_OV 0x200 #define ACIOPHY_BIST_MAC_USBPHY_CFG_OV2_LN0_PWR_DOWN_OV 0x20 +/* T8152 BIST block (ACIOPHY_BIST_BLK) */ +#define ACIOPHY_T8152_BIST_CFG0 0x2400 +#define ACIOPHY_T8152_BIST_CFG0_CLOCK_EN BIT(0) +#define ACIOPHY_T8152_BIST_CFG0_USB_REGSYNC BIT(6) + +#define ACIOPHY_T8152_BIST_CFG2 0x240c +#define ACIOPHY_T8152_BIST_CFG2_LN0_PHY_STATUS_RE BIT(0) + +#define ACIOPHY_T8152_BIST_STATUS1 0x24a0 +#define ACIOPHY_T8152_BIST_STATUS1_LN0_PHY_STATUS BIT(6) +#define ACIOPHY_T8152_BIST_STATUS1_LN0_PHY_STATUS2 BIT(7) + +#define ACIOPHY_T8152_BIST_OV1 0x24b0 +#define ACIOPHY_T8152_BIST_OV1_LN0_PIPE_RESET_N BIT(0) +#define ACIOPHY_T8152_BIST_OV1_LN0_PWR_DOWN GENMASK(8, 5) + +#define ACIOPHY_T8152_BIST_OV2 0x24b8 +#define ACIOPHY_T8152_BIST_OV2_LN0_PIPE_RESET_N_OV BIT(5) +#define ACIOPHY_T8152_BIST_OV2_LN0_UNK6 BIT(6) +#define ACIOPHY_T8152_BIST_OV2_LN0_PWR_DOWN_OV BIT(9) +#define ACIOPHY_T8152_BIST_OV2_LN0_UNK10 BIT(10) +#define ACIOPHY_T8152_BIST_OV2_LN0 \ + (ACIOPHY_T8152_BIST_OV2_LN0_PIPE_RESET_N_OV | \ + ACIOPHY_T8152_BIST_OV2_LN0_UNK6 | \ + ACIOPHY_T8152_BIST_OV2_LN0_PWR_DOWN_OV | \ + ACIOPHY_T8152_BIST_OV2_LN0_UNK10) + +/* T8152 lane power controls in the always-on top block (ACIOPHY_TOP_AON_BLK) */ +#define ACIOPHY_T8152_AON_LANE0 0x1e18 +#define ACIOPHY_T8152_AON_LANE_CLAMP_EN BIT(0) +#define ACIOPHY_T8152_AON_LANE_SLEEP_SMALL BIT(1) +#define ACIOPHY_T8152_AON_LANE_SLEEP_BIG BIT(2) +#define ACIOPHY_T8152_AON_LANE_AHB_RESET_N BIT(5) + +#define ACIOPHY_T8152_AON_SLEEP_CTRL2 0x1e24 +#define ACIOPHY_T8152_AON_SLEEP_CTRL2_RXA_LFPS_SMALL_LN0 BIT(12) +#define ACIOPHY_T8152_AON_SLEEP_CTRL2_RXA_LFPS_BIG_LN0 BIT(16) + #define ACIOPHY_SLEEP_CTRL 0x1b0 #define ACIOPHY_SLEEP_CTRL_TX_BIG GENMASK(1, 0) #define ACIOPHY_SLEEP_CTRL_TX_BIG_OV GENMASK(3, 2) @@ -274,6 +312,16 @@ enum atcphy_lane_mode { #define ATCPHY_MISC_RESET_N BIT(0) #define ATCPHY_MISC_LANE_SWAP BIT(2) +/* + * T8152 has the USB controller's DARTs at 0x20000 and 0x40000 of its ATC + * window, and the power and reset block (ATCPHY_CFG_BLK) follows at 0x60000. + * There the lane swap is bit 1 of 0x60008, and the reset the power-up releases + * first is bit 0 of the always-on sync reset at 0x60030. + */ +#define ATCPHY_T8152_CFG_OFFSET 0x40000 +#define ATCPHY_T8152_MISC_LANE_SWAP BIT(1) +#define ATCPHY_T8152_SYNC_RESET 0x60030 + #define ACIOPHY_LANE_DP_CFG_BLK_TX_DP_CTRL0 0x7000 #define DP_PMA_BYTECLK_RESET BIT(0) #define DP_MAC_DIV20_CLK_SEL BIT(1) @@ -596,6 +644,7 @@ enum atcphy_generation { ATCPHY_GENERATION_T8103, ATCPHY_GENERATION_T8122, ATCPHY_GENERATION_T8132, + ATCPHY_GENERATION_T8152, }; enum atcphy_dp_link_rate { @@ -675,10 +724,18 @@ struct apple_atcphy; /** * struct atcphy_hw - SoC-specific PHY description - * @configure_post_tunable: Generation-specific setup after the tunables + * @configure_post_tunable: Generation-specific setup after the tunables, if any * @gen: Register programming generation - * @aciophy_lane_mode: Lane mode register offset + * @aciophy_lane_mode: Lane mode register offset, or zero to leave the lane + * mode alone (T8152 sets its lanes up through the crossbar) * @aciophy_crossbar: Crossbar register offset + * @cfg_offset: Offset of the power and reset block (ATCPHY_POWER_CTRL, + * ATCPHY_POWER_STAT, ATCPHY_MISC) from where those definitions + * place it + * @sync_reset: Register whose bit 0 is the reset the PHY's power-up releases + * first and its power-down asserts last, instead of + * ATCPHY_MISC_RESET_N, or zero + * @lane_swap: Lane swap bit in ATCPHY_MISC, or zero for ATCPHY_MISC_LANE_SWAP * @has_usb4: A USB4/Thunderbolt controller sits behind the PHY * @usb2_only: Uses the USB2 subset unless its banked SuperSpeed resources exist * @usb2phy_sig_host: Host role field mask, or zero for the original layout @@ -691,6 +748,9 @@ struct apple_atcphy; * still works without the latter * @park_pipe_unlocked: A stopped controller may park without a PIPE handshake * @clear_boot_hold: Release the boot PIPE hold before dummy backend selection + * @pipe_lock_unacked: The PIPE handler takes the lock request but never + * acknowledges it, so the PIPE changes under the request + * without waiting for the acknowledge * @dp_banked_tunables: DisplayPort requires separate LIOA/common calibration * @dp_t8122: DisplayPort runs the T8122 AUX, AUSPLL and lane sequences * @park_dummy_phy: Enable the dummy PIPE backend whenever the PIPE is parked on @@ -710,6 +770,9 @@ struct atcphy_hw { enum atcphy_generation gen; int aciophy_lane_mode; int aciophy_crossbar; + u32 cfg_offset; + u32 sync_reset; + u32 lane_swap; bool has_usb4; bool usb2_only; u32 usb2phy_sig_host; @@ -723,6 +786,7 @@ struct atcphy_hw { bool park_pipe_unlocked; bool park_dummy_phy; bool clear_boot_hold; + bool pipe_lock_unacked; bool restore_after_pd_off; bool idle_power_off; }; @@ -796,6 +860,11 @@ struct atcphy_cio_sleep { * behind the T6030 HDMI port; it maps only its core window * @fixed_usb2: The USB2 pairs go to a fixed hub on the USB controller, which * stays in host mode; the PHY provides USB2 from probe on + * @fixed_usb3: The SuperSpeed lanes go straight to a USB3 device or hub, with + * no Type-C mux in between (apple,fixed-usb3): the PHY runs USB3 + * on lane 0 from probe on and provides only the USB3 PHY of the + * controller, which is a host; its USB2 side and its reset are + * left to the bootloader * @typec_mode: Mode the Type-C mux last asked for; a fixed-hub port returns to * it when the PHY is brought back up after a power-off * @host_active: dwc3 has selected host mode on the USB3 PHY; a fixed-hub port @@ -910,6 +979,7 @@ struct apple_atcphy { bool dp_presets_valid[5]; bool dp_only; bool fixed_usb2; + bool fixed_usb3; enum atcphy_mode typec_mode; bool host_active; /* @@ -1276,6 +1346,65 @@ static inline u32 core_read32(struct apple_atcphy *atcphy, u32 reg) return readl(atcphy->regs.core + reg); } +/* A register of the power and reset block, see atcphy_hw.cfg_offset */ +static inline u32 atcphy_cfg(const struct apple_atcphy *atcphy, u32 reg) +{ + return reg + atcphy->hw->cfg_offset; +} + +static inline u32 atcphy_lane_swap(const struct apple_atcphy *atcphy) +{ + return atcphy->hw->lane_swap ?: ATCPHY_MISC_LANE_SWAP; +} + +/* + * T8152 keeps a lane's registers in AHB reset until the lane is powered up on + * its own, and they drop their tunables meanwhile. Power lane 0, the USB3 lane + * of a fixed-USB3 port, up after the common-a tunables: its LFPS receivers, + * then out of sleep, unclamped and out of AHB reset. Set the crossbar right + * after, before the remaining tunables, as the T8152 sequence does: 0x110 for + * USB3, i.e. USB3+DP with single PMA 0x008. atcphy_configure_lanes() writes the + * same value again later. + */ +static void atcphy_lanes_up_t8152(struct apple_atcphy *atcphy, enum atcphy_mode mode) +{ + const struct atcphy_mode_configuration *mode_cfg = atcphy_get_mode_config(atcphy, mode); + + core_set32(atcphy, ACIOPHY_T8152_AON_SLEEP_CTRL2, + ACIOPHY_T8152_AON_SLEEP_CTRL2_RXA_LFPS_SMALL_LN0); + udelay(1); + core_set32(atcphy, ACIOPHY_T8152_AON_SLEEP_CTRL2, + ACIOPHY_T8152_AON_SLEEP_CTRL2_RXA_LFPS_BIG_LN0); + udelay(1); + core_set32(atcphy, ACIOPHY_T8152_AON_LANE0, ACIOPHY_T8152_AON_LANE_SLEEP_SMALL); + udelay(1); + core_set32(atcphy, ACIOPHY_T8152_AON_LANE0, ACIOPHY_T8152_AON_LANE_SLEEP_BIG); + udelay(1); + core_clear32(atcphy, ACIOPHY_T8152_AON_LANE0, ACIOPHY_T8152_AON_LANE_CLAMP_EN); + udelay(1); + core_set32(atcphy, ACIOPHY_T8152_AON_LANE0, ACIOPHY_T8152_AON_LANE_AHB_RESET_N); + udelay(1); + + core_mask32(atcphy, atcphy->hw->aciophy_crossbar, + ACIOPHY_CROSSBAR_PROTOCOL | ACIOPHY_CROSSBAR_DP_SINGLE_PMA, + FIELD_PREP(ACIOPHY_CROSSBAR_PROTOCOL, mode_cfg->crossbar) | + FIELD_PREP(ACIOPHY_CROSSBAR_DP_SINGLE_PMA, + mode_cfg->crossbar_dp_single_pma)); +} + +/* T8152: power lane 0 down as the PHY powers down, the reverse of the above */ +static void atcphy_lanes_down_t8152(struct apple_atcphy *atcphy) +{ + core_clear32(atcphy, ACIOPHY_T8152_AON_LANE0, ACIOPHY_T8152_AON_LANE_AHB_RESET_N); + udelay(1); + core_set32(atcphy, ACIOPHY_T8152_AON_LANE0, ACIOPHY_T8152_AON_LANE_CLAMP_EN); + udelay(1); + core_clear32(atcphy, ACIOPHY_T8152_AON_LANE0, ACIOPHY_T8152_AON_LANE_SLEEP_BIG); + udelay(1); + core_clear32(atcphy, ACIOPHY_T8152_AON_LANE0, ACIOPHY_T8152_AON_LANE_SLEEP_SMALL); + udelay(1); +} + /* Static configuration fields already read/modified by the public DP path. */ static void j700_dp_tunables(struct apple_atcphy *atcphy) { @@ -1305,6 +1434,8 @@ static void atcphy_apply_tunables(struct apple_atcphy *atcphy, enum atcphy_mode } apple_tunable_apply(atcphy->regs.core, atcphy->tunables.common[0]); + if (atcphy->hw->gen == ATCPHY_GENERATION_T8152) + atcphy_lanes_up_t8152(atcphy, mode); apple_tunable_apply(atcphy->regs.axi2af, atcphy->tunables.axi2af); apple_tunable_apply(atcphy->regs.core, atcphy->tunables.common[1]); @@ -1389,6 +1520,10 @@ static int atcphy_pipehandler_lock(struct apple_atcphy *atcphy) if (IS_ENABLED(CONFIG_PHY_APPLE_ATC_KUNIT_TEST)) KUNIT_STATIC_STUB_REDIRECT(atcphy_pipehandler_lock, atcphy); + if (atcphy->hw->pipe_lock_unacked) { + set32(atcphy->regs.pipehandler + PIPEHANDLER_LOCK_REQ, PIPEHANDLER_LOCK_EN); + return 0; + } return atcphy_pipehandler_lock_timeout(atcphy, atcphy->hw->gen == ATCPHY_GENERATION_T8132 ? 6000 : PIPEHANDLER_LOCK_ACK_TIMEOUT_US); @@ -1631,6 +1766,77 @@ static int atcphy_configure_pipehandler_usb3_host_t8132(struct apple_atcphy *atc return ret; } +/* T8152: latch the BIST override registers into the USB side of the PHY */ +static void atcphy_t8152_bist_sync(struct apple_atcphy *atcphy) +{ + core_set32(atcphy, ACIOPHY_T8152_BIST_CFG0, ACIOPHY_T8152_BIST_CFG0_USB_REGSYNC); + core_read32(atcphy, ACIOPHY_T8152_BIST_CFG0); + core_clear32(atcphy, ACIOPHY_T8152_BIST_CFG0, ACIOPHY_T8152_BIST_CFG0_USB_REGSYNC); +} + +static void atcphy_t8152_bist_ack(struct apple_atcphy *atcphy) +{ + core_set32(atcphy, ACIOPHY_T8152_BIST_CFG2, ACIOPHY_T8152_BIST_CFG2_LN0_PHY_STATUS_RE); + core_clear32(atcphy, ACIOPHY_T8152_BIST_CFG2, ACIOPHY_T8152_BIST_CFG2_LN0_PHY_STATUS_RE); +} + +/* + * T8152: while the PIPE moves from the dummy PHY to this one, the BIST + * overrides hold lane 0's PIPE reset and power-down, the power-down stepping + * from P2 to P3, and the non-selected PHY override is released under them. + */ +static int atcphy_configure_pipehandler_usb3_host_t8152(struct apple_atcphy *atcphy) +{ + void __iomem *status = atcphy->regs.core + ACIOPHY_T8152_BIST_STATUS1; + int ret, error = 0; + u32 reg; + + core_set32(atcphy, ACIOPHY_T8152_BIST_CFG0, ACIOPHY_T8152_BIST_CFG0_CLOCK_EN); + core_mask32(atcphy, ACIOPHY_T8152_BIST_OV1, ACIOPHY_T8152_BIST_OV1_LN0_PWR_DOWN, + ACIOPHY_T8152_BIST_OV1_LN0_PIPE_RESET_N | + FIELD_PREP(ACIOPHY_T8152_BIST_OV1_LN0_PWR_DOWN, 2)); + core_mask32(atcphy, ACIOPHY_T8152_BIST_OV2, ACIOPHY_T8152_BIST_OV2_LN0, + ACIOPHY_T8152_BIST_OV2_LN0_PIPE_RESET_N_OV | + ACIOPHY_T8152_BIST_OV2_LN0_PWR_DOWN_OV); + atcphy_t8152_bist_sync(atcphy); + ret = readl_poll_timeout(status, reg, !(reg & ACIOPHY_T8152_BIST_STATUS1_LN0_PHY_STATUS2), + 10, 20000); + if (ret) { + error = ret; + dev_warn(atcphy->dev, "T8152 USB3 BIST: PHY status stuck in P2 (%#x)\n", reg); + } + atcphy_t8152_bist_ack(atcphy); + + core_mask32(atcphy, ACIOPHY_T8152_BIST_OV1, ACIOPHY_T8152_BIST_OV1_LN0_PWR_DOWN, + FIELD_PREP(ACIOPHY_T8152_BIST_OV1_LN0_PWR_DOWN, 3)); + core_mask32(atcphy, ACIOPHY_T8152_BIST_OV2, + ACIOPHY_T8152_BIST_OV2_LN0_PWR_DOWN_OV | ACIOPHY_T8152_BIST_OV2_LN0_UNK10, + ACIOPHY_T8152_BIST_OV2_LN0_PWR_DOWN_OV); + atcphy_t8152_bist_sync(atcphy); + ret = readl_poll_timeout(status, reg, reg & ACIOPHY_T8152_BIST_STATUS1_LN0_PHY_STATUS, + 10, 130000); + if (ret) { + if (!error) + error = ret; + dev_warn(atcphy->dev, "T8152 USB3 BIST: no PHY status in P3 (%#x)\n", reg); + } + ret = readl_poll_timeout(status, reg, !(reg & ACIOPHY_T8152_BIST_STATUS1_LN0_PHY_STATUS2), + 10, 1000); + if (ret) { + if (!error) + error = ret; + dev_warn(atcphy->dev, "T8152 USB3 BIST: PHY status stuck in P3 (%#x)\n", reg); + } + atcphy_t8152_bist_ack(atcphy); + + atcphy_clear_nonselected_phy_reset(atcphy); + + core_clear32(atcphy, ACIOPHY_T8152_BIST_OV2, ACIOPHY_T8152_BIST_OV2_LN0); + atcphy_t8152_bist_sync(atcphy); + core_clear32(atcphy, ACIOPHY_T8152_BIST_CFG0, ACIOPHY_T8152_BIST_CFG0_CLOCK_EN); + return error; +} + static int atcphy_configure_pipehandler_usb3_host_t8103(struct apple_atcphy *atcphy) { int ret, error = 0; @@ -1738,6 +1944,8 @@ static int atcphy_configure_pipehandler_usb3(struct apple_atcphy *atcphy, bool h ret = atcphy_configure_pipehandler_usb3_host_t8103(atcphy); else if (atcphy->hw->gen == ATCPHY_GENERATION_T8132) ret = atcphy_configure_pipehandler_usb3_host_t8132(atcphy); + else if (atcphy->hw->gen == ATCPHY_GENERATION_T8152) + ret = atcphy_configure_pipehandler_usb3_host_t8152(atcphy); else ret = atcphy_configure_pipehandler_usb3_host_t8122(atcphy); if (ret) { @@ -2147,21 +2355,23 @@ static int atcphy_configure_lanes(struct apple_atcphy *atcphy, enum atcphy_mode mode == APPLE_ATCPHY_MODE_DP)) return j700_dp_route(atcphy, mode == APPLE_ATCPHY_MODE_DP); - core_mask32(atcphy, atcphy->hw->aciophy_lane_mode, ACIOPHY_LANE_MODE_RX0, - FIELD_PREP(ACIOPHY_LANE_MODE_RX0, mode_cfg->lane_mode[0])); - core_mask32(atcphy, atcphy->hw->aciophy_lane_mode, ACIOPHY_LANE_MODE_TX0, - FIELD_PREP(ACIOPHY_LANE_MODE_TX0, mode_cfg->lane_mode[0])); - core_mask32(atcphy, atcphy->hw->aciophy_lane_mode, ACIOPHY_LANE_MODE_RX1, - FIELD_PREP(ACIOPHY_LANE_MODE_RX1, mode_cfg->lane_mode[1])); - core_mask32(atcphy, atcphy->hw->aciophy_lane_mode, ACIOPHY_LANE_MODE_TX1, - FIELD_PREP(ACIOPHY_LANE_MODE_TX1, mode_cfg->lane_mode[1])); + if (atcphy->hw->aciophy_lane_mode) { + core_mask32(atcphy, atcphy->hw->aciophy_lane_mode, ACIOPHY_LANE_MODE_RX0, + FIELD_PREP(ACIOPHY_LANE_MODE_RX0, mode_cfg->lane_mode[0])); + core_mask32(atcphy, atcphy->hw->aciophy_lane_mode, ACIOPHY_LANE_MODE_TX0, + FIELD_PREP(ACIOPHY_LANE_MODE_TX0, mode_cfg->lane_mode[0])); + core_mask32(atcphy, atcphy->hw->aciophy_lane_mode, ACIOPHY_LANE_MODE_RX1, + FIELD_PREP(ACIOPHY_LANE_MODE_RX1, mode_cfg->lane_mode[1])); + core_mask32(atcphy, atcphy->hw->aciophy_lane_mode, ACIOPHY_LANE_MODE_TX1, + FIELD_PREP(ACIOPHY_LANE_MODE_TX1, mode_cfg->lane_mode[1])); + } core_mask32(atcphy, atcphy->hw->aciophy_crossbar, ACIOPHY_CROSSBAR_PROTOCOL, FIELD_PREP(ACIOPHY_CROSSBAR_PROTOCOL, mode_cfg->crossbar)); if (mode_cfg->set_swap) - core_set32(atcphy, ATCPHY_MISC, ATCPHY_MISC_LANE_SWAP); + core_set32(atcphy, atcphy_cfg(atcphy, ATCPHY_MISC), atcphy_lane_swap(atcphy)); else - core_clear32(atcphy, ATCPHY_MISC, ATCPHY_MISC_LANE_SWAP); + core_clear32(atcphy, atcphy_cfg(atcphy, ATCPHY_MISC), atcphy_lane_swap(atcphy)); core_mask32(atcphy, atcphy->hw->aciophy_crossbar, ACIOPHY_CROSSBAR_DP_SINGLE_PMA, FIELD_PREP(ACIOPHY_CROSSBAR_DP_SINGLE_PMA, mode_cfg->crossbar_dp_single_pma)); @@ -2173,8 +2383,10 @@ static int atcphy_configure_lanes(struct apple_atcphy *atcphy, enum atcphy_mode /* * The PMA FSM override below is for the T8103 generation. T8122 DP lanes * are started by the link rate sequence, see atcphy_dp_set_rate_t8122(). + * T8152 runs USB3 alone. */ - if (atcphy->hw->gen == ATCPHY_GENERATION_T8122) + if (atcphy->hw->gen == ATCPHY_GENERATION_T8122 || + atcphy->hw->gen == ATCPHY_GENERATION_T8152) return 0; if (mode_cfg->dp_lane[0]) { @@ -2707,34 +2919,43 @@ static int atcphy_power_off(struct apple_atcphy *atcphy) u32 reg; int ret; - if (atcphy->hw->gen != ATCPHY_GENERATION_T8132) { + /* A fixed-USB3 port has no DisplayPort side */ + if (atcphy->hw->gen != ATCPHY_GENERATION_T8132 && !atcphy->fixed_usb3) { ret = atcphy_disable_dp_aux(atcphy); if (ret) return ret; } /* Enable all reset lines */ - core_clear32(atcphy, ATCPHY_POWER_CTRL, ATCPHY_POWER_PHY_RESET_N); - core_set32(atcphy, ATCPHY_POWER_CTRL, ATCPHY_POWER_CLAMP_EN); - core_clear32(atcphy, ATCPHY_MISC, ATCPHY_MISC_RESET_N | ATCPHY_MISC_LANE_SWAP); - core_clear32(atcphy, ATCPHY_POWER_CTRL, ATCPHY_POWER_APB_RESET_N); - - core_clear32(atcphy, ATCPHY_POWER_CTRL, ATCPHY_POWER_SLEEP_BIG); - ret = readl_poll_timeout(atcphy->regs.core + ATCPHY_POWER_STAT, reg, + core_clear32(atcphy, atcphy_cfg(atcphy, ATCPHY_POWER_CTRL), ATCPHY_POWER_PHY_RESET_N); + if (atcphy->hw->gen == ATCPHY_GENERATION_T8152) + atcphy_lanes_down_t8152(atcphy); + core_set32(atcphy, atcphy_cfg(atcphy, ATCPHY_POWER_CTRL), ATCPHY_POWER_CLAMP_EN); + if (!atcphy->hw->sync_reset) + core_clear32(atcphy, atcphy_cfg(atcphy, ATCPHY_MISC), + ATCPHY_MISC_RESET_N | ATCPHY_MISC_LANE_SWAP); + core_clear32(atcphy, atcphy_cfg(atcphy, ATCPHY_POWER_CTRL), ATCPHY_POWER_APB_RESET_N); + + core_clear32(atcphy, atcphy_cfg(atcphy, ATCPHY_POWER_CTRL), ATCPHY_POWER_SLEEP_BIG); + ret = readl_poll_timeout(atcphy->regs.core + atcphy_cfg(atcphy, ATCPHY_POWER_STAT), reg, !(reg & ATCPHY_POWER_SLEEP_BIG), 10, 1000); if (ret) { dev_err(atcphy->dev, "Failed to sleep atcphy \"big\"\n"); return ret; } - core_clear32(atcphy, ATCPHY_POWER_CTRL, ATCPHY_POWER_SLEEP_SMALL); - ret = readl_poll_timeout(atcphy->regs.core + ATCPHY_POWER_STAT, reg, + core_clear32(atcphy, atcphy_cfg(atcphy, ATCPHY_POWER_CTRL), ATCPHY_POWER_SLEEP_SMALL); + ret = readl_poll_timeout(atcphy->regs.core + atcphy_cfg(atcphy, ATCPHY_POWER_STAT), reg, !(reg & ATCPHY_POWER_SLEEP_SMALL), 10, 1000); if (ret) { dev_err(atcphy->dev, "Failed to sleep atcphy \"small\"\n"); return ret; } + /* A separate sync reset is asserted last, once the block sleeps */ + if (atcphy->hw->sync_reset) + core_clear32(atcphy, atcphy->hw->sync_reset, ATCPHY_MISC_RESET_N); + return 0; } @@ -2792,29 +3013,30 @@ static int atcphy_power_on(struct apple_atcphy *atcphy) u32 reg; int ret; - if (!atcphy->dp_only) + if (!atcphy->dp_only && !atcphy->fixed_usb3) atcphy_usb2_power_on(atcphy); - core_set32(atcphy, ATCPHY_MISC, ATCPHY_MISC_RESET_N); + core_set32(atcphy, atcphy->hw->sync_reset ?: atcphy_cfg(atcphy, ATCPHY_MISC), + ATCPHY_MISC_RESET_N); - core_set32(atcphy, ATCPHY_POWER_CTRL, ATCPHY_POWER_SLEEP_SMALL); - ret = readl_poll_timeout(atcphy->regs.core + ATCPHY_POWER_STAT, reg, + core_set32(atcphy, atcphy_cfg(atcphy, ATCPHY_POWER_CTRL), ATCPHY_POWER_SLEEP_SMALL); + ret = readl_poll_timeout(atcphy->regs.core + atcphy_cfg(atcphy, ATCPHY_POWER_STAT), reg, reg & ATCPHY_POWER_SLEEP_SMALL, 100, 100000); if (ret) { dev_err(atcphy->dev, "failed to wakeup atcphy \"small\"\n"); return ret; } - core_set32(atcphy, ATCPHY_POWER_CTRL, ATCPHY_POWER_SLEEP_BIG); - ret = readl_poll_timeout(atcphy->regs.core + ATCPHY_POWER_STAT, reg, + core_set32(atcphy, atcphy_cfg(atcphy, ATCPHY_POWER_CTRL), ATCPHY_POWER_SLEEP_BIG); + ret = readl_poll_timeout(atcphy->regs.core + atcphy_cfg(atcphy, ATCPHY_POWER_STAT), reg, reg & ATCPHY_POWER_SLEEP_BIG, 100, 100000); if (ret) { dev_err(atcphy->dev, "failed to wakeup atcphy \"big\"\n"); return ret; } - core_clear32(atcphy, ATCPHY_POWER_CTRL, ATCPHY_POWER_CLAMP_EN); - core_set32(atcphy, ATCPHY_POWER_CTRL, ATCPHY_POWER_APB_RESET_N); + core_clear32(atcphy, atcphy_cfg(atcphy, ATCPHY_POWER_CTRL), ATCPHY_POWER_CLAMP_EN); + core_set32(atcphy, atcphy_cfg(atcphy, ATCPHY_POWER_CTRL), ATCPHY_POWER_APB_RESET_N); return 0; } @@ -4265,7 +4487,8 @@ static int atcphy_configure(struct apple_atcphy *atcphy, enum atcphy_mode mode) apple_tunable_apply(atcphy->regs.lioa, atcphy->tunables.dp_lioa); apple_tunable_apply(atcphy->regs.lpdptx, atcphy->tunables.dp_common_config); } - atcphy->hw->configure_post_tunable(atcphy, mode); + if (atcphy->hw->configure_post_tunable) + atcphy->hw->configure_post_tunable(atcphy, mode); /* Setup AUX channel if DP altmode is requested */ if (atcphy_modes[mode].enable_dp_aux) { @@ -4284,7 +4507,7 @@ static int atcphy_configure(struct apple_atcphy *atcphy, enum atcphy_mode mode) return ret; /* Take the USB3 PHY out of reset */ - core_set32(atcphy, ATCPHY_POWER_CTRL, ATCPHY_POWER_PHY_RESET_N); + core_set32(atcphy, atcphy_cfg(atcphy, ATCPHY_POWER_CTRL), ATCPHY_POWER_PHY_RESET_N); /* * NOTE: Not what macos does, it takes the phy out of reset right before * writing to ACIOPHY_CFG0_COMMON_SMALL, does lane configuration with phy @@ -4753,7 +4976,7 @@ static int atcphy_usb3_set_mode(struct phy *phy, enum phy_mode mode, int submode readl(atcphy->regs.pipehandler + PIPEHANDLER_MUX_CTRL), readl(atcphy->regs.pipehandler + PIPEHANDLER_NONSELECTED_OVERRIDE), readl(atcphy->regs.pipehandler + PIPEHANDLER_T8132_USB2_CONFIG)); - if (!ret || !atcphy->fixed_usb2 || mode != PHY_MODE_USB_HOST) + if (!ret || !(atcphy->fixed_usb2 || atcphy->fixed_usb3) || mode != PHY_MODE_USB_HOST) return ret; /* @@ -4761,7 +4984,8 @@ static int atcphy_usb3_set_mode(struct phy *phy, enum phy_mode mode, int submode * fails, xHCI registers neither of its root hubs. Let it start, with * the PIPE parked if that works: the Type-C mux update that restores * the lanes or retries the handoff routes the PIPE, with the - * SuperSpeed port off. + * SuperSpeed port off. On a fixed-USB3 port the controller's next + * power-on of this PHY tries again. */ if (atcphy_park_pipehandler(atcphy, false)) dev_warn(atcphy->dev, "Host starts with its PIPE not parked\n"); @@ -4770,6 +4994,35 @@ static int atcphy_usb3_set_mode(struct phy *phy, enum phy_mode mode, int submode return 0; } +/* + * A fixed-USB3 port's controller is a host by construction. It powers this + * PHY on after its core reset, before the host starts: route the PIPE to the + * USB3 PHY then, bringing the PHY up in USB3 again first if a power-off took + * it down. A failure here would stop the controller altogether, and with it + * the USB2 side of the same device, so the host then starts with its PIPE + * parked instead. + */ +static int atcphy_usb3_power_on(struct phy *phy) +{ + struct apple_atcphy *atcphy = phy_get_drvdata(phy); + int ret = 0; + + guard(mutex)(&atcphy->lock); + atcphy->host_active = true; + if (atcphy->mode != APPLE_ATCPHY_MODE_USB3 || atcphy->mode_dirty) + ret = atcphy_configure(atcphy, APPLE_ATCPHY_MODE_USB3); + if (!ret) + ret = atcphy_usb3_route(atcphy, true); + if (!ret) + return 0; + + if (atcphy_park_pipehandler(atcphy, false)) + dev_warn(atcphy->dev, "Host starts with its PIPE not parked\n"); + else + dev_warn(atcphy->dev, "Host starts without USB3: %d\n", ret); + return 0; +} + static int atcphy_usb3_exit(struct phy *phy) { struct apple_atcphy *atcphy = phy_get_drvdata(phy); @@ -4817,6 +5070,17 @@ static const struct phy_ops apple_atc_usb3_phy_ops = { .set_mode = atcphy_rpm_usb3_set_mode, }; +/* + * A fixed-USB3 port also routes its PIPE at power-on. Its PHY never + * runtime-suspends (see atcphy_rpm_get()), so it needs no runtime PM wrappers. + */ +static const struct phy_ops apple_atc_fixed_usb3_phy_ops = { + .owner = THIS_MODULE, + .power_on = atcphy_usb3_power_on, + .power_off = atcphy_usb3_power_off, + .set_mode = atcphy_usb3_set_mode, +}; + /* * The T8132 PHY has no DisplayPort alternate mode: its DP PHY only exists so * that a DisplayPort tunnel can get its pixel clock, see @@ -5206,7 +5470,7 @@ static struct phy *atcphy_xlate(struct device *dev, const struct of_phandle_args default: return ERR_PTR(-ENODEV); } - /* A DisplayPort-only or USB2-only instance omits the other PHYs. */ + /* A DisplayPort-, USB2- or USB3-only instance omits the other PHYs. */ return phy ?: ERR_PTR(-ENODEV); } @@ -5217,18 +5481,20 @@ static int atcphy_probe_phy(struct apple_atcphy *atcphy) const struct phy_ops *ops; } phys[] = { { &atcphy->phys.usb2, &apple_atc_usb2_phy_ops }, - { &atcphy->phys.usb3, &apple_atc_usb3_phy_ops }, + { &atcphy->phys.usb3, atcphy->fixed_usb3 ? &apple_atc_fixed_usb3_phy_ops : + &apple_atc_usb3_phy_ops }, { &atcphy->phys.dp, &apple_atc_dp_phy_ops }, }; /* * A T8132 PHY with its USB3/USB4 banks gets a DP PHY for DisplayPort * tunnels only (see atcphy_dpphy_set_mode_t8132()); creating it does - * not touch the hardware. + * not touch the hardware. A fixed-USB3 PHY gets its USB3 PHY only. */ for (int i = 0; i < ARRAY_SIZE(phys); i++) { if ((atcphy->dp_only && phys[i].phy != &atcphy->phys.dp) || - (atcphy_usb2_only(atcphy) && i != 0)) + (atcphy_usb2_only(atcphy) && i != 0) || + (atcphy->fixed_usb3 && phys[i].phy != &atcphy->phys.usb3)) continue; *phys[i].phy = devm_phy_create(atcphy->dev, NULL, phys[i].ops); if (IS_ERR(*phys[i].phy)) @@ -6412,6 +6678,14 @@ static int atcphy_load_tunables(struct apple_atcphy *atcphy) bool lane_dp = tunables[i].tunable == &atcphy->tunables.lane_dp[0] || tunables[i].tunable == &atcphy->tunables.lane_dp[1]; + /* a fixed-USB3 port runs USB3 on lane 0 alone and has no axi2af window */ + if (atcphy->fixed_usb3 && + tunables[i].tunable != &atcphy->tunables.common[0] && + tunables[i].tunable != &atcphy->tunables.common[1] && + tunables[i].tunable != &atcphy->tunables.lane_usb3[0]) { + *tunables[i].tunable = NULL; + continue; + } if (!atcphy->hw->has_usb4 && (tunables[i].tunable == &atcphy->tunables.lane_usb4[0] || tunables[i].tunable == &atcphy->tunables.lane_usb4[1])) { @@ -6516,6 +6790,28 @@ static int atcphy_map_resources(struct platform_device *pdev, struct apple_atcph struct resource *res; void __iomem *addr; + /* + * A fixed-USB3 PHY has its core and PIPE windows only. On T8152 the + * core window also holds the USB controller's DARTs, so it is mapped + * without claiming it. + */ + if (atcphy->fixed_usb3) { + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "core"); + if (!res) + return dev_err_probe(atcphy->dev, -EINVAL, "Missing core regs\n"); + atcphy->regs.core = devm_ioremap(&pdev->dev, res->start, resource_size(res)); + if (!atcphy->regs.core) + return -ENOMEM; + atcphy->res.core = res; + + addr = devm_platform_ioremap_resource_byname(pdev, "pipehandler"); + if (IS_ERR(addr)) + return dev_err_probe(atcphy->dev, PTR_ERR(addr), + "Unable to map pipehandler regs\n"); + atcphy->regs.pipehandler = addr; + return 0; + } + if (atcphy->hw->gen == ATCPHY_GENERATION_T8132 && platform_get_resource_byname(pdev, IORESOURCE_MEM, "common-config")) { static const char * const names[] = { @@ -6743,6 +7039,34 @@ static int atcphy_probe_finalize_dp_only(struct apple_atcphy *atcphy) return 0; } +/* + * A fixed-USB3 port: the bootloader hands its controller over running, with + * the controller's reset and its USB2 side its own, and no Type-C mux sits in + * front of the lanes, so there is no reset controller, mux or switch to + * register. Take the PHY from the state the bootloader left it in to USB3; the + * PIPE follows when the controller powers its USB3 PHY on, which also tries + * again if this fails, see atcphy_usb3_power_on(). + */ +static int atcphy_probe_finalize_fixed_usb3(struct apple_atcphy *atcphy) +{ + int ret; + + lockdep_assert_held(&atcphy->lock); + + atcphy_power_off(atcphy); + atcphy_setup_pipehandler(atcphy); + ret = atcphy_configure(atcphy, APPLE_ATCPHY_MODE_USB3); + if (ret) + dev_warn(atcphy->dev, "USB3 not up yet: %d\n", ret); + + ret = atcphy_probe_phy(atcphy); + if (ret) { + atcphy_configure(atcphy, APPLE_ATCPHY_MODE_OFF); + return dev_err_probe(atcphy->dev, ret, "Probing phy failed"); + } + return 0; +} + static int atcphy_probe_finalize(struct apple_atcphy *atcphy) { int ret; @@ -6751,6 +7075,8 @@ static int atcphy_probe_finalize(struct apple_atcphy *atcphy) if (atcphy->dp_only) return atcphy_probe_finalize_dp_only(atcphy); + if (atcphy->fixed_usb3) + return atcphy_probe_finalize_fixed_usb3(atcphy); /* Reset dwc3 on probe, let dwc3 (consumer) deassert it */ _atcphy_dwc3_reset_assert(atcphy); @@ -6882,6 +7208,25 @@ static bool atcphy_has_t8103_usb3_workaround(const struct atcphy_hw *hw, of_device_is_compatible(root, "apple,t8103"); } +/* + * The driver core attaches a single power domain. A fixed-USB3 PHY may list + * several, like T8152's ATC power states and PSD service: hold them all on + * while it is bound, powered up in the order they are listed. + */ +static int atcphy_probe_power_domains(struct apple_atcphy *atcphy) +{ + struct dev_pm_domain_attach_data pd_data = { .pd_flags = PD_FLAG_DEV_LINK_ON }; + struct dev_pm_domain_list *pd_list; + int ret; + + if (!atcphy->fixed_usb3 || atcphy->dev->pm_domain) + return 0; + ret = devm_pm_domain_attach_list(atcphy->dev, &pd_data, &pd_list); + if (ret < 0) + return dev_err_probe(atcphy->dev, ret, "Failed to attach power domains\n"); + return 0; +} + static void atcphy_sleep_finish_work(struct work_struct *work); static int atcphy_probe(struct platform_device *pdev) @@ -6904,6 +7249,10 @@ static int atcphy_probe(struct platform_device *pdev) atcphy->np = dev->of_node; atcphy->t8132_dp_alt = atcphy->hw->gen == ATCPHY_GENERATION_T8132 && of_property_read_bool(dev->of_node, "apple,dp-alt-mode"); + atcphy->fixed_usb3 = of_property_read_bool(dev->of_node, "apple,fixed-usb3"); + /* T8152 is supported on a fixed-USB3 port only */ + if (atcphy->hw->gen == ATCPHY_GENERATION_T8152 && !atcphy->fixed_usb3) + return dev_err_probe(dev, -ENODEV, "Only a fixed-USB3 port is supported\n"); apple_atc_tunnel_wiring(atcphy); mutex_init(&atcphy->lock); platform_set_drvdata(pdev, atcphy); @@ -6912,6 +7261,9 @@ static int atcphy_probe(struct platform_device *pdev) if (ret) return ret; ret = atcphy_load_tunables(atcphy); + if (ret) + return ret; + ret = atcphy_probe_power_domains(atcphy); if (ret) return ret; @@ -7983,12 +8335,37 @@ static const struct atcphy_hw atcphy_hw_t8142 = { .clear_boot_hold = true, }; +/* + * T8152 as the USB3 PHY of a fixed-USB3 port: no USB4, DisplayPort or lane + * mode register and nothing to wake after the tunables. Its power domains are + * not followed: the controller's power-off and power-on of the PHY, as around + * a system sleep, take it down and up again. + */ +static const struct atcphy_hw atcphy_hw_t8152 = { + .gen = ATCPHY_GENERATION_T8152, + .aciophy_crossbar = ACIOPHY_CROSSBAR_T8103, + .cfg_offset = ATCPHY_T8152_CFG_OFFSET, + .sync_reset = ATCPHY_T8152_SYNC_RESET, + .lane_swap = ATCPHY_T8152_MISC_LANE_SWAP, + .pipe_mux_clk = PIPEHANDLER_MUX_CTRL_CLK_T8142, + .pipe_mux_data = PIPEHANDLER_MUX_CTRL_DATA_T8142, + .park_dummy_phy = true, + .clear_boot_hold = true, + /* + * With the controller out of reset, the J873g front port's PIPE handler + * left the lock unacknowledged for 150 ms in both directions, while the + * PIPE moved to USB3 and back to the dummy PHY under the request. + */ + .pipe_lock_unacked = true, +}; + static const struct of_device_id atcphy_match[] = { { .compatible = "apple,t8103-atcphy", .data = &atcphy_hw_t8103 }, { .compatible = "apple,t8122-atcphy", .data = &atcphy_hw_t8122 }, { .compatible = "apple,t8132-atcphy", .data = &atcphy_hw_t8132 }, { .compatible = "apple,t8142-atcphy", .data = &atcphy_hw_t8142 }, { .compatible = "apple,t8140-atcphy", .data = &atcphy_hw_t8140 }, + { .compatible = "apple,t8152-atcphy", .data = &atcphy_hw_t8152 }, {}, }; MODULE_DEVICE_TABLE(of, atcphy_match); diff --git a/tools/asahi/atc-usb3-tests.py b/tools/asahi/atc-usb3-tests.py index 3a7955197c9f9..d9f9aacb4d38f 100644 --- a/tools/asahi/atc-usb3-tests.py +++ b/tools/asahi/atc-usb3-tests.py @@ -78,7 +78,7 @@ def block(source, marker): STUBS = r''' struct atcphy_hw { enum atcphy_generation gen; bool has_t8140_dp, dp_t8122, has_usb4, park_pipe_unlocked, park_dummy_phy, usb2_only; - bool clear_boot_hold, dp_banked_tunables; }; + bool clear_boot_hold, dp_banked_tunables, pipe_lock_unacked; }; struct device_node { const char *const *compatible; unsigned int count; }; static bool of_device_is_compatible(const struct device_node *root, const char *compatible) { if (!root) return false; @@ -98,7 +98,7 @@ def block(source, marker): enum atcphy_pipehandler_state pipe_state; enum atcphy_mode typec_mode; bool pipe_pending, t8103_dummy_pending, t8103_usb3_retry, t8103_usb3_workaround, mode_dirty, usb_off_pending; - bool host_active, usb3_port_off, dp_only, ss_tunables, fixed_usb2, t8140_dp_tunables, dp_tunables; + bool host_active, usb3_port_off, dp_only, ss_tunables, fixed_usb2, fixed_usb3, t8140_dp_tunables, dp_tunables; /* T8132 ownership is tested without entering its lane-setup backend. */ bool t8132_ss, t8132_common_owned, t8132_failed, cio_tunables, t8132_dp_alt; struct { void *usb3_dp; } tunables; @@ -185,6 +185,9 @@ def block(source, marker): static int atcphy_configure_pipehandler_usb3_host_t8132(struct apple_atcphy *a) { (void)a; assert(!"T8132 PIPE setup reached"); return -EINVAL; } +static int atcphy_configure_pipehandler_usb3_host_t8152(struct apple_atcphy *a) { + (void)a; assert(!"T8152 PIPE setup reached"); return -EINVAL; +} static void atcphy_usb2_power_on(struct apple_atcphy *a) { (void)a; assert(!"USB2-only power restore reached"); } diff --git a/tools/testing/selftests/drivers/apple/atc-t8132-usb3.py b/tools/testing/selftests/drivers/apple/atc-t8132-usb3.py index 7eeb90baf4385..ed02e7f33b562 100755 --- a/tools/testing/selftests/drivers/apple/atc-t8132-usb3.py +++ b/tools/testing/selftests/drivers/apple/atc-t8132-usb3.py @@ -92,7 +92,8 @@ def main(): ''' declarations = r''' struct apple_tunable { unsigned id; }; -struct atcphy_hw { int gen; bool usb2_only, has_usb2phy_reg, park_pipe_unlocked; u32 usb2phy_sig_host; }; +struct atcphy_hw { int gen; bool usb2_only, has_usb2phy_reg, park_pipe_unlocked; u32 usb2phy_sig_host; + u32 cfg_offset, sync_reset; }; enum suspend_state { PM_SUSPEND_TO_IDLE = 1, PM_SUSPEND_MEM = 3 }; static enum suspend_state pm_suspend_target_state; static bool rpm_suspended; @@ -106,7 +107,7 @@ def main(): bool t8132_ss, t8132_common_owned, t8132_suspended, t8132_failed, host_active; bool ss_tunables, mode_dirty, pipe_pending, swap_lanes; bool cio_tunables, t8132_dp_alt, fixed_usb2, hibernated, pd_was_off, idle_rpm; - bool t8103_dummy_pending, t8103_usb3_workaround; + bool t8103_dummy_pending, t8103_usb3_workaround, fixed_usb3; unsigned tunnel_users; struct { bool prepared, changed, restored; } cio_sleep; int mode, pipe_state, lock; @@ -122,6 +123,8 @@ def main(): struct device { struct apple_atcphy *atc; }; static struct apple_atcphy *dev_get_drvdata(struct device *d) { return d->atc; } static struct apple_atcphy *phy_get_drvdata(struct phy *p) { return p->atc; } +/* T8152 only: these rows run T8132, which never reaches it. */ +static void atcphy_lanes_down_t8152(struct apple_atcphy *a) { (void)a; assert(0); } static u32 core[0x24000/4], usb2[0x4000/4], pipe_regs[0x4000/4]; static unsigned tunes[16], tune_count, reset_releases, bist_phase, writes, core_reads; static unsigned stall_power, stall_bist, expected_tunes, stall_sleep; @@ -215,7 +218,7 @@ def main(): } ''' names = ["atcphy_mode_is_cio", "atcphy_usb2_sig_host", "atcphy_t8132_dp_on", - "atcphy_usb2_power_off", "atcphy_power_off", "atcphy_usb2_power_on", + "atcphy_cfg", "atcphy_usb2_power_off", "atcphy_power_off", "atcphy_usb2_power_on", "atcphy_t8132_cold", "atcphy_t8132_common_start", "atcphy_t8132_phy_stop", "atcphy_t8132_full_stop", "atcphy_configure_t8132", "atcphy_usb2_set_mode", "atcphy_t8132_bist_pulse", diff --git a/tools/testing/selftests/drivers/gpu/apple-dcp/common.py b/tools/testing/selftests/drivers/gpu/apple-dcp/common.py index 980a7a8773b97..aee2f68cc7bed 100644 --- a/tools/testing/selftests/drivers/gpu/apple-dcp/common.py +++ b/tools/testing/selftests/drivers/gpu/apple-dcp/common.py @@ -194,6 +194,18 @@ def atc_cio_helpers(source): return result +def atc_cfg_helpers(source): + """Where the power and reset block sits and which bit swaps the lanes, both of + which T8152 moves; the power-up, power-down and lane functions call these. + + Marked unused, as a unit may extract only some of their callers. Older + sources have neither: ''. + """ + return ''.join(atc_function(source, name).replace( + 'static inline ', 'static inline __attribute__((unused)) ', 1) + for name in ('atcphy_cfg', 'atcphy_lane_swap')) + + def atc_restore_helpers(source): """What atcphy_restore_after_pd_off() needs beyond the parking helpers. diff --git a/tools/testing/selftests/drivers/gpu/apple-dcp/dwc3/mocks.c b/tools/testing/selftests/drivers/gpu/apple-dcp/dwc3/mocks.c index cc3197c1b738a..a2d8076ac8b3d 100644 --- a/tools/testing/selftests/drivers/gpu/apple-dcp/dwc3/mocks.c +++ b/tools/testing/selftests/drivers/gpu/apple-dcp/dwc3/mocks.c @@ -25,7 +25,7 @@ struct apple_atcphy { bool aux, pll; unsigned int pairs, rate; } dp_t8122; - bool fixed_usb2, host_active, mode_dirty, ss_tunables, dp_tunables, + bool fixed_usb2, fixed_usb3, host_active, mode_dirty, ss_tunables, dp_tunables, aux_power_requested; unsigned int dp_owned_pmas, dp_idle_pmas; unsigned int dp_usb_context_valid, dp_usb_context_dirty; @@ -252,11 +252,15 @@ static void atcphy_restore_after_pd_off(struct apple_atcphy *p); static int atcphy_power_off(struct apple_atcphy *p); static int atcphy_configure(struct apple_atcphy *p, enum atcphy_mode mode); -/* These units exercise older PHY generations. Never accept a T8132 dispatch. */ +/* These units exercise older PHY generations. Never accept a T8132 or T8152 dispatch. */ static int __attribute__((unused)) atcphy_configure_t8132(struct apple_atcphy *p, enum atcphy_mode mode) { (void)p; (void)mode; assert(false); return -EOPNOTSUPP; } static int __attribute__((unused)) atcphy_configure_pipehandler_usb3_host_t8132(struct apple_atcphy *p) { (void)p; assert(false); return -EOPNOTSUPP; } +static int __attribute__((unused)) atcphy_configure_pipehandler_usb3_host_t8152(struct apple_atcphy *p) +{ (void)p; assert(false); return -EOPNOTSUPP; } +static void __attribute__((unused)) atcphy_lanes_down_t8152(struct apple_atcphy *p) +{ (void)p; assert(false); } /* Model the USB2 power-on boundary's running state. */ diff --git a/tools/testing/selftests/drivers/gpu/apple-dcp/lifecycle.py b/tools/testing/selftests/drivers/gpu/apple-dcp/lifecycle.py index e41e10447eb22..2fc3385d1df6e 100644 --- a/tools/testing/selftests/drivers/gpu/apple-dcp/lifecycle.py +++ b/tools/testing/selftests/drivers/gpu/apple-dcp/lifecycle.py @@ -3,7 +3,7 @@ """Actual disconnect authority, DWC3 teardown and firmware resource admission.""" from pathlib import Path import re -from common import block, apple_function, internal_inline, atc_mux_without_pm, source_defines, ATC_POST_TUNABLE, tipd_pm_header, firmware_lineage, atc_restore_helpers, atc_cio_helpers +from common import block, apple_function, internal_inline, atc_mux_without_pm, source_defines, ATC_POST_TUNABLE, tipd_pm_header, firmware_lineage, atc_restore_helpers, atc_cio_helpers, atc_cfg_helpers def disconnect(root): # Copyright 2026 Ryan Murray @@ -1182,7 +1182,7 @@ def fn(n, name): names = {n: tuple(name for name in group if re.search(r'^(?:static [^\n]*\b|(?:int|void) )' + name + r'\(', files[n], re.M)) for n, group in names.items()} context = (fn('atc', 'core_read32') + '\n' + fn('atc', 'atcphy_get_mode_config') + '\n' + fn('atc', 'j700_field_update') + '\n' + files['dp'][files['dp'].index('/* Masks are the union'):files['dp'].index('/* Retry only the idle operations')]) - functions = atc_cio_helpers(files['atc']) + '\n\n'.join(fn(n, name) for n, group in names.items() for name in group) + functions = atc_cio_helpers(files['atc']) + atc_cfg_helpers(files['atc']) + '\n\n'.join(fn(n, name) for n, group in names.items() for name in group) definitions = [] lines = iter(files['atc'].splitlines()) for line in lines: diff --git a/tools/testing/selftests/drivers/gpu/apple-dcp/phy.py b/tools/testing/selftests/drivers/gpu/apple-dcp/phy.py index 26c0f62dabb25..45c8275bf462e 100644 --- a/tools/testing/selftests/drivers/gpu/apple-dcp/phy.py +++ b/tools/testing/selftests/drivers/gpu/apple-dcp/phy.py @@ -5,7 +5,7 @@ import re from common import (block, source_defines, atc_mux_without_pm, ATC_POST_TUNABLE, atc_function, ATC_SPLIT, ATC_T8103_LIVE, atc_restore_helpers, atc_common_state_helpers, - atc_cio_helpers) + atc_cio_helpers, atc_cfg_helpers) def parking(root): @@ -46,7 +46,7 @@ def function(source, name): struct reset_controller_dev rcdev; void *dev; int lock, dp_link_rate; - bool fixed_usb2, host_active, swap_lanes, ss_tunables, dp_tunables; + bool fixed_usb2, fixed_usb3, host_active, swap_lanes, ss_tunables, dp_tunables; bool aux_power_requested, mode_dirty, dp_spread_spectrum, dp_presets_valid[5]; u32 dp_presets[5][16]; unsigned int dp_idle_pmas, dp_owned_pmas; @@ -67,6 +67,7 @@ def function(source, name): start = atc.index('static const struct {\n\tconst struct atcphy_mode_configuration normal;') parts.append(atc[start:atc.index('\n};', start) + 3]) parts.append(atc_cio_helpers(atc)) + parts.append(atc_cfg_helpers(atc)) parts.append(r''' struct phy_configure_opts_dp { unsigned int link_rate, lanes, voltage[4], pre[4]; @@ -160,11 +161,15 @@ def function(source, name): static int atcphy_power_off(struct apple_atcphy *); static int atcphy_configure(struct apple_atcphy *, enum atcphy_mode); -/* These units exercise older PHY generations. Never accept a T8132 dispatch. */ +/* These units exercise older PHY generations. Never accept a T8132 or T8152 dispatch. */ static int __attribute__((unused)) atcphy_configure_t8132(struct apple_atcphy *p, enum atcphy_mode mode) { (void)p; (void)mode; assert(false); return -EOPNOTSUPP; } static int __attribute__((unused)) atcphy_configure_pipehandler_usb3_host_t8132(struct apple_atcphy *p) { (void)p; assert(false); return -EOPNOTSUPP; } +static int __attribute__((unused)) atcphy_configure_pipehandler_usb3_host_t8152(struct apple_atcphy *p) +{ (void)p; assert(false); return -EOPNOTSUPP; } +static void __attribute__((unused)) atcphy_lanes_down_t8152(struct apple_atcphy *p) +{ (void)p; assert(false); } ''') @@ -1948,7 +1953,7 @@ def function(name): struct { unsigned char *core, *pipehandler; } regs; void *dev; int lock; - bool fixed_usb2, host_active, ss_tunables, dp_tunables, mode_dirty; + bool fixed_usb2, fixed_usb3, host_active, ss_tunables, dp_tunables, mode_dirty; unsigned int dp_owned_pmas, dp_idle_pmas; unsigned int dp_usb_context_valid, dp_usb_context_dirty; u32 dp_usb_context[2][27]; @@ -1993,11 +1998,13 @@ def function(name): static void __attribute__((unused)) atcphy_restore_after_pd_off(struct apple_atcphy *p) { assert(!p->pd_was_off); } static int atcphy_configure(struct apple_atcphy *p, enum atcphy_mode mode); -/* These units exercise older PHY generations. Never accept a T8132 dispatch. */ +/* These units exercise older PHY generations. Never accept a T8132 or T8152 dispatch. */ static int __attribute__((unused)) atcphy_configure_t8132(struct apple_atcphy *p, enum atcphy_mode mode) { (void)p; (void)mode; assert(false); return -EOPNOTSUPP; } static int __attribute__((unused)) atcphy_configure_pipehandler_usb3_host_t8132(struct apple_atcphy *p) { (void)p; assert(false); return -EOPNOTSUPP; } +static int __attribute__((unused)) atcphy_configure_pipehandler_usb3_host_t8152(struct apple_atcphy *p) +{ (void)p; assert(false); return -EOPNOTSUPP; } ''') for name in ('core_read32', 'atcphy_get_mode_config'): @@ -2348,7 +2355,7 @@ def function(source, name): struct { unsigned char *core, *lpdptx, *lioa; } regs; void *dev; int lock, dp_link_rate; - bool fixed_usb2, host_active, swap_lanes, ss_tunables, dp_tunables; + bool fixed_usb2, fixed_usb3, host_active, swap_lanes, ss_tunables, dp_tunables; bool aux_power_requested, mode_dirty, dp_spread_spectrum, dp_presets_valid[5]; u32 dp_presets[5][16]; unsigned int dp_idle_pmas, dp_owned_pmas; @@ -2364,6 +2371,7 @@ def function(source, name): start = atc.index('static const struct {\n\tconst struct atcphy_mode_configuration normal;') parts.append(atc[start:atc.index('\n};', start) + 3]) parts.append(atc_cio_helpers(atc)) + parts.append(atc_cfg_helpers(atc)) parts.append(r''' struct phy_configure_opts_dp { unsigned int link_rate, lanes, voltage[4], pre[4]; @@ -2424,11 +2432,13 @@ def function(source, name): static int atcphy_power_off(struct apple_atcphy *); static int atcphy_configure(struct apple_atcphy *, enum atcphy_mode); -/* These units exercise older PHY generations. Never accept a T8132 dispatch. */ +/* These units exercise older PHY generations. Never accept a T8132 or T8152 dispatch. */ static int __attribute__((unused)) atcphy_configure_t8132(struct apple_atcphy *p, enum atcphy_mode mode) { (void)p; (void)mode; assert(false); return -EOPNOTSUPP; } static int __attribute__((unused)) atcphy_configure_pipehandler_usb3_host_t8132(struct apple_atcphy *p) { (void)p; assert(false); return -EOPNOTSUPP; } +static void __attribute__((unused)) atcphy_lanes_down_t8152(struct apple_atcphy *p) +{ (void)p; assert(false); } static int atcphy_park_pipehandler(struct apple_atcphy *p, bool keep_dp) From 3911b2c0d48ec192701891039307d1fbd009b198 Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Thu, 19 Nov 2026 22:14:52 +0100 Subject: [PATCH 11/31] arm64: dts: apple: j873: USB3 on the front ports The two front USB-C ports sit behind an on-board VL822 hub on usb-drd2. The hub's USB2 side is on the controller's eUSB2 PHY, which the loader sets up, and its USB3 side on ATC2's Type-C PHY, wired directly without a Type-C mux. So far the controller was limited to high speed and the hub ran at USB2 only. Describe ATC2's PHY as an apple,t8152-atcphy with apple,fixed-usb3, hand it to usb-drd2 as its USB3 PHY and drop the controller's high-speed limit. Nothing changes for usb-drd1 (the back-left port). The PHY's power domains are ATC2's USB_AON, COMMON_DP_0 and COMMON_DP_1 PMGR power states, in a new node for the ATCs' block of PMGR states at 0x308290000, and its common domain, PSD service 57 (ADT clock-gates 57). The T8152 USB3 bring-up runs the power states without automatic power management, so they are marked apple,no-auto-pm. The tunables are the groups of the ADT's atc-phy2 node (26A434) that apply to USB3 on lane 0, in the order they are applied: the common and PLL defaults as common-a, the fabric, PLL and USBC0 groups as common-b and the lane 0 groups as lane0-usb. Some of them differ between the four ATCs of the same machine, so they likely carry per-device calibration. There is no atcphy2 alias, as the loader's ATC tunable copy would replace them with values for another PHY layout. Signed-off-by: Thomas Glanzmann --- arch/arm64/boot/dts/apple/t8152-j873-usb.dtsi | 311 ++++++++++++++++-- 1 file changed, 275 insertions(+), 36 deletions(-) diff --git a/arch/arm64/boot/dts/apple/t8152-j873-usb.dtsi b/arch/arm64/boot/dts/apple/t8152-j873-usb.dtsi index 924df52e3622b..2085434c423ff 100644 --- a/arch/arm64/boot/dts/apple/t8152-j873-usb.dtsi +++ b/arch/arm64/boot/dts/apple/t8152-j873-usb.dtsi @@ -1,15 +1,18 @@ // SPDX-License-Identifier: GPL-2.0+ OR MIT /* - * J873g USB2 host bring-up: usb-drd1 (back-left port) and usb-drd2 - * (front ports via the on-board hub). + * J873g USB host bring-up: usb-drd1 (back-left port, USB2) and usb-drd2 + * (front ports via the on-board hub, USB2 and USB3). * The loader powers the controllers and sets up the USB2 side of their ATC - * PHYs for host mode before Linux starts (there is no T8152 ATC PHY or Type-C + * PHYs for host mode before Linux starts (there is no T8152 USB2 PHY or Type-C * support yet). * The controllers are described by their DWC3 core region, as hosts behind * their two DARTs (apple,t8152-dwc3); their PHY reset, and on the Type-C port * the role switch, exist but are left to the loader. + * usb-drd2's hub is wired to ATC2's PHY without a Type-C mux, so Linux brings + * that PHY up in USB3 mode (atc2_phy). * Resources are from the 26A434 ADT: dart-usb1/2, usb-drd1/2 (on atc-phy1 and - * atc-phy2) and the pmgr devices ATC1_USB_AON/USB and ATC2_USB_AON/USB. + * atc-phy2), atc-phy2 and the pmgr devices ATC1_USB_AON/USB, ATC2_USB_AON/USB + * and ATC2_COMMON_DP_0/1. * * dart-usb1 and dart-usb2 each have two DART instances (ADT reg[0] and * reg[1], 0xc000 each, sharing one interrupt). t8152-peripherals.dtsi lists @@ -19,6 +22,8 @@ * own window only, and describe instance 1 as a node of its own. */ +#include + &dwc3_1_dart { reg = <0x4 0x0b020000 0x0 0xc000>; power-domains = <&ps_atc1_usb>; @@ -33,15 +38,47 @@ / { soc { + dwc3_1_dart_1: iommu@40b040000 { + compatible = "apple,t8152-dart", "apple,t8110-dart"; + reg = <0x4 0x0b040000 0x0 0xc000>; + interrupts = ; + #iommu-cells = <1>; + power-domains = <&ps_atc1_usb>; + }; + + usb1: usb@40a430000 { + compatible = "apple,t8152-dwc3"; + reg = <0x4 0x0a430000 0x0 0xcd00>; + interrupts = ; + dr_mode = "host"; + maximum-speed = "high-speed"; + iommus = <&dwc3_1_dart 0>, <&dwc3_1_dart_1 1>; + power-domains = <&ps_atc1_usb>; + snps,dis_u2_susphy_quirk; + snps,dis_u3_susphy_quirk; + }; + + dwc3_2_dart_1: iommu@383040000 { + compatible = "apple,t8152-dart", "apple,t8110-dart"; + reg = <0x3 0x83040000 0x0 0xc000>; + interrupts = ; + #iommu-cells = <1>; + power-domains = <&ps_atc2_usb>; + }; + /* - * The ATCs' PMGR power states (ADT pmgr devices ATCn_USB_AON and - * ATCn_USB from 0x308290100, 0x40 apart per ATC). The ADT gives - * usb-drd1/2 service-gates 175/176, but those PSD service blocks - * (0x303a1af00, 0x303a1b000) take a bus error from the CPU. + * The ATCs' PMGR power states (ADT pmgr devices ATCn_COMMON_DP_0/1 + * from 0x308290000 and ATCn_USB_AON/USB from 0x308290100, 0x40 + * apart per ATC). The T8152 USB bring-up runs them without + * automatic power management. * - * The loader leaves them on; they hold the controllers' reset and - * the USB2 PHY setup it did, which Linux cannot redo yet. So they - * stay on, without automatic power management. + * ATCn_USB is the controller's state. The ADT also gives + * usb-drd1/2 service-gates 175/176, but those PSD service blocks + * (0x303a1af00, 0x303a1b000) take a bus error from the CPU. The + * loader leaves ATCn_USB and ATCn_USB_AON on; they hold the + * controllers' reset and the USB2 PHY setup it did, which Linux + * cannot redo yet, so they stay on. ATC2_COMMON_DP_0/1 are what + * ATC2's PHY needs besides. */ pmgr_atc: power-management@308290000 { compatible = "apple,t8152-pmgr", "apple,t8103-pmgr", @@ -50,6 +87,26 @@ #size-cells = <1>; reg = <0x3 0x08290000 0x0 0x1000>; + ps_atc2_common_dp_0: power-controller@80 { + compatible = "apple,t8152-pmgr-pwrstate", + "apple,t8103-pmgr-pwrstate"; + reg = <0x80 4>; + #power-domain-cells = <0>; + #reset-cells = <0>; + label = "atc2_common_dp_0"; + apple,no-auto-pm; + }; + + ps_atc2_common_dp_1: power-controller@a0 { + compatible = "apple,t8152-pmgr-pwrstate", + "apple,t8103-pmgr-pwrstate"; + reg = <0xa0 4>; + #power-domain-cells = <0>; + #reset-cells = <0>; + label = "atc2_common_dp_1"; + apple,no-auto-pm; + }; + ps_atc1_usb_aon: power-controller@140 { compatible = "apple,t8152-pmgr-pwrstate", "apple,t8103-pmgr-pwrstate"; @@ -73,6 +130,11 @@ apple,always-on; }; + /* + * Kept on: it holds the USB controller's reset and the + * PIPE handler state the loader set up. Switched off, the + * controller stays in reset until the next boot. + */ ps_atc2_usb_aon: power-controller@180 { compatible = "apple,t8152-pmgr-pwrstate", "apple,t8103-pmgr-pwrstate"; @@ -97,32 +159,208 @@ }; }; - dwc3_1_dart_1: iommu@40b040000 { - compatible = "apple,t8152-dart", "apple,t8110-dart"; - reg = <0x4 0x0b040000 0x0 0xc000>; - interrupts = ; - #iommu-cells = <1>; - power-domains = <&ps_atc1_usb>; - }; - - usb1: usb@40a430000 { - compatible = "apple,t8152-dwc3"; - reg = <0x4 0x0a430000 0x0 0xcd00>; - interrupts = ; - dr_mode = "host"; - maximum-speed = "high-speed"; - iommus = <&dwc3_1_dart 0>, <&dwc3_1_dart_1 1>; - power-domains = <&ps_atc1_usb>; - snps,dis_u2_susphy_quirk; - snps,dis_u3_susphy_quirk; + /* ATC2's common domain: PSD service 57 (ADT atc-phy2 clock-gates). */ + ps_atc2_common: power-controller@303a13900 { + compatible = "apple,t8152-psd"; + reg = <0x3 0x03a13900 0x0 0x100>; + #power-domain-cells = <0>; + label = "atc2_common"; }; - dwc3_2_dart_1: iommu@383040000 { - compatible = "apple,t8152-dart", "apple,t8110-dart"; - reg = <0x3 0x83040000 0x0 0xc000>; - interrupts = ; - #iommu-cells = <1>; - power-domains = <&ps_atc2_usb>; + /* + * ADT atc-phy2 as usb-drd2's USB3 PHY: the hub is wired to its + * lanes directly. The power domains are listed in the order the + * PHY needs them powered up. The tunables are the atc-phy2 + * tunable_* groups of the 26A434 ADT that apply to USB3 on lane + * 0, in the order they are applied: common-a before lane 0 is + * powered up and the crossbar set, then common-b and lane0-usb. + * Some of them differ between the four ATCs of the same machine, + * so they likely carry per-device calibration. There is no + * atcphy2 alias: the loader's ATC tunable copy would then replace + * these with values for another PHY layout. + */ + atc2_phy: phy@383000000 { + compatible = "apple,t8152-atcphy"; + reg = <0x3 0x83000000 0x0 0x84000>, + <0x3 0x82414000 0x0 0x4000>; + reg-names = "core", "pipehandler"; + #phy-cells = <1>; + apple,fixed-usb3; + power-domains = <&ps_atc2_usb_aon>, <&ps_atc2_common>, + <&ps_atc2_common_dp_0>, <&ps_atc2_common_dp_1>; + apple,tunable-common-a = + /* ACIOPHY_CMN_DFLT */ + <0x00800 0x00fc0000 0x00fc0000>, + <0x0084c 0x000ff800 0x000ff800>, + <0x0085c 0x000000ff 0x00000080>, + <0x00860 0x007fffff 0x0052bc27>, + <0x00864 0x02c00000 0x00800000>, + /* CIOPLL_CORE_DFLT */ + <0x01614 0x0003ffc0 0x0001e5c0>, + <0x01640 0x00000007 0x00000003>, + <0x01668 0x00000ffc 0x000005f0>; + apple,tunable-common-b = + /* ATC_FABRIC */ + <0x6c004 0x003f003f 0x00200020>, + <0x6c00c 0x000000f1 0x000000a1>, + <0x6c010 0x0000801f 0x00000004>, + <0x6c018 0x003f003f 0x00200020>, + <0x6c020 0x000000f1 0x000000a1>, + <0x6c024 0x0000801f 0x00000004>, + <0x6c02c 0x007f007f 0x00410041>, + <0x6c034 0x000000f1 0x00000071>, + <0x6c038 0x0000801f 0x00000004>, + <0x6c040 0x0000001f 0x00000010>, + <0x6c048 0x0000801f 0x00000004>, + <0x6c050 0x007f007f 0x00450045>, + <0x6c058 0x000000f1 0x00000051>, + <0x6c05c 0x0000801f 0x00000004>, + <0x6c064 0x0000003f 0x00000020>, + <0x6c06c 0x0000801f 0x00000004>, + <0x6c074 0x00000001 0x00000001>, + <0x6c078 0x0000801f 0x00000004>, + <0x6c080 0x001f001f 0x00100010>, + <0x6c084 0x000000f1 0x00000011>, + <0x6c088 0x00000001 0x00000001>, + <0x6c08c 0x00000001 0x00000001>, + <0x6c090 0x0000801f 0x00000004>, + <0x6c098 0x001f001f 0x00100010>, + <0x6c09c 0x000000f1 0x00000011>, + <0x6c0a0 0x0000801f 0x00000004>, + <0x6c0a8 0x000000ff 0x000000a0>, + <0x6c0ac 0x0000801f 0x00000004>, + <0x6c0b4 0x0000003f 0x00000020>, + <0x6c0bc 0x0000801f 0x00000004>, + <0x6c0c4 0x0000003f 0x00000020>, + <0x6c0cc 0x0000801f 0x00000004>, + <0x6c0d4 0x0000000f 0x00000008>, + <0x6c0d8 0x0000801f 0x00000004>, + <0x6c0e0 0x001f001f 0x00180018>, + <0x6c0e4 0x0000801f 0x00000004>, + <0x6c0ec 0x001f001f 0x00180018>, + <0x6c0f0 0x0000801f 0x00000004>, + <0x6c0f8 0x001f001f 0x00180018>, + <0x6c0fc 0x0000801f 0x00000004>, + <0x6c104 0x001f001f 0x00180018>, + <0x6c108 0x0000801f 0x00000004>, + <0x6c110 0x00000001 0x00000001>, + <0x6c114 0x0000801f 0x00000004>, + <0x6c11c 0x0000801f 0x00000004>, + <0x6c124 0x0000801f 0x00000004>, + <0x6c12c 0x0000801f 0x00000004>, + <0x6c134 0x0000801f 0x00000004>, + <0x6c13c 0xffffffff 0x01010101>, + <0x6c140 0x0000801f 0x00000004>, + <0x6c148 0x0000801f 0x00000004>, + <0x6c150 0xffffffff 0x01010101>, + <0x6c154 0x0000ffff 0x00000101>, + <0x6c158 0x0000801f 0x00000004>, + <0x6c160 0x0000801f 0x00000004>, + <0x6c168 0x0000801f 0x00000004>, + <0x6c170 0x0000801f 0x00000004>, + <0x6c178 0x0000801f 0x00000004>, + <0x6c180 0xffffffff 0x01010101>, + <0x6c184 0x0000801f 0x00000004>, + <0x6c18c 0x0000801f 0x00000004>, + <0x6c194 0x0000801f 0x00000004>, + /* DPPLL_CORE_DFLT */ + <0x01040 0x0000000c 0x00000008>, + <0x01060 0x0001c000 0x0000c000>, + <0x01098 0x00000f00 0x00000800>, + <0x0109c 0x000fe000 0x000fe000>, + <0x01108 0x07c00000 0x04000000>, + <0x0110c 0x0000007c 0x00000010>, + /* DPPLL_TOP_DFLT */ + <0x00e8c 0x0000007f 0x0000003c>, + <0x00e9c 0x0000007f 0x00000032>, + <0x00eac 0x0000007f 0x00000032>, + <0x00ebc 0x0000007f 0x0000005a>, + /* CIOPLL_TOP_DFLT */ + <0x01488 0x000001ff 0x00000128>, + <0x01494 0x00000100 0x00000100>, + /* ACIOPHY_USBC0_DFLT */ + <0x15c04 0x0f000000 0x00000000>, + <0x15c0c 0x0007c000 0x00020000>, + /* ACIOPHY_USBC0_USB */ + <0x15c50 0x60000000 0x00000000>; + apple,tunable-lane0-usb = + /* LN0_ARBITER_REGS_DFLT */ + <0x082d8 0xf0000000 0x70000000>, + <0x082dc 0x0000000f 0x00000007>, + /* LN0_RX_TOP_REGS_DFLT */ + <0x08cf4 0x00000020 0x00000020>, + /* LN0_RX_DFE_REGS_DFLT */ + <0x077c4 0x0003ff00 0x0000fa00>, + /* LN0_SMGR_REGS_DFLT */ + <0x07dbc 0x00000078 0x00000030>, + <0x07dd8 0x000003f0 0x00000000>, + <0x07de8 0x00000003 0x00000003>, + <0x07dec 0x00000002 0x00000002>, + /* LN0_RXAEQ_TOP_REGS_DFLT */ + <0x07a00 0x000000f0 0x00000010>, + <0x07a08 0x00000fff 0x00000001>, + <0x07a28 0x0ff00000 0x0cf00000>, + <0x07a40 0x07ffffff 0x028154a5>, + <0x07a7c 0x20000000 0x00000000>, + <0x07a80 0x0000001f 0x00000002>, + <0x07b98 0x3f00003f 0x31000014>, + <0x07b9c 0x0003ffff 0x0000ef4b>, + <0x07ba8 0x0fc1f800 0x05005000>, + <0x07bac 0x07ffffe0 0x013f0e40>, + <0x07bbc 0x000001c7 0x00000145>, + <0x07bc8 0x000007f8 0x00000018>, + /* LN0_RX_SHM_REGS_DFLT */ + <0x08728 0x0000010f 0x0000010f>, + <0x0878c 0xfc000000 0xfc000000>, + <0x08790 0x00000001 0x00000001>, + <0x087b4 0x0e018000 0x06008000>, + <0x08708 0x40000000 0x40000000>, + /* LN0_TXSEQ_REGS_DFLT */ + <0x04c80 0x3f800000 0x00000000>, + <0x04c88 0x001fffff 0x00000000>, + /* LN0_TX_SHM_AHB_DFLT */ + <0x04fd4 0x03800000 0x02800000>, + /* LN0_TX_TXSPL_CM_DFLT */ + <0x04e20 0x00fff000 0x00723000>, + /* LN0_ASDC_TXSPL_CM_DFLT */ + <0x08980 0x00fff000 0x00723000>, + /* LN0_DIV40_REGS_DFLT */ + <0x085e4 0x00000004 0x00000000>, + /* LN0_RX_PCTRL_REGS_DFLT */ + <0x08628 0x00000ff0 0x00000660>, + <0x0862c 0x00000ff0 0x00000ea0>, + /* LN0_CTLE_EQ_REGS_DFLT */ + <0x08000 0x0000000a 0x00000000>, + <0x08014 0x000003ff 0x00000042>, + /* L0_RXCALACC_HALFUI_DFLT */ + <0x07304 0x0000000f 0x00000006>, + <0x07334 0x01ffffff 0x001004ea>, + /* L0_RXCALACC_EDSKEW_DFLT */ + <0x07284 0x0000000f 0x00000006>, + <0x072cc 0x0003ffff 0x000004ea>, + /* LN0_TXSPL_TXDCC_DFLT */ + <0x04d84 0x001c0000 0x00000000>, + /* LN0_SMGR_REGS_USB */ + <0x07d88 0x000000f0 0x00000030>, + <0x07da8 0xff000000 0x44000000>, + <0x07dd8 0x00003000 0x00003000>, + /* LN0_DETECTOR_REGS_USB */ + <0x0848c 0x00008000 0x00000000>, + /* LN0_DIV40_REGS_USB */ + <0x08594 0x00000001 0x00000001>, + <0x085b0 0x0000ffff 0x00001010>, + <0x085b8 0x0000ffff 0x00001010>, + <0x085cc 0x68100000 0x00000000>, + <0x085d0 0x68100000 0x00000000>, + /* LN0_CTLE_EQ_REGS_USB */ + <0x07fdc 0x000001ff 0x000000b4>, + <0x07fe0 0x000001ff 0x000000aa>, + /* LN0_RXAEQ_TOP_REGS_USB */ + <0x07a1c 0x00000ff8 0x00000578>, + <0x07a2c 0x0003ffff 0x000154b4>, + <0x07bb8 0x00007000 0x00000000>, + /* LN0_TXSEQ_REGS_USB */ + <0x04ca0 0x00000002 0x00000000>; }; /* usb-drd2: on-board VL822 hub behind the two front USB-C ports. */ @@ -131,7 +369,8 @@ reg = <0x3 0x82430000 0x0 0xcd00>; interrupts = ; dr_mode = "host"; - maximum-speed = "high-speed"; + phys = <&atc2_phy PHY_TYPE_USB3>; + phy-names = "usb3-phy"; iommus = <&dwc3_2_dart 0>, <&dwc3_2_dart_1 1>; power-domains = <&ps_atc2_usb>; snps,dis_u2_susphy_quirk; From c7802793ac213767ac5f71faa0af7f61d5408e99 Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Tue, 17 Nov 2026 14:31:49 +0100 Subject: [PATCH 12/31] 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 8725e73ba216bdf78ba5b79ead1a9e382401de47 Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Tue, 17 Nov 2026 14:31:49 +0100 Subject: [PATCH 13/31] 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 8d7e9e72aabda..467bc38a9af24 100644 --- a/drivers/pci/controller/pcie-apple.c +++ b/drivers/pci/controller/pcie-apple.c @@ -481,6 +481,22 @@ static const struct hw_info t6050_pciec_hw = { .s2idle_hold_domain = 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[]; /** @@ -3394,8 +3410,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; @@ -3432,19 +3465,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; } @@ -3478,7 +3498,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)) { @@ -7588,6 +7608,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 1ec5abeec8f3b8959ab1610c5d304a9c6ce9b4da Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Thu, 19 Nov 2026 19:58:23 +0100 Subject: [PATCH 14/31] dt-bindings: mailbox: apple,mailbox: add the T8152 ACIO mailbox Each T8152 USB4 router's coprocessor has a 0x80-byte mailbox window with the counted FIFOs of the SMC mailbox, at offset 0x80 of its register block. Describe it with apple,t8152-smc-mailbox as the fallback, so the SMC mailbox's match data serves it, and with its send-empty and recv-not-empty interrupts. Signed-off-by: Thomas Glanzmann --- .../devicetree/bindings/mailbox/apple,mailbox.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Documentation/devicetree/bindings/mailbox/apple,mailbox.yaml b/Documentation/devicetree/bindings/mailbox/apple,mailbox.yaml index 7626c8afcedbd..caa9e431a4a10 100644 --- a/Documentation/devicetree/bindings/mailbox/apple,mailbox.yaml +++ b/Documentation/devicetree/bindings/mailbox/apple,mailbox.yaml @@ -44,6 +44,14 @@ properties: recv-not-empty interrupts. const: apple,t8152-ascwrap-v8-mailbox + - description: + T8152 ACIO mailbox of a USB4 router's coprocessor, a 0x80 window + with the counted FIFOs of the SMC mailbox, described with its + send-empty and recv-not-empty interrupts. + items: + - const: apple,t8152-cio-mailbox + - const: apple,t8152-smc-mailbox + - description: ASC mailboxes are the most common variant found on the M1 used for example for the display controller, the system management From 0ce98117bd0158c3af3f17111c9a937a7eb3c1f0 Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Tue, 17 Nov 2026 23:21:08 +0100 Subject: [PATCH 15/31] dt-bindings: reset: apple,t8103-cio-reset: add T8152 The T8152 CIO reset block resets the rear USB4 routers of the J873g. It has a request and an acknowledge register instead of T8142's control register, so it gets its own compatible. Signed-off-by: Thomas Glanzmann --- .../devicetree/bindings/reset/apple,t8103-cio-reset.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/reset/apple,t8103-cio-reset.yaml b/Documentation/devicetree/bindings/reset/apple,t8103-cio-reset.yaml index 3b05fab7e7af1..f72d6e97577cc 100644 --- a/Documentation/devicetree/bindings/reset/apple,t8103-cio-reset.yaml +++ b/Documentation/devicetree/bindings/reset/apple,t8103-cio-reset.yaml @@ -38,6 +38,7 @@ properties: - enum: - apple,t8103-cio-reset - apple,t8142-cio-reset + - apple,t8152-cio-reset - apple,t6050-cio-reset - apple,t6000-cio-reset - apple,t6041-cio-reset From 5846c7c6bd232054c8f503535d0a9b78af118213 Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Tue, 17 Nov 2026 23:21:09 +0100 Subject: [PATCH 16/31] reset: apple-cio: add T8152 The T8152 CIO reset block requests a router reset in register 0x68 and acknowledges it in 0x6c. Wait for the router's pair of busy bits to clear, request, wait for the acknowledgment and clear it. Signed-off-by: Thomas Glanzmann --- drivers/reset/reset-apple-cio.c | 38 +++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/drivers/reset/reset-apple-cio.c b/drivers/reset/reset-apple-cio.c index e5755ebb39aff..1a023b41051fe 100644 --- a/drivers/reset/reset-apple-cio.c +++ b/drivers/reset/reset-apple-cio.c @@ -77,6 +77,15 @@ #define T8142_CIO_CTRL_INIT_BUSY(port) BIT(2 * (port) + 1) #define T8142_CIO_CTRL_BUSY_MASK 0xaa +/* T8152: the request and its completion are in two registers, one bit per port. */ +#define T8152_CIO_INIT_REQ 0x68 +#define T8152_CIO_INIT_DONE 0x6c +/* A request waits until none of its port pair (0-1 or 2-3) is pending. */ +#define T8152_CIO_INIT_PAIR_MASK(port) ((port) < 2 ? GENMASK(1, 0) : GENMASK(3, 2)) +#define T8152_CIO_POLL_US 10 +/* As long as a t6050 reconfiguration. */ +#define T8152_CIO_TIMEOUT_US APPLE_CIO_RESET_T6050_TIMEOUT_US + struct apple_cio_reset; struct apple_cio_reset_variant { @@ -200,6 +209,34 @@ static int t8142_cio_deassert(struct apple_cio_reset *priv, unsigned long id) APPLE_CIO_RESET_TIMEOUT_US); } +static int t8152_cio_deassert(struct apple_cio_reset *priv, unsigned long id) +{ + u32 val; + int ret; + + guard(mutex)(&priv->lock); + ret = regmap_read_poll_timeout(priv->regmap, T8152_CIO_INIT_REQ, val, + !(val & T8152_CIO_INIT_PAIR_MASK(id)), + T8152_CIO_POLL_US, T8152_CIO_TIMEOUT_US); + if (ret) + return ret; + ret = regmap_write(priv->regmap, T8152_CIO_INIT_REQ, BIT(id)); + if (ret) + return ret; + ret = regmap_read_poll_timeout(priv->regmap, T8152_CIO_INIT_DONE, val, + val & BIT(id), T8152_CIO_POLL_US, + T8152_CIO_TIMEOUT_US); + if (ret) + return ret; + /* Acknowledge the completion. */ + return regmap_write(priv->regmap, T8152_CIO_INIT_DONE, BIT(id)); +} + +static const struct apple_cio_reset_variant apple_t8152_cio_reset = { + .nr_resets = 4, + .deassert = t8152_cio_deassert, +}; + static const struct apple_cio_reset_variant apple_t8142_cio_reset = { .nr_resets = 4, .ctrl = T8142_CIO_CTRL, @@ -330,6 +367,7 @@ static int apple_cio_reset_probe(struct platform_device *pdev) } static const struct of_device_id apple_cio_reset_match[] = { + { .compatible = "apple,t8152-cio-reset", .data = &apple_t8152_cio_reset }, { .compatible = "apple,t6050-cio-reset", .data = &apple_t6050_cio_reset, From 26e68268014e2d7c7e336927d132b9fc779012b8 Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Tue, 17 Nov 2026 23:21:09 +0100 Subject: [PATCH 17/31] dt-bindings: iommu: apple,dart: add the T8152 ACIO and PCIe-C DARTs The DARTs of the J873g rear USB4 routers (NHI streams) and of their PCIe-C tunnels are Gen3 DARTs like the display ones, but start unlocked with inactive streams. Each has its own slot in the shared TLB invalidation aperture and its DMA window. Their tunables are the ADT's (dart-acioN, dart-apciecN), which the bootloader copies into the node, so the binding does not require them in a device tree. Signed-off-by: Thomas Glanzmann --- .../devicetree/bindings/iommu/apple,dart.yaml | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/iommu/apple,dart.yaml b/Documentation/devicetree/bindings/iommu/apple,dart.yaml index 3a8a8c64fb8c2..252c44db78c4d 100644 --- a/Documentation/devicetree/bindings/iommu/apple,dart.yaml +++ b/Documentation/devicetree/bindings/iommu/apple,dart.yaml @@ -33,6 +33,8 @@ properties: - apple,t8110-dart - apple,t6000-dart - apple,t8152-dart-gen3 + - apple,t8152-acio-dart + - apple,t8152-pciec-dart - apple,t8152-avd-dart - items: - const: apple,t8140-ane-dart @@ -384,6 +386,8 @@ allOf: contains: enum: - apple,t8152-dart-gen3 + - apple,t8152-acio-dart + - apple,t8152-pciec-dart - apple,t8152-avd-dart then: description: @@ -392,9 +396,12 @@ allOf: locked, and the operating system only adds page table entries in root slots that are empty at handoff. Their TLB command register answers translation queries; a stream is invalidated through the - TLB invalidation aperture instead. The T8152 AVD instance uses the - same invalidation aperture, but starts unlocked with inactive streams - and is initialized by the operating system after its PSD domain is on. + TLB invalidation aperture instead. The DARTs of the rear USB4 + routers (ACIO NHI streams) and of their PCIe-C tunnels use the same + invalidation aperture, each at its own slot, but start unlocked with + inactive streams and are initialized by the operating system. + The T8152 AVD instance uses the same aperture, starts unlocked with + inactive streams and is initialized after its PSD domain is on. properties: reg: minItems: 2 @@ -423,6 +430,19 @@ allOf: - apple,dma-range - apple,tunable + - if: + properties: + compatible: + contains: + enum: + - apple,t8152-acio-dart + - apple,t8152-pciec-dart + then: + # apple,tunable: the bootloader copies it from the ADT (dart-acioN, + # dart-apciecN); a device tree describes these DARTs without one. + required: + - apple,dma-range + additionalProperties: false examples: From 7659cc30f1da3f02a6dd66bafb205d362025ff55 Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Mon, 23 Nov 2026 05:28:27 +0100 Subject: [PATCH 18/31] iommu: apple-dart: initialize the cold T8152 ACIO and PCIe-C DARTs The DARTs of the T8152 USB4 routers and their PCIe-C tunnels are Gen3 DARTs that, unlike the display ones, the bootloader leaves unlocked with inactive streams, as it does the AVD instance. Extend the AVD instance's cold Gen3 setup to them: version 0x300, their tunables and inactive streams, then clear the streams, apply the tunables and invalidate through the Gen3 TLBI aperture before translation is enabled. Domains use the same two-level 16K tables inside a single 64 GiB DMA window. The streams the operating system sets up now come from a mask per instance: - AVD DART (apple,t8152-avd-dart): streams 0-2, the decoder's, with its 16 streams and its power domain checked as before. Its stream enable becomes a read-modify-write like the others', and other stream IDs are refused when a consumer attaches. - ACIO DART (apple,t8152-acio-dart): 32 streams, NHI streams 0-11 and 16-27. - PCIe-C DART (apple,t8152-pciec-dart): translated streams 0-252, with 253 and 255 in bypass for host transactions and MSI writes to the AIC (the ADT reserves them), firmware's stream 254 preserved, 16K pages, 42-bit addresses; it must be tunnelled and have its power domain. Without the bypass on 255, NVMe completions were polled and the DART faulted at the AIC. Each DART invalidates through the TLBI slot its "tlbi" resource names. The slot has to be the port's own: with port 3's slot on port 1's DART, reads returned wrong data with DART faults. The locked display DARTs and all other Gen3 instances stay as they were. Signed-off-by: Thomas Glanzmann --- drivers/iommu/apple-dart.c | 83 +++++++++++++++++-- .../drivers/apple/bcm4377-radio-sids.py | 3 +- 2 files changed, 76 insertions(+), 10 deletions(-) diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c index bf7a4fc0807fa..23e436e29392c 100644 --- a/drivers/iommu/apple-dart.c +++ b/drivers/iommu/apple-dart.c @@ -362,6 +362,8 @@ struct apple_dart_fw_tree { struct apple_dart { bool cold_gen3; + u32 cold_gen3_sids; + bool cold_gen3_pcie; struct device *dev; const struct apple_dart_hw *hw; @@ -2826,11 +2828,33 @@ static int apple_dart_hw_reset(struct apple_dart *dart) if (dart->cold_gen3) { stream_map.dart = dart; bitmap_zero(stream_map.sidmap, DART_MAX_STREAMS); - bitmap_set(stream_map.sidmap, 0, 3); + for (i = 0; i < 32; i++) + if (dart->cold_gen3_sids & BIT(i)) + __set_bit(i, stream_map.sidmap); + if (dart->cold_gen3_pcie) + bitmap_set(stream_map.sidmap, 0, 253); apple_dart_hw_disable_dma(&stream_map); apple_dart_hw_clear_all_ttbrs(&stream_map); apple_dart_apply_own_tunables(dart); - apple_dart_writel(dart, 7, dart->hw->enable_streams); + apple_dart_writel(dart, apple_dart_readl(dart, dart->hw->enable_streams) | + dart->cold_gen3_sids, dart->hw->enable_streams); + if (dart->cold_gen3_pcie) { + /* ADT reserves 253/255 for host transactions, including MSI + * writes to AIC. Stream 254 belongs to firmware; preserve it. + */ + for (i = 253; i <= 255; i += 2) { + apple_dart_writel(dart, DART_T8110_TCR_BYPASS_DART, + DART_TCR(dart, i)); + __set_bit(i, stream_map.sidmap); + } + for (i = 0; i < 8; i++) { + u32 reg = dart->hw->enable_streams + i * 4; + u32 enabled = apple_dart_readl(dart, reg); + + enabled |= i == 7 ? (U32_MAX & ~BIT(30)) : U32_MAX; + apple_dart_writel(dart, enabled, reg); + } + } return dart->hw->invalidate_tlb(&stream_map); } @@ -4198,6 +4222,9 @@ static int apple_dart_of_xlate(struct device *dev, return i; sid = args->args[0]; + if (dart->cold_gen3 && (dart->cold_gen3_pcie ? (sid < 0 || sid >= 253) : + (sid < 0 || sid >= 32 || !(dart->cold_gen3_sids & BIT(sid))))) + return -EPERM; if (dart->isp_host && sid != 0 && sid != 12) return -EINVAL; if (dart->cold_ane && sid != 0) @@ -5628,6 +5655,7 @@ static int apple_dart_probe(struct platform_device *pdev) of_node_name_prefix(dev->of_node->parent, "usb4-pcie-tunnel-"); bool j713_display, j713_dcpext, j713_dispext, j713_radio; + bool cold_avd = of_device_is_compatible(dev->of_node, "apple,t8152-avd-dart"); /* * The M4 internal display DARTs are live: DCP firmware (SID23) @@ -5729,7 +5757,20 @@ static int apple_dart_probe(struct platform_device *pdev) dart->dev = dev; dart->hw = of_device_get_match_data(dev); dart->tunneled = tunneled; - dart->cold_gen3 = of_device_is_compatible(dev->of_node, "apple,t8152-avd-dart"); + /* Streams 0-2 of the AVD instance, the ones the decoder uses. */ + if (cold_avd) { + dart->cold_gen3 = true; + dart->cold_gen3_sids = 0x7; + } + if (of_device_is_compatible(dev->of_node, "apple,t8152-acio-dart")) { + dart->cold_gen3 = true; + dart->cold_gen3_sids = 0x0fff0fff; + } + if (of_device_is_compatible(dev->of_node, "apple,t8152-pciec-dart")) { + dart->cold_gen3 = true; + dart->cold_gen3_pcie = true; + dart->cold_gen3_sids = U32_MAX; + } dart->cold_ane = of_device_is_compatible(dev->of_node, "apple,t8140-ane-dart") || of_device_is_compatible(dev->of_node, "apple,t8142-ane-dart"); if (dart->cold_ane && !IS_BUILTIN(CONFIG_APPLE_DART)) @@ -5942,7 +5983,7 @@ static int apple_dart_probe(struct platform_device *pdev) ret = devm_pm_runtime_enable(dev); if (ret) goto err_clk_disable; - if (tunneled && dart->tunables) { + if (tunneled && dart->tunables && !dart->cold_gen3) { dev_dbg(dev, "applying %zu PCIe-C DART tunables\n", dart->tunables->sz); apple_dart_apply_tunables(dart, dart->tunables); @@ -5958,7 +5999,15 @@ static int apple_dart_probe(struct platform_device *pdev) * pages, a 32-bit IOVA, a 36-bit PA and as many streams as its * register block describes. */ - if (dart->hw->type == DART_T8110) { + if (dart->cold_gen3_pcie) { + dart->pgsize = SZ_16K; + dart->supports_bypass = true; + dart->ias = 42; + dart->oas = 42; + dart->num_streams = 256; + dart->four_level = false; + dart->version = 0x300; + } else if (dart->hw->type == DART_T8110) { dart->pgsize = 1 << DART_PCIEC_PAGE_SHIFT; dart->supports_bypass = true; dart->ias = DART_PCIEC_ADDR_WIDTH; @@ -6158,18 +6207,32 @@ static int apple_dart_probe(struct platform_device *pdev) if (dart->hw->gen3) { struct resource *tlbi; - /* Cold initialization is qualified only for the AVD instance. */ + /* Cold setup only for the instances a T8152 compatible selects. */ if (!dart->locked && !dart->cold_gen3) { dev_err(dev, "Gen3 DART is not locked; cold setup is not supported\n"); ret = -ENODEV; goto err_clk_disable; } - if (dart->cold_gen3 && (dart->locked || dart->version != 0x300 || - dart->num_streams != 16 || !dev->pm_domain || !dart->tunables || - (apple_dart_readl(dart, dart->hw->enable_streams) & 7))) { + if (dart->cold_gen3 && + (dart->locked || dart->version != 0x300 || !dart->tunables || + (dart->cold_gen3_pcie ? (!tunneled || !dev->pm_domain) : + cold_avd ? (dart->num_streams != 16 || !dev->pm_domain) : + dart->num_streams != 32) || + (apple_dart_readl(dart, dart->hw->enable_streams) & dart->cold_gen3_sids))) { ret = -EINVAL; goto err_clk_disable; } + if (dart->cold_gen3_pcie) { + for (sid = 0; sid < 8; sid++) { + u32 mask = sid == 7 ? GENMASK(28, 0) : U32_MAX; + u32 reg = dart->hw->enable_streams + sid * 4; + + if (apple_dart_readl(dart, reg) & mask) { + ret = -EBUSY; + goto err_clk_disable; + } + } + } /* The aperture is shared by every Gen3 DART: map, do not claim. */ tlbi = platform_get_resource_byname(pdev, IORESOURCE_MEM, "tlbi"); if (!tlbi || resource_size(tlbi) < 16) { @@ -7599,6 +7662,8 @@ static const struct dev_pm_ops apple_dart_pm_ops = { static const struct of_device_id apple_dart_of_match[] = { { .compatible = "apple,t8152-dart-gen3", .data = &apple_dart_hw_gen3 }, { .compatible = "apple,t8152-avd-dart", .data = &apple_dart_hw_gen3 }, + { .compatible = "apple,t8152-acio-dart", .data = &apple_dart_hw_gen3 }, + { .compatible = "apple,t8152-pciec-dart", .data = &apple_dart_hw_gen3 }, { .compatible = "apple,t8103-dart", .data = &apple_dart_hw_t8103 }, { .compatible = "apple,t8103-usb4-dart", .data = &apple_dart_hw_t8103_usb4 }, { .compatible = "apple,t8110-dart", .data = &apple_dart_hw_t8110 }, diff --git a/tools/testing/selftests/drivers/apple/bcm4377-radio-sids.py b/tools/testing/selftests/drivers/apple/bcm4377-radio-sids.py index e9166c1f40abc..bf0ffb0b06e98 100755 --- a/tools/testing/selftests/drivers/apple/bcm4377-radio-sids.py +++ b/tools/testing/selftests/drivers/apple/bcm4377-radio-sids.py @@ -115,7 +115,8 @@ def main(): bool four_level, per_stream, tunneled, fw_mirror, fw_handoff; bool pending, preserve_display; bool isp_host, cold_ane, live_mtp, display_dark, display_tlb_stale; - bool cold_gen3; + bool cold_gen3, cold_gen3_pcie; + u32 cold_gen3_sids; void *tunables; unsigned long static_bypass[4]; void *dcp, *frontend[2]; From 3656e19931331ab6020a031e1bdf61f0674b89f9 Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Tue, 17 Nov 2026 23:21:09 +0100 Subject: [PATCH 19/31] dt-bindings: pci: apple,pcie: add T8152 PCIe-C The PCIe-C ports tunnelled through the J873g rear USB4 routers are laid out like T8142's: Intr2AXI MSI slices, the T6050 tunnel controls, and no port reset of their own. Signed-off-by: Thomas Glanzmann --- Documentation/devicetree/bindings/pci/apple,pcie.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Documentation/devicetree/bindings/pci/apple,pcie.yaml b/Documentation/devicetree/bindings/pci/apple,pcie.yaml index 06405f7179fe8..70700cb86b839 100644 --- a/Documentation/devicetree/bindings/pci/apple,pcie.yaml +++ b/Documentation/devicetree/bindings/pci/apple,pcie.yaml @@ -102,6 +102,7 @@ properties: - const: apple,t6000-pciec - const: apple,t6050-pciec - const: apple,t8142-pciec + - const: apple,t8152-pciec - items: - const: apple,t8132-pciec - const: apple,t8122-pciec @@ -376,6 +377,7 @@ allOf: enum: - apple,t8132-pciec - apple,t8142-pciec + - apple,t8152-pciec - apple,t6040-pciec then: required: @@ -504,6 +506,7 @@ allOf: - apple,t6040-pciec - apple,t6050-pciec - apple,t8142-pciec + - apple,t8152-pciec then: properties: reg: From f76529a75100e87ff0eaf1e3700328e87f5932eb Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Thu, 19 Nov 2026 19:59:15 +0100 Subject: [PATCH 20/31] PCI: apple: add T8152 PCIe-C The T8152 tunnelled PCIe-C ports use the T6050 tunnel controls with the Intr2AXI MSI path, like T8142, and their MSI slices are checked the same way: from msi-ranges and apple,msi-vector-base alone. The J873g's three bridges use 0x60 (CIO0, ECAM 0x1c50000000), 0x80 (CIO1, 0x1c60000000) and 0xc0 (CIO3, 0x1c80000000) of the window at AIC 1879. Signed-off-by: Thomas Glanzmann --- drivers/pci/controller/pcie-apple.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c index 467bc38a9af24..602a4fee07b3e 100644 --- a/drivers/pci/controller/pcie-apple.c +++ b/drivers/pci/controller/pcie-apple.c @@ -497,6 +497,22 @@ static const struct hw_info t8142_pciec_hw = { .mps_timers = true, }; +/* T8152 PCIe-C: the T8142 layout, with a third PCIe-C bridge (CIO3). */ +static const struct hw_info t8152_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[]; /** @@ -3410,7 +3426,8 @@ 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 == &t8132_pciec_hw || pcie->hw == &t8142_pciec_hw) { + if (pcie->hw == &t8132_pciec_hw || pcie->hw == &t8142_pciec_hw || + pcie->hw == &t8152_pciec_hw) { /* * msi-ranges names the AIC input of global vector * apple,msi-vector-base in a linear window, so the slice is @@ -3498,7 +3515,8 @@ 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 == &t8142_pciec_hw) && + pcie->hw == &t6040_pciec_hw || pcie->hw == &t8142_pciec_hw || + pcie->hw == &t8152_pciec_hw) && (!pcie->nvecs || pcie->nvecs > 256 || pcie->msi_vector_base > FIELD_MAX(PORT_MSIMAP_TARGET) + 1 - pcie->nvecs)) { @@ -7609,6 +7627,7 @@ 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,t8152-pciec", .data = &t8152_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 8bd5ca9736950d9a9b2e8629f1ec6e847a0da4c5 Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Tue, 17 Nov 2026 23:21:09 +0100 Subject: [PATCH 21/31] dt-bindings: thunderbolt: add the T8152 USB4 routers Add the T8152 ACIO and NHI. The T8152 router CPU is started by a reconfiguration request through its mailbox, so it has no cpu window. A second range maps the shared Gen3 TLB invalidation aperture for the router's DART. Signed-off-by: Thomas Glanzmann --- .../thunderbolt/apple,t8103-usb4-acio.yaml | 30 +++++++++++++++++-- .../thunderbolt/apple,t8103-usb4-nhi.yaml | 3 ++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/thunderbolt/apple,t8103-usb4-acio.yaml b/Documentation/devicetree/bindings/thunderbolt/apple,t8103-usb4-acio.yaml index 29c64e3b3c33e..70a883b4696fe 100644 --- a/Documentation/devicetree/bindings/thunderbolt/apple,t8103-usb4-acio.yaml +++ b/Documentation/devicetree/bindings/thunderbolt/apple,t8103-usb4-acio.yaml @@ -30,6 +30,7 @@ properties: oneOf: - const: apple,t8103-usb4-acio - const: apple,t8142-usb4-acio + - const: apple,t8152-usb4-acio - const: apple,t6040-usb4-acio - const: apple,t6050-usb4-acio - items: @@ -69,6 +70,14 @@ properties: - const: rc - const: sram - const: cpu + - description: + T8152, whose router CPU is started by a reconfiguration request + through its mailbox and has no window of its own + items: + - const: rc + - const: sram + - const: pcie-adapter + - const: router-ap-fw mboxes: maxItems: 1 @@ -185,8 +194,12 @@ properties: const: 1 ranges: - maxItems: 1 - description: Single 16 MiB MMIO window containing all child registers + minItems: 1 + maxItems: 2 + description: + 16 MiB MMIO window containing the child registers. On T8152 a second + range maps the shared Gen3 DART TLB invalidation aperture for the + router's DART. nonposted-mmio: true @@ -254,12 +267,23 @@ allOf: - apple,t6040-usb4-acio - apple,t8132-usb4-acio - apple,t8142-usb4-acio + - apple,t8152-usb4-acio then: properties: reg: minItems: 4 reg-names: minItems: 4 + - if: + properties: + compatible: + not: + contains: + const: apple,t8152-usb4-acio + then: + properties: + ranges: + maxItems: 1 - if: properties: compatible: @@ -269,6 +293,7 @@ allOf: - apple,t6050-usb4-acio - apple,t8132-usb4-acio - apple,t8142-usb4-acio + - apple,t8152-usb4-acio then: properties: pinctrl-names: @@ -319,6 +344,7 @@ allOf: enum: - apple,t6050-usb4-acio - apple,t8142-usb4-acio + - apple,t8152-usb4-acio then: properties: apple,tunable-router-ap-fw: false diff --git a/Documentation/devicetree/bindings/thunderbolt/apple,t8103-usb4-nhi.yaml b/Documentation/devicetree/bindings/thunderbolt/apple,t8103-usb4-nhi.yaml index 28718fed167c5..c68f883b10d0f 100644 --- a/Documentation/devicetree/bindings/thunderbolt/apple,t8103-usb4-nhi.yaml +++ b/Documentation/devicetree/bindings/thunderbolt/apple,t8103-usb4-nhi.yaml @@ -22,6 +22,7 @@ properties: oneOf: - const: apple,t8103-usb4-nhi - const: apple,t8142-usb4-nhi + - const: apple,t8152-usb4-nhi - const: apple,t6040-usb4-nhi - const: apple,t6050-usb4-nhi - items: @@ -131,6 +132,7 @@ allOf: contains: enum: - apple,t8142-usb4-nhi + - apple,t8152-usb4-nhi - apple,t6040-usb4-nhi - apple,t6050-usb4-nhi then: @@ -155,6 +157,7 @@ allOf: - apple,t8122-usb4-nhi - apple,t8132-usb4-nhi - apple,t8142-usb4-nhi + - apple,t8152-usb4-nhi - apple,t6040-usb4-nhi - apple,t6050-usb4-nhi then: From 5e8d7d9d6dc573a4f7c2d38872334f72baa00d60 Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Tue, 17 Nov 2026 23:21:09 +0100 Subject: [PATCH 22/31] thunderbolt: apple: support the T8152 routers The T8152 router is a Type 7 MXWrap-v2p3 that a reconfiguration request starts through its counted mailbox. Its DP IN path is not qualified. Release the CIO domains in reverse order and suspend each one synchronously, because deleting the device link only queues an idle request: the PHY reset and the next router start need them cold. Signed-off-by: Thomas Glanzmann --- drivers/thunderbolt/apple.c | 57 +++++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 15 deletions(-) diff --git a/drivers/thunderbolt/apple.c b/drivers/thunderbolt/apple.c index e21cf99212eba..a22d8129a7b32 100644 --- a/drivers/thunderbolt/apple.c +++ b/drivers/thunderbolt/apple.c @@ -171,6 +171,8 @@ struct apple_cio_hw { bool gen4_link_recovery; /* Leave the host router's TMU to its firmware; host TMU constants. */ bool host_tmu; + /* Drain PSD runtime power-off before the PHY is reset or reused. */ + bool psd_power_cycle; const struct apple_dpin_policy *dp; }; @@ -206,6 +208,17 @@ static const struct apple_cio_hw apple_cio_t8132_hw = { .dp = &apple_dpin_m4, }; +/* MXWrap-v2p3 is started by reconfiguration, using its counted mailbox. */ +static const struct apple_cio_hw apple_cio_t8152_hw = { + .psd_power_cycle = true, + .type7 = true, + .lstx_after_boot = true, + .strict_fw_ready = true, + .no_host_clx = true, + .no_asym = true, + .dp = &apple_dpin_disabled, +}; + /* Type 7 uses its existing ready-state check and has no qualified DP route. */ static const struct apple_cio_hw apple_cio_t8142_hw = { .type7 = true, @@ -1305,7 +1318,8 @@ static void apple_cio_of_node_put(void *data) static bool apple_cio_pciec_eligible(const struct device_node *np) { - return of_device_is_compatible(np, "apple,t6040-pciec") || + return of_device_is_compatible(np, "apple,t8152-pciec") || + 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"); @@ -2591,7 +2605,8 @@ static int apple_nhi_probe(struct platform_device *pdev) /* The T6050 router is the Type 7 one released by a RUN store. */ if (acio->type7 != - (of_device_is_compatible(pdev->dev.of_node, "apple,t8142-usb4-nhi") || + (of_device_is_compatible(pdev->dev.of_node, "apple,t8152-usb4-nhi") || + of_device_is_compatible(pdev->dev.of_node, "apple,t8142-usb4-nhi") || of_device_is_compatible(pdev->dev.of_node, "apple,t6040-usb4-nhi") || of_device_is_compatible(pdev->dev.of_node, "apple,t6050-usb4-nhi")) || acio->hw->run_store != @@ -3097,6 +3112,7 @@ static const struct of_device_id apple_nhi_match[] = { { .compatible = "apple,t6050-usb4-nhi", }, + { .compatible = "apple,t8152-usb4-nhi" }, { .compatible = "apple,t8142-usb4-nhi", }, @@ -3307,6 +3323,26 @@ static void apple_cio_test_log_guards(struct apple_cio *acio) dev_info(acio->dev, "TEST sv6t7: ACIO stop, its domain links go next: PS_PROT%s\n", buf); } +static void apple_cio_release_domains(struct apple_cio *acio) +{ + int n, i, ret; + + for (n = 0; n < acio->pd_list->num_pds; n++) { + i = acio->hw->psd_power_cycle ? acio->pd_list->num_pds - 1 - n : n; + dev_pm_syscore_device(acio->pd_list->pd_devs[i], false); + if (!acio->pd_list->pd_links[i]) + continue; + device_link_del(acio->pd_list->pd_links[i]); + acio->pd_list->pd_links[i] = NULL; + if (!acio->hw->psd_power_cycle) + continue; + /* Link removal only queues idle; finish it before returning. */ + ret = pm_runtime_suspend(acio->pd_list->pd_devs[i]); + if (ret < 0) + dev_warn(acio->dev, "PSD domain %d failed to suspend: %d\n", i, ret); + } +} + /** * apple_cio_stop - Stop and power down the ACIO complex * @acio: ACIO complex to stop @@ -3317,7 +3353,7 @@ static void apple_cio_test_log_guards(struct apple_cio *acio) */ static void apple_cio_stop(struct apple_cio *acio) { - int ret, i; + int ret; lockdep_assert_held(&acio->lock); if (!acio->current_cable_info) @@ -3342,12 +3378,7 @@ static void apple_cio_stop(struct apple_cio *acio) apple_cio_test_log_guards(acio); /* Finally, remove the links to the PD domains to power everything off */ - for (i = 0; i < acio->pd_list->num_pds; i++) { - if (acio->pd_list->pd_links[i]) - device_link_del(acio->pd_list->pd_links[i]); - acio->pd_list->pd_links[i] = NULL; - dev_pm_syscore_device(acio->pd_list->pd_devs[i], false); - } + apple_cio_release_domains(acio); acio->current_cable_info = 0; acio->resume_link_failed = false; @@ -3608,12 +3639,7 @@ static int apple_cio_start(struct apple_cio *acio) acio->rtk = NULL; apple_cio_cpu_halt(acio); /* Cut power to reset the entire block */ - for (i = 0; i < acio->pd_list->num_pds; i++) { - if (acio->pd_list->pd_links[i]) - device_link_del(acio->pd_list->pd_links[i]); - acio->pd_list->pd_links[i] = NULL; - dev_pm_syscore_device(acio->pd_list->pd_devs[i], false); - } + apple_cio_release_domains(acio); return ret; } @@ -4773,6 +4799,7 @@ static const struct of_device_id apple_acio_match[] = { .compatible = "apple,t6050-usb4-acio", .data = &apple_cio_t6050_hw, }, + { .compatible = "apple,t8152-usb4-acio", .data = &apple_cio_t8152_hw }, { .compatible = "apple,t8142-usb4-acio", .data = &apple_cio_t8142_hw, From 4c3261906e86de2a832863e71c629fe5a85b2032 Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Fri, 20 Nov 2026 01:21:48 +0100 Subject: [PATCH 23/31] dt-bindings: phy: apple,atcphy: add the T8152 Type-C ports in CIO mode The J873g's three rear USB-C ports have T8152 ATC PHYs behind a Type-C mux, with a USB4 router behind each. Linux runs them in CIO (USB4) mode only for now: their DisplayPort alt mode is still driven by the display controllers, and their USB2 side by the bootloader. Allow a T8152 PHY without apple,fixed-usb3 for such a port: its core bank alone (the power and reset block at 0x60000 is part of it, and the display controllers map the same bank), the orientation and mode switches with port@0 to the connector's SuperSpeed port, the ATC's four power domains in power-up order, and the common and lane CIO tunables. The display controller takes the PHY through its DisplayPort PHY. Signed-off-by: Thomas Glanzmann --- .../devicetree/bindings/phy/apple,atcphy.yaml | 89 +++++++++++++++---- 1 file changed, 72 insertions(+), 17 deletions(-) diff --git a/Documentation/devicetree/bindings/phy/apple,atcphy.yaml b/Documentation/devicetree/bindings/phy/apple,atcphy.yaml index 783f6732fae3a..d3e7f3722d214 100644 --- a/Documentation/devicetree/bindings/phy/apple,atcphy.yaml +++ b/Documentation/devicetree/bindings/phy/apple,atcphy.yaml @@ -40,12 +40,17 @@ description: > DisplayPort also requires separate bootloader-provided calibration lists for that bank and the common configuration in the lpdptx region. - The T8152 variant is supported as the USB3 PHY of a fixed-USB3 port only, - see apple,fixed-usb3. It is described by its core and pipehandler banks; the - core bank also holds the USB controller's DARTs. Its power domains are the - ATC's PMGR power states and PSD service the PHY needs, in the order they are - powered up. Lane 0 is powered up and the crossbar set between the common-a - tunables and the others. + The T8152 variant is supported as the USB3 PHY of a fixed-USB3 port, see + apple,fixed-usb3, and as the PHY of a Type-C port in USB4/Thunderbolt + ("Converged IO", CIO) mode alone. Its core bank also holds the USB + controller's DARTs. Its power domains are the ATC's PMGR power states and + PSD service the PHY needs, in the order they are powered up. The lanes of + the mode are powered up and the crossbar set between the common-a tunables + and the others. A fixed-USB3 port is described by its core and pipehandler + banks. A Type-C port is described by its core bank alone: its DisplayPort + alternate mode is driven by the display controller, which takes the PHY + through its DisplayPort PHY (PHY_TYPE_DP) and has the PHY's power domains + powered while it drives it, and its USB2 side is left to the bootloader. allOf: - $ref: /schemas/usb/usb-switch.yaml# @@ -137,12 +142,14 @@ allOf: then: properties: reg: + minItems: 1 items: - description: PHY core with its power and reset block, which also holds the USB controller's DARTs - - description: USB3 PIPE interface controls + - description: USB3 PIPE interface controls (fixed-USB3 port) reg-names: + minItems: 1 items: - const: core - const: pipehandler @@ -189,11 +196,28 @@ allOf: then: properties: "#reset-cells": false - mode-switch: false - orientation-switch: false - ports: false - required: - - apple,fixed-usb3 + if: + required: + - apple,fixed-usb3 + then: + properties: + mode-switch: false + orientation-switch: false + ports: false + reg: + minItems: 2 + reg-names: + minItems: 2 + else: + properties: + reg: + maxItems: 1 + reg-names: + maxItems: 1 + required: + - mode-switch + - orientation-switch + - ports else: properties: apple,fixed-usb3: false @@ -382,11 +406,12 @@ properties: apple,fixed-usb3: type: boolean description: > - T8152 only, and required there. The port's SuperSpeed lanes go straight - to a USB3 device or hub, with no Type-C mux in between, so the PHY runs - USB3 on lane 0 from probe on and ignores mux and orientation changes. It - provides only the USB3 PHY of its USB controller, which is a host, and - leaves the controller's USB2 side and reset to the bootloader. + T8152 only. The port's SuperSpeed lanes go straight to a USB3 device or + hub, with no Type-C mux in between, so the PHY runs USB3 on lane 0 from + probe on and ignores mux and orientation changes. It provides only the + USB3 PHY of its USB controller, which is a host, and leaves the + controller's USB2 side and reset to the bootloader. Without it a T8152 + PHY is a Type-C port's, run in CIO mode alone. apple,dp-alt-mode: type: boolean @@ -707,4 +732,34 @@ examples: apple,tunable-common-b = <0x6c004 0x003f003f 0x00200020>; apple,tunable-lane0-usb = <0x082d8 0xf0000000 0x70000000>; }; + + phy@413000000 { + compatible = "apple,t8152-atcphy"; + reg = <0x4 0x13000000 0x0 0x84000>; + reg-names = "core"; + + #phy-cells = <1>; + orientation-switch; + mode-switch; + power-domains = <&ps_atc3_usb_aon>, <&ps_atc3_common>, + <&ps_atc3_common_dp_0>, <&ps_atc3_common_dp_1>; + + apple,tunable-common-a = <0x00800 0x00fc0000 0x00fc0000>; + apple,tunable-common-b = <0x6c004 0x003f003f 0x00200020>; + apple,tunable-lane0-cio = <0x082d8 0xf0000000 0x70000000>; + apple,tunable-lane1-cio = <0x112d8 0xf0000000 0x70000000>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + + endpoint { + remote-endpoint = <&typec3_ss>; + }; + }; + }; + }; }; From b6cfb6496809160fb08d9cb803dac84bfaf274ae Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Fri, 20 Nov 2026 01:26:02 +0100 Subject: [PATCH 24/31] phy: apple: atc: run the T8152 Type-C ports in CIO mode The J873g's three rear USB-C ports have T8152 ATC PHYs with a USB4 router behind each. Their DisplayPort alt mode is still programmed by the display driver (drm/apple's T8152 code), and their USB2 side is the bootloader's. Run such a PHY in CIO mode for a USB4 partner and leave it to the display driver otherwise, as a Type-C port of its own kind (cio_only, selected by the T8152 match data for a PHY without apple,fixed-usb3). The Type-C port driver sets the mux before it starts the router and after it stops it, as on T8142. CIO mode uses the T8152 layout of the fixed-USB3 support: the power and reset block at 0x60000 with the sync reset at 0x60030, the crossbar at 0x4c (USB4 0, USB4 swapped 1), no lane mode register. It differs from USB3 in that both lanes are powered up, one after the other, between the common-a tunables and the others (LFPS receivers 0x1e24 bits 12/16 and 14/18, then the lane controls at 0x1e18 and 0x1e1c out of sleep, unclamped and out of AHB reset), and in that a reversed plug sets the lane swap (bit 1 of 0x60008) next to the swapped crossbar, where T8142 leaves it clear. On the way down AUX is clamped (0x1e24 bit 10, sleeps 6 and 8 cleared) and both lanes' LFPS receivers are dropped before the lanes, as the T8152 CIO shutdown does: these always-on controls keep their state while the common block is off. The lanes are only touched while the register bus (0x60000 bit 3) is out of reset. This is the sequence the earlier port monitor ran, with which a rear port trained USB4 at 2 x 20 Gb/s and carried an NVMe enclosure at 16 GT/s x4. The PHY's four power domains (USB_AON, the common PSD service, DP_0, DP_1) are attached without device links. They are held while the PHY runs CIO mode, and dropped synchronously after the CIO shutdown, so that the common block goes cold before the next partner: a training from a powered common block asserted in the router's firmware. The PHY and the display driver take turns, explicitly: - The display driver powers the PHY's DP PHY on before it touches the PHY and off when it has let go of it. The DP PHY holds the domains for it and keeps CIO mode out: a USB4 mode change fails with -ETIMEDOUT, and the mux declares its timeouts transient, so the port driver retries until the display is gone. A DP PHY power-on in CIO mode fails with -EBUSY. - Either takes the PHY only when its power and reset block is as its power-up leaves it (0x60000 = 0x4, no sleep acknowledged, sync reset 0); CIO mode is refused otherwise. - A display the bootloader started has all four domains on and a busy block at probe. Its domains are then held for the display driver, which takes the PHY over, until its DP PHY goes off. Once DisplayPort moves into this driver, the DP PHY programs it itself, both modes switch under the PHY's lock and this arbitration goes away. Thunderbolt alt mode is refused on these ports for now: the T8152 routers have only been run with USB4 partners. The other SoCs are unchanged: the new paths are taken for a cio_only PHY or the T8152 generation only, and T8152 now sets has_usb4, which a fixed-USB3 port's tunable list does not consult. KUnit cases check the CIO lanes, crossbar and swap in both orientations, the power-down, the idle test and which Type-C states ask for CIO. The DCP host-test fixtures that compile the power-up and power-down get the new field. Signed-off-by: Thomas Glanzmann --- drivers/phy/apple/atc-test.c | 129 ++++- drivers/phy/apple/atc.c | 462 ++++++++++++++++-- .../selftests/drivers/apple/atc-t8132-usb3.py | 2 +- .../drivers/gpu/apple-dcp/dwc3/mocks.c | 2 +- .../selftests/drivers/gpu/apple-dcp/phy.py | 6 +- 5 files changed, 541 insertions(+), 60 deletions(-) diff --git a/drivers/phy/apple/atc-test.c b/drivers/phy/apple/atc-test.c index a34e19b1ab432..000f8c28834da 100644 --- a/drivers/phy/apple/atc-test.c +++ b/drivers/phy/apple/atc-test.c @@ -1493,8 +1493,8 @@ static void atcphy_test_t8152_lanes(struct kunit *test) atcphy_lanes_up_t8152(atcphy, APPLE_ATCPHY_MODE_USB3); KUNIT_EXPECT_EQ(test, readl(core + ACIOPHY_T8152_AON_LANE0), ATCPHY_TEST_T8152_LANE0_UP); KUNIT_EXPECT_EQ(test, readl(core + ACIOPHY_T8152_AON_SLEEP_CTRL2), - ACIOPHY_T8152_AON_SLEEP_CTRL2_RXA_LFPS_SMALL_LN0 | - ACIOPHY_T8152_AON_SLEEP_CTRL2_RXA_LFPS_BIG_LN0); + ACIOPHY_T8152_AON_SLEEP_CTRL2_RXA_LFPS_SMALL(0) | + ACIOPHY_T8152_AON_SLEEP_CTRL2_RXA_LFPS_BIG(0)); KUNIT_EXPECT_EQ(test, readl(core + ACIOPHY_CROSSBAR_T8103), 0x110U); KUNIT_EXPECT_EQ(test, atcphy_configure_lanes(atcphy, APPLE_ATCPHY_MODE_USB3), 0); @@ -1550,10 +1550,135 @@ static void atcphy_test_t8152_pipe_lock(struct kunit *test) KUNIT_EXPECT_EQ(test, readl(atcphy->regs.pipehandler + PIPEHANDLER_LOCK_REQ), 0U); } +/* Both LFPS receivers of a lane on */ +static u32 atcphy_test_t8152_lfps(unsigned int lane) +{ + return ACIOPHY_T8152_AON_SLEEP_CTRL2_RXA_LFPS_SMALL(lane) | + ACIOPHY_T8152_AON_SLEEP_CTRL2_RXA_LFPS_BIG(lane); +} + +/* + * CIO on a rear port: both lanes powered up one after the other, the USB4 + * crossbar by the orientation, the lane swap for a reversed plug too, and on + * the way down both lanes clamped, their LFPS receivers off and AUX clamped. + */ +static void atcphy_test_t8152_cio_lanes(struct kunit *test) +{ + struct apple_atcphy *atcphy = atcphy_test_alloc_t8152(test); + void __iomem *core = atcphy->regs.core; + u32 ctrl = ATCPHY_T8152_CFG_OFFSET + ATCPHY_POWER_CTRL; + u32 misc = ATCPHY_T8152_CFG_OFFSET + ATCPHY_MISC; + + atcphy->fixed_usb3 = false; + atcphy->cio_only = true; + for (int reversed = 0; reversed < 2; reversed++) { + atcphy->swap_lanes = reversed; + writel(ACIOPHY_T8152_AON_LANE_CLAMP_EN, core + ACIOPHY_T8152_AON_LANE(0)); + writel(ACIOPHY_T8152_AON_LANE_CLAMP_EN, core + ACIOPHY_T8152_AON_LANE(1)); + writel(ACIOPHY_T8152_AON_SLEEP_CTRL2_AUX_CLAMP_EN, + core + ACIOPHY_T8152_AON_SLEEP_CTRL2); + writel(reversed ? 0 : ATCPHY_T8152_MISC_LANE_SWAP, core + misc); + writel(ACIOPHY_CROSSBAR_DP_SINGLE_PMA_UNK100 << 5 | ACIOPHY_CROSSBAR_DP_BOTH_PMA, + core + ACIOPHY_CROSSBAR_T8103); + + atcphy_lanes_up_t8152(atcphy, APPLE_ATCPHY_MODE_USB4); + KUNIT_EXPECT_EQ(test, readl(core + ACIOPHY_T8152_AON_LANE(0)), + ATCPHY_TEST_T8152_LANE0_UP); + KUNIT_EXPECT_EQ(test, readl(core + ACIOPHY_T8152_AON_LANE(1)), + ATCPHY_TEST_T8152_LANE0_UP); + KUNIT_EXPECT_EQ(test, readl(core + ACIOPHY_T8152_AON_SLEEP_CTRL2), + ACIOPHY_T8152_AON_SLEEP_CTRL2_AUX_CLAMP_EN | + atcphy_test_t8152_lfps(0) | atcphy_test_t8152_lfps(1)); + KUNIT_EXPECT_EQ(test, readl(core + ACIOPHY_CROSSBAR_T8103), + (u32)ACIOPHY_CROSSBAR_DP_BOTH_PMA | reversed); + + KUNIT_EXPECT_EQ(test, atcphy_configure_lanes(atcphy, APPLE_ATCPHY_MODE_USB4), 0); + KUNIT_EXPECT_EQ(test, readl(core + ACIOPHY_CROSSBAR_T8103), (u32)reversed); + KUNIT_EXPECT_EQ(test, readl(core + misc), + reversed ? ATCPHY_T8152_MISC_LANE_SWAP : 0U); + + atcphy->mode = APPLE_ATCPHY_MODE_USB4; + writel(ATCPHY_POWER_APB_RESET_N, core + ctrl); + atcphy_lanes_down_t8152(atcphy); + KUNIT_EXPECT_EQ(test, readl(core + ACIOPHY_T8152_AON_LANE(0)), + ACIOPHY_T8152_AON_LANE_CLAMP_EN); + KUNIT_EXPECT_EQ(test, readl(core + ACIOPHY_T8152_AON_LANE(1)), + ACIOPHY_T8152_AON_LANE_CLAMP_EN); + KUNIT_EXPECT_EQ(test, readl(core + ACIOPHY_T8152_AON_SLEEP_CTRL2), + ACIOPHY_T8152_AON_SLEEP_CTRL2_AUX_CLAMP_EN); + atcphy->mode = APPLE_ATCPHY_MODE_OFF; + atcphy_test_t8152_untouched(test, atcphy); + } +} + +/* A lane power-down with the register bus in reset leaves the lanes alone */ +static void atcphy_test_t8152_lanes_bus_reset(struct kunit *test) +{ + struct apple_atcphy *atcphy = atcphy_test_alloc_t8152(test); + void __iomem *core = atcphy->regs.core; + + writel(ATCPHY_TEST_T8152_LANE0_UP, core + ACIOPHY_T8152_AON_LANE0); + writel(ATCPHY_POWER_CLAMP_EN, core + ATCPHY_T8152_CFG_OFFSET + ATCPHY_POWER_CTRL); + atcphy_lanes_down_t8152(atcphy); + KUNIT_EXPECT_EQ(test, readl(core + ACIOPHY_T8152_AON_LANE0), ATCPHY_TEST_T8152_LANE0_UP); +} + +/* Only USB4 in its own mode, and Thunderbolt, ask a CIO-only PHY for CIO */ +static void atcphy_test_cio_target_mode(struct kunit *test) +{ + struct typec_altmode dp = { .svid = USB_TYPEC_DP_SID }; + struct typec_altmode tbt = { .svid = USB_TYPEC_TBT_SID }; + struct enter_usb_data usb4 = { .eudo = FIELD_PREP(EUDO_USB_MODE_MASK, EUDO_USB_MODE_USB4) }; + struct enter_usb_data usb3 = { .eudo = FIELD_PREP(EUDO_USB_MODE_MASK, EUDO_USB_MODE_USB3) }; + struct typec_mux_state state = { .mode = TYPEC_MODE_USB4, .data = &usb4 }; + + KUNIT_EXPECT_EQ(test, atcphy_cio_target_mode(&state), APPLE_ATCPHY_MODE_USB4); + state.data = &usb3; + KUNIT_EXPECT_EQ(test, atcphy_cio_target_mode(&state), APPLE_ATCPHY_MODE_OFF); + state.data = NULL; + KUNIT_EXPECT_EQ(test, atcphy_cio_target_mode(&state), APPLE_ATCPHY_MODE_OFF); + state.alt = &tbt; + state.mode = TYPEC_TBT_MODE; + KUNIT_EXPECT_EQ(test, atcphy_cio_target_mode(&state), APPLE_ATCPHY_MODE_TBT); + state.alt = &dp; + state.mode = TYPEC_DP_STATE_D; + KUNIT_EXPECT_EQ(test, atcphy_cio_target_mode(&state), APPLE_ATCPHY_MODE_OFF); + state.alt = NULL; + state.mode = TYPEC_STATE_USB; + KUNIT_EXPECT_EQ(test, atcphy_cio_target_mode(&state), APPLE_ATCPHY_MODE_OFF); + state.mode = TYPEC_STATE_SAFE; + KUNIT_EXPECT_EQ(test, atcphy_cio_target_mode(&state), APPLE_ATCPHY_MODE_OFF); +} + +/* The PHY is idle only as its power-up leaves it */ +static void atcphy_test_t8152_cio_idle(struct kunit *test) +{ + struct apple_atcphy *atcphy = atcphy_test_alloc_t8152(test); + void __iomem *core = atcphy->regs.core; + u32 ctrl = ATCPHY_T8152_CFG_OFFSET + ATCPHY_POWER_CTRL; + u32 stat = ATCPHY_T8152_CFG_OFFSET + ATCPHY_POWER_STAT; + + writel(ATCPHY_POWER_CLAMP_EN, core + ctrl); + KUNIT_EXPECT_TRUE(test, atcphy_cio_idle(atcphy)); + /* the display driver's DisplayPort setup */ + writel(0x1b, core + ctrl); + KUNIT_EXPECT_FALSE(test, atcphy_cio_idle(atcphy)); + writel(ATCPHY_POWER_CLAMP_EN, core + ctrl); + writel(ATCPHY_POWER_SLEEP_SMALL, core + stat); + KUNIT_EXPECT_FALSE(test, atcphy_cio_idle(atcphy)); + writel(0, core + stat); + writel(ATCPHY_MISC_RESET_N, core + ATCPHY_T8152_SYNC_RESET); + KUNIT_EXPECT_FALSE(test, atcphy_cio_idle(atcphy)); +} + static struct kunit_case atcphy_t8152_test_cases[] = { KUNIT_CASE(atcphy_test_t8152_lanes), KUNIT_CASE(atcphy_test_t8152_power), KUNIT_CASE(atcphy_test_t8152_pipe_lock), + KUNIT_CASE(atcphy_test_t8152_cio_lanes), + KUNIT_CASE(atcphy_test_t8152_lanes_bus_reset), + KUNIT_CASE(atcphy_test_cio_target_mode), + KUNIT_CASE(atcphy_test_t8152_cio_idle), {} }; diff --git a/drivers/phy/apple/atc.c b/drivers/phy/apple/atc.c index 347d2a4d6ec03..e139ac328fbbe 100644 --- a/drivers/phy/apple/atc.c +++ b/drivers/phy/apple/atc.c @@ -277,15 +277,19 @@ enum atcphy_lane_mode { ACIOPHY_T8152_BIST_OV2_LN0_UNK10) /* T8152 lane power controls in the always-on top block (ACIOPHY_TOP_AON_BLK) */ -#define ACIOPHY_T8152_AON_LANE0 0x1e18 +#define ACIOPHY_T8152_AON_LANE(n) (0x1e18 + 4 * (n)) +#define ACIOPHY_T8152_AON_LANE0 ACIOPHY_T8152_AON_LANE(0) #define ACIOPHY_T8152_AON_LANE_CLAMP_EN BIT(0) #define ACIOPHY_T8152_AON_LANE_SLEEP_SMALL BIT(1) #define ACIOPHY_T8152_AON_LANE_SLEEP_BIG BIT(2) #define ACIOPHY_T8152_AON_LANE_AHB_RESET_N BIT(5) #define ACIOPHY_T8152_AON_SLEEP_CTRL2 0x1e24 -#define ACIOPHY_T8152_AON_SLEEP_CTRL2_RXA_LFPS_SMALL_LN0 BIT(12) -#define ACIOPHY_T8152_AON_SLEEP_CTRL2_RXA_LFPS_BIG_LN0 BIT(16) +#define ACIOPHY_T8152_AON_SLEEP_CTRL2_AUX_SLEEP_BIG BIT(6) +#define ACIOPHY_T8152_AON_SLEEP_CTRL2_AUX_SLEEP_SMALL BIT(8) +#define ACIOPHY_T8152_AON_SLEEP_CTRL2_AUX_CLAMP_EN BIT(10) +#define ACIOPHY_T8152_AON_SLEEP_CTRL2_RXA_LFPS_SMALL(n) BIT(12 + 2 * (n)) +#define ACIOPHY_T8152_AON_SLEEP_CTRL2_RXA_LFPS_BIG(n) BIT(16 + 2 * (n)) #define ACIOPHY_SLEEP_CTRL 0x1b0 #define ACIOPHY_SLEEP_CTRL_TX_BIG GENMASK(1, 0) @@ -736,6 +740,10 @@ struct apple_atcphy; * first and its power-down asserts last, instead of * ATCPHY_MISC_RESET_N, or zero * @lane_swap: Lane swap bit in ATCPHY_MISC, or zero for ATCPHY_MISC_LANE_SWAP + * @cio_lane_swap: CIO (USB4) mode sets @lane_swap for a reversed plug as well, + * next to the swapped crossbar + * @typec_cio_only: On a Type-C port the PHY runs only CIO (USB4) mode, see + * apple_atcphy.cio_only * @has_usb4: A USB4/Thunderbolt controller sits behind the PHY * @usb2_only: Uses the USB2 subset unless its banked SuperSpeed resources exist * @usb2phy_sig_host: Host role field mask, or zero for the original layout @@ -773,6 +781,8 @@ struct atcphy_hw { u32 cfg_offset; u32 sync_reset; u32 lane_swap; + bool cio_lane_swap; + bool typec_cio_only; bool has_usb4; bool usb2_only; u32 usb2phy_sig_host; @@ -865,6 +875,16 @@ struct atcphy_cio_sleep { * on lane 0 from probe on and provides only the USB3 PHY of the * controller, which is a host; its USB2 side and its reset are * left to the bootloader + * @cio_only: A Type-C port on which the PHY runs CIO (USB4) mode alone + * (atcphy_hw.typec_cio_only): its DisplayPort mode is the display + * driver's, which powers the DP PHY while it drives the PHY itself, + * and its USB2 side is left to the bootloader. See + * atcphy_cio_mux_set(). + * @cio_pds: The power domains of a @cio_only PHY, in power-up order + * @cio_powered: The PHY holds @cio_pds for CIO mode + * @display_owned: The display driver drives a @cio_only PHY and holds @cio_pds + * through the DP PHY, or the bootloader left it driving a + * display, which the display driver takes over * @typec_mode: Mode the Type-C mux last asked for; a fixed-hub port returns to * it when the PHY is brought back up after a power-off * @host_active: dwc3 has selected host mode on the USB3 PHY; a fixed-hub port @@ -980,6 +1000,10 @@ struct apple_atcphy { bool dp_only; bool fixed_usb2; bool fixed_usb3; + bool cio_only; + struct dev_pm_domain_list *cio_pds; + bool cio_powered; + bool display_owned; enum atcphy_mode typec_mode; bool host_active; /* @@ -1357,33 +1381,45 @@ static inline u32 atcphy_lane_swap(const struct apple_atcphy *atcphy) return atcphy->hw->lane_swap ?: ATCPHY_MISC_LANE_SWAP; } +/* T8152: the lanes a mode runs on, lane 0 for USB3, both for CIO (USB4) */ +static unsigned int atcphy_lanes_t8152(enum atcphy_mode mode) +{ + return mode == APPLE_ATCPHY_MODE_USB4 || mode == APPLE_ATCPHY_MODE_TBT ? 2 : 1; +} + /* * T8152 keeps a lane's registers in AHB reset until the lane is powered up on - * its own, and they drop their tunables meanwhile. Power lane 0, the USB3 lane - * of a fixed-USB3 port, up after the common-a tunables: its LFPS receivers, - * then out of sleep, unclamped and out of AHB reset. Set the crossbar right - * after, before the remaining tunables, as the T8152 sequence does: 0x110 for - * USB3, i.e. USB3+DP with single PMA 0x008. atcphy_configure_lanes() writes the - * same value again later. + * its own, and they drop their tunables meanwhile. Power the lanes of the mode + * up after the common-a tunables, one after the other: lane 0, the USB3 lane + * of a fixed-USB3 port, and in CIO mode lane 1 too. Each gets its LFPS + * receivers, then goes out of sleep, unclamped and out of AHB reset. Set the + * crossbar right after, before the remaining tunables, as the T8152 sequence + * does: 0x110 for USB3, i.e. USB3+DP with single PMA 0x008, and 0 or 1 for + * CIO by the plug orientation. atcphy_configure_lanes() writes the same value + * again later. */ static void atcphy_lanes_up_t8152(struct apple_atcphy *atcphy, enum atcphy_mode mode) { const struct atcphy_mode_configuration *mode_cfg = atcphy_get_mode_config(atcphy, mode); - core_set32(atcphy, ACIOPHY_T8152_AON_SLEEP_CTRL2, - ACIOPHY_T8152_AON_SLEEP_CTRL2_RXA_LFPS_SMALL_LN0); - udelay(1); - core_set32(atcphy, ACIOPHY_T8152_AON_SLEEP_CTRL2, - ACIOPHY_T8152_AON_SLEEP_CTRL2_RXA_LFPS_BIG_LN0); - udelay(1); - core_set32(atcphy, ACIOPHY_T8152_AON_LANE0, ACIOPHY_T8152_AON_LANE_SLEEP_SMALL); - udelay(1); - core_set32(atcphy, ACIOPHY_T8152_AON_LANE0, ACIOPHY_T8152_AON_LANE_SLEEP_BIG); - udelay(1); - core_clear32(atcphy, ACIOPHY_T8152_AON_LANE0, ACIOPHY_T8152_AON_LANE_CLAMP_EN); - udelay(1); - core_set32(atcphy, ACIOPHY_T8152_AON_LANE0, ACIOPHY_T8152_AON_LANE_AHB_RESET_N); - udelay(1); + for (unsigned int lane = 0; lane < atcphy_lanes_t8152(mode); lane++) { + u32 ctrl = ACIOPHY_T8152_AON_LANE(lane); + + core_set32(atcphy, ACIOPHY_T8152_AON_SLEEP_CTRL2, + ACIOPHY_T8152_AON_SLEEP_CTRL2_RXA_LFPS_SMALL(lane)); + udelay(1); + core_set32(atcphy, ACIOPHY_T8152_AON_SLEEP_CTRL2, + ACIOPHY_T8152_AON_SLEEP_CTRL2_RXA_LFPS_BIG(lane)); + udelay(1); + core_set32(atcphy, ctrl, ACIOPHY_T8152_AON_LANE_SLEEP_SMALL); + udelay(1); + core_set32(atcphy, ctrl, ACIOPHY_T8152_AON_LANE_SLEEP_BIG); + udelay(1); + core_clear32(atcphy, ctrl, ACIOPHY_T8152_AON_LANE_CLAMP_EN); + udelay(1); + core_set32(atcphy, ctrl, ACIOPHY_T8152_AON_LANE_AHB_RESET_N); + udelay(1); + } core_mask32(atcphy, atcphy->hw->aciophy_crossbar, ACIOPHY_CROSSBAR_PROTOCOL | ACIOPHY_CROSSBAR_DP_SINGLE_PMA, @@ -1392,17 +1428,55 @@ static void atcphy_lanes_up_t8152(struct apple_atcphy *atcphy, enum atcphy_mode mode_cfg->crossbar_dp_single_pma)); } -/* T8152: power lane 0 down as the PHY powers down, the reverse of the above */ +/* + * T8152: power the lanes of the current mode down as the PHY powers down, the + * reverse of the above, while the register bus is still out of reset (a + * failed power-up may not have released it). A CIO-only PHY only ever runs + * CIO mode, so both of its lanes, also after a failed CIO power-up. Leaving + * CIO mode also clamps AUX and drops both lanes' LFPS receivers first, as the + * T8152 CIO shutdown does; the lanes' power controls are always-on and keep + * what they are left with across the common block's power-down. + */ static void atcphy_lanes_down_t8152(struct apple_atcphy *atcphy) { - core_clear32(atcphy, ACIOPHY_T8152_AON_LANE0, ACIOPHY_T8152_AON_LANE_AHB_RESET_N); - udelay(1); - core_set32(atcphy, ACIOPHY_T8152_AON_LANE0, ACIOPHY_T8152_AON_LANE_CLAMP_EN); - udelay(1); - core_clear32(atcphy, ACIOPHY_T8152_AON_LANE0, ACIOPHY_T8152_AON_LANE_SLEEP_BIG); - udelay(1); - core_clear32(atcphy, ACIOPHY_T8152_AON_LANE0, ACIOPHY_T8152_AON_LANE_SLEEP_SMALL); - udelay(1); + unsigned int lanes = atcphy->cio_only ? 2 : atcphy_lanes_t8152(atcphy->mode); + + if (!(core_read32(atcphy, atcphy_cfg(atcphy, ATCPHY_POWER_CTRL)) & + ATCPHY_POWER_APB_RESET_N)) + return; + + if (lanes > 1) { + core_set32(atcphy, ACIOPHY_T8152_AON_SLEEP_CTRL2, + ACIOPHY_T8152_AON_SLEEP_CTRL2_AUX_CLAMP_EN); + udelay(1); + core_clear32(atcphy, ACIOPHY_T8152_AON_SLEEP_CTRL2, + ACIOPHY_T8152_AON_SLEEP_CTRL2_AUX_SLEEP_BIG); + udelay(1); + core_clear32(atcphy, ACIOPHY_T8152_AON_SLEEP_CTRL2, + ACIOPHY_T8152_AON_SLEEP_CTRL2_AUX_SLEEP_SMALL); + udelay(1); + for (unsigned int lane = 0; lane < lanes; lane++) { + core_clear32(atcphy, ACIOPHY_T8152_AON_SLEEP_CTRL2, + ACIOPHY_T8152_AON_SLEEP_CTRL2_RXA_LFPS_SMALL(lane)); + udelay(1); + core_clear32(atcphy, ACIOPHY_T8152_AON_SLEEP_CTRL2, + ACIOPHY_T8152_AON_SLEEP_CTRL2_RXA_LFPS_BIG(lane)); + udelay(1); + } + } + + for (unsigned int lane = 0; lane < lanes; lane++) { + u32 ctrl = ACIOPHY_T8152_AON_LANE(lane); + + core_clear32(atcphy, ctrl, ACIOPHY_T8152_AON_LANE_AHB_RESET_N); + udelay(1); + core_set32(atcphy, ctrl, ACIOPHY_T8152_AON_LANE_CLAMP_EN); + udelay(1); + core_clear32(atcphy, ctrl, ACIOPHY_T8152_AON_LANE_SLEEP_BIG); + udelay(1); + core_clear32(atcphy, ctrl, ACIOPHY_T8152_AON_LANE_SLEEP_SMALL); + udelay(1); + } } /* Static configuration fields already read/modified by the public DP path. */ @@ -2368,7 +2442,8 @@ static int atcphy_configure_lanes(struct apple_atcphy *atcphy, enum atcphy_mode core_mask32(atcphy, atcphy->hw->aciophy_crossbar, ACIOPHY_CROSSBAR_PROTOCOL, FIELD_PREP(ACIOPHY_CROSSBAR_PROTOCOL, mode_cfg->crossbar)); - if (mode_cfg->set_swap) + if (mode_cfg->set_swap || + (atcphy->hw->cio_lane_swap && atcphy_mode_is_cio(mode) && atcphy->swap_lanes)) core_set32(atcphy, atcphy_cfg(atcphy, ATCPHY_MISC), atcphy_lane_swap(atcphy)); else core_clear32(atcphy, atcphy_cfg(atcphy, ATCPHY_MISC), atcphy_lane_swap(atcphy)); @@ -2383,7 +2458,7 @@ static int atcphy_configure_lanes(struct apple_atcphy *atcphy, enum atcphy_mode /* * The PMA FSM override below is for the T8103 generation. T8122 DP lanes * are started by the link rate sequence, see atcphy_dp_set_rate_t8122(). - * T8152 runs USB3 alone. + * T8152 runs USB3 or CIO alone. */ if (atcphy->hw->gen == ATCPHY_GENERATION_T8122 || atcphy->hw->gen == ATCPHY_GENERATION_T8152) @@ -2919,8 +2994,9 @@ static int atcphy_power_off(struct apple_atcphy *atcphy) u32 reg; int ret; - /* A fixed-USB3 port has no DisplayPort side */ - if (atcphy->hw->gen != ATCPHY_GENERATION_T8132 && !atcphy->fixed_usb3) { + /* A fixed-USB3 port has no DisplayPort side, a CIO-only port leaves it alone */ + if (atcphy->hw->gen != ATCPHY_GENERATION_T8132 && !atcphy->fixed_usb3 && + !atcphy->cio_only) { ret = atcphy_disable_dp_aux(atcphy); if (ret) return ret; @@ -3013,7 +3089,7 @@ static int atcphy_power_on(struct apple_atcphy *atcphy) u32 reg; int ret; - if (!atcphy->dp_only && !atcphy->fixed_usb3) + if (!atcphy->dp_only && !atcphy->fixed_usb3 && !atcphy->cio_only) atcphy_usb2_power_on(atcphy); core_set32(atcphy, atcphy->hw->sync_reset ?: atcphy_cfg(atcphy, ATCPHY_MISC), @@ -5452,6 +5528,192 @@ int apple_atc_dp_tunnel_open(struct phy *phy) } EXPORT_SYMBOL_GPL(apple_atc_dp_tunnel_open); +/* + * T8152's rear USB-C ports (atcphy_hw.typec_cio_only, apple_atcphy.cio_only): + * the PHY runs CIO mode for a USB4 partner and is left alone otherwise. + * + * Their DisplayPort alt mode is still driven by the display driver, which + * programs the PHY's power and reset block, lanes and display crossbar + * itself. The two take turns on the PHY: + * + * - The display driver powers the DP PHY on before it touches the PHY and + * off once it has let go of it. The DP PHY then holds the PHY's power + * domains for it, and keeps the PHY out of CIO mode: a USB4 mode change + * fails with -ETIMEDOUT, which the Type-C port driver retries (the mux + * declares its timeouts transient) until the display driver is done. + * - A DP PHY power-on is refused with -EBUSY while the PHY runs CIO mode. + * - Either takes the PHY only from its idle state: the power and reset block + * as the power-up leaves it, clamped and asleep, its sync reset asserted. + * Anything else means another user still has it, and CIO mode is refused. + * - A display the bootloader brought up keeps running for the display + * driver: such a PHY has all its domains on and is not idle at probe, and + * the domains are held for the display driver until its DP PHY goes off. + * + * Once the DisplayPort mode moves into this driver, the DP PHY programs it + * itself, both modes switch under the PHY's lock, and this arbitration goes. + */ +static int atcphy_cio_pds_on(struct apple_atcphy *atcphy) +{ + struct dev_pm_domain_list *pds = atcphy->cio_pds; + int ret; + + for (unsigned int i = 0; i < pds->num_pds; i++) { + ret = pm_runtime_resume_and_get(pds->pd_devs[i]); + if (ret < 0) { + while (i--) + pm_runtime_put_sync(pds->pd_devs[i]); + return ret; + } + } + return 0; +} + +/* Synchronously: the next CIO mode or display must find them off. */ +static void atcphy_cio_pds_off(struct apple_atcphy *atcphy) +{ + struct dev_pm_domain_list *pds = atcphy->cio_pds; + + for (unsigned int i = pds->num_pds; i > 0; i--) + pm_runtime_put_sync(pds->pd_devs[i - 1]); +} + +/* The power and reset block as its power-up leaves it, with its domains on */ +static bool atcphy_cio_idle(struct apple_atcphy *atcphy) +{ + return core_read32(atcphy, atcphy_cfg(atcphy, ATCPHY_POWER_CTRL)) == + ATCPHY_POWER_CLAMP_EN && + !(core_read32(atcphy, atcphy_cfg(atcphy, ATCPHY_POWER_STAT)) & + (ATCPHY_POWER_SLEEP_SMALL | ATCPHY_POWER_SLEEP_BIG)) && + !core_read32(atcphy, atcphy->hw->sync_reset); +} + +/* + * The CIO shutdown, then the power domains: the common block goes cold, so + * that the next partner, in either orientation, starts from a cold PHY. With + * the common block left powered, the next link training asserted in the + * router's firmware. A failed shutdown keeps the domains for the next try. + */ +static int atcphy_cio_stop(struct apple_atcphy *atcphy) +{ + int ret; + + lockdep_assert_held(&atcphy->lock); + ret = atcphy_configure(atcphy, APPLE_ATCPHY_MODE_OFF); + if (ret) { + dev_err(atcphy->dev, "CIO shutdown failed: %d\n", ret); + return ret; + } + atcphy_cio_pds_off(atcphy); + atcphy->cio_powered = false; + dev_dbg(atcphy->dev, "CIO mode off\n"); + return 0; +} + +static int atcphy_cio_start(struct apple_atcphy *atcphy, enum atcphy_mode mode) +{ + int ret; + + lockdep_assert_held(&atcphy->lock); + /* The router's Thunderbolt mode is not qualified on these ports. */ + if (mode != APPLE_ATCPHY_MODE_USB4) { + dev_info(atcphy->dev, "Thunderbolt alt mode is not supported on this port\n"); + return -ENODEV; + } + if (atcphy->display_owned) { + dev_dbg(atcphy->dev, "USB4 waits for the display driver to release the PHY\n"); + return -ETIMEDOUT; + } + ret = atcphy_cio_pds_on(atcphy); + if (ret) + return ret; + if (!atcphy_cio_idle(atcphy)) { + dev_warn(atcphy->dev, "PHY not idle (power control %#x), USB4 refused\n", + core_read32(atcphy, atcphy_cfg(atcphy, ATCPHY_POWER_CTRL))); + atcphy_cio_pds_off(atcphy); + return -EBUSY; + } + atcphy->cio_powered = true; + ret = atcphy_configure(atcphy, mode); + if (ret) { + dev_err(atcphy->dev, "CIO mode failed: %d\n", ret); + atcphy_cio_stop(atcphy); + return ret; + } + dev_dbg(atcphy->dev, "CIO mode on, %s\n", atcphy->swap_lanes ? "reversed" : "normal"); + return 0; +} + +/* USB4 asks for CIO mode; every other state leaves the PHY to its other users. */ +static enum atcphy_mode atcphy_cio_target_mode(const struct typec_mux_state *state) +{ + const struct enter_usb_data *data = state->data; + + if (state->alt && state->alt->svid == USB_TYPEC_TBT_SID) + return APPLE_ATCPHY_MODE_TBT; + if (!state->alt && state->mode == TYPEC_MODE_USB4 && data && + FIELD_GET(EUDO_USB_MODE_MASK, data->eudo) == EUDO_USB_MODE_USB4) + return APPLE_ATCPHY_MODE_USB4; + return APPLE_ATCPHY_MODE_OFF; +} + +/* + * The Type-C port driver sets the mux before it starts the USB4 router and + * after it stops it, so CIO mode comes up before the router starts and goes + * down after it stopped. + */ +static int atcphy_cio_mux_set(struct typec_mux_dev *mux, struct typec_mux_state *state) +{ + struct apple_atcphy *atcphy = typec_mux_get_drvdata(mux); + enum atcphy_mode mode = atcphy_cio_target_mode(state); + int ret; + + guard(mutex)(&atcphy->lock); + if (atcphy->cio_powered) { + if (atcphy->mode == mode && !atcphy->mode_dirty) + return 0; + ret = atcphy_cio_stop(atcphy); + if (ret) + return ret; + } + if (mode == APPLE_ATCPHY_MODE_OFF) + return 0; + return atcphy_cio_start(atcphy, mode); +} + +/* The display driver takes the PHY of a CIO-only port, see above. */ +static int atcphy_cio_dp_power_on(struct phy *phy) +{ + struct apple_atcphy *atcphy = phy_get_drvdata(phy); + int ret; + + guard(mutex)(&atcphy->lock); + if (atcphy->display_owned) + return 0; + if (atcphy->cio_powered) + return -EBUSY; + ret = atcphy_cio_pds_on(atcphy); + if (!ret) + atcphy->display_owned = true; + return ret; +} + +static int atcphy_cio_dp_power_off(struct phy *phy) +{ + struct apple_atcphy *atcphy = phy_get_drvdata(phy); + + guard(mutex)(&atcphy->lock); + if (atcphy->display_owned) + atcphy_cio_pds_off(atcphy); + atcphy->display_owned = false; + return 0; +} + +static const struct phy_ops apple_atc_cio_dp_phy_ops = { + .owner = THIS_MODULE, + .power_on = atcphy_cio_dp_power_on, + .power_off = atcphy_cio_dp_power_off, +}; + static struct phy *atcphy_xlate(struct device *dev, const struct of_phandle_args *args) { struct apple_atcphy *atcphy = dev_get_drvdata(dev); @@ -5483,16 +5745,18 @@ static int atcphy_probe_phy(struct apple_atcphy *atcphy) { &atcphy->phys.usb2, &apple_atc_usb2_phy_ops }, { &atcphy->phys.usb3, atcphy->fixed_usb3 ? &apple_atc_fixed_usb3_phy_ops : &apple_atc_usb3_phy_ops }, - { &atcphy->phys.dp, &apple_atc_dp_phy_ops }, + { &atcphy->phys.dp, atcphy->cio_only ? &apple_atc_cio_dp_phy_ops : + &apple_atc_dp_phy_ops }, }; /* * A T8132 PHY with its USB3/USB4 banks gets a DP PHY for DisplayPort * tunnels only (see atcphy_dpphy_set_mode_t8132()); creating it does - * not touch the hardware. A fixed-USB3 PHY gets its USB3 PHY only. + * not touch the hardware. A fixed-USB3 PHY gets its USB3 PHY only, a + * CIO-only PHY the DP PHY through which the display driver takes it. */ for (int i = 0; i < ARRAY_SIZE(phys); i++) { - if ((atcphy->dp_only && phys[i].phy != &atcphy->phys.dp) || + if (((atcphy->dp_only || atcphy->cio_only) && phys[i].phy != &atcphy->phys.dp) || (atcphy_usb2_only(atcphy) && i != 0) || (atcphy->fixed_usb3 && phys[i].phy != &atcphy->phys.usb3)) continue; @@ -6460,9 +6724,10 @@ static int atcphy_probe_mux(struct apple_atcphy *atcphy) struct typec_mux_desc mux_desc = { .drvdata = atcphy, .fwnode = atcphy->dev->fwnode, - .set = atcphy_mux_set, + .set = atcphy->cio_only ? atcphy_cio_mux_set : atcphy_mux_set, .safe_after_role = !atcphy->fixed_usb2, - .transient_timeouts = atcphy_mux_transient_timeouts(atcphy), + /* A CIO-only PHY times out while the display driver has it. */ + .transient_timeouts = atcphy->cio_only || atcphy_mux_transient_timeouts(atcphy), }; mux = typec_mux_register(atcphy->dev, &mux_desc); @@ -6686,6 +6951,15 @@ static int atcphy_load_tunables(struct apple_atcphy *atcphy) *tunables[i].tunable = NULL; continue; } + /* a CIO-only port has its common and CIO lane tunables alone */ + if (atcphy->cio_only && + tunables[i].tunable != &atcphy->tunables.common[0] && + tunables[i].tunable != &atcphy->tunables.common[1] && + tunables[i].tunable != &atcphy->tunables.lane_usb4[0] && + tunables[i].tunable != &atcphy->tunables.lane_usb4[1]) { + *tunables[i].tunable = NULL; + continue; + } if (!atcphy->hw->has_usb4 && (tunables[i].tunable == &atcphy->tunables.lane_usb4[0] || tunables[i].tunable == &atcphy->tunables.lane_usb4[1])) { @@ -6791,11 +7065,12 @@ static int atcphy_map_resources(struct platform_device *pdev, struct apple_atcph void __iomem *addr; /* - * A fixed-USB3 PHY has its core and PIPE windows only. On T8152 the - * core window also holds the USB controller's DARTs, so it is mapped - * without claiming it. + * A fixed-USB3 PHY has its core and PIPE windows only, a CIO-only PHY its + * core window. On T8152 the core window also holds the USB controller's + * DARTs, and the display driver maps it too, so it is mapped without + * claiming it. */ - if (atcphy->fixed_usb3) { + if (atcphy->fixed_usb3 || atcphy->cio_only) { res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "core"); if (!res) return dev_err_probe(atcphy->dev, -EINVAL, "Missing core regs\n"); @@ -6803,6 +7078,8 @@ static int atcphy_map_resources(struct platform_device *pdev, struct apple_atcph if (!atcphy->regs.core) return -ENOMEM; atcphy->res.core = res; + if (atcphy->cio_only) + return 0; addr = devm_platform_ioremap_resource_byname(pdev, "pipehandler"); if (IS_ERR(addr)) @@ -7067,6 +7344,64 @@ static int atcphy_probe_finalize_fixed_usb3(struct apple_atcphy *atcphy) return 0; } +/* Let go of the PHY of a CIO-only port on unbind, see atcphy_cio_mux_set(). */ +static void atcphy_cio_release(void *data) +{ + struct apple_atcphy *atcphy = data; + + guard(mutex)(&atcphy->lock); + if (atcphy->cio_powered) + atcphy_cio_stop(atcphy); + if (atcphy->display_owned) + atcphy_cio_pds_off(atcphy); + atcphy->display_owned = false; +} + +/* + * A CIO-only port: probe leaves the hardware as it is. A display the + * bootloader brought up on the port has all of the PHY's power domains on, + * and the PHY is not idle: hold the domains for the display driver, which + * takes it over, until its DP PHY goes off. Otherwise the domains are left to + * their power domain driver. Then register the mux, the orientation switch + * and the DP PHY. + */ +static int atcphy_probe_finalize_cio_only(struct apple_atcphy *atcphy) +{ + struct dev_pm_domain_list *pds = atcphy->cio_pds; + bool all_on = true; + int ret; + + lockdep_assert_held(&atcphy->lock); + + ret = devm_add_action(atcphy->dev, atcphy_cio_release, atcphy); + if (ret) + return ret; + for (unsigned int i = 0; i < pds->num_pds; i++) + all_on &= dev_pm_genpd_is_on(pds->pd_devs[i]); + if (all_on) { + ret = atcphy_cio_pds_on(atcphy); + if (ret) + return dev_err_probe(atcphy->dev, ret, "Failed to power the PHY\n"); + if (atcphy_cio_idle(atcphy)) { + atcphy_cio_pds_off(atcphy); + } else { + atcphy->display_owned = true; + dev_info(atcphy->dev, "PHY in use at boot, held for the display driver\n"); + } + } + + ret = atcphy_probe_mux(atcphy); + if (ret) + return dev_err_probe(atcphy->dev, ret, "Probing mux failed\n"); + ret = atcphy_probe_switch(atcphy); + if (ret) + return dev_err_probe(atcphy->dev, ret, "Probing switch failed\n"); + ret = atcphy_probe_phy(atcphy); + if (ret) + return dev_err_probe(atcphy->dev, ret, "Probing phy failed\n"); + return 0; +} + static int atcphy_probe_finalize(struct apple_atcphy *atcphy) { int ret; @@ -7077,6 +7412,8 @@ static int atcphy_probe_finalize(struct apple_atcphy *atcphy) return atcphy_probe_finalize_dp_only(atcphy); if (atcphy->fixed_usb3) return atcphy_probe_finalize_fixed_usb3(atcphy); + if (atcphy->cio_only) + return atcphy_probe_finalize_cio_only(atcphy); /* Reset dwc3 on probe, let dwc3 (consumer) deassert it */ _atcphy_dwc3_reset_assert(atcphy); @@ -7219,6 +7556,18 @@ static int atcphy_probe_power_domains(struct apple_atcphy *atcphy) struct dev_pm_domain_list *pd_list; int ret; + /* + * A CIO-only PHY powers its domains only while it runs CIO mode or the + * display driver has it, see atcphy_cio_mux_set(). + */ + if (atcphy->cio_only) { + pd_data.pd_flags = PD_FLAG_NO_DEV_LINK; + ret = devm_pm_domain_attach_list(atcphy->dev, &pd_data, &atcphy->cio_pds); + if (ret <= 0) + return dev_err_probe(atcphy->dev, ret ?: -EINVAL, + "Failed to attach power domains\n"); + return 0; + } if (!atcphy->fixed_usb3 || atcphy->dev->pm_domain) return 0; ret = devm_pm_domain_attach_list(atcphy->dev, &pd_data, &pd_list); @@ -7250,9 +7599,7 @@ static int atcphy_probe(struct platform_device *pdev) atcphy->t8132_dp_alt = atcphy->hw->gen == ATCPHY_GENERATION_T8132 && of_property_read_bool(dev->of_node, "apple,dp-alt-mode"); atcphy->fixed_usb3 = of_property_read_bool(dev->of_node, "apple,fixed-usb3"); - /* T8152 is supported on a fixed-USB3 port only */ - if (atcphy->hw->gen == ATCPHY_GENERATION_T8152 && !atcphy->fixed_usb3) - return dev_err_probe(dev, -ENODEV, "Only a fixed-USB3 port is supported\n"); + atcphy->cio_only = atcphy->hw->typec_cio_only && !atcphy->fixed_usb3; apple_atc_tunnel_wiring(atcphy); mutex_init(&atcphy->lock); platform_set_drvdata(pdev, atcphy); @@ -8336,10 +8683,11 @@ static const struct atcphy_hw atcphy_hw_t8142 = { }; /* - * T8152 as the USB3 PHY of a fixed-USB3 port: no USB4, DisplayPort or lane - * mode register and nothing to wake after the tunables. Its power domains are - * not followed: the controller's power-off and power-on of the PHY, as around - * a system sleep, take it down and up again. + * T8152 as the USB3 PHY of a fixed-USB3 port, or as a Type-C port's PHY in CIO + * mode alone (see atcphy_cio_mux_set()): no DisplayPort mode, no lane mode + * register and nothing to wake after the tunables. A fixed-USB3 port does not + * follow its power domains: the controller's power-off and power-on of the + * PHY, as around a system sleep, take it down and up again. */ static const struct atcphy_hw atcphy_hw_t8152 = { .gen = ATCPHY_GENERATION_T8152, @@ -8349,6 +8697,7 @@ static const struct atcphy_hw atcphy_hw_t8152 = { .lane_swap = ATCPHY_T8152_MISC_LANE_SWAP, .pipe_mux_clk = PIPEHANDLER_MUX_CTRL_CLK_T8142, .pipe_mux_data = PIPEHANDLER_MUX_CTRL_DATA_T8142, + .has_usb4 = true, .park_dummy_phy = true, .clear_boot_hold = true, /* @@ -8357,6 +8706,13 @@ static const struct atcphy_hw atcphy_hw_t8152 = { * PIPE moved to USB3 and back to the dummy PHY under the request. */ .pipe_lock_unacked = true, + /* + * Its Type-C ports run CIO mode alone; a reversed plug takes the + * swapped crossbar and the lane swap, with which the J873g's rear ports + * trained USB4 at 2 x 20 Gb/s. + */ + .typec_cio_only = true, + .cio_lane_swap = true, }; static const struct of_device_id atcphy_match[] = { diff --git a/tools/testing/selftests/drivers/apple/atc-t8132-usb3.py b/tools/testing/selftests/drivers/apple/atc-t8132-usb3.py index ed02e7f33b562..dfa3d7aad45f5 100755 --- a/tools/testing/selftests/drivers/apple/atc-t8132-usb3.py +++ b/tools/testing/selftests/drivers/apple/atc-t8132-usb3.py @@ -107,7 +107,7 @@ def main(): bool t8132_ss, t8132_common_owned, t8132_suspended, t8132_failed, host_active; bool ss_tunables, mode_dirty, pipe_pending, swap_lanes; bool cio_tunables, t8132_dp_alt, fixed_usb2, hibernated, pd_was_off, idle_rpm; - bool t8103_dummy_pending, t8103_usb3_workaround, fixed_usb3; + bool t8103_dummy_pending, t8103_usb3_workaround, fixed_usb3, cio_only; unsigned tunnel_users; struct { bool prepared, changed, restored; } cio_sleep; int mode, pipe_state, lock; diff --git a/tools/testing/selftests/drivers/gpu/apple-dcp/dwc3/mocks.c b/tools/testing/selftests/drivers/gpu/apple-dcp/dwc3/mocks.c index a2d8076ac8b3d..dd3cb7476f43b 100644 --- a/tools/testing/selftests/drivers/gpu/apple-dcp/dwc3/mocks.c +++ b/tools/testing/selftests/drivers/gpu/apple-dcp/dwc3/mocks.c @@ -25,7 +25,7 @@ struct apple_atcphy { bool aux, pll; unsigned int pairs, rate; } dp_t8122; - bool fixed_usb2, fixed_usb3, host_active, mode_dirty, ss_tunables, dp_tunables, + bool fixed_usb2, fixed_usb3, cio_only, host_active, mode_dirty, ss_tunables, dp_tunables, aux_power_requested; unsigned int dp_owned_pmas, dp_idle_pmas; unsigned int dp_usb_context_valid, dp_usb_context_dirty; diff --git a/tools/testing/selftests/drivers/gpu/apple-dcp/phy.py b/tools/testing/selftests/drivers/gpu/apple-dcp/phy.py index 45c8275bf462e..544b698f70e8c 100644 --- a/tools/testing/selftests/drivers/gpu/apple-dcp/phy.py +++ b/tools/testing/selftests/drivers/gpu/apple-dcp/phy.py @@ -46,7 +46,7 @@ def function(source, name): struct reset_controller_dev rcdev; void *dev; int lock, dp_link_rate; - bool fixed_usb2, fixed_usb3, host_active, swap_lanes, ss_tunables, dp_tunables; + bool fixed_usb2, fixed_usb3, cio_only, host_active, swap_lanes, ss_tunables, dp_tunables; bool aux_power_requested, mode_dirty, dp_spread_spectrum, dp_presets_valid[5]; u32 dp_presets[5][16]; unsigned int dp_idle_pmas, dp_owned_pmas; @@ -1953,7 +1953,7 @@ def function(name): struct { unsigned char *core, *pipehandler; } regs; void *dev; int lock; - bool fixed_usb2, fixed_usb3, host_active, ss_tunables, dp_tunables, mode_dirty; + bool fixed_usb2, fixed_usb3, cio_only, host_active, ss_tunables, dp_tunables, mode_dirty; unsigned int dp_owned_pmas, dp_idle_pmas; unsigned int dp_usb_context_valid, dp_usb_context_dirty; u32 dp_usb_context[2][27]; @@ -2355,7 +2355,7 @@ def function(source, name): struct { unsigned char *core, *lpdptx, *lioa; } regs; void *dev; int lock, dp_link_rate; - bool fixed_usb2, fixed_usb3, host_active, swap_lanes, ss_tunables, dp_tunables; + bool fixed_usb2, fixed_usb3, cio_only, host_active, swap_lanes, ss_tunables, dp_tunables; bool aux_power_requested, mode_dirty, dp_spread_spectrum, dp_presets_valid[5]; u32 dp_presets[5][16]; unsigned int dp_idle_pmas, dp_owned_pmas; From ce92f422991611f43cc3dcac17de0143ed330331 Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Fri, 20 Nov 2026 01:26:26 +0100 Subject: [PATCH 25/31] dt-bindings: display: apple,t8152-dcp-iboot: add the USB-C ports' PHYs A rear USB-C port's ATC PHY is also its USB4 PHY, run by the ATC PHY driver, which powers the PHY. Give each usb-c port node the port's PHY in DisplayPort use (PHY_TYPE_DP): a DCP powers it while it drives the PHY, from before a cold start until the PHY is powered down, and the PHY driver keeps the PHY powered and out of USB4 meanwhile. Signed-off-by: Thomas Glanzmann --- .../bindings/display/apple,t8152-dcp-iboot.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Documentation/devicetree/bindings/display/apple,t8152-dcp-iboot.yaml b/Documentation/devicetree/bindings/display/apple,t8152-dcp-iboot.yaml index cc7ea1045a323..b25cd3a74cfa0 100644 --- a/Documentation/devicetree/bindings/display/apple,t8152-dcp-iboot.yaml +++ b/Documentation/devicetree/bindings/display/apple,t8152-dcp-iboot.yaml @@ -243,6 +243,14 @@ patternProperties: apple,tunable-post: $ref: /schemas/types.yaml#/definitions/uint32-matrix description: As the node's apple,tunable-post, for this port's PHY. + phys: + maxItems: 1 + description: + The port's ATC PHY in DisplayPort use (PHY_TYPE_DP). A DCP powers + it while it drives the PHY, from before its cold start until its + power-down, and keeps it powered for a display the bootloader + started; the PHY driver powers the PHY's domains meanwhile and + keeps it out of USB4. The PHY refuses this while it runs USB4. mode-switch: type: boolean description: @@ -315,6 +323,7 @@ examples: <0x3 0x03a13a00 0x0 0xc0>; reg-names = "atc", "atc-ps", "atc-psd"; apple,dfp-endpoint = <3>; + phys = <&atc3_phy 6>; mode-switch; port { From 2cf0f423e24357d995004388e456c45c7e1f44c7 Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Fri, 20 Nov 2026 01:26:26 +0100 Subject: [PATCH 26/31] drm/apple: power the T8152 ATC PHYs through their PHY driver The T8152 DCPs powered a rear USB-C port's ATC PHY themselves: before a cold start they set the port's USB_AON, DP_0 and DP_1 PMGR power states (PS +0x100, +0, +0x20) to 0xf and its common PSD service to 0, and after a power-down they set back those that had been off. The same PHY now runs CIO mode for USB4, through the ATC PHY driver, which powers it through the PMGR and PSD power domain drivers. With two writers of the same states, one would switch off what the other uses, or leave the power domain drivers believing a domain on that is off. Take the PHY through the port's DP PHY instead (the usb-c node's phys): power it on before the cold start's first PHY access and off once the PHY is powered down. The PHY driver then holds the PHY's power domains and keeps it out of USB4; while the PHY runs USB4 the power-on fails with -EBUSY and the cold start with it. A display the bootloader left running is kept powered by the PHY driver from its probe; the DCP that adopts it powers the DP PHY on at once and so takes that over. A port whose common block runs but whose DP PHY cannot be powered is in USB4, not a bootloader display: the power and reset block (CFG +0x60000) reads 0x1b in both. The PMGR and PSD state registers are still read to tell whether the PHY can be looked at. The DisplayPort programming itself is unchanged. Signed-off-by: Thomas Glanzmann --- drivers/gpu/drm/apple/t8152_atc.c | 116 +++++++++++++----------------- 1 file changed, 48 insertions(+), 68 deletions(-) diff --git a/drivers/gpu/drm/apple/t8152_atc.c b/drivers/gpu/drm/apple/t8152_atc.c index f712339ebb7ac..4c2a5cd9ba1ba 100644 --- a/drivers/gpu/drm/apple/t8152_atc.c +++ b/drivers/gpu/drm/apple/t8152_atc.c @@ -14,6 +14,11 @@ * route, and with the display off or unplugged a full power down and a cold * start. A DCP drives one USB-C port at a time: the one it claims from the * shared ports once their Type-C state shows a sink (t8152_typec.c). + * + * The ATC PHY driver powers the PHY: it holds the PHY's power domains while + * the port's DP PHY is on, and keeps the PHY out of USB4 meanwhile. So the DP + * PHY goes on before any PHY register access of a cold start, and off once + * the PHY is powered down, and a bootloader display's PHY stays on with it. */ #include @@ -24,6 +29,7 @@ #include #include #include +#include #include "dptxep.h" #include "t8152_display.h" @@ -55,11 +61,11 @@ struct t8152_atc_port { u32 dfp; /* AP DisplayPort AUX controller aux0 (shared), for the EDID */ struct t8152_aux *aux; - /* PMGR power states of the four ATC dependencies */ + /* PMGR power states of the ATC dependencies, read to tell if it runs */ void __iomem *ps; void __iomem *psd; - /* the dependencies this driver powered up, and may power down */ - u8 owned; + /* the port's DP PHY of the ATC PHY driver, which powers the PHY */ + struct phy *phy; /* {offset, mask, value} tunables, before and after the lane setup */ const __be32 *tunable[2]; int tunable_len[2]; @@ -385,50 +391,7 @@ static int atc_dp_start(struct t8152_display *disp, struct t8152_atc_port *atc, return 0; } -/* - * The power dependencies, in order: the ATC's USB AON (PS +0x100), its common - * PSD, then its two DP PS registers (+0, +0x20), with the values they idle at - * (ATC3: PS 0x1c0, PSD 58, PS 0xc0, 0xe0). - */ -#define ATC_PSD_TARGET 0x90 #define ATC_PSD_STATE 0x80 -static const u32 atc_ps_offset[] = { 0x100, 0, 0x0, 0x20 }; -static const u32 atc_ps_idle[] = { 0x300, 6, 0x244, 0x244 }; - -static int atc_psd_wait(struct t8152_atc_port *atc, u32 state) -{ - u32 reg; - - /* - * Only the state: the acknowledge bit stays clear when Linux switches - * the PSD, in either direction. - */ - return readl_poll_timeout(atc->psd + ATC_PSD_STATE, reg, - (reg & 7) == state, 1, ATC_TIMEOUT_US); -} - -static int atc_gate(struct t8152_atc_port *atc, unsigned int i, bool on) -{ - u32 value = on ? (atc_ps_idle[i] & 0xfffffcf0) | 15 : atc_ps_idle[i]; - u32 reg; - - /* Already up (the bootloader's or an earlier activation's). */ - if (on && (i == 1 ? !(readl(atc->psd + ATC_PSD_STATE) & 7) : - (readl(atc->ps + atc_ps_offset[i]) & 0xf0) == 0xf0)) - return 0; - if (on) - atc->owned |= BIT(i); - else - atc->owned &= ~BIT(i); - if (i == 1) { - writel(on ? 0 : atc_ps_idle[i], atc->psd + ATC_PSD_TARGET); - return atc_psd_wait(atc, on ? 0 : atc_ps_idle[i]); - } - writel(value, atc->ps + atc_ps_offset[i]); - return readl_poll_timeout(atc->ps + atc_ps_offset[i], reg, - (reg & 0xf0) == ((value & 15) << 4), 1, - ATC_TIMEOUT_US); -} static void atc_apply_tunables(struct t8152_atc_port *atc, unsigned int which) { @@ -439,13 +402,13 @@ static void atc_apply_tunables(struct t8152_atc_port *atc, unsigned int which) be32_to_cpu(t[i + 2])); } -/* Cold start: the power dependencies, the common block and AUX, then the lanes at HBR. */ +/* Cold start: the PHY's power, the common block and AUX, then the lanes at HBR. */ static int atc_activate(struct t8152_display *disp) { struct t8152_atc_port *atc = atc_cur(disp); void __iomem *cfg = atc->base + ATC_CFG; - unsigned int gates = 0; u32 reg; + int ret; if (READ_ONCE(atc_owner[atc->index]) != disp->dev) return -EBUSY; @@ -453,9 +416,12 @@ static int atc_activate(struct t8152_display *disp) return 0; if (!atc->tunable[0] || !atc->tunable[1]) return -EOPNOTSUPP; - for (; gates < ARRAY_SIZE(atc_ps_idle); gates++) - if (atc_gate(atc, gates, true)) - goto fail; + /* -EBUSY while the PHY runs USB4 */ + ret = phy_power_on(atc->phy); + if (ret) { + dev_err(disp->dev, "ATC%u: PHY not powered: %d\n", atc->index, ret); + return ret; + } if (readl(cfg) != 4 || (readl(cfg + 4) & 3) || readl(cfg + 0x30)) goto fail; writel(readl(cfg + 0x30) | BIT(0), cfg + 0x30); @@ -497,14 +463,13 @@ static int atc_activate(struct t8152_display *disp) */ return atc_dp_start(disp, atc, 1); fail: - dev_err(disp->dev, "ATC%u: cold start failed (gates %u, cfg %#x/%#x)\n", - atc->index, gates, - gates == ARRAY_SIZE(atc_ps_idle) ? readl(cfg) : 0, - gates == ARRAY_SIZE(atc_ps_idle) ? readl(cfg + 4) : 0); + dev_err(disp->dev, "ATC%u: cold start failed (cfg %#x/%#x)\n", + atc->index, readl(cfg), readl(cfg + 4)); + phy_power_off(atc->phy); return -EIO; } -/* Power the PHY down, dependencies included. */ +/* Power the PHY down, its power included. */ static int atc_deactivate(struct t8152_display *disp) { struct t8152_atc_port *atc = atc_cur(disp); @@ -541,13 +506,9 @@ static int atc_deactivate(struct t8152_display *disp) } writel(readl(cfg + 0x30) & ~BIT(0), cfg + 0x30); atc->active = false; - /* - * Then the power dependencies it powered up: the next activation starts - * it cold. The USB controller of a port keeps the ones it uses. - */ - for (int i = ARRAY_SIZE(atc_ps_idle) - 1; i >= 0; i--) - if ((atc->owned & BIT(i)) && atc_gate(atc, i, false)) - ret = -ETIMEDOUT; + /* Then its power: the next activation starts it cold. */ + if (phy_power_off(atc->phy)) + ret = -ETIMEDOUT; dev_info(disp->dev, "ATC%u: powered down: %d\n", atc->index, ret); return ret; } @@ -820,6 +781,9 @@ static int atc_port_init(struct t8152_display *disp, struct t8152_atc *atc, port->psd = atc_map(disp, np, "atc-psd"); if (!port->base || !port->ps || !port->psd) return -ENOMEM; + port->phy = devm_of_phy_optional_get(disp->dev, np, NULL); + if (IS_ERR(port->phy)) + return dev_err_probe(disp->dev, PTR_ERR(port->phy), "%pOF: no PHY\n", np); /* The node without ports is ATC3's (J873g back-right). */ port->dfp = 3; of_property_read_u32(np, "apple,dfp-endpoint", &port->dfp); @@ -847,6 +811,15 @@ static int atc_port_init(struct t8152_display *disp, struct t8152_atc *atc, return 0; cfg = readl(port->base + ATC_CFG); port->active = atc_link_up(cfg); + /* + * The bootloader's display keeps the PHY powered through its DP PHY. The + * common block runs the same way in USB4, whose PHY refuses the DP PHY. + */ + if (port->active && phy_power_on(port->phy)) { + dev_info(disp->dev, "ATC%u: runs USB4\n", port->index); + port->active = false; + return 0; + } if ((readl(port->base + 0x4c) & 0x1f) == 0x10 || (readl(port->base + 0x4c) & 0x1f) == 0x11) { port->lanes = 2; @@ -860,9 +833,6 @@ static int atc_port_init(struct t8152_display *disp, struct t8152_atc *atc, if (port->active && (readl(port->base + 0x2040) & BIT(16)) && r < ARRAY_SIZE(atc_rates)) port->link_rate = atc_rates[r]; - /* The bootloader's display: its dependencies are the display's. */ - if (port->active) - port->owned = GENMASK(ARRAY_SIZE(atc_ps_idle) - 1, 0); dev_info(disp->dev, "ATC%u: inherited state: active %d, rate %#x, route %d, reversed %d (cfg %#x)\n", port->index, port->active, port->link_rate, port->route_started, @@ -970,12 +940,12 @@ int t8152_atc_init(struct t8152_display *disp) break; ret = atc_port_init(disp, atc, child, dp_clock); if (ret) - return ret; + goto err_power; } if (!atc->nports) { ret = atc_port_init(disp, atc, np, dp_clock); if (ret) - return ret; + goto err_power; } /* Only adopt a bootloader route belonging to this DCP. */ @@ -995,4 +965,14 @@ int t8152_atc_init(struct t8152_display *disp) dev_info(disp->dev, "USB-C display on ATC%u (%u ports)\n", atc->cur->index, atc->nports); return 0; + +err_power: + /* + * A later port failed or deferred: the probe starts over, so give back + * the PHY power atc_port_init() took for an inherited link. + */ + for (unsigned int i = 0; i < atc->nports; i++) + if (atc->port[i].active) + phy_power_off(atc->port[i].phy); + return ret; } From 60f525a8dd6513c90d74525026f684b6260075d1 Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Fri, 20 Nov 2026 01:26:41 +0100 Subject: [PATCH 27/31] arm64: dts: apple: t8152-j873g: describe the rear ports' ATC PHYs The three rear USB-C ports' ATC PHYs (ADT atc-phy0, 1 and 3) were only known to the display controllers, as register windows they program and power themselves. Describe them as T8152 Type-C PHYs, which the ATC PHY driver runs in CIO mode for USB4: - their core windows (0x403000000, 0x40b000000, 0x413000000, 0x84000 each, also mapped by the display controllers); - the orientation and mode switches, linked to the SuperSpeed port (port@1) of the port's usb-c-connector; - their power domains, in power-up order: the ATC's USB_AON, its common PSD service (55, 56, 58) and its COMMON_DP_0/1 power states, new nodes next to ATC2's. The USB_AON states are kept on, as ATC2's: they hold the rear USB controllers' state the loader set up; - the CIO tunables of the ADT's atc-phyN groups, at the PHY blocks they apply to: the common defaults before the lanes are powered up, the fabric, PLL and remaining common groups after them, then each lane's groups. They are the lists the earlier port monitor applied, with which a rear port trained USB4. The display controllers' usb-c port nodes take the PHYs through their DP PHY, which powers them while a controller drives the port. Signed-off-by: Thomas Glanzmann --- arch/arm64/boot/dts/apple/t8152-j873-dcp.dtsi | 51 +- arch/arm64/boot/dts/apple/t8152-j873-usb.dtsi | 872 +++++++++++++++++- 2 files changed, 906 insertions(+), 17 deletions(-) diff --git a/arch/arm64/boot/dts/apple/t8152-j873-dcp.dtsi b/arch/arm64/boot/dts/apple/t8152-j873-dcp.dtsi index 2cc188ea99d91..0c7df8e3a55dd 100644 --- a/arch/arm64/boot/dts/apple/t8152-j873-dcp.dtsi +++ b/arch/arm64/boot/dts/apple/t8152-j873-dcp.dtsi @@ -138,6 +138,15 @@ reg = <0>; }; + /* SuperSpeed: the ATC PHY */ + port@1 { + reg = <1>; + + typec0_ss: endpoint { + remote-endpoint = <&atc0_phy_typec>; + }; + }; + /* DisplayPort: the DCPs' display switch */ port@3 { reg = <3>; @@ -173,6 +182,15 @@ reg = <0>; }; + /* SuperSpeed: the ATC PHY */ + port@1 { + reg = <1>; + + typec1_ss: endpoint { + remote-endpoint = <&atc1_phy_typec>; + }; + }; + /* DisplayPort: the DCPs' display switch */ port@3 { reg = <3>; @@ -208,6 +226,15 @@ reg = <0>; }; + /* SuperSpeed: the ATC PHY */ + port@1 { + reg = <1>; + + typec3_ss: endpoint { + remote-endpoint = <&atc3_phy_typec>; + }; + }; + /* DisplayPort: the DCPs' display switch */ port@3 { reg = <3>; @@ -276,8 +303,10 @@ /* * USB-C back-middle: ADT atc-phy0. PS: the ATC's DP_0, DP_1 and * USB_AON power states (+0, +0x20, +0x100), PSD: its common - * domain. Tunables before and after the lane crossbar setup. - * The node is also the port's display switch for all DCPs. + * domain, read to tell whether the PHY runs; the ATC PHY + * driver powers them while the DP PHY is on. Tunables before + * and after the lane crossbar setup. The node is also the + * port's display switch for all DCPs. */ usb-c@403000000 { reg = <0x4 0x03000000 0x0 0x84000>, @@ -285,6 +314,8 @@ <0x3 0x03a13700 0x0 0xc0>; reg-names = "atc", "atc-ps", "atc-psd"; apple,dfp-endpoint = <0>; + /* Powered while a DCP drives it */ + phys = <&atc0_phy PHY_TYPE_DP>; /* The DCPs' display switch of the port */ mode-switch; apple,tunable-pre = @@ -387,8 +418,10 @@ /* * USB-C back-left: ADT atc-phy1. PS: the ATC's DP_0, DP_1 and * USB_AON power states (+0, +0x20, +0x100), PSD: its common - * domain. Tunables before and after the lane crossbar setup. - * The node is also the port's display switch for all DCPs. + * domain, read to tell whether the PHY runs; the ATC PHY + * driver powers them while the DP PHY is on. Tunables before + * and after the lane crossbar setup. The node is also the + * port's display switch for all DCPs. */ usb-c@40b000000 { reg = <0x4 0x0b000000 0x0 0x84000>, @@ -396,6 +429,8 @@ <0x3 0x03a13800 0x0 0xc0>; reg-names = "atc", "atc-ps", "atc-psd"; apple,dfp-endpoint = <1>; + /* Powered while a DCP drives it */ + phys = <&atc1_phy PHY_TYPE_DP>; /* The DCPs' display switch of the port */ mode-switch; apple,tunable-pre = @@ -498,8 +533,10 @@ /* * USB-C back-right: ADT atc-phy3. PS: the ATC's DP_0, DP_1 and * USB_AON power states (+0, +0x20, +0x100), PSD: its common - * domain. Tunables before and after the lane crossbar setup. - * The node is also the port's display switch for all DCPs. + * domain, read to tell whether the PHY runs; the ATC PHY + * driver powers them while the DP PHY is on. Tunables before + * and after the lane crossbar setup. The node is also the + * port's display switch for all DCPs. */ usb-c@413000000 { reg = <0x4 0x13000000 0x0 0x84000>, @@ -507,6 +544,8 @@ <0x3 0x03a13a00 0x0 0xc0>; reg-names = "atc", "atc-ps", "atc-psd"; apple,dfp-endpoint = <3>; + /* Powered while a DCP drives it */ + phys = <&atc3_phy PHY_TYPE_DP>; /* The DCPs' display switch of the port */ mode-switch; apple,tunable-pre = diff --git a/arch/arm64/boot/dts/apple/t8152-j873-usb.dtsi b/arch/arm64/boot/dts/apple/t8152-j873-usb.dtsi index 2085434c423ff..83c99eced8749 100644 --- a/arch/arm64/boot/dts/apple/t8152-j873-usb.dtsi +++ b/arch/arm64/boot/dts/apple/t8152-j873-usb.dtsi @@ -10,9 +10,12 @@ * the role switch, exist but are left to the loader. * usb-drd2's hub is wired to ATC2's PHY without a Type-C mux, so Linux brings * that PHY up in USB3 mode (atc2_phy). + * The rear ports' ATC PHYs (atc0_phy, atc1_phy, atc3_phy) run CIO mode for + * USB4 alone: their DisplayPort alt mode is the display controllers', which + * take a PHY through its DP PHY, and their USB2 side stays with the loader. * Resources are from the 26A434 ADT: dart-usb1/2, usb-drd1/2 (on atc-phy1 and - * atc-phy2), atc-phy2 and the pmgr devices ATC1_USB_AON/USB, ATC2_USB_AON/USB - * and ATC2_COMMON_DP_0/1. + * atc-phy2), atc-phy0-3 and the pmgr devices ATCn_USB_AON, ATC1/2_USB and + * ATCn_COMMON_DP_0/1. * * dart-usb1 and dart-usb2 each have two DART instances (ADT reg[0] and * reg[1], 0xc000 each, sharing one interrupt). t8152-peripherals.dtsi lists @@ -69,16 +72,16 @@ /* * The ATCs' PMGR power states (ADT pmgr devices ATCn_COMMON_DP_0/1 * from 0x308290000 and ATCn_USB_AON/USB from 0x308290100, 0x40 - * apart per ATC). The T8152 USB bring-up runs them without - * automatic power management. + * apart per ATC). Each ATC's three are those its PHY needs, and + * ATC1_USB and ATC2_USB are the USB controllers' states. The + * T8152 USB3 and CIO bring-ups run them without automatic power + * management. * - * ATCn_USB is the controller's state. The ADT also gives - * usb-drd1/2 service-gates 175/176, but those PSD service blocks - * (0x303a1af00, 0x303a1b000) take a bus error from the CPU. The - * loader leaves ATCn_USB and ATCn_USB_AON on; they hold the - * controllers' reset and the USB2 PHY setup it did, which Linux - * cannot redo yet, so they stay on. ATC2_COMMON_DP_0/1 are what - * ATC2's PHY needs besides. + * The ADT also gives usb-drd1/2 service-gates 175/176, but those + * PSD service blocks (0x303a1af00, 0x303a1b000) take a bus error + * from the CPU. The loader leaves ATC1/2_USB on; with USB_AON + * they hold the controllers' reset and the USB2 PHY setup it + * did, which Linux cannot redo yet, so they stay on. */ pmgr_atc: power-management@308290000 { compatible = "apple,t8152-pmgr", "apple,t8103-pmgr", @@ -87,6 +90,46 @@ #size-cells = <1>; reg = <0x3 0x08290000 0x0 0x1000>; + ps_atc0_common_dp_0: power-controller@0 { + compatible = "apple,t8152-pmgr-pwrstate", + "apple,t8103-pmgr-pwrstate"; + reg = <0x0 4>; + #power-domain-cells = <0>; + #reset-cells = <0>; + label = "atc0_common_dp_0"; + apple,no-auto-pm; + }; + + ps_atc0_common_dp_1: power-controller@20 { + compatible = "apple,t8152-pmgr-pwrstate", + "apple,t8103-pmgr-pwrstate"; + reg = <0x20 4>; + #power-domain-cells = <0>; + #reset-cells = <0>; + label = "atc0_common_dp_1"; + apple,no-auto-pm; + }; + + ps_atc1_common_dp_0: power-controller@40 { + compatible = "apple,t8152-pmgr-pwrstate", + "apple,t8103-pmgr-pwrstate"; + reg = <0x40 4>; + #power-domain-cells = <0>; + #reset-cells = <0>; + label = "atc1_common_dp_0"; + apple,no-auto-pm; + }; + + ps_atc1_common_dp_1: power-controller@60 { + compatible = "apple,t8152-pmgr-pwrstate", + "apple,t8103-pmgr-pwrstate"; + reg = <0x60 4>; + #power-domain-cells = <0>; + #reset-cells = <0>; + label = "atc1_common_dp_1"; + apple,no-auto-pm; + }; + ps_atc2_common_dp_0: power-controller@80 { compatible = "apple,t8152-pmgr-pwrstate", "apple,t8103-pmgr-pwrstate"; @@ -107,6 +150,42 @@ apple,no-auto-pm; }; + ps_atc3_common_dp_0: power-controller@c0 { + compatible = "apple,t8152-pmgr-pwrstate", + "apple,t8103-pmgr-pwrstate"; + reg = <0xc0 4>; + #power-domain-cells = <0>; + #reset-cells = <0>; + label = "atc3_common_dp_0"; + apple,no-auto-pm; + }; + + ps_atc3_common_dp_1: power-controller@e0 { + compatible = "apple,t8152-pmgr-pwrstate", + "apple,t8103-pmgr-pwrstate"; + reg = <0xe0 4>; + #power-domain-cells = <0>; + #reset-cells = <0>; + label = "atc3_common_dp_1"; + apple,no-auto-pm; + }; + + /* + * The USB_AON states are kept on: each holds its USB + * controller's reset and PIPE handler state, and the + * rear ports' controllers stay with the loader. + */ + ps_atc0_usb_aon: power-controller@100 { + compatible = "apple,t8152-pmgr-pwrstate", + "apple,t8103-pmgr-pwrstate"; + reg = <0x100 4>; + #power-domain-cells = <0>; + #reset-cells = <0>; + label = "atc0_usb_aon"; + apple,no-auto-pm; + apple,always-on; + }; + ps_atc1_usb_aon: power-controller@140 { compatible = "apple,t8152-pmgr-pwrstate", "apple,t8103-pmgr-pwrstate"; @@ -157,6 +236,42 @@ apple,no-auto-pm; apple,always-on; }; + + ps_atc3_usb_aon: power-controller@1c0 { + compatible = "apple,t8152-pmgr-pwrstate", + "apple,t8103-pmgr-pwrstate"; + reg = <0x1c0 4>; + #power-domain-cells = <0>; + #reset-cells = <0>; + label = "atc3_usb_aon"; + apple,no-auto-pm; + apple,always-on; + }; + }; + + /* + * The rear ports' ATCs' common domains: PSD services 55, 56 and 58 + * (ADT atc-phy0/1/3 clock-gates). + */ + ps_atc0_common: power-controller@303a13700 { + compatible = "apple,t8152-psd"; + reg = <0x3 0x03a13700 0x0 0x100>; + #power-domain-cells = <0>; + label = "atc0_common"; + }; + + ps_atc1_common: power-controller@303a13800 { + compatible = "apple,t8152-psd"; + reg = <0x3 0x03a13800 0x0 0x100>; + #power-domain-cells = <0>; + label = "atc1_common"; + }; + + ps_atc3_common: power-controller@303a13a00 { + compatible = "apple,t8152-psd"; + reg = <0x3 0x03a13a00 0x0 0x100>; + #power-domain-cells = <0>; + label = "atc3_common"; }; /* ATC2's common domain: PSD service 57 (ADT atc-phy2 clock-gates). */ @@ -363,6 +478,741 @@ <0x04ca0 0x00000002 0x00000000>; }; + /* + * USB-C Back-middle: ADT atc-phy0 in CIO mode, see atc2_phy for the + * layout. The tunables are the atc-phy0 groups the CIO mode + * applies, in that order: the common and PLL defaults as + * common-a, the fabric, PLL and the other common groups as + * common-b, and each lane's groups. + */ + atc0_phy: phy@403000000 { + compatible = "apple,t8152-atcphy"; + reg = <0x4 0x03000000 0x0 0x84000>; + reg-names = "core"; + #phy-cells = <1>; + orientation-switch; + mode-switch; + power-domains = <&ps_atc0_usb_aon>, <&ps_atc0_common>, + <&ps_atc0_common_dp_0>, <&ps_atc0_common_dp_1>; + apple,tunable-common-a = + <0x00800 0x00fc0000 0x00fc0000>, + <0x0084c 0x000ff800 0x000ff800>, + <0x0085c 0x000000ff 0x00000080>, + <0x00860 0x007fffff 0x0052bca4>, + <0x00864 0x02c00000 0x00800000>, + <0x01614 0x0003ffc0 0x0001e5c0>, + <0x01640 0x00000007 0x00000003>, + <0x01668 0x00000ffc 0x000005f0>; + apple,tunable-common-b = + <0x6c004 0x003f003f 0x00200020>, + <0x6c00c 0x000000f1 0x000000a1>, + <0x6c010 0x0000801f 0x00000004>, + <0x6c018 0x003f003f 0x00200020>, + <0x6c020 0x000000f1 0x000000a1>, + <0x6c024 0x0000801f 0x00000004>, + <0x6c02c 0x007f007f 0x00410041>, + <0x6c034 0x000000f1 0x00000071>, + <0x6c038 0x0000801f 0x00000004>, + <0x6c040 0x0000001f 0x00000010>, + <0x6c048 0x0000801f 0x00000004>, + <0x6c050 0x007f007f 0x00450045>, + <0x6c058 0x000000f1 0x00000051>, + <0x6c05c 0x0000801f 0x00000004>, + <0x6c064 0x0000003f 0x00000020>, + <0x6c06c 0x0000801f 0x00000004>, + <0x6c074 0x00000001 0x00000001>, + <0x6c078 0x0000801f 0x00000004>, + <0x6c080 0x001f001f 0x00100010>, + <0x6c084 0x000000f1 0x00000011>, + <0x6c088 0x00000001 0x00000001>, + <0x6c08c 0x00000001 0x00000001>, + <0x6c090 0x0000801f 0x00000004>, + <0x6c098 0x001f001f 0x00100010>, + <0x6c09c 0x000000f1 0x00000011>, + <0x6c0a0 0x0000801f 0x00000004>, + <0x6c0a8 0x000000ff 0x000000a0>, + <0x6c0ac 0x0000801f 0x00000004>, + <0x6c0b4 0x0000003f 0x00000020>, + <0x6c0bc 0x0000801f 0x00000004>, + <0x6c0c4 0x0000003f 0x00000020>, + <0x6c0cc 0x0000801f 0x00000004>, + <0x6c0d4 0x0000000f 0x00000008>, + <0x6c0d8 0x0000801f 0x00000004>, + <0x6c0e0 0x001f001f 0x00180018>, + <0x6c0e4 0x0000801f 0x00000004>, + <0x6c0ec 0x001f001f 0x00180018>, + <0x6c0f0 0x0000801f 0x00000004>, + <0x6c0f8 0x001f001f 0x00180018>, + <0x6c0fc 0x0000801f 0x00000004>, + <0x6c104 0x001f001f 0x00180018>, + <0x6c108 0x0000801f 0x00000004>, + <0x6c110 0x00000001 0x00000001>, + <0x6c114 0x0000801f 0x00000004>, + <0x6c11c 0x0000801f 0x00000004>, + <0x6c124 0x0000801f 0x00000004>, + <0x6c12c 0x0000801f 0x00000004>, + <0x6c134 0x0000801f 0x00000004>, + <0x6c13c 0xffffffff 0x01010101>, + <0x6c140 0x0000801f 0x00000004>, + <0x6c148 0x0000801f 0x00000004>, + <0x6c150 0xffffffff 0x01010101>, + <0x6c154 0x0000ffff 0x00000101>, + <0x6c158 0x0000801f 0x00000004>, + <0x6c160 0x0000801f 0x00000004>, + <0x6c168 0x0000801f 0x00000004>, + <0x6c170 0x0000801f 0x00000004>, + <0x6c178 0x0000801f 0x00000004>, + <0x6c180 0xffffffff 0x01010101>, + <0x6c184 0x0000801f 0x00000004>, + <0x6c18c 0x0000801f 0x00000004>, + <0x6c194 0x0000801f 0x00000004>, + <0x01040 0x0000000c 0x00000008>, + <0x01060 0x0001c000 0x0000c000>, + <0x01098 0x00000f00 0x00000800>, + <0x0109c 0x000fe000 0x000fe000>, + <0x01108 0x07c00000 0x04000000>, + <0x0110c 0x0000007c 0x00000010>, + <0x00e8c 0x0000007f 0x0000003c>, + <0x00e9c 0x0000007f 0x00000032>, + <0x00eac 0x0000007f 0x00000032>, + <0x00ebc 0x0000007f 0x0000005a>, + <0x01488 0x000001ff 0x00000128>, + <0x01494 0x00000100 0x00000100>, + <0x01a44 0x0000040f 0x0000040f>, + <0x01a48 0x0000040f 0x0000040f>; + apple,tunable-lane0-cio = + <0x082d8 0xf0000000 0x70000000>, + <0x082dc 0x0000000f 0x00000007>, + <0x08cf4 0x00000020 0x00000020>, + <0x077c4 0x0003ff00 0x0000fa00>, + <0x07dbc 0x00000078 0x00000030>, + <0x07dd8 0x000003f0 0x00000000>, + <0x07de8 0x00000003 0x00000003>, + <0x07dec 0x00000002 0x00000002>, + <0x07a00 0x000000f0 0x00000010>, + <0x07a08 0x00000fff 0x00000001>, + <0x07a28 0x0ff00000 0x0cf00000>, + <0x07a40 0x07ffffff 0x028154a5>, + <0x07a7c 0x20000000 0x00000000>, + <0x07a80 0x0000001f 0x00000002>, + <0x07b98 0x3f00003f 0x31000014>, + <0x07b9c 0x0003ffff 0x0000ef4b>, + <0x07ba8 0x0fc1f800 0x05005000>, + <0x07bac 0x07ffffe0 0x013f0e40>, + <0x07bbc 0x000001c7 0x00000145>, + <0x07bc8 0x000007f8 0x00000018>, + <0x08728 0x0000010f 0x0000010f>, + <0x0878c 0xfc000000 0xfc000000>, + <0x08790 0x00000001 0x00000001>, + <0x087b4 0x0e018000 0x06008000>, + <0x08708 0x40000000 0x40000000>, + <0x04c80 0x3f800000 0x00000000>, + <0x04c88 0x001fffff 0x00000000>, + <0x04fd4 0x03800000 0x02800000>, + <0x04e20 0x00fff000 0x00723000>, + <0x08980 0x00fff000 0x00723000>, + <0x085e4 0x00000004 0x00000000>, + <0x08628 0x00000ff0 0x00000660>, + <0x0862c 0x00000ff0 0x00000ea0>, + <0x08000 0x0000000a 0x00000000>, + <0x08014 0x000003ff 0x00000042>, + <0x07304 0x0000000f 0x00000006>, + <0x07334 0x01ffffff 0x001004ea>, + <0x07284 0x0000000f 0x00000006>, + <0x072cc 0x0003ffff 0x000004ea>, + <0x04d84 0x001c0000 0x00000000>, + <0x07f80 0xffffffff 0x00000148>, + <0x07f90 0x0003ff00 0x0002f700>, + <0x07fd0 0x00000100 0x00000000>, + <0x07d88 0x000000ff 0x00000041>, + <0x07da8 0xffff0000 0x22110000>, + <0x07dac 0x000000ff 0x00000044>, + <0x07dd8 0x0000c000 0x00000000>, + <0x07ddc 0x00000003 0x00000000>, + <0x07a1c 0x00000ff8 0x00000528>, + <0x07a2c 0x0003ffff 0x000140aa>, + <0x07a30 0x00001e00 0x00001000>, + <0x07a34 0x00ff0000 0x000a0000>, + <0x07b84 0x000000ff 0x00000028>, + <0x07b88 0x0000f00f 0x00007008>, + <0x07b8c 0x0000f00f 0x00006007>, + <0x07b90 0x0000f00f 0x00004005>, + <0x07bb4 0x0000703f 0x0000502d>, + <0x07bb8 0x0000703f 0x00002013>, + <0x07bbc 0x00000e00 0x00000600>, + <0x08af4 0x01fe0000 0x01540000>, + <0x08af8 0x003fc000 0x002a8000>, + <0x04e94 0x01fe0000 0x01540000>, + <0x04e98 0x003fc000 0x002a8000>; + apple,tunable-lane1-cio = + <0x112d8 0xf0000000 0x70000000>, + <0x112dc 0x0000000f 0x00000007>, + <0x11cf4 0x00000020 0x00000020>, + <0x107c4 0x0003ff00 0x0000fa00>, + <0x10dbc 0x00000078 0x00000030>, + <0x10dd8 0x000003f0 0x00000000>, + <0x10de8 0x00000003 0x00000003>, + <0x10dec 0x00000002 0x00000002>, + <0x10a00 0x000000f0 0x00000010>, + <0x10a08 0x00000fff 0x00000001>, + <0x10a28 0x0ff00000 0x0cf00000>, + <0x10a40 0x07ffffff 0x028154a5>, + <0x10a7c 0x20000000 0x00000000>, + <0x10a80 0x0000001f 0x00000002>, + <0x10b98 0x3f00003f 0x31000014>, + <0x10b9c 0x0003ffff 0x0000ef4b>, + <0x10ba8 0x0fc1f800 0x05005000>, + <0x10bac 0x07ffffe0 0x013f0e40>, + <0x10bbc 0x000001c7 0x00000145>, + <0x10bc8 0x000007f8 0x00000018>, + <0x11728 0x0000010f 0x0000010f>, + <0x1178c 0xfc000000 0xfc000000>, + <0x11790 0x00000001 0x00000001>, + <0x117b4 0x0e018000 0x06008000>, + <0x11708 0x40000000 0x40000000>, + <0x0dc80 0x3f800000 0x00000000>, + <0x0dc88 0x001fffff 0x00000000>, + <0x0dfd4 0x03800000 0x02800000>, + <0x0de20 0x00fff000 0x00723000>, + <0x11980 0x00fff000 0x00723000>, + <0x115e4 0x00000004 0x00000000>, + <0x11628 0x00000ff0 0x00000660>, + <0x1162c 0x00000ff0 0x00000ea0>, + <0x11000 0x0000000a 0x00000000>, + <0x11014 0x000003ff 0x00000042>, + <0x10304 0x0000000f 0x00000006>, + <0x10334 0x01ffffff 0x001004ea>, + <0x10284 0x0000000f 0x00000006>, + <0x102cc 0x0003ffff 0x000004ea>, + <0x0dd84 0x001c0000 0x00000000>, + <0x10f80 0xffffffff 0x00000148>, + <0x10f90 0x0003ff00 0x0002f700>, + <0x10fd0 0x00000100 0x00000000>, + <0x10d88 0x000000ff 0x00000041>, + <0x10da8 0xffff0000 0x22110000>, + <0x10dac 0x000000ff 0x00000044>, + <0x10dd8 0x0000c000 0x00000000>, + <0x10ddc 0x00000003 0x00000000>, + <0x10a1c 0x00000ff8 0x00000528>, + <0x10a2c 0x0003ffff 0x000140aa>, + <0x10a30 0x00001e00 0x00001000>, + <0x10a34 0x00ff0000 0x000a0000>, + <0x10b84 0x000000ff 0x00000028>, + <0x10b88 0x0000f00f 0x00007008>, + <0x10b8c 0x0000f00f 0x00006007>, + <0x10b90 0x0000f00f 0x00004005>, + <0x10bb4 0x0000703f 0x0000502d>, + <0x10bb8 0x0000703f 0x00002013>, + <0x10bbc 0x00000e00 0x00000600>, + <0x11af4 0x01fe0000 0x01540000>, + <0x11af8 0x003fc000 0x002a8000>, + <0x0de94 0x01fe0000 0x01540000>, + <0x0de98 0x003fc000 0x002a8000>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + + atc0_phy_typec: endpoint { + remote-endpoint = <&typec0_ss>; + }; + }; + }; + }; + + /* + * USB-C Back-left: ADT atc-phy1 in CIO mode, see atc2_phy for the + * layout. The tunables are the atc-phy1 groups the CIO mode + * applies, in that order: the common and PLL defaults as + * common-a, the fabric, PLL and the other common groups as + * common-b, and each lane's groups. + */ + atc1_phy: phy@40b000000 { + compatible = "apple,t8152-atcphy"; + reg = <0x4 0x0b000000 0x0 0x84000>; + reg-names = "core"; + #phy-cells = <1>; + orientation-switch; + mode-switch; + power-domains = <&ps_atc1_usb_aon>, <&ps_atc1_common>, + <&ps_atc1_common_dp_0>, <&ps_atc1_common_dp_1>; + apple,tunable-common-a = + <0x00800 0x00fc0000 0x00fc0000>, + <0x0084c 0x000ff800 0x000ff800>, + <0x0085c 0x000000ff 0x00000080>, + <0x00860 0x007fffff 0x0052bc26>, + <0x00864 0x02c00000 0x00800000>, + <0x01614 0x0003ffc0 0x0001e5c0>, + <0x01640 0x00000007 0x00000003>, + <0x01668 0x00000ffc 0x000005f0>; + apple,tunable-common-b = + <0x6c004 0x003f003f 0x00200020>, + <0x6c00c 0x000000f1 0x000000a1>, + <0x6c010 0x0000801f 0x00000004>, + <0x6c018 0x003f003f 0x00200020>, + <0x6c020 0x000000f1 0x000000a1>, + <0x6c024 0x0000801f 0x00000004>, + <0x6c02c 0x007f007f 0x00410041>, + <0x6c034 0x000000f1 0x00000071>, + <0x6c038 0x0000801f 0x00000004>, + <0x6c040 0x0000001f 0x00000010>, + <0x6c048 0x0000801f 0x00000004>, + <0x6c050 0x007f007f 0x00450045>, + <0x6c058 0x000000f1 0x00000051>, + <0x6c05c 0x0000801f 0x00000004>, + <0x6c064 0x0000003f 0x00000020>, + <0x6c06c 0x0000801f 0x00000004>, + <0x6c074 0x00000001 0x00000001>, + <0x6c078 0x0000801f 0x00000004>, + <0x6c080 0x001f001f 0x00100010>, + <0x6c084 0x000000f1 0x00000011>, + <0x6c088 0x00000001 0x00000001>, + <0x6c08c 0x00000001 0x00000001>, + <0x6c090 0x0000801f 0x00000004>, + <0x6c098 0x001f001f 0x00100010>, + <0x6c09c 0x000000f1 0x00000011>, + <0x6c0a0 0x0000801f 0x00000004>, + <0x6c0a8 0x000000ff 0x000000a0>, + <0x6c0ac 0x0000801f 0x00000004>, + <0x6c0b4 0x0000003f 0x00000020>, + <0x6c0bc 0x0000801f 0x00000004>, + <0x6c0c4 0x0000003f 0x00000020>, + <0x6c0cc 0x0000801f 0x00000004>, + <0x6c0d4 0x0000000f 0x00000008>, + <0x6c0d8 0x0000801f 0x00000004>, + <0x6c0e0 0x001f001f 0x00180018>, + <0x6c0e4 0x0000801f 0x00000004>, + <0x6c0ec 0x001f001f 0x00180018>, + <0x6c0f0 0x0000801f 0x00000004>, + <0x6c0f8 0x001f001f 0x00180018>, + <0x6c0fc 0x0000801f 0x00000004>, + <0x6c104 0x001f001f 0x00180018>, + <0x6c108 0x0000801f 0x00000004>, + <0x6c110 0x00000001 0x00000001>, + <0x6c114 0x0000801f 0x00000004>, + <0x6c11c 0x0000801f 0x00000004>, + <0x6c124 0x0000801f 0x00000004>, + <0x6c12c 0x0000801f 0x00000004>, + <0x6c134 0x0000801f 0x00000004>, + <0x6c13c 0xffffffff 0x01010101>, + <0x6c140 0x0000801f 0x00000004>, + <0x6c148 0x0000801f 0x00000004>, + <0x6c150 0xffffffff 0x01010101>, + <0x6c154 0x0000ffff 0x00000101>, + <0x6c158 0x0000801f 0x00000004>, + <0x6c160 0x0000801f 0x00000004>, + <0x6c168 0x0000801f 0x00000004>, + <0x6c170 0x0000801f 0x00000004>, + <0x6c178 0x0000801f 0x00000004>, + <0x6c180 0xffffffff 0x01010101>, + <0x6c184 0x0000801f 0x00000004>, + <0x6c18c 0x0000801f 0x00000004>, + <0x6c194 0x0000801f 0x00000004>, + <0x01040 0x0000000c 0x00000008>, + <0x01060 0x0001c000 0x0000c000>, + <0x01098 0x00000f00 0x00000800>, + <0x0109c 0x000fe000 0x000fe000>, + <0x01108 0x07c00000 0x04000000>, + <0x0110c 0x0000007c 0x00000010>, + <0x00e8c 0x0000007f 0x0000003c>, + <0x00e9c 0x0000007f 0x00000032>, + <0x00eac 0x0000007f 0x00000032>, + <0x00ebc 0x0000007f 0x0000005a>, + <0x01488 0x000001ff 0x00000128>, + <0x01494 0x00000100 0x00000100>, + <0x01a44 0x0000040f 0x0000040f>, + <0x01a48 0x0000040f 0x0000040f>; + apple,tunable-lane0-cio = + <0x082d8 0xf0000000 0x70000000>, + <0x082dc 0x0000000f 0x00000007>, + <0x08cf4 0x00000020 0x00000020>, + <0x077c4 0x0003ff00 0x0000fa00>, + <0x07dbc 0x00000078 0x00000030>, + <0x07dd8 0x000003f0 0x00000000>, + <0x07de8 0x00000003 0x00000003>, + <0x07dec 0x00000002 0x00000002>, + <0x07a00 0x000000f0 0x00000010>, + <0x07a08 0x00000fff 0x00000001>, + <0x07a28 0x0ff00000 0x0cf00000>, + <0x07a40 0x07ffffff 0x028154a5>, + <0x07a7c 0x20000000 0x00000000>, + <0x07a80 0x0000001f 0x00000002>, + <0x07b98 0x3f00003f 0x31000014>, + <0x07b9c 0x0003ffff 0x0000ef4b>, + <0x07ba8 0x0fc1f800 0x05005000>, + <0x07bac 0x07ffffe0 0x013f0e40>, + <0x07bbc 0x000001c7 0x00000145>, + <0x07bc8 0x000007f8 0x00000018>, + <0x08728 0x0000010f 0x0000010f>, + <0x0878c 0xfc000000 0xfc000000>, + <0x08790 0x00000001 0x00000001>, + <0x087b4 0x0e018000 0x06008000>, + <0x08708 0x40000000 0x40000000>, + <0x04c80 0x3f800000 0x00000000>, + <0x04c88 0x001fffff 0x00000000>, + <0x04fd4 0x03800000 0x02800000>, + <0x04e20 0x00fff000 0x00723000>, + <0x08980 0x00fff000 0x00723000>, + <0x085e4 0x00000004 0x00000000>, + <0x08628 0x00000ff0 0x00000660>, + <0x0862c 0x00000ff0 0x00000ea0>, + <0x08000 0x0000000a 0x00000000>, + <0x08014 0x000003ff 0x00000042>, + <0x07304 0x0000000f 0x00000006>, + <0x07334 0x01ffffff 0x001004ea>, + <0x07284 0x0000000f 0x00000006>, + <0x072cc 0x0003ffff 0x000004ea>, + <0x04d84 0x001c0000 0x00000000>, + <0x07f80 0xffffffff 0x00000148>, + <0x07f90 0x0003ff00 0x0002f700>, + <0x07fd0 0x00000100 0x00000000>, + <0x07d88 0x000000ff 0x00000041>, + <0x07da8 0xffff0000 0x22110000>, + <0x07dac 0x000000ff 0x00000044>, + <0x07dd8 0x0000c000 0x00000000>, + <0x07ddc 0x00000003 0x00000000>, + <0x07a1c 0x00000ff8 0x00000528>, + <0x07a2c 0x0003ffff 0x000140aa>, + <0x07a30 0x00001e00 0x00001000>, + <0x07a34 0x00ff0000 0x000a0000>, + <0x07b84 0x000000ff 0x00000028>, + <0x07b88 0x0000f00f 0x00007008>, + <0x07b8c 0x0000f00f 0x00006007>, + <0x07b90 0x0000f00f 0x00004005>, + <0x07bb4 0x0000703f 0x0000502d>, + <0x07bb8 0x0000703f 0x00002013>, + <0x07bbc 0x00000e00 0x00000600>, + <0x08af4 0x01fe0000 0x01540000>, + <0x08af8 0x003fc000 0x002a8000>, + <0x04e94 0x01fe0000 0x01540000>, + <0x04e98 0x003fc000 0x002a8000>; + apple,tunable-lane1-cio = + <0x112d8 0xf0000000 0x70000000>, + <0x112dc 0x0000000f 0x00000007>, + <0x11cf4 0x00000020 0x00000020>, + <0x107c4 0x0003ff00 0x0000fa00>, + <0x10dbc 0x00000078 0x00000030>, + <0x10dd8 0x000003f0 0x00000000>, + <0x10de8 0x00000003 0x00000003>, + <0x10dec 0x00000002 0x00000002>, + <0x10a00 0x000000f0 0x00000010>, + <0x10a08 0x00000fff 0x00000001>, + <0x10a28 0x0ff00000 0x0cf00000>, + <0x10a40 0x07ffffff 0x028154a5>, + <0x10a7c 0x20000000 0x00000000>, + <0x10a80 0x0000001f 0x00000002>, + <0x10b98 0x3f00003f 0x31000014>, + <0x10b9c 0x0003ffff 0x0000ef4b>, + <0x10ba8 0x0fc1f800 0x05005000>, + <0x10bac 0x07ffffe0 0x013f0e40>, + <0x10bbc 0x000001c7 0x00000145>, + <0x10bc8 0x000007f8 0x00000018>, + <0x11728 0x0000010f 0x0000010f>, + <0x1178c 0xfc000000 0xfc000000>, + <0x11790 0x00000001 0x00000001>, + <0x117b4 0x0e018000 0x06008000>, + <0x11708 0x40000000 0x40000000>, + <0x0dc80 0x3f800000 0x00000000>, + <0x0dc88 0x001fffff 0x00000000>, + <0x0dfd4 0x03800000 0x02800000>, + <0x0de20 0x00fff000 0x00723000>, + <0x11980 0x00fff000 0x00723000>, + <0x115e4 0x00000004 0x00000000>, + <0x11628 0x00000ff0 0x00000660>, + <0x1162c 0x00000ff0 0x00000ea0>, + <0x11000 0x0000000a 0x00000000>, + <0x11014 0x000003ff 0x00000042>, + <0x10304 0x0000000f 0x00000006>, + <0x10334 0x01ffffff 0x001004ea>, + <0x10284 0x0000000f 0x00000006>, + <0x102cc 0x0003ffff 0x000004ea>, + <0x0dd84 0x001c0000 0x00000000>, + <0x10f80 0xffffffff 0x00000148>, + <0x10f90 0x0003ff00 0x0002f700>, + <0x10fd0 0x00000100 0x00000000>, + <0x10d88 0x000000ff 0x00000041>, + <0x10da8 0xffff0000 0x22110000>, + <0x10dac 0x000000ff 0x00000044>, + <0x10dd8 0x0000c000 0x00000000>, + <0x10ddc 0x00000003 0x00000000>, + <0x10a1c 0x00000ff8 0x00000528>, + <0x10a2c 0x0003ffff 0x000140aa>, + <0x10a30 0x00001e00 0x00001000>, + <0x10a34 0x00ff0000 0x000a0000>, + <0x10b84 0x000000ff 0x00000028>, + <0x10b88 0x0000f00f 0x00007008>, + <0x10b8c 0x0000f00f 0x00006007>, + <0x10b90 0x0000f00f 0x00004005>, + <0x10bb4 0x0000703f 0x0000502d>, + <0x10bb8 0x0000703f 0x00002013>, + <0x10bbc 0x00000e00 0x00000600>, + <0x11af4 0x01fe0000 0x01540000>, + <0x11af8 0x003fc000 0x002a8000>, + <0x0de94 0x01fe0000 0x01540000>, + <0x0de98 0x003fc000 0x002a8000>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + + atc1_phy_typec: endpoint { + remote-endpoint = <&typec1_ss>; + }; + }; + }; + }; + + /* + * USB-C Back-right: ADT atc-phy3 in CIO mode, see atc2_phy for the + * layout. The tunables are the atc-phy3 groups the CIO mode + * applies, in that order: the common and PLL defaults as + * common-a, the fabric, PLL and the other common groups as + * common-b, and each lane's groups. + */ + atc3_phy: phy@413000000 { + compatible = "apple,t8152-atcphy"; + reg = <0x4 0x13000000 0x0 0x84000>; + reg-names = "core"; + #phy-cells = <1>; + orientation-switch; + mode-switch; + power-domains = <&ps_atc3_usb_aon>, <&ps_atc3_common>, + <&ps_atc3_common_dp_0>, <&ps_atc3_common_dp_1>; + apple,tunable-common-a = + <0x00800 0x00fc0000 0x00fc0000>, + <0x0084c 0x000ff800 0x000ff800>, + <0x0085c 0x000000ff 0x00000080>, + <0x00860 0x007fffff 0x0052bc26>, + <0x00864 0x02c00000 0x00800000>, + <0x01614 0x0003ffc0 0x0001e5c0>, + <0x01640 0x00000007 0x00000003>, + <0x01668 0x00000ffc 0x000005f0>; + apple,tunable-common-b = + <0x6c004 0x003f003f 0x00200020>, + <0x6c00c 0x000000f1 0x000000a1>, + <0x6c010 0x0000801f 0x00000004>, + <0x6c018 0x003f003f 0x00200020>, + <0x6c020 0x000000f1 0x000000a1>, + <0x6c024 0x0000801f 0x00000004>, + <0x6c02c 0x007f007f 0x00410041>, + <0x6c034 0x000000f1 0x00000071>, + <0x6c038 0x0000801f 0x00000004>, + <0x6c040 0x0000001f 0x00000010>, + <0x6c048 0x0000801f 0x00000004>, + <0x6c050 0x007f007f 0x00450045>, + <0x6c058 0x000000f1 0x00000051>, + <0x6c05c 0x0000801f 0x00000004>, + <0x6c064 0x0000003f 0x00000020>, + <0x6c06c 0x0000801f 0x00000004>, + <0x6c074 0x00000001 0x00000001>, + <0x6c078 0x0000801f 0x00000004>, + <0x6c080 0x001f001f 0x00100010>, + <0x6c084 0x000000f1 0x00000011>, + <0x6c088 0x00000001 0x00000001>, + <0x6c08c 0x00000001 0x00000001>, + <0x6c090 0x0000801f 0x00000004>, + <0x6c098 0x001f001f 0x00100010>, + <0x6c09c 0x000000f1 0x00000011>, + <0x6c0a0 0x0000801f 0x00000004>, + <0x6c0a8 0x000000ff 0x000000a0>, + <0x6c0ac 0x0000801f 0x00000004>, + <0x6c0b4 0x0000003f 0x00000020>, + <0x6c0bc 0x0000801f 0x00000004>, + <0x6c0c4 0x0000003f 0x00000020>, + <0x6c0cc 0x0000801f 0x00000004>, + <0x6c0d4 0x0000000f 0x00000008>, + <0x6c0d8 0x0000801f 0x00000004>, + <0x6c0e0 0x001f001f 0x00180018>, + <0x6c0e4 0x0000801f 0x00000004>, + <0x6c0ec 0x001f001f 0x00180018>, + <0x6c0f0 0x0000801f 0x00000004>, + <0x6c0f8 0x001f001f 0x00180018>, + <0x6c0fc 0x0000801f 0x00000004>, + <0x6c104 0x001f001f 0x00180018>, + <0x6c108 0x0000801f 0x00000004>, + <0x6c110 0x00000001 0x00000001>, + <0x6c114 0x0000801f 0x00000004>, + <0x6c11c 0x0000801f 0x00000004>, + <0x6c124 0x0000801f 0x00000004>, + <0x6c12c 0x0000801f 0x00000004>, + <0x6c134 0x0000801f 0x00000004>, + <0x6c13c 0xffffffff 0x01010101>, + <0x6c140 0x0000801f 0x00000004>, + <0x6c148 0x0000801f 0x00000004>, + <0x6c150 0xffffffff 0x01010101>, + <0x6c154 0x0000ffff 0x00000101>, + <0x6c158 0x0000801f 0x00000004>, + <0x6c160 0x0000801f 0x00000004>, + <0x6c168 0x0000801f 0x00000004>, + <0x6c170 0x0000801f 0x00000004>, + <0x6c178 0x0000801f 0x00000004>, + <0x6c180 0xffffffff 0x01010101>, + <0x6c184 0x0000801f 0x00000004>, + <0x6c18c 0x0000801f 0x00000004>, + <0x6c194 0x0000801f 0x00000004>, + <0x01040 0x0000000c 0x00000008>, + <0x01060 0x0001c000 0x0000c000>, + <0x01098 0x00000f00 0x00000800>, + <0x0109c 0x000fe000 0x000fe000>, + <0x01108 0x07c00000 0x04000000>, + <0x0110c 0x0000007c 0x00000010>, + <0x00e8c 0x0000007f 0x0000003c>, + <0x00e9c 0x0000007f 0x00000032>, + <0x00eac 0x0000007f 0x00000032>, + <0x00ebc 0x0000007f 0x0000005a>, + <0x01488 0x000001ff 0x00000128>, + <0x01494 0x00000100 0x00000100>, + <0x01a44 0x0000040f 0x0000040f>, + <0x01a48 0x0000040f 0x0000040f>; + apple,tunable-lane0-cio = + <0x082d8 0xf0000000 0x70000000>, + <0x082dc 0x0000000f 0x00000007>, + <0x08cf4 0x00000020 0x00000020>, + <0x077c4 0x0003ff00 0x0000fa00>, + <0x07dbc 0x00000078 0x00000030>, + <0x07dd8 0x000003f0 0x00000000>, + <0x07de8 0x00000003 0x00000003>, + <0x07dec 0x00000002 0x00000002>, + <0x07a00 0x000000f0 0x00000010>, + <0x07a08 0x00000fff 0x00000001>, + <0x07a28 0x0ff00000 0x0cf00000>, + <0x07a40 0x07ffffff 0x028154a5>, + <0x07a7c 0x20000000 0x00000000>, + <0x07a80 0x0000001f 0x00000002>, + <0x07b98 0x3f00003f 0x31000014>, + <0x07b9c 0x0003ffff 0x0000ef4b>, + <0x07ba8 0x0fc1f800 0x05005000>, + <0x07bac 0x07ffffe0 0x013f0e40>, + <0x07bbc 0x000001c7 0x00000145>, + <0x07bc8 0x000007f8 0x00000018>, + <0x08728 0x0000010f 0x0000010f>, + <0x0878c 0xfc000000 0xfc000000>, + <0x08790 0x00000001 0x00000001>, + <0x087b4 0x0e018000 0x06008000>, + <0x08708 0x40000000 0x40000000>, + <0x04c80 0x3f800000 0x00000000>, + <0x04c88 0x001fffff 0x00000000>, + <0x04fd4 0x03800000 0x02800000>, + <0x04e20 0x00fff000 0x00723000>, + <0x08980 0x00fff000 0x00723000>, + <0x085e4 0x00000004 0x00000000>, + <0x08628 0x00000ff0 0x00000660>, + <0x0862c 0x00000ff0 0x00000ea0>, + <0x08000 0x0000000a 0x00000000>, + <0x08014 0x000003ff 0x00000042>, + <0x07304 0x0000000f 0x00000006>, + <0x07334 0x01ffffff 0x001004ea>, + <0x07284 0x0000000f 0x00000006>, + <0x072cc 0x0003ffff 0x000004ea>, + <0x04d84 0x001c0000 0x00000000>, + <0x07f80 0xffffffff 0x00000148>, + <0x07f90 0x0003ff00 0x0002f700>, + <0x07fd0 0x00000100 0x00000000>, + <0x07d88 0x000000ff 0x00000041>, + <0x07da8 0xffff0000 0x22110000>, + <0x07dac 0x000000ff 0x00000044>, + <0x07dd8 0x0000c000 0x00000000>, + <0x07ddc 0x00000003 0x00000000>, + <0x07a1c 0x00000ff8 0x00000528>, + <0x07a2c 0x0003ffff 0x000140aa>, + <0x07a30 0x00001e00 0x00001000>, + <0x07a34 0x00ff0000 0x000a0000>, + <0x07b84 0x000000ff 0x00000028>, + <0x07b88 0x0000f00f 0x00007008>, + <0x07b8c 0x0000f00f 0x00006007>, + <0x07b90 0x0000f00f 0x00004005>, + <0x07bb4 0x0000703f 0x0000502d>, + <0x07bb8 0x0000703f 0x00002013>, + <0x07bbc 0x00000e00 0x00000600>, + <0x08af4 0x01fe0000 0x01540000>, + <0x08af8 0x003fc000 0x002a8000>, + <0x04e94 0x01fe0000 0x01540000>, + <0x04e98 0x003fc000 0x002a8000>; + apple,tunable-lane1-cio = + <0x112d8 0xf0000000 0x70000000>, + <0x112dc 0x0000000f 0x00000007>, + <0x11cf4 0x00000020 0x00000020>, + <0x107c4 0x0003ff00 0x0000fa00>, + <0x10dbc 0x00000078 0x00000030>, + <0x10dd8 0x000003f0 0x00000000>, + <0x10de8 0x00000003 0x00000003>, + <0x10dec 0x00000002 0x00000002>, + <0x10a00 0x000000f0 0x00000010>, + <0x10a08 0x00000fff 0x00000001>, + <0x10a28 0x0ff00000 0x0cf00000>, + <0x10a40 0x07ffffff 0x028154a5>, + <0x10a7c 0x20000000 0x00000000>, + <0x10a80 0x0000001f 0x00000002>, + <0x10b98 0x3f00003f 0x31000014>, + <0x10b9c 0x0003ffff 0x0000ef4b>, + <0x10ba8 0x0fc1f800 0x05005000>, + <0x10bac 0x07ffffe0 0x013f0e40>, + <0x10bbc 0x000001c7 0x00000145>, + <0x10bc8 0x000007f8 0x00000018>, + <0x11728 0x0000010f 0x0000010f>, + <0x1178c 0xfc000000 0xfc000000>, + <0x11790 0x00000001 0x00000001>, + <0x117b4 0x0e018000 0x06008000>, + <0x11708 0x40000000 0x40000000>, + <0x0dc80 0x3f800000 0x00000000>, + <0x0dc88 0x001fffff 0x00000000>, + <0x0dfd4 0x03800000 0x02800000>, + <0x0de20 0x00fff000 0x00723000>, + <0x11980 0x00fff000 0x00723000>, + <0x115e4 0x00000004 0x00000000>, + <0x11628 0x00000ff0 0x00000660>, + <0x1162c 0x00000ff0 0x00000ea0>, + <0x11000 0x0000000a 0x00000000>, + <0x11014 0x000003ff 0x00000042>, + <0x10304 0x0000000f 0x00000006>, + <0x10334 0x01ffffff 0x001004ea>, + <0x10284 0x0000000f 0x00000006>, + <0x102cc 0x0003ffff 0x000004ea>, + <0x0dd84 0x001c0000 0x00000000>, + <0x10f80 0xffffffff 0x00000148>, + <0x10f90 0x0003ff00 0x0002f700>, + <0x10fd0 0x00000100 0x00000000>, + <0x10d88 0x000000ff 0x00000041>, + <0x10da8 0xffff0000 0x22110000>, + <0x10dac 0x000000ff 0x00000044>, + <0x10dd8 0x0000c000 0x00000000>, + <0x10ddc 0x00000003 0x00000000>, + <0x10a1c 0x00000ff8 0x00000528>, + <0x10a2c 0x0003ffff 0x000140aa>, + <0x10a30 0x00001e00 0x00001000>, + <0x10a34 0x00ff0000 0x000a0000>, + <0x10b84 0x000000ff 0x00000028>, + <0x10b88 0x0000f00f 0x00007008>, + <0x10b8c 0x0000f00f 0x00006007>, + <0x10b90 0x0000f00f 0x00004005>, + <0x10bb4 0x0000703f 0x0000502d>, + <0x10bb8 0x0000703f 0x00002013>, + <0x10bbc 0x00000e00 0x00000600>, + <0x11af4 0x01fe0000 0x01540000>, + <0x11af8 0x003fc000 0x002a8000>, + <0x0de94 0x01fe0000 0x01540000>, + <0x0de98 0x003fc000 0x002a8000>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + + atc3_phy_typec: endpoint { + remote-endpoint = <&typec3_ss>; + }; + }; + }; + }; + /* usb-drd2: on-board VL822 hub behind the two front USB-C ports. */ usb2: usb@382430000 { compatible = "apple,t8152-dwc3"; From e027cdf96f5ccc0665ac6268a7f688ce921227f1 Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Fri, 20 Nov 2026 01:26:41 +0100 Subject: [PATCH 28/31] thunderbolt: apple: stop the T8152 routers before a reboot A reboot or power-off shuts the PCIe-C host and the router's and the tunnel's DARTs down before the router, while a started router still runs over them. With the J873g's rear ports, the earlier port monitor stopped the routers from a reboot notifier for this. Without a port monitor, do that in the router driver: for routers whose match data asks for it (T8152), stop a started router from a reboot notifier, as the port driver does for an unplugged cable, and refuse a new start from then on. Signed-off-by: Thomas Glanzmann --- drivers/thunderbolt/apple.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/thunderbolt/apple.c b/drivers/thunderbolt/apple.c index a22d8129a7b32..cdce656a28a5c 100644 --- a/drivers/thunderbolt/apple.c +++ b/drivers/thunderbolt/apple.c @@ -95,6 +95,7 @@ #include #include #include +#include #include #include #include @@ -173,6 +174,8 @@ struct apple_cio_hw { bool host_tmu; /* Drain PSD runtime power-off before the PHY is reset or reused. */ bool psd_power_cycle; + /* Stop a started router before a reboot shuts its PCIe and DARTs down. */ + bool stop_at_reboot; const struct apple_dpin_policy *dp; }; @@ -211,6 +214,7 @@ static const struct apple_cio_hw apple_cio_t8132_hw = { /* MXWrap-v2p3 is started by reconfiguration, using its counted mailbox. */ static const struct apple_cio_hw apple_cio_t8152_hw = { .psd_power_cycle = true, + .stop_at_reboot = true, .type7 = true, .lstx_after_boot = true, .strict_fw_ready = true, @@ -513,6 +517,7 @@ struct apple_cio { u64 link_lost_cycle_activity; /* remote activity at the last cycle */ bool link_lost_restart; /* protected by lock: cycle requested */ struct notifier_block pm_notifier; + struct notifier_block reboot_notifier; /* * T6050: the displays behind this port go at the start of the sleep's entry, before any * port's power-off. @sleep_dp_paused: this entry closed the DP IN admission; @@ -4498,6 +4503,24 @@ static int apple_cio_pcie_notify(struct notifier_block *nb, return NOTIFY_OK; } +/* + * A reboot or power-off shuts the PCIe-C host and the router's and the + * tunnel's DARTs down before this device, with the router still running + * over them. Stop a started router first, as the port driver does for an + * unplugged cable, and refuse a new start from then on. + */ +static int apple_cio_reboot_notify(struct notifier_block *nb, unsigned long action, + void *data) +{ + struct apple_cio *acio = container_of(nb, struct apple_cio, reboot_notifier); + + guard(mutex)(&acio->lock); + acio->removing = true; + if (acio->current_cable_info) + apple_cio_stop(acio); + return NOTIFY_DONE; +} + static int apple_cio_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -4759,6 +4782,10 @@ static int apple_cio_probe(struct platform_device *pdev) acio->pm_notifier_dp.notifier_call = apple_cio_dp_pm_notify; acio->pm_notifier_dp.priority = 20; register_pm_notifier(&acio->pm_notifier_dp); + if (acio->hw->stop_at_reboot) { + acio->reboot_notifier.notifier_call = apple_cio_reboot_notify; + register_reboot_notifier(&acio->reboot_notifier); + } return 0; } @@ -4766,6 +4793,8 @@ static void apple_cio_remove(struct platform_device *pdev) { struct apple_cio *acio = platform_get_drvdata(pdev); + if (acio->hw->stop_at_reboot) + unregister_reboot_notifier(&acio->reboot_notifier); /* Refuse new activation before draining callbacks and workers. */ scoped_guard(mutex, &acio->lock) acio->removing = true; From 24d3c85bce4c0dda2473fcf6eb3f60eace72a444 Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Fri, 20 Nov 2026 01:26:41 +0100 Subject: [PATCH 29/31] arm64: dts: apple: t8152-j873g: enable the rear USB4 ports Describe the three rear USB4 routers (ADT acio0, acio1, acio3) with their mailboxes, NHI, ACIO DARTs, PCIe-C tunnels and their DARTs, the CIO reset block, the PSD services they need and the LSTX pins. Generated from the J873g ADT, including the router, NHI, DART and PCIe-C tunables and the router DROMs, whose UID field is the port index. Each router coprocessor's mailbox has apple,t8152-smc-mailbox as its fallback and the two interrupts of the ADT's acio-cpuN node, which list send-empty first, as the SMC mailbox's do. Each router's Thunderbolt switch (its port@1) is linked to the USB4 port (port@4) of its port's usb-c-connector, as on the J813: the PD controller driver sets the port's ATC PHY to CIO mode and then starts the router with the cable's EUDO and orientation, and stops the router before it takes the PHY out of CIO mode. Signed-off-by: Thomas Glanzmann --- .../arm64/boot/dts/apple/t8152-j873-usb4.dtsi | 1314 +++++++++++++++++ arch/arm64/boot/dts/apple/t8152-j873g.dts | 1 + 2 files changed, 1315 insertions(+) create mode 100644 arch/arm64/boot/dts/apple/t8152-j873-usb4.dtsi diff --git a/arch/arm64/boot/dts/apple/t8152-j873-usb4.dtsi b/arch/arm64/boot/dts/apple/t8152-j873-usb4.dtsi new file mode 100644 index 0000000000000..ff1579e5d08f3 --- /dev/null +++ b/arch/arm64/boot/dts/apple/t8152-j873-usb4.dtsi @@ -0,0 +1,1314 @@ +// SPDX-License-Identifier: GPL-2.0+ OR MIT +/* + * J873g rear USB-C ports in USB4 mode: three ACIO host routers with their + * NHI, PCIe-C tunnel and DARTs, and the T8152 PSD services they need. Each + * router's Thunderbolt switch is linked to the USB4 port (port@4) of its + * port's usb-c-connector, whose PD controller driver starts and stops it + * after it set the port's ATC PHY to CIO mode. + * + * Generated from the J873g ADT (27.2 iBoot): /arm-io/acio{0,1,3}, acio-cpuN, + * dart-acioN, apciecN and dart-apciecN. + * + * Each router coprocessor's mailbox is the 0x80 window at +0x80 of its + * acio-cpuN register block, with the SMC mailbox's counted FIFOs. Its + * interrupts are acio-cpuN's two, in the order the SMC mailbox's ADT list + * gives its own: send-empty, recv-not-empty. + */ + +#include + +/ { + soc { + cio_reset: reset-controller@300780000 { + compatible = "apple,t8152-cio-reset"; + reg = <0x3 0x00780000 0x0 0x4000>; + #reset-cells = <1>; + }; + + cio_psd59: power-controller@303a13b00 { + compatible = "apple,t8152-psd"; + reg = <0x3 0x3a13b00 0x0 0x100>; + #power-domain-cells = <0>; + }; + + cio_psd60: power-controller@303a13c00 { + compatible = "apple,t8152-psd"; + reg = <0x3 0x3a13c00 0x0 0x100>; + #power-domain-cells = <0>; + }; + + cio_psd62: power-controller@303a13e00 { + compatible = "apple,t8152-psd"; + reg = <0x3 0x3a13e00 0x0 0x100>; + #power-domain-cells = <0>; + }; + + cio_psd63: power-controller@303a13f00 { + compatible = "apple,t8152-psd"; + reg = <0x3 0x3a13f00 0x0 0x100>; + #power-domain-cells = <0>; + }; + + cio_psd64: power-controller@303a14000 { + compatible = "apple,t8152-psd"; + reg = <0x3 0x3a14000 0x0 0x100>; + #power-domain-cells = <0>; + }; + + cio_psd66: power-controller@303a14200 { + compatible = "apple,t8152-psd"; + reg = <0x3 0x3a14200 0x0 0x100>; + #power-domain-cells = <0>; + }; + + cio_psd67: power-controller@303a14300 { + compatible = "apple,t8152-psd"; + reg = <0x3 0x3a14300 0x0 0x100>; + #power-domain-cells = <0>; + }; + + cio_psd68: power-controller@303a14400 { + compatible = "apple,t8152-psd"; + reg = <0x3 0x3a14400 0x0 0x100>; + #power-domain-cells = <0>; + }; + + cio_psd70: power-controller@303a14600 { + compatible = "apple,t8152-psd"; + reg = <0x3 0x3a14600 0x0 0x100>; + #power-domain-cells = <0>; + }; + + cio_psd86: power-controller@303a15600 { + compatible = "apple,t8152-psd"; + reg = <0x3 0x3a15600 0x0 0x100>; + #power-domain-cells = <0>; + }; + + cio_psd87: power-controller@303a15700 { + compatible = "apple,t8152-psd"; + reg = <0x3 0x3a15700 0x0 0x100>; + #power-domain-cells = <0>; + }; + + cio_psd89: power-controller@303a15900 { + compatible = "apple,t8152-psd"; + reg = <0x3 0x3a15900 0x0 0x100>; + #power-domain-cells = <0>; + }; + + cio0_mbox: mailbox@401178080 { + compatible = "apple,t8152-cio-mailbox", + "apple,t8152-smc-mailbox"; + reg = <0x4 0x1178080 0x0 0x80>; + interrupts = , + ; + interrupt-names = "send-empty", "recv-not-empty"; + #mbox-cells = <0>; + }; + + /* acio@ avoids the bootloader's legacy cio@ register-index fixup. */ + usb4_0: acio@401ac0000 { + compatible = "apple,t8152-usb4-acio"; + reg = <0x4 0x1ac0000 0x0 0xc000>, + <0x4 0x1080000 0x0 0x26000>, + <0x4 0x1e44000 0x0 0x4000>, + <0x4 0x1c80000 0x0 0x4000>; + reg-names = "rc", "sram", "pcie-adapter", "router-ap-fw"; + #address-cells = <1>; + #size-cells = <1>; + /* The router window and the shared Gen3 TLB invalidation aperture. */ + ranges = <0x0 0x4 0x1000000 0x1000000>, + <0x1000000 0x2 0x0 0x1000>; + nonposted-mmio; + mboxes = <&cio0_mbox>; + resets = <&cio_reset 0>; + power-domains = <&cio_psd59>, <&cio_psd63>, <&cio_psd67>, <&cio_psd86>; + pinctrl-names = "lstx"; + pinctrl-0 = <&usb4_0_lstx_pins>; + lstx-gpios = <&pinctrl_aop 19 GPIO_ACTIVE_HIGH>; + thunderbolt-switch; + apple,pcie-tunnel = <&usb4_0_tunnel>; + apple,tunable-rc = + <0x0 0xfff0 0x5010>, + <0x2c 0x4 0x0>, + <0xac 0xffffffff 0x84638463>, + <0x4004 0x1ff01ff 0x1000100>, + <0x4008 0x801f 0x4>, + <0x4010 0x7f 0x40>, + <0x4014 0x801f 0x4>, + <0x401c 0x7f 0x40>, + <0x4024 0x801f 0x4>, + <0x402c 0x7f 0x40>, + <0x4030 0x801f 0x4>, + <0x4038 0xffffffff 0x1010101>, + <0x403c 0xffff 0x101>, + <0x4040 0x1 0x1>, + <0x4044 0xffffffff 0x1010101>, + <0x4048 0x1 0x1>, + <0x404c 0x801f 0x4>, + <0x8004 0x70007 0x40004>, + <0x8008 0x801f 0x4>, + <0x8010 0xf000f 0x80008>, + <0x8018 0x801f 0x4>, + <0x8020 0x70007 0x40004>, + <0x8028 0x801f 0x4>, + <0x8030 0x801f 0x4>, + <0x8038 0x801f 0x4>, + <0x8040 0x801f 0x4>, + <0x8048 0x801f 0x4>, + <0x8050 0x801f 0x4>, + <0x8058 0x801f 0x4>, + <0x8060 0x801f 0x4>; + apple,tunable-pcie-adapter = + <0x1008 0x6 0x6>; + apple,tunable-router-ap-fw = + <0x8 0xff2 0x482>; + + usb4_0_dart: iommu@a80000 { + compatible = "apple,t8152-acio-dart"; + reg = <0xa80000 0xc000>, + <0x1000100 0x10>; + reg-names = "dart", "tlbi"; + #iommu-cells = <1>; + interrupt-parent = <&aic>; + interrupts = ; + apple,dma-range = <0x100 0x0 0x10 0x0>; + 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>, + <0x4600 0x2 0x2>; + }; + + usb4_0_nhi: nhi@f00000 { + compatible = "apple,t8152-usb4-nhi"; + reg = <0xf00000 0x100000>; + reg-names = "nhi"; + interrupt-parent = <&aic>; + 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 = <&usb4_0_dart 0>, <&usb4_0_dart 1>, <&usb4_0_dart 2>, + <&usb4_0_dart 3>, <&usb4_0_dart 4>, <&usb4_0_dart 5>, + <&usb4_0_dart 6>, <&usb4_0_dart 7>, <&usb4_0_dart 8>, + <&usb4_0_dart 9>, <&usb4_0_dart 10>, <&usb4_0_dart 11>, + <&usb4_0_dart 16>, <&usb4_0_dart 17>, <&usb4_0_dart 18>, + <&usb4_0_dart 19>, <&usb4_0_dart 20>, <&usb4_0_dart 21>, + <&usb4_0_dart 22>, <&usb4_0_dart 23>, <&usb4_0_dart 24>, + <&usb4_0_dart 25>, <&usb4_0_dart 26>, <&usb4_0_dart 27>; + apple,thunderbolt-drom = + [db 00 00 00 00 00 00 00 00 5d 2d 12 e9 01 42 00 + 01 00 0f 00 01 00 08 81 80 02 80 00 00 00 08 82 + 90 01 80 00 00 00 03 83 20 02 84 05 85 09 01 00 + 05 86 09 01 00 02 87 05 88 09 01 00 0d 01 41 70 + 70 6c 65 20 49 6e 63 2e 00 06 02 69 4f 53 00 00]; + apple,tunable-nhi = + <0xf8004 0xff 0x80>, + <0xf8008 0x801f 0x4>, + <0xf8010 0x3f 0x20>, + <0xf8014 0x801f 0x4>, + <0xf801c 0x1f 0x10>, + <0xf8020 0x801f 0x4>, + <0xf8028 0xff 0x80>, + <0xf802c 0x801f 0x4>, + <0xf8034 0xff 0x80>, + <0xf8038 0x801f 0x4>, + <0xf8040 0x3f 0x20>, + <0xf8044 0x801f 0x4>, + <0xf804c 0x8007 0x1>, + <0xfc004 0x7 0x4>, + <0xfc008 0x801f 0x4>, + <0xfc010 0x7 0x4>, + <0xfc014 0x801f 0x4>, + <0xfc01c 0x7 0x4>, + <0xfc020 0x801f 0x4>, + <0xfc028 0x7 0x4>, + <0xfc02c 0x801f 0x4>, + <0xfc034 0x7 0x4>, + <0xfc038 0x801f 0x4>, + <0xfc040 0x7 0x4>, + <0xfc044 0x801f 0x4>, + <0xfc04c 0x8007 0x1>, + <0x4000 0x1000000f 0x10000002>, + <0x4004 0x1000000f 0x10000002>, + <0x4008 0x1000000f 0x10000002>, + <0x400c 0x1000000f 0x10000002>, + <0x4010 0x1000000f 0x10000002>, + <0x4014 0x1000000f 0x10000002>, + <0x4018 0x1000000f 0x10000002>, + <0x401c 0x1000000f 0x10000002>, + <0x4020 0x1000000f 0x10000002>, + <0x4024 0x1000000f 0x10000002>, + <0x4028 0x1000000f 0x10000002>, + <0x402c 0x1000000f 0x10000002>, + <0x4040 0x1000000f 0x10000002>, + <0x4044 0x1000000f 0x10000002>, + <0x4048 0x1000000f 0x10000002>, + <0x404c 0x1000000f 0x10000002>, + <0x4050 0x1000000f 0x10000002>, + <0x4054 0x1000000f 0x10000002>, + <0x4058 0x1000000f 0x10000002>, + <0x405c 0x1000000f 0x10000002>, + <0x4060 0x1000000f 0x10000002>, + <0x4064 0x1000000f 0x10000002>, + <0x4068 0x1000000f 0x10000002>, + <0x406c 0x1000000f 0x10000002>, + <0x4080 0x1000000f 0x10000002>, + <0x4084 0x1000000f 0x10000002>, + <0x4088 0x1000000f 0x10000002>, + <0x408c 0x1000000f 0x10000002>, + <0x4090 0x1000000f 0x10000002>, + <0x4094 0x1000000f 0x10000002>, + <0x4098 0x1000000f 0x10000002>, + <0x409c 0x1000000f 0x10000002>, + <0x40a0 0x1000000f 0x10000002>, + <0x40a4 0x1000000f 0x10000002>, + <0x40a8 0x1000000f 0x10000002>, + <0x40ac 0x1000000f 0x10000002>, + <0x40c0 0x1000000f 0x10000002>, + <0x40c4 0x1000000f 0x10000002>, + <0x40c8 0x1000000f 0x10000002>, + <0x40cc 0x1000000f 0x10000002>, + <0x40d0 0x1000000f 0x10000002>, + <0x40d4 0x1000000f 0x10000002>, + <0x40d8 0x1000000f 0x10000002>, + <0x40dc 0x1000000f 0x10000002>, + <0x40e0 0x1000000f 0x10000002>, + <0x40e4 0x1000000f 0x10000002>, + <0x40e8 0x1000000f 0x10000002>, + <0x40ec 0x1000000f 0x10000002>, + <0x4100 0x1000000f 0x10000002>, + <0x4104 0x1000000f 0x10000002>, + <0x4108 0x1000000f 0x10000002>, + <0x410c 0x1000000f 0x10000002>, + <0x4110 0x1000000f 0x10000002>, + <0x4114 0x1000000f 0x10000002>, + <0x4118 0x1000000f 0x10000002>, + <0x411c 0x1000000f 0x10000002>, + <0x4120 0x1000000f 0x10000002>, + <0x4124 0x1000000f 0x10000002>, + <0x4128 0x1000000f 0x10000002>, + <0x412c 0x1000000f 0x10000002>, + <0x4140 0x1000000f 0x10000002>, + <0x4144 0x1000000f 0x10000002>, + <0x4148 0x1000000f 0x10000002>, + <0x414c 0x1000000f 0x10000002>, + <0x4150 0x1000000f 0x10000002>, + <0x4154 0x1000000f 0x10000002>, + <0x4158 0x1000000f 0x10000002>, + <0x415c 0x1000000f 0x10000002>, + <0x4160 0x1000000f 0x10000002>, + <0x4164 0x1000000f 0x10000002>, + <0x4168 0x1000000f 0x10000002>, + <0x416c 0x1000000f 0x10000002>, + <0x43e4 0x7 0x7>; + }; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@1 { + reg = <1>; + usb4_0_sw: endpoint { + remote-endpoint = <&typec0_usb4>; + }; + }; + }; + }; + + cio1_mbox: mailbox@409178080 { + compatible = "apple,t8152-cio-mailbox", + "apple,t8152-smc-mailbox"; + reg = <0x4 0x9178080 0x0 0x80>; + interrupts = , + ; + interrupt-names = "send-empty", "recv-not-empty"; + #mbox-cells = <0>; + }; + + /* acio@ avoids the bootloader's legacy cio@ register-index fixup. */ + usb4_1: acio@409ac0000 { + compatible = "apple,t8152-usb4-acio"; + reg = <0x4 0x9ac0000 0x0 0xc000>, + <0x4 0x9080000 0x0 0x26000>, + <0x4 0x9e44000 0x0 0x4000>, + <0x4 0x9c80000 0x0 0x4000>; + reg-names = "rc", "sram", "pcie-adapter", "router-ap-fw"; + #address-cells = <1>; + #size-cells = <1>; + /* The router window and the shared Gen3 TLB invalidation aperture. */ + ranges = <0x0 0x4 0x9000000 0x1000000>, + <0x1000000 0x2 0x0 0x1000>; + nonposted-mmio; + mboxes = <&cio1_mbox>; + resets = <&cio_reset 1>; + power-domains = <&cio_psd60>, <&cio_psd64>, <&cio_psd68>, <&cio_psd87>; + pinctrl-names = "lstx"; + pinctrl-0 = <&usb4_1_lstx_pins>; + lstx-gpios = <&pinctrl_aop 21 GPIO_ACTIVE_HIGH>; + thunderbolt-switch; + apple,pcie-tunnel = <&usb4_1_tunnel>; + apple,tunable-rc = + <0x0 0xfff0 0x5010>, + <0x2c 0x4 0x0>, + <0xac 0xffffffff 0x84638463>, + <0x4004 0x1ff01ff 0x1000100>, + <0x4008 0x801f 0x4>, + <0x4010 0x7f 0x40>, + <0x4014 0x801f 0x4>, + <0x401c 0x7f 0x40>, + <0x4024 0x801f 0x4>, + <0x402c 0x7f 0x40>, + <0x4030 0x801f 0x4>, + <0x4038 0xffffffff 0x1010101>, + <0x403c 0xffff 0x101>, + <0x4040 0x1 0x1>, + <0x4044 0xffffffff 0x1010101>, + <0x4048 0x1 0x1>, + <0x404c 0x801f 0x4>, + <0x8004 0x70007 0x40004>, + <0x8008 0x801f 0x4>, + <0x8010 0xf000f 0x80008>, + <0x8018 0x801f 0x4>, + <0x8020 0x70007 0x40004>, + <0x8028 0x801f 0x4>, + <0x8030 0x801f 0x4>, + <0x8038 0x801f 0x4>, + <0x8040 0x801f 0x4>, + <0x8048 0x801f 0x4>, + <0x8050 0x801f 0x4>, + <0x8058 0x801f 0x4>, + <0x8060 0x801f 0x4>; + apple,tunable-pcie-adapter = + <0x1008 0x6 0x6>; + apple,tunable-router-ap-fw = + <0x8 0xff2 0x482>; + + usb4_1_dart: iommu@a80000 { + compatible = "apple,t8152-acio-dart"; + reg = <0xa80000 0xc000>, + <0x1000180 0x10>; + reg-names = "dart", "tlbi"; + #iommu-cells = <1>; + interrupt-parent = <&aic>; + interrupts = ; + apple,dma-range = <0x100 0x0 0x10 0x0>; + 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>, + <0x4600 0x2 0x2>; + }; + + usb4_1_nhi: nhi@f00000 { + compatible = "apple,t8152-usb4-nhi"; + reg = <0xf00000 0x100000>; + reg-names = "nhi"; + interrupt-parent = <&aic>; + 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 = <&usb4_1_dart 0>, <&usb4_1_dart 1>, <&usb4_1_dart 2>, + <&usb4_1_dart 3>, <&usb4_1_dart 4>, <&usb4_1_dart 5>, + <&usb4_1_dart 6>, <&usb4_1_dart 7>, <&usb4_1_dart 8>, + <&usb4_1_dart 9>, <&usb4_1_dart 10>, <&usb4_1_dart 11>, + <&usb4_1_dart 16>, <&usb4_1_dart 17>, <&usb4_1_dart 18>, + <&usb4_1_dart 19>, <&usb4_1_dart 20>, <&usb4_1_dart 21>, + <&usb4_1_dart 22>, <&usb4_1_dart 23>, <&usb4_1_dart 24>, + <&usb4_1_dart 25>, <&usb4_1_dart 26>, <&usb4_1_dart 27>; + apple,thunderbolt-drom = + [c8 01 00 00 00 00 00 00 00 06 7e 74 db 01 42 00 + 01 00 0f 00 01 00 08 81 81 02 81 00 00 00 08 82 + 91 01 81 00 00 00 03 83 20 02 84 05 85 09 01 00 + 05 86 09 01 00 02 87 05 88 09 01 00 0d 01 41 70 + 70 6c 65 20 49 6e 63 2e 00 06 02 69 4f 53 00 00]; + apple,tunable-nhi = + <0xf8004 0xff 0x80>, + <0xf8008 0x801f 0x4>, + <0xf8010 0x3f 0x20>, + <0xf8014 0x801f 0x4>, + <0xf801c 0x1f 0x10>, + <0xf8020 0x801f 0x4>, + <0xf8028 0xff 0x80>, + <0xf802c 0x801f 0x4>, + <0xf8034 0xff 0x80>, + <0xf8038 0x801f 0x4>, + <0xf8040 0x3f 0x20>, + <0xf8044 0x801f 0x4>, + <0xf804c 0x8007 0x1>, + <0xfc004 0x7 0x4>, + <0xfc008 0x801f 0x4>, + <0xfc010 0x7 0x4>, + <0xfc014 0x801f 0x4>, + <0xfc01c 0x7 0x4>, + <0xfc020 0x801f 0x4>, + <0xfc028 0x7 0x4>, + <0xfc02c 0x801f 0x4>, + <0xfc034 0x7 0x4>, + <0xfc038 0x801f 0x4>, + <0xfc040 0x7 0x4>, + <0xfc044 0x801f 0x4>, + <0xfc04c 0x8007 0x1>, + <0x4000 0x1000000f 0x10000002>, + <0x4004 0x1000000f 0x10000002>, + <0x4008 0x1000000f 0x10000002>, + <0x400c 0x1000000f 0x10000002>, + <0x4010 0x1000000f 0x10000002>, + <0x4014 0x1000000f 0x10000002>, + <0x4018 0x1000000f 0x10000002>, + <0x401c 0x1000000f 0x10000002>, + <0x4020 0x1000000f 0x10000002>, + <0x4024 0x1000000f 0x10000002>, + <0x4028 0x1000000f 0x10000002>, + <0x402c 0x1000000f 0x10000002>, + <0x4040 0x1000000f 0x10000002>, + <0x4044 0x1000000f 0x10000002>, + <0x4048 0x1000000f 0x10000002>, + <0x404c 0x1000000f 0x10000002>, + <0x4050 0x1000000f 0x10000002>, + <0x4054 0x1000000f 0x10000002>, + <0x4058 0x1000000f 0x10000002>, + <0x405c 0x1000000f 0x10000002>, + <0x4060 0x1000000f 0x10000002>, + <0x4064 0x1000000f 0x10000002>, + <0x4068 0x1000000f 0x10000002>, + <0x406c 0x1000000f 0x10000002>, + <0x4080 0x1000000f 0x10000002>, + <0x4084 0x1000000f 0x10000002>, + <0x4088 0x1000000f 0x10000002>, + <0x408c 0x1000000f 0x10000002>, + <0x4090 0x1000000f 0x10000002>, + <0x4094 0x1000000f 0x10000002>, + <0x4098 0x1000000f 0x10000002>, + <0x409c 0x1000000f 0x10000002>, + <0x40a0 0x1000000f 0x10000002>, + <0x40a4 0x1000000f 0x10000002>, + <0x40a8 0x1000000f 0x10000002>, + <0x40ac 0x1000000f 0x10000002>, + <0x40c0 0x1000000f 0x10000002>, + <0x40c4 0x1000000f 0x10000002>, + <0x40c8 0x1000000f 0x10000002>, + <0x40cc 0x1000000f 0x10000002>, + <0x40d0 0x1000000f 0x10000002>, + <0x40d4 0x1000000f 0x10000002>, + <0x40d8 0x1000000f 0x10000002>, + <0x40dc 0x1000000f 0x10000002>, + <0x40e0 0x1000000f 0x10000002>, + <0x40e4 0x1000000f 0x10000002>, + <0x40e8 0x1000000f 0x10000002>, + <0x40ec 0x1000000f 0x10000002>, + <0x4100 0x1000000f 0x10000002>, + <0x4104 0x1000000f 0x10000002>, + <0x4108 0x1000000f 0x10000002>, + <0x410c 0x1000000f 0x10000002>, + <0x4110 0x1000000f 0x10000002>, + <0x4114 0x1000000f 0x10000002>, + <0x4118 0x1000000f 0x10000002>, + <0x411c 0x1000000f 0x10000002>, + <0x4120 0x1000000f 0x10000002>, + <0x4124 0x1000000f 0x10000002>, + <0x4128 0x1000000f 0x10000002>, + <0x412c 0x1000000f 0x10000002>, + <0x4140 0x1000000f 0x10000002>, + <0x4144 0x1000000f 0x10000002>, + <0x4148 0x1000000f 0x10000002>, + <0x414c 0x1000000f 0x10000002>, + <0x4150 0x1000000f 0x10000002>, + <0x4154 0x1000000f 0x10000002>, + <0x4158 0x1000000f 0x10000002>, + <0x415c 0x1000000f 0x10000002>, + <0x4160 0x1000000f 0x10000002>, + <0x4164 0x1000000f 0x10000002>, + <0x4168 0x1000000f 0x10000002>, + <0x416c 0x1000000f 0x10000002>, + <0x43e4 0x7 0x7>; + }; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@1 { + reg = <1>; + usb4_1_sw: endpoint { + remote-endpoint = <&typec1_usb4>; + }; + }; + }; + }; + + cio3_mbox: mailbox@411178080 { + compatible = "apple,t8152-cio-mailbox", + "apple,t8152-smc-mailbox"; + reg = <0x4 0x11178080 0x0 0x80>; + interrupts = , + ; + interrupt-names = "send-empty", "recv-not-empty"; + #mbox-cells = <0>; + }; + + /* acio@ avoids the bootloader's legacy cio@ register-index fixup. */ + usb4_3: acio@411ac0000 { + compatible = "apple,t8152-usb4-acio"; + reg = <0x4 0x11ac0000 0x0 0xc000>, + <0x4 0x11080000 0x0 0x26000>, + <0x4 0x11e44000 0x0 0x4000>, + <0x4 0x11c80000 0x0 0x4000>; + reg-names = "rc", "sram", "pcie-adapter", "router-ap-fw"; + #address-cells = <1>; + #size-cells = <1>; + /* The router window and the shared Gen3 TLB invalidation aperture. */ + ranges = <0x0 0x4 0x11000000 0x1000000>, + <0x1000000 0x2 0x0 0x1000>; + nonposted-mmio; + mboxes = <&cio3_mbox>; + resets = <&cio_reset 3>; + power-domains = <&cio_psd62>, <&cio_psd66>, <&cio_psd70>, <&cio_psd89>; + pinctrl-names = "lstx"; + pinctrl-0 = <&usb4_3_lstx_pins>; + lstx-gpios = <&pinctrl_aop 25 GPIO_ACTIVE_HIGH>; + thunderbolt-switch; + apple,pcie-tunnel = <&usb4_3_tunnel>; + apple,tunable-rc = + <0x0 0xfff0 0x5010>, + <0x2c 0x4 0x0>, + <0xac 0xffffffff 0x84638463>, + <0x4004 0x1ff01ff 0x1000100>, + <0x4008 0x801f 0x4>, + <0x4010 0x7f 0x40>, + <0x4014 0x801f 0x4>, + <0x401c 0x7f 0x40>, + <0x4024 0x801f 0x4>, + <0x402c 0x7f 0x40>, + <0x4030 0x801f 0x4>, + <0x4038 0xffffffff 0x1010101>, + <0x403c 0xffff 0x101>, + <0x4040 0x1 0x1>, + <0x4044 0xffffffff 0x1010101>, + <0x4048 0x1 0x1>, + <0x404c 0x801f 0x4>, + <0x8004 0x70007 0x40004>, + <0x8008 0x801f 0x4>, + <0x8010 0xf000f 0x80008>, + <0x8018 0x801f 0x4>, + <0x8020 0x70007 0x40004>, + <0x8028 0x801f 0x4>, + <0x8030 0x801f 0x4>, + <0x8038 0x801f 0x4>, + <0x8040 0x801f 0x4>, + <0x8048 0x801f 0x4>, + <0x8050 0x801f 0x4>, + <0x8058 0x801f 0x4>, + <0x8060 0x801f 0x4>; + apple,tunable-pcie-adapter = + <0x1008 0x6 0x6>; + apple,tunable-router-ap-fw = + <0x8 0xff2 0x482>; + + usb4_3_dart: iommu@a80000 { + compatible = "apple,t8152-acio-dart"; + reg = <0xa80000 0xc000>, + <0x1000280 0x10>; + reg-names = "dart", "tlbi"; + #iommu-cells = <1>; + interrupt-parent = <&aic>; + interrupts = ; + apple,dma-range = <0x100 0x0 0x10 0x0>; + 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>, + <0x4600 0x2 0x2>; + }; + + usb4_3_nhi: nhi@f00000 { + compatible = "apple,t8152-usb4-nhi"; + reg = <0xf00000 0x100000>; + reg-names = "nhi"; + interrupt-parent = <&aic>; + 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 = <&usb4_3_dart 0>, <&usb4_3_dart 1>, <&usb4_3_dart 2>, + <&usb4_3_dart 3>, <&usb4_3_dart 4>, <&usb4_3_dart 5>, + <&usb4_3_dart 6>, <&usb4_3_dart 7>, <&usb4_3_dart 8>, + <&usb4_3_dart 9>, <&usb4_3_dart 10>, <&usb4_3_dart 11>, + <&usb4_3_dart 16>, <&usb4_3_dart 17>, <&usb4_3_dart 18>, + <&usb4_3_dart 19>, <&usb4_3_dart 20>, <&usb4_3_dart 21>, + <&usb4_3_dart 22>, <&usb4_3_dart 23>, <&usb4_3_dart 24>, + <&usb4_3_dart 25>, <&usb4_3_dart 26>, <&usb4_3_dart 27>; + apple,thunderbolt-drom = + [ee 03 00 00 00 00 00 00 00 4e bc d0 4b 01 3d 00 + 01 00 0f 00 01 00 08 81 83 02 83 00 00 00 08 82 + 93 01 83 00 00 00 03 83 20 02 84 05 85 09 01 00 + 05 86 09 01 00 02 87 0d 01 41 70 70 6c 65 20 49 + 6e 63 2e 00 06 02 69 4f 53 00 00 00]; + apple,tunable-nhi = + <0xf8004 0xff 0x80>, + <0xf8008 0x801f 0x4>, + <0xf8010 0x3f 0x20>, + <0xf8014 0x801f 0x4>, + <0xf801c 0x1f 0x10>, + <0xf8020 0x801f 0x4>, + <0xf8028 0xff 0x80>, + <0xf802c 0x801f 0x4>, + <0xf8034 0xff 0x80>, + <0xf8038 0x801f 0x4>, + <0xf8040 0x3f 0x20>, + <0xf8044 0x801f 0x4>, + <0xf804c 0x8007 0x1>, + <0xfc004 0x7 0x4>, + <0xfc008 0x801f 0x4>, + <0xfc010 0x7 0x4>, + <0xfc014 0x801f 0x4>, + <0xfc01c 0x7 0x4>, + <0xfc020 0x801f 0x4>, + <0xfc028 0x7 0x4>, + <0xfc02c 0x801f 0x4>, + <0xfc034 0x7 0x4>, + <0xfc038 0x801f 0x4>, + <0xfc040 0x7 0x4>, + <0xfc044 0x801f 0x4>, + <0xfc04c 0x8007 0x1>, + <0x4000 0x1000000f 0x10000002>, + <0x4004 0x1000000f 0x10000002>, + <0x4008 0x1000000f 0x10000002>, + <0x400c 0x1000000f 0x10000002>, + <0x4010 0x1000000f 0x10000002>, + <0x4014 0x1000000f 0x10000002>, + <0x4018 0x1000000f 0x10000002>, + <0x401c 0x1000000f 0x10000002>, + <0x4020 0x1000000f 0x10000002>, + <0x4024 0x1000000f 0x10000002>, + <0x4028 0x1000000f 0x10000002>, + <0x402c 0x1000000f 0x10000002>, + <0x4040 0x1000000f 0x10000002>, + <0x4044 0x1000000f 0x10000002>, + <0x4048 0x1000000f 0x10000002>, + <0x404c 0x1000000f 0x10000002>, + <0x4050 0x1000000f 0x10000002>, + <0x4054 0x1000000f 0x10000002>, + <0x4058 0x1000000f 0x10000002>, + <0x405c 0x1000000f 0x10000002>, + <0x4060 0x1000000f 0x10000002>, + <0x4064 0x1000000f 0x10000002>, + <0x4068 0x1000000f 0x10000002>, + <0x406c 0x1000000f 0x10000002>, + <0x4080 0x1000000f 0x10000002>, + <0x4084 0x1000000f 0x10000002>, + <0x4088 0x1000000f 0x10000002>, + <0x408c 0x1000000f 0x10000002>, + <0x4090 0x1000000f 0x10000002>, + <0x4094 0x1000000f 0x10000002>, + <0x4098 0x1000000f 0x10000002>, + <0x409c 0x1000000f 0x10000002>, + <0x40a0 0x1000000f 0x10000002>, + <0x40a4 0x1000000f 0x10000002>, + <0x40a8 0x1000000f 0x10000002>, + <0x40ac 0x1000000f 0x10000002>, + <0x40c0 0x1000000f 0x10000002>, + <0x40c4 0x1000000f 0x10000002>, + <0x40c8 0x1000000f 0x10000002>, + <0x40cc 0x1000000f 0x10000002>, + <0x40d0 0x1000000f 0x10000002>, + <0x40d4 0x1000000f 0x10000002>, + <0x40d8 0x1000000f 0x10000002>, + <0x40dc 0x1000000f 0x10000002>, + <0x40e0 0x1000000f 0x10000002>, + <0x40e4 0x1000000f 0x10000002>, + <0x40e8 0x1000000f 0x10000002>, + <0x40ec 0x1000000f 0x10000002>, + <0x4100 0x1000000f 0x10000002>, + <0x4104 0x1000000f 0x10000002>, + <0x4108 0x1000000f 0x10000002>, + <0x410c 0x1000000f 0x10000002>, + <0x4110 0x1000000f 0x10000002>, + <0x4114 0x1000000f 0x10000002>, + <0x4118 0x1000000f 0x10000002>, + <0x411c 0x1000000f 0x10000002>, + <0x4120 0x1000000f 0x10000002>, + <0x4124 0x1000000f 0x10000002>, + <0x4128 0x1000000f 0x10000002>, + <0x412c 0x1000000f 0x10000002>, + <0x4140 0x1000000f 0x10000002>, + <0x4144 0x1000000f 0x10000002>, + <0x4148 0x1000000f 0x10000002>, + <0x414c 0x1000000f 0x10000002>, + <0x4150 0x1000000f 0x10000002>, + <0x4154 0x1000000f 0x10000002>, + <0x4158 0x1000000f 0x10000002>, + <0x415c 0x1000000f 0x10000002>, + <0x4160 0x1000000f 0x10000002>, + <0x4164 0x1000000f 0x10000002>, + <0x4168 0x1000000f 0x10000002>, + <0x416c 0x1000000f 0x10000002>, + <0x43e4 0x7 0x7>; + }; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@1 { + reg = <1>; + usb4_3_sw: endpoint { + remote-endpoint = <&typec3_usb4>; + }; + }; + }; + }; + }; + + usb4_0_tunnel: usb4-pcie-tunnel-0 { + #address-cells = <2>; + #size-cells = <2>; + ranges; + nonposted-mmio; + + usb4_0_pcie_dart: iommu@404000000 { + compatible = "apple,t8152-pciec-dart"; + reg = <0x4 0x4000000 0x0 0xc000>, + <0x2 0x100 0x0 0x10>; + reg-names = "dart", "tlbi"; + #iommu-cells = <1>; + interrupt-parent = <&aic>; + interrupts = ; + power-domains = <&cio_psd86>; + apple,dma-range = <0x100 0x80000000 0x0 0x7ff00000>; + apple,tunable = + <0x20c 0x80000121 0x80000121>, + <0x220 0xf0f 0xf0f>, + <0x224 0xffff 0x909>, + <0x300 0x1f31 0x1>, + <0x308 0x3ffffffc 0x10000000>, + <0x310 0x3ffffffc 0x3ffffffc>, + <0x4600 0x2 0x2>; + }; + + usb4_0_pcie: pcie@1c50000000 { + compatible = "apple,t8152-pciec"; + device_type = "pci"; + reg = <0x1c 0x50000000 0x0 0x10000000>, + <0x4 0x4034000 0x0 0x4000>, + <0x4 0x4020000 0x0 0x8000>, + <0x4 0x4038000 0x0 0x4000>, + <0x4 0x4060000 0x0 0x4000>, + <0x4 0x402c000 0x0 0x4000>, + <0x4 0x4028000 0x0 0x4000>; + reg-names = "config", "rc", "port0", "fabric", "debug", "ltssm", "intr2axi"; + interrupt-parent = <&aic>; + interrupts = ; + power-domains = <&cio_psd86>; + apple,pciec-kernel-init; + msi-controller; + msi-parent = <&usb4_0_pcie>; + msi-ranges = <&aic AIC_IRQ 1975 IRQ_TYPE_EDGE_RISING 32>; + apple,msi-vector-base = <96>; + iommu-map = <0 &usb4_0_pcie_dart 0 0x40>; + iommu-map-mask = <0x3f>; + linux,pci-domain = <1>; + bus-range = <0 0x7f>; + #address-cells = <3>; + #size-cells = <2>; + ranges = <0x43000000 0x8 0x0 0x8 0x0 0x2 0x0>, + <0x2000000 0x0 0x100000 0xa 0x100000 0x0 0x3ff00000>, + <0x42000000 0x0 0x40000000 0xa 0x40000000 0x0 0x40000000>; + apple,tunable-debug = + <0x1000 0x1 0x0>; + apple,tunable-fabric = + <0x4 0x3f003f 0x200020>, + <0x8 0x1 0x1>, + <0xc 0x1 0x1>, + <0x10 0x801f 0x4>, + <0x18 0x1ff 0x100>, + <0x1c 0x1 0x1>, + <0x20 0x801f 0x4>, + <0x28 0x1f 0x10>, + <0x2c 0x801f 0x4>, + <0x34 0x3f 0x20>, + <0x38 0x801f 0x4>, + <0x40 0x3f 0x20>, + <0x44 0x801f 0x4>, + <0x4c 0x10001 0x10001>, + <0x50 0x1 0x1>, + <0x54 0x1 0x1>, + <0x58 0x801f 0x4>, + <0x60 0x7f007f 0x450045>, + <0x64 0x801f 0x4>, + <0x6c 0x1f001f 0x100010>, + <0x70 0x801f 0x4>, + <0x78 0x801f 0x4>, + <0x80 0x1 0x1>, + <0x84 0x1 0x1>, + <0x88 0x801f 0x4>, + <0x90 0x1 0x1>, + <0x94 0x801f 0x4>, + <0x9c 0x1 0x1>, + <0xa0 0x801f 0x4>, + <0xa8 0x1 0x1>, + <0xac 0x1 0x1>, + <0xb0 0x801f 0x4>, + <0xb8 0x801f 0x4>, + <0xc0 0x801f 0x4>; + apple,tunable-rc = + <0x78 0x7000 0x0>, + <0x718 0x7c000 0x0>, + <0x814 0xffffffff 0x2000f060>, + <0x8bc 0x1 0x0>; + + usb4_0_pcie_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 &usb4_0_pcie_port 0 0 0 0>, + <0 0 0 2 &usb4_0_pcie_port 0 0 0 1>, + <0 0 0 3 &usb4_0_pcie_port 0 0 0 2>, + <0 0 0 4 &usb4_0_pcie_port 0 0 0 3>; + apple,tunable = + <0x140 0x1 0x1>, + <0x2a0 0x7e 0xa>; + }; + }; + }; + + usb4_1_tunnel: usb4-pcie-tunnel-1 { + #address-cells = <2>; + #size-cells = <2>; + ranges; + nonposted-mmio; + + usb4_1_pcie_dart: iommu@40c000000 { + compatible = "apple,t8152-pciec-dart"; + reg = <0x4 0xc000000 0x0 0xc000>, + <0x2 0x180 0x0 0x10>; + reg-names = "dart", "tlbi"; + #iommu-cells = <1>; + interrupt-parent = <&aic>; + interrupts = ; + power-domains = <&cio_psd87>; + apple,dma-range = <0x100 0x80000000 0x0 0x7ff00000>; + apple,tunable = + <0x20c 0x80000121 0x80000121>, + <0x220 0xf0f 0xf0f>, + <0x224 0xffff 0x909>, + <0x300 0x1f31 0x1>, + <0x308 0x3ffffffc 0x10000000>, + <0x310 0x3ffffffc 0x3ffffffc>, + <0x4600 0x2 0x2>; + }; + + usb4_1_pcie: pcie@1c60000000 { + compatible = "apple,t8152-pciec"; + device_type = "pci"; + reg = <0x1c 0x60000000 0x0 0x10000000>, + <0x4 0xc034000 0x0 0x4000>, + <0x4 0xc020000 0x0 0x8000>, + <0x4 0xc038000 0x0 0x4000>, + <0x4 0xc060000 0x0 0x4000>, + <0x4 0xc02c000 0x0 0x4000>, + <0x4 0xc028000 0x0 0x4000>; + reg-names = "config", "rc", "port0", "fabric", "debug", "ltssm", "intr2axi"; + interrupt-parent = <&aic>; + interrupts = ; + power-domains = <&cio_psd87>; + apple,pciec-kernel-init; + msi-controller; + msi-parent = <&usb4_1_pcie>; + msi-ranges = <&aic AIC_IRQ 2007 IRQ_TYPE_EDGE_RISING 32>; + apple,msi-vector-base = <128>; + iommu-map = <0 &usb4_1_pcie_dart 0 0x40>; + iommu-map-mask = <0x3f>; + linux,pci-domain = <2>; + bus-range = <0 0x7f>; + #address-cells = <3>; + #size-cells = <2>; + ranges = <0x43000000 0xc 0x0 0xc 0x0 0x2 0x0>, + <0x2000000 0x0 0x100000 0xe 0x100000 0x0 0x3ff00000>, + <0x42000000 0x0 0x40000000 0xe 0x40000000 0x0 0x40000000>; + apple,tunable-debug = + <0x1000 0x1 0x0>; + apple,tunable-fabric = + <0x4 0x3f003f 0x200020>, + <0x8 0x1 0x1>, + <0xc 0x1 0x1>, + <0x10 0x801f 0x4>, + <0x18 0x1ff 0x100>, + <0x1c 0x1 0x1>, + <0x20 0x801f 0x4>, + <0x28 0x1f 0x10>, + <0x2c 0x801f 0x4>, + <0x34 0x3f 0x20>, + <0x38 0x801f 0x4>, + <0x40 0x3f 0x20>, + <0x44 0x801f 0x4>, + <0x4c 0x10001 0x10001>, + <0x50 0x1 0x1>, + <0x54 0x1 0x1>, + <0x58 0x801f 0x4>, + <0x60 0x7f007f 0x450045>, + <0x64 0x801f 0x4>, + <0x6c 0x1f001f 0x100010>, + <0x70 0x801f 0x4>, + <0x78 0x801f 0x4>, + <0x80 0x1 0x1>, + <0x84 0x1 0x1>, + <0x88 0x801f 0x4>, + <0x90 0x1 0x1>, + <0x94 0x801f 0x4>, + <0x9c 0x1 0x1>, + <0xa0 0x801f 0x4>, + <0xa8 0x1 0x1>, + <0xac 0x1 0x1>, + <0xb0 0x801f 0x4>, + <0xb8 0x801f 0x4>, + <0xc0 0x801f 0x4>; + apple,tunable-rc = + <0x78 0x7000 0x0>, + <0x718 0x7c000 0x0>, + <0x814 0xffffffff 0x2000f060>, + <0x8bc 0x1 0x0>; + + usb4_1_pcie_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 &usb4_1_pcie_port 0 0 0 0>, + <0 0 0 2 &usb4_1_pcie_port 0 0 0 1>, + <0 0 0 3 &usb4_1_pcie_port 0 0 0 2>, + <0 0 0 4 &usb4_1_pcie_port 0 0 0 3>; + apple,tunable = + <0x140 0x1 0x1>, + <0x2a0 0x7e 0xa>; + }; + }; + }; + + usb4_3_tunnel: usb4-pcie-tunnel-3 { + #address-cells = <2>; + #size-cells = <2>; + ranges; + nonposted-mmio; + + usb4_3_pcie_dart: iommu@414000000 { + compatible = "apple,t8152-pciec-dart"; + reg = <0x4 0x14000000 0x0 0xc000>, + <0x2 0x280 0x0 0x10>; + reg-names = "dart", "tlbi"; + #iommu-cells = <1>; + interrupt-parent = <&aic>; + interrupts = ; + power-domains = <&cio_psd89>; + apple,dma-range = <0x100 0x80000000 0x0 0x7ff00000>; + apple,tunable = + <0x20c 0x80000121 0x80000121>, + <0x220 0xf0f 0xf0f>, + <0x224 0xffff 0x909>, + <0x300 0x1f31 0x1>, + <0x308 0x3ffffffc 0x10000000>, + <0x310 0x3ffffffc 0x3ffffffc>, + <0x4600 0x2 0x2>; + }; + + usb4_3_pcie: pcie@1c80000000 { + compatible = "apple,t8152-pciec"; + device_type = "pci"; + reg = <0x1c 0x80000000 0x0 0x10000000>, + <0x4 0x14034000 0x0 0x4000>, + <0x4 0x14020000 0x0 0x8000>, + <0x4 0x14038000 0x0 0x4000>, + <0x4 0x14060000 0x0 0x4000>, + <0x4 0x1402c000 0x0 0x4000>, + <0x4 0x14028000 0x0 0x4000>; + reg-names = "config", "rc", "port0", "fabric", "debug", "ltssm", "intr2axi"; + interrupt-parent = <&aic>; + interrupts = ; + power-domains = <&cio_psd89>; + apple,pciec-kernel-init; + msi-controller; + msi-parent = <&usb4_3_pcie>; + msi-ranges = <&aic AIC_IRQ 2071 IRQ_TYPE_EDGE_RISING 32>; + apple,msi-vector-base = <192>; + iommu-map = <0 &usb4_3_pcie_dart 0 0x40>; + iommu-map-mask = <0x3f>; + linux,pci-domain = <4>; + bus-range = <0 0x7f>; + #address-cells = <3>; + #size-cells = <2>; + ranges = <0x43000000 0x14 0x0 0x14 0x0 0x2 0x0>, + <0x2000000 0x0 0x100000 0x16 0x100000 0x0 0x3ff00000>, + <0x42000000 0x0 0x40000000 0x16 0x40000000 0x0 0x40000000>; + apple,tunable-debug = + <0x1000 0x1 0x0>; + apple,tunable-fabric = + <0x4 0x3f003f 0x200020>, + <0x8 0x1 0x1>, + <0xc 0x1 0x1>, + <0x10 0x801f 0x4>, + <0x18 0x1ff 0x100>, + <0x1c 0x1 0x1>, + <0x20 0x801f 0x4>, + <0x28 0x1f 0x10>, + <0x2c 0x801f 0x4>, + <0x34 0x3f 0x20>, + <0x38 0x801f 0x4>, + <0x40 0x3f 0x20>, + <0x44 0x801f 0x4>, + <0x4c 0x10001 0x10001>, + <0x50 0x1 0x1>, + <0x54 0x1 0x1>, + <0x58 0x801f 0x4>, + <0x60 0x7f007f 0x450045>, + <0x64 0x801f 0x4>, + <0x6c 0x1f001f 0x100010>, + <0x70 0x801f 0x4>, + <0x78 0x801f 0x4>, + <0x80 0x1 0x1>, + <0x84 0x1 0x1>, + <0x88 0x801f 0x4>, + <0x90 0x1 0x1>, + <0x94 0x801f 0x4>, + <0x9c 0x1 0x1>, + <0xa0 0x801f 0x4>, + <0xa8 0x1 0x1>, + <0xac 0x1 0x1>, + <0xb0 0x801f 0x4>, + <0xb8 0x801f 0x4>, + <0xc0 0x801f 0x4>; + apple,tunable-rc = + <0x78 0x7000 0x0>, + <0x718 0x7c000 0x0>, + <0x814 0xffffffff 0x2000f060>, + <0x8bc 0x1 0x0>; + + usb4_3_pcie_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 &usb4_3_pcie_port 0 0 0 0>, + <0 0 0 2 &usb4_3_pcie_port 0 0 0 1>, + <0 0 0 3 &usb4_3_pcie_port 0 0 0 2>, + <0 0 0 4 &usb4_3_pcie_port 0 0 0 3>; + apple,tunable = + <0x140 0x1 0x1>, + <0x2a0 0x7e 0xa>; + }; + }; + }; +}; + +&pinctrl_aop { + usb4_0_lstx_pins: usb4-0-lstx-pins { + pinmux = <0x10013>; + }; + + usb4_1_lstx_pins: usb4-1-lstx-pins { + pinmux = <0x10015>; + }; + + usb4_3_lstx_pins: usb4-3-lstx-pins { + pinmux = <0x10019>; + }; +}; + +/* USB-C Back-middle: its router */ +&typec0 { + ports { + port@4 { + reg = <4>; + + typec0_usb4: endpoint { + remote-endpoint = <&usb4_0_sw>; + }; + }; + }; +}; + +/* USB-C Back-left: its router */ +&typec1 { + ports { + port@4 { + reg = <4>; + + typec1_usb4: endpoint { + remote-endpoint = <&usb4_1_sw>; + }; + }; + }; +}; + +/* USB-C Back-right: its router */ +&typec3 { + ports { + port@4 { + reg = <4>; + + typec3_usb4: endpoint { + remote-endpoint = <&usb4_3_sw>; + }; + }; + }; +}; diff --git a/arch/arm64/boot/dts/apple/t8152-j873g.dts b/arch/arm64/boot/dts/apple/t8152-j873g.dts index 5c229e74d5b0a..c3416ac0fd457 100644 --- a/arch/arm64/boot/dts/apple/t8152-j873g.dts +++ b/arch/arm64/boot/dts/apple/t8152-j873g.dts @@ -504,3 +504,4 @@ #include "t8152-j873-audio.dtsi" #include "t8152-j873-dcp.dtsi" #include "t8152-j873-avd.dtsi" +#include "t8152-j873-usb4.dtsi" From 16a3d4f5c420f3cd61052553ded76147196141e8 Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Sun, 22 Nov 2026 15:30:42 +0100 Subject: [PATCH 30/31] arm64: dts: apple: t8152-j873g: power domains for the ACIO DARTs Every enabled DART must name the power state of the engine it serves (scripts/dtc/apple-dart-pd-check.py). The three rear routers' NHI DARTs named none. A DART sits inside its router, so it takes the router's first PSD service (59, 60 and 62: ADT acioN power-gates), the one the router powers up first and down last. The router populates the DART only once it is powered and its firmware is ready, and removes it before it powers down, so the DART's vote never holds the router on after a stop. Signed-off-by: Thomas Glanzmann --- arch/arm64/boot/dts/apple/t8152-j873-usb4.dtsi | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm64/boot/dts/apple/t8152-j873-usb4.dtsi b/arch/arm64/boot/dts/apple/t8152-j873-usb4.dtsi index ff1579e5d08f3..41083f7ebccaa 100644 --- a/arch/arm64/boot/dts/apple/t8152-j873-usb4.dtsi +++ b/arch/arm64/boot/dts/apple/t8152-j873-usb4.dtsi @@ -173,6 +173,7 @@ #iommu-cells = <1>; interrupt-parent = <&aic>; interrupts = ; + power-domains = <&cio_psd59>; apple,dma-range = <0x100 0x0 0x10 0x0>; apple,tunable = <0x20c 0x80000121 0x80000121>, @@ -442,6 +443,7 @@ #iommu-cells = <1>; interrupt-parent = <&aic>; interrupts = ; + power-domains = <&cio_psd60>; apple,dma-range = <0x100 0x0 0x10 0x0>; apple,tunable = <0x20c 0x80000121 0x80000121>, @@ -711,6 +713,7 @@ #iommu-cells = <1>; interrupt-parent = <&aic>; interrupts = ; + power-domains = <&cio_psd62>; apple,dma-range = <0x100 0x0 0x10 0x0>; apple,tunable = <0x20c 0x80000121 0x80000121>, From da3173dfb4c925b8f412fb0f28b4bdb2ec93a077 Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Tue, 24 Nov 2026 12:33:41 +0100 Subject: [PATCH 31/31] arm64: dts: apple: t8152-j873g: take the USB-C tunables and DROMs from the bootloader The J873g's USB4 and ATC PHY nodes carried one Mac's ADT tables (26A434 and 27.2 are identical): - the routers' RC, PCIe adapter, AP firmware and NHI tables; - the ACIO and PCIe-C DARTs' tables; - the PCIe-C ports' debug, fabric, RC and port tables; - the four ATC PHYs' common and lane tables; - the routers' DROMs. One ATC row (ACIOPHY_CMN_DFLT at 0x860) differs between the four PHYs of the same Mac, so it is calibration, and each DROM carries the host router's UID. None of it belongs in a public device tree. Take them from the Mac's own ADT at boot, as on the J813 (linux#2142 with aura#302 and aura#435). The bootloader fills: - the routers' and NHIs' tables and the DROMs, with a per-Mac UID, through usb4-N-acio, usb4-N-pcie-adapter and usb4-N-nhi, for ADT acio0, acio1 and acio3; - the PCIe-C ports' tables through usb4-N-pcie (ADT apciecN); - the ACIO and PCIe-C DARTs' tables, matched by address; - the ATC PHYs' tables through atcphy0-3 (ADT atc-phy0-3): the USB3 set for the fixed-USB3 front port, the CIO set for the rear ports. This needs aura's T8152 support for these copies. With an older loader nothing is filled, and the drivers refuse the ports rather than run them untuned: the ATC PHYs ("Failed to read tunable"), the routers and NHIs ("Missing bootloader ... tuning") and the PCIe-C ports. Checked offline against the 26A434 and 27.2 ADTs: the bootloader's copy reproduces every removed table row for row (all four ATC PHYs, all three routers, their NHIs, DARTs and PCIe-C ports), and the DROMs differ only in the UID it writes. Signed-off-by: Thomas Glanzmann --- arch/arm64/boot/dts/apple/t8152-j873-usb.dtsi | 855 +----------------- .../arm64/boot/dts/apple/t8152-j873-usb4.dtsi | 683 +------------- 2 files changed, 51 insertions(+), 1487 deletions(-) diff --git a/arch/arm64/boot/dts/apple/t8152-j873-usb.dtsi b/arch/arm64/boot/dts/apple/t8152-j873-usb.dtsi index 83c99eced8749..24154e986e380 100644 --- a/arch/arm64/boot/dts/apple/t8152-j873-usb.dtsi +++ b/arch/arm64/boot/dts/apple/t8152-j873-usb.dtsi @@ -40,6 +40,14 @@ }; / { + aliases { + /* aura copies each ATC PHY's tunables from ADT atc-phyN here. */ + atcphy0 = &atc0_phy; + atcphy1 = &atc1_phy; + atcphy2 = &atc2_phy; + atcphy3 = &atc3_phy; + }; + soc { dwc3_1_dart_1: iommu@40b040000 { compatible = "apple,t8152-dart", "apple,t8110-dart"; @@ -285,14 +293,12 @@ /* * ADT atc-phy2 as usb-drd2's USB3 PHY: the hub is wired to its * lanes directly. The power domains are listed in the order the - * PHY needs them powered up. The tunables are the atc-phy2 - * tunable_* groups of the 26A434 ADT that apply to USB3 on lane - * 0, in the order they are applied: common-a before lane 0 is - * powered up and the crossbar set, then common-b and lane0-usb. - * Some of them differ between the four ATCs of the same machine, - * so they likely carry per-device calibration. There is no - * atcphy2 alias: the loader's ATC tunable copy would then replace - * these with values for another PHY layout. + * PHY needs them powered up. Its tunables are the atc-phy2 + * tunable_* groups that apply to USB3 on lane 0, applied as + * common-a before lane 0 is powered up and the crossbar set, then + * common-b and lane0-usb. Some of them differ between the four + * ATCs of the same Mac (calibration), so the bootloader copies + * them from the Mac's own ADT, through the atcphy2 alias. */ atc2_phy: phy@383000000 { compatible = "apple,t8152-atcphy"; @@ -303,186 +309,13 @@ apple,fixed-usb3; power-domains = <&ps_atc2_usb_aon>, <&ps_atc2_common>, <&ps_atc2_common_dp_0>, <&ps_atc2_common_dp_1>; - apple,tunable-common-a = - /* ACIOPHY_CMN_DFLT */ - <0x00800 0x00fc0000 0x00fc0000>, - <0x0084c 0x000ff800 0x000ff800>, - <0x0085c 0x000000ff 0x00000080>, - <0x00860 0x007fffff 0x0052bc27>, - <0x00864 0x02c00000 0x00800000>, - /* CIOPLL_CORE_DFLT */ - <0x01614 0x0003ffc0 0x0001e5c0>, - <0x01640 0x00000007 0x00000003>, - <0x01668 0x00000ffc 0x000005f0>; - apple,tunable-common-b = - /* ATC_FABRIC */ - <0x6c004 0x003f003f 0x00200020>, - <0x6c00c 0x000000f1 0x000000a1>, - <0x6c010 0x0000801f 0x00000004>, - <0x6c018 0x003f003f 0x00200020>, - <0x6c020 0x000000f1 0x000000a1>, - <0x6c024 0x0000801f 0x00000004>, - <0x6c02c 0x007f007f 0x00410041>, - <0x6c034 0x000000f1 0x00000071>, - <0x6c038 0x0000801f 0x00000004>, - <0x6c040 0x0000001f 0x00000010>, - <0x6c048 0x0000801f 0x00000004>, - <0x6c050 0x007f007f 0x00450045>, - <0x6c058 0x000000f1 0x00000051>, - <0x6c05c 0x0000801f 0x00000004>, - <0x6c064 0x0000003f 0x00000020>, - <0x6c06c 0x0000801f 0x00000004>, - <0x6c074 0x00000001 0x00000001>, - <0x6c078 0x0000801f 0x00000004>, - <0x6c080 0x001f001f 0x00100010>, - <0x6c084 0x000000f1 0x00000011>, - <0x6c088 0x00000001 0x00000001>, - <0x6c08c 0x00000001 0x00000001>, - <0x6c090 0x0000801f 0x00000004>, - <0x6c098 0x001f001f 0x00100010>, - <0x6c09c 0x000000f1 0x00000011>, - <0x6c0a0 0x0000801f 0x00000004>, - <0x6c0a8 0x000000ff 0x000000a0>, - <0x6c0ac 0x0000801f 0x00000004>, - <0x6c0b4 0x0000003f 0x00000020>, - <0x6c0bc 0x0000801f 0x00000004>, - <0x6c0c4 0x0000003f 0x00000020>, - <0x6c0cc 0x0000801f 0x00000004>, - <0x6c0d4 0x0000000f 0x00000008>, - <0x6c0d8 0x0000801f 0x00000004>, - <0x6c0e0 0x001f001f 0x00180018>, - <0x6c0e4 0x0000801f 0x00000004>, - <0x6c0ec 0x001f001f 0x00180018>, - <0x6c0f0 0x0000801f 0x00000004>, - <0x6c0f8 0x001f001f 0x00180018>, - <0x6c0fc 0x0000801f 0x00000004>, - <0x6c104 0x001f001f 0x00180018>, - <0x6c108 0x0000801f 0x00000004>, - <0x6c110 0x00000001 0x00000001>, - <0x6c114 0x0000801f 0x00000004>, - <0x6c11c 0x0000801f 0x00000004>, - <0x6c124 0x0000801f 0x00000004>, - <0x6c12c 0x0000801f 0x00000004>, - <0x6c134 0x0000801f 0x00000004>, - <0x6c13c 0xffffffff 0x01010101>, - <0x6c140 0x0000801f 0x00000004>, - <0x6c148 0x0000801f 0x00000004>, - <0x6c150 0xffffffff 0x01010101>, - <0x6c154 0x0000ffff 0x00000101>, - <0x6c158 0x0000801f 0x00000004>, - <0x6c160 0x0000801f 0x00000004>, - <0x6c168 0x0000801f 0x00000004>, - <0x6c170 0x0000801f 0x00000004>, - <0x6c178 0x0000801f 0x00000004>, - <0x6c180 0xffffffff 0x01010101>, - <0x6c184 0x0000801f 0x00000004>, - <0x6c18c 0x0000801f 0x00000004>, - <0x6c194 0x0000801f 0x00000004>, - /* DPPLL_CORE_DFLT */ - <0x01040 0x0000000c 0x00000008>, - <0x01060 0x0001c000 0x0000c000>, - <0x01098 0x00000f00 0x00000800>, - <0x0109c 0x000fe000 0x000fe000>, - <0x01108 0x07c00000 0x04000000>, - <0x0110c 0x0000007c 0x00000010>, - /* DPPLL_TOP_DFLT */ - <0x00e8c 0x0000007f 0x0000003c>, - <0x00e9c 0x0000007f 0x00000032>, - <0x00eac 0x0000007f 0x00000032>, - <0x00ebc 0x0000007f 0x0000005a>, - /* CIOPLL_TOP_DFLT */ - <0x01488 0x000001ff 0x00000128>, - <0x01494 0x00000100 0x00000100>, - /* ACIOPHY_USBC0_DFLT */ - <0x15c04 0x0f000000 0x00000000>, - <0x15c0c 0x0007c000 0x00020000>, - /* ACIOPHY_USBC0_USB */ - <0x15c50 0x60000000 0x00000000>; - apple,tunable-lane0-usb = - /* LN0_ARBITER_REGS_DFLT */ - <0x082d8 0xf0000000 0x70000000>, - <0x082dc 0x0000000f 0x00000007>, - /* LN0_RX_TOP_REGS_DFLT */ - <0x08cf4 0x00000020 0x00000020>, - /* LN0_RX_DFE_REGS_DFLT */ - <0x077c4 0x0003ff00 0x0000fa00>, - /* LN0_SMGR_REGS_DFLT */ - <0x07dbc 0x00000078 0x00000030>, - <0x07dd8 0x000003f0 0x00000000>, - <0x07de8 0x00000003 0x00000003>, - <0x07dec 0x00000002 0x00000002>, - /* LN0_RXAEQ_TOP_REGS_DFLT */ - <0x07a00 0x000000f0 0x00000010>, - <0x07a08 0x00000fff 0x00000001>, - <0x07a28 0x0ff00000 0x0cf00000>, - <0x07a40 0x07ffffff 0x028154a5>, - <0x07a7c 0x20000000 0x00000000>, - <0x07a80 0x0000001f 0x00000002>, - <0x07b98 0x3f00003f 0x31000014>, - <0x07b9c 0x0003ffff 0x0000ef4b>, - <0x07ba8 0x0fc1f800 0x05005000>, - <0x07bac 0x07ffffe0 0x013f0e40>, - <0x07bbc 0x000001c7 0x00000145>, - <0x07bc8 0x000007f8 0x00000018>, - /* LN0_RX_SHM_REGS_DFLT */ - <0x08728 0x0000010f 0x0000010f>, - <0x0878c 0xfc000000 0xfc000000>, - <0x08790 0x00000001 0x00000001>, - <0x087b4 0x0e018000 0x06008000>, - <0x08708 0x40000000 0x40000000>, - /* LN0_TXSEQ_REGS_DFLT */ - <0x04c80 0x3f800000 0x00000000>, - <0x04c88 0x001fffff 0x00000000>, - /* LN0_TX_SHM_AHB_DFLT */ - <0x04fd4 0x03800000 0x02800000>, - /* LN0_TX_TXSPL_CM_DFLT */ - <0x04e20 0x00fff000 0x00723000>, - /* LN0_ASDC_TXSPL_CM_DFLT */ - <0x08980 0x00fff000 0x00723000>, - /* LN0_DIV40_REGS_DFLT */ - <0x085e4 0x00000004 0x00000000>, - /* LN0_RX_PCTRL_REGS_DFLT */ - <0x08628 0x00000ff0 0x00000660>, - <0x0862c 0x00000ff0 0x00000ea0>, - /* LN0_CTLE_EQ_REGS_DFLT */ - <0x08000 0x0000000a 0x00000000>, - <0x08014 0x000003ff 0x00000042>, - /* L0_RXCALACC_HALFUI_DFLT */ - <0x07304 0x0000000f 0x00000006>, - <0x07334 0x01ffffff 0x001004ea>, - /* L0_RXCALACC_EDSKEW_DFLT */ - <0x07284 0x0000000f 0x00000006>, - <0x072cc 0x0003ffff 0x000004ea>, - /* LN0_TXSPL_TXDCC_DFLT */ - <0x04d84 0x001c0000 0x00000000>, - /* LN0_SMGR_REGS_USB */ - <0x07d88 0x000000f0 0x00000030>, - <0x07da8 0xff000000 0x44000000>, - <0x07dd8 0x00003000 0x00003000>, - /* LN0_DETECTOR_REGS_USB */ - <0x0848c 0x00008000 0x00000000>, - /* LN0_DIV40_REGS_USB */ - <0x08594 0x00000001 0x00000001>, - <0x085b0 0x0000ffff 0x00001010>, - <0x085b8 0x0000ffff 0x00001010>, - <0x085cc 0x68100000 0x00000000>, - <0x085d0 0x68100000 0x00000000>, - /* LN0_CTLE_EQ_REGS_USB */ - <0x07fdc 0x000001ff 0x000000b4>, - <0x07fe0 0x000001ff 0x000000aa>, - /* LN0_RXAEQ_TOP_REGS_USB */ - <0x07a1c 0x00000ff8 0x00000578>, - <0x07a2c 0x0003ffff 0x000154b4>, - <0x07bb8 0x00007000 0x00000000>, - /* LN0_TXSEQ_REGS_USB */ - <0x04ca0 0x00000002 0x00000000>; }; /* * USB-C Back-middle: ADT atc-phy0 in CIO mode, see atc2_phy for the - * layout. The tunables are the atc-phy0 groups the CIO mode - * applies, in that order: the common and PLL defaults as - * common-a, the fabric, PLL and the other common groups as + * layout. The bootloader copies the atc-phy0 groups the CIO mode + * applies, through the atcphy0 alias: the common and PLL defaults + * as common-a, the fabric, PLL and the other common groups as * common-b, and each lane's groups. */ atc0_phy: phy@403000000 { @@ -494,220 +327,6 @@ mode-switch; power-domains = <&ps_atc0_usb_aon>, <&ps_atc0_common>, <&ps_atc0_common_dp_0>, <&ps_atc0_common_dp_1>; - apple,tunable-common-a = - <0x00800 0x00fc0000 0x00fc0000>, - <0x0084c 0x000ff800 0x000ff800>, - <0x0085c 0x000000ff 0x00000080>, - <0x00860 0x007fffff 0x0052bca4>, - <0x00864 0x02c00000 0x00800000>, - <0x01614 0x0003ffc0 0x0001e5c0>, - <0x01640 0x00000007 0x00000003>, - <0x01668 0x00000ffc 0x000005f0>; - apple,tunable-common-b = - <0x6c004 0x003f003f 0x00200020>, - <0x6c00c 0x000000f1 0x000000a1>, - <0x6c010 0x0000801f 0x00000004>, - <0x6c018 0x003f003f 0x00200020>, - <0x6c020 0x000000f1 0x000000a1>, - <0x6c024 0x0000801f 0x00000004>, - <0x6c02c 0x007f007f 0x00410041>, - <0x6c034 0x000000f1 0x00000071>, - <0x6c038 0x0000801f 0x00000004>, - <0x6c040 0x0000001f 0x00000010>, - <0x6c048 0x0000801f 0x00000004>, - <0x6c050 0x007f007f 0x00450045>, - <0x6c058 0x000000f1 0x00000051>, - <0x6c05c 0x0000801f 0x00000004>, - <0x6c064 0x0000003f 0x00000020>, - <0x6c06c 0x0000801f 0x00000004>, - <0x6c074 0x00000001 0x00000001>, - <0x6c078 0x0000801f 0x00000004>, - <0x6c080 0x001f001f 0x00100010>, - <0x6c084 0x000000f1 0x00000011>, - <0x6c088 0x00000001 0x00000001>, - <0x6c08c 0x00000001 0x00000001>, - <0x6c090 0x0000801f 0x00000004>, - <0x6c098 0x001f001f 0x00100010>, - <0x6c09c 0x000000f1 0x00000011>, - <0x6c0a0 0x0000801f 0x00000004>, - <0x6c0a8 0x000000ff 0x000000a0>, - <0x6c0ac 0x0000801f 0x00000004>, - <0x6c0b4 0x0000003f 0x00000020>, - <0x6c0bc 0x0000801f 0x00000004>, - <0x6c0c4 0x0000003f 0x00000020>, - <0x6c0cc 0x0000801f 0x00000004>, - <0x6c0d4 0x0000000f 0x00000008>, - <0x6c0d8 0x0000801f 0x00000004>, - <0x6c0e0 0x001f001f 0x00180018>, - <0x6c0e4 0x0000801f 0x00000004>, - <0x6c0ec 0x001f001f 0x00180018>, - <0x6c0f0 0x0000801f 0x00000004>, - <0x6c0f8 0x001f001f 0x00180018>, - <0x6c0fc 0x0000801f 0x00000004>, - <0x6c104 0x001f001f 0x00180018>, - <0x6c108 0x0000801f 0x00000004>, - <0x6c110 0x00000001 0x00000001>, - <0x6c114 0x0000801f 0x00000004>, - <0x6c11c 0x0000801f 0x00000004>, - <0x6c124 0x0000801f 0x00000004>, - <0x6c12c 0x0000801f 0x00000004>, - <0x6c134 0x0000801f 0x00000004>, - <0x6c13c 0xffffffff 0x01010101>, - <0x6c140 0x0000801f 0x00000004>, - <0x6c148 0x0000801f 0x00000004>, - <0x6c150 0xffffffff 0x01010101>, - <0x6c154 0x0000ffff 0x00000101>, - <0x6c158 0x0000801f 0x00000004>, - <0x6c160 0x0000801f 0x00000004>, - <0x6c168 0x0000801f 0x00000004>, - <0x6c170 0x0000801f 0x00000004>, - <0x6c178 0x0000801f 0x00000004>, - <0x6c180 0xffffffff 0x01010101>, - <0x6c184 0x0000801f 0x00000004>, - <0x6c18c 0x0000801f 0x00000004>, - <0x6c194 0x0000801f 0x00000004>, - <0x01040 0x0000000c 0x00000008>, - <0x01060 0x0001c000 0x0000c000>, - <0x01098 0x00000f00 0x00000800>, - <0x0109c 0x000fe000 0x000fe000>, - <0x01108 0x07c00000 0x04000000>, - <0x0110c 0x0000007c 0x00000010>, - <0x00e8c 0x0000007f 0x0000003c>, - <0x00e9c 0x0000007f 0x00000032>, - <0x00eac 0x0000007f 0x00000032>, - <0x00ebc 0x0000007f 0x0000005a>, - <0x01488 0x000001ff 0x00000128>, - <0x01494 0x00000100 0x00000100>, - <0x01a44 0x0000040f 0x0000040f>, - <0x01a48 0x0000040f 0x0000040f>; - apple,tunable-lane0-cio = - <0x082d8 0xf0000000 0x70000000>, - <0x082dc 0x0000000f 0x00000007>, - <0x08cf4 0x00000020 0x00000020>, - <0x077c4 0x0003ff00 0x0000fa00>, - <0x07dbc 0x00000078 0x00000030>, - <0x07dd8 0x000003f0 0x00000000>, - <0x07de8 0x00000003 0x00000003>, - <0x07dec 0x00000002 0x00000002>, - <0x07a00 0x000000f0 0x00000010>, - <0x07a08 0x00000fff 0x00000001>, - <0x07a28 0x0ff00000 0x0cf00000>, - <0x07a40 0x07ffffff 0x028154a5>, - <0x07a7c 0x20000000 0x00000000>, - <0x07a80 0x0000001f 0x00000002>, - <0x07b98 0x3f00003f 0x31000014>, - <0x07b9c 0x0003ffff 0x0000ef4b>, - <0x07ba8 0x0fc1f800 0x05005000>, - <0x07bac 0x07ffffe0 0x013f0e40>, - <0x07bbc 0x000001c7 0x00000145>, - <0x07bc8 0x000007f8 0x00000018>, - <0x08728 0x0000010f 0x0000010f>, - <0x0878c 0xfc000000 0xfc000000>, - <0x08790 0x00000001 0x00000001>, - <0x087b4 0x0e018000 0x06008000>, - <0x08708 0x40000000 0x40000000>, - <0x04c80 0x3f800000 0x00000000>, - <0x04c88 0x001fffff 0x00000000>, - <0x04fd4 0x03800000 0x02800000>, - <0x04e20 0x00fff000 0x00723000>, - <0x08980 0x00fff000 0x00723000>, - <0x085e4 0x00000004 0x00000000>, - <0x08628 0x00000ff0 0x00000660>, - <0x0862c 0x00000ff0 0x00000ea0>, - <0x08000 0x0000000a 0x00000000>, - <0x08014 0x000003ff 0x00000042>, - <0x07304 0x0000000f 0x00000006>, - <0x07334 0x01ffffff 0x001004ea>, - <0x07284 0x0000000f 0x00000006>, - <0x072cc 0x0003ffff 0x000004ea>, - <0x04d84 0x001c0000 0x00000000>, - <0x07f80 0xffffffff 0x00000148>, - <0x07f90 0x0003ff00 0x0002f700>, - <0x07fd0 0x00000100 0x00000000>, - <0x07d88 0x000000ff 0x00000041>, - <0x07da8 0xffff0000 0x22110000>, - <0x07dac 0x000000ff 0x00000044>, - <0x07dd8 0x0000c000 0x00000000>, - <0x07ddc 0x00000003 0x00000000>, - <0x07a1c 0x00000ff8 0x00000528>, - <0x07a2c 0x0003ffff 0x000140aa>, - <0x07a30 0x00001e00 0x00001000>, - <0x07a34 0x00ff0000 0x000a0000>, - <0x07b84 0x000000ff 0x00000028>, - <0x07b88 0x0000f00f 0x00007008>, - <0x07b8c 0x0000f00f 0x00006007>, - <0x07b90 0x0000f00f 0x00004005>, - <0x07bb4 0x0000703f 0x0000502d>, - <0x07bb8 0x0000703f 0x00002013>, - <0x07bbc 0x00000e00 0x00000600>, - <0x08af4 0x01fe0000 0x01540000>, - <0x08af8 0x003fc000 0x002a8000>, - <0x04e94 0x01fe0000 0x01540000>, - <0x04e98 0x003fc000 0x002a8000>; - apple,tunable-lane1-cio = - <0x112d8 0xf0000000 0x70000000>, - <0x112dc 0x0000000f 0x00000007>, - <0x11cf4 0x00000020 0x00000020>, - <0x107c4 0x0003ff00 0x0000fa00>, - <0x10dbc 0x00000078 0x00000030>, - <0x10dd8 0x000003f0 0x00000000>, - <0x10de8 0x00000003 0x00000003>, - <0x10dec 0x00000002 0x00000002>, - <0x10a00 0x000000f0 0x00000010>, - <0x10a08 0x00000fff 0x00000001>, - <0x10a28 0x0ff00000 0x0cf00000>, - <0x10a40 0x07ffffff 0x028154a5>, - <0x10a7c 0x20000000 0x00000000>, - <0x10a80 0x0000001f 0x00000002>, - <0x10b98 0x3f00003f 0x31000014>, - <0x10b9c 0x0003ffff 0x0000ef4b>, - <0x10ba8 0x0fc1f800 0x05005000>, - <0x10bac 0x07ffffe0 0x013f0e40>, - <0x10bbc 0x000001c7 0x00000145>, - <0x10bc8 0x000007f8 0x00000018>, - <0x11728 0x0000010f 0x0000010f>, - <0x1178c 0xfc000000 0xfc000000>, - <0x11790 0x00000001 0x00000001>, - <0x117b4 0x0e018000 0x06008000>, - <0x11708 0x40000000 0x40000000>, - <0x0dc80 0x3f800000 0x00000000>, - <0x0dc88 0x001fffff 0x00000000>, - <0x0dfd4 0x03800000 0x02800000>, - <0x0de20 0x00fff000 0x00723000>, - <0x11980 0x00fff000 0x00723000>, - <0x115e4 0x00000004 0x00000000>, - <0x11628 0x00000ff0 0x00000660>, - <0x1162c 0x00000ff0 0x00000ea0>, - <0x11000 0x0000000a 0x00000000>, - <0x11014 0x000003ff 0x00000042>, - <0x10304 0x0000000f 0x00000006>, - <0x10334 0x01ffffff 0x001004ea>, - <0x10284 0x0000000f 0x00000006>, - <0x102cc 0x0003ffff 0x000004ea>, - <0x0dd84 0x001c0000 0x00000000>, - <0x10f80 0xffffffff 0x00000148>, - <0x10f90 0x0003ff00 0x0002f700>, - <0x10fd0 0x00000100 0x00000000>, - <0x10d88 0x000000ff 0x00000041>, - <0x10da8 0xffff0000 0x22110000>, - <0x10dac 0x000000ff 0x00000044>, - <0x10dd8 0x0000c000 0x00000000>, - <0x10ddc 0x00000003 0x00000000>, - <0x10a1c 0x00000ff8 0x00000528>, - <0x10a2c 0x0003ffff 0x000140aa>, - <0x10a30 0x00001e00 0x00001000>, - <0x10a34 0x00ff0000 0x000a0000>, - <0x10b84 0x000000ff 0x00000028>, - <0x10b88 0x0000f00f 0x00007008>, - <0x10b8c 0x0000f00f 0x00006007>, - <0x10b90 0x0000f00f 0x00004005>, - <0x10bb4 0x0000703f 0x0000502d>, - <0x10bb8 0x0000703f 0x00002013>, - <0x10bbc 0x00000e00 0x00000600>, - <0x11af4 0x01fe0000 0x01540000>, - <0x11af8 0x003fc000 0x002a8000>, - <0x0de94 0x01fe0000 0x01540000>, - <0x0de98 0x003fc000 0x002a8000>; ports { #address-cells = <1>; @@ -725,9 +344,9 @@ /* * USB-C Back-left: ADT atc-phy1 in CIO mode, see atc2_phy for the - * layout. The tunables are the atc-phy1 groups the CIO mode - * applies, in that order: the common and PLL defaults as - * common-a, the fabric, PLL and the other common groups as + * layout. The bootloader copies the atc-phy1 groups the CIO mode + * applies, through the atcphy1 alias: the common and PLL defaults + * as common-a, the fabric, PLL and the other common groups as * common-b, and each lane's groups. */ atc1_phy: phy@40b000000 { @@ -739,220 +358,6 @@ mode-switch; power-domains = <&ps_atc1_usb_aon>, <&ps_atc1_common>, <&ps_atc1_common_dp_0>, <&ps_atc1_common_dp_1>; - apple,tunable-common-a = - <0x00800 0x00fc0000 0x00fc0000>, - <0x0084c 0x000ff800 0x000ff800>, - <0x0085c 0x000000ff 0x00000080>, - <0x00860 0x007fffff 0x0052bc26>, - <0x00864 0x02c00000 0x00800000>, - <0x01614 0x0003ffc0 0x0001e5c0>, - <0x01640 0x00000007 0x00000003>, - <0x01668 0x00000ffc 0x000005f0>; - apple,tunable-common-b = - <0x6c004 0x003f003f 0x00200020>, - <0x6c00c 0x000000f1 0x000000a1>, - <0x6c010 0x0000801f 0x00000004>, - <0x6c018 0x003f003f 0x00200020>, - <0x6c020 0x000000f1 0x000000a1>, - <0x6c024 0x0000801f 0x00000004>, - <0x6c02c 0x007f007f 0x00410041>, - <0x6c034 0x000000f1 0x00000071>, - <0x6c038 0x0000801f 0x00000004>, - <0x6c040 0x0000001f 0x00000010>, - <0x6c048 0x0000801f 0x00000004>, - <0x6c050 0x007f007f 0x00450045>, - <0x6c058 0x000000f1 0x00000051>, - <0x6c05c 0x0000801f 0x00000004>, - <0x6c064 0x0000003f 0x00000020>, - <0x6c06c 0x0000801f 0x00000004>, - <0x6c074 0x00000001 0x00000001>, - <0x6c078 0x0000801f 0x00000004>, - <0x6c080 0x001f001f 0x00100010>, - <0x6c084 0x000000f1 0x00000011>, - <0x6c088 0x00000001 0x00000001>, - <0x6c08c 0x00000001 0x00000001>, - <0x6c090 0x0000801f 0x00000004>, - <0x6c098 0x001f001f 0x00100010>, - <0x6c09c 0x000000f1 0x00000011>, - <0x6c0a0 0x0000801f 0x00000004>, - <0x6c0a8 0x000000ff 0x000000a0>, - <0x6c0ac 0x0000801f 0x00000004>, - <0x6c0b4 0x0000003f 0x00000020>, - <0x6c0bc 0x0000801f 0x00000004>, - <0x6c0c4 0x0000003f 0x00000020>, - <0x6c0cc 0x0000801f 0x00000004>, - <0x6c0d4 0x0000000f 0x00000008>, - <0x6c0d8 0x0000801f 0x00000004>, - <0x6c0e0 0x001f001f 0x00180018>, - <0x6c0e4 0x0000801f 0x00000004>, - <0x6c0ec 0x001f001f 0x00180018>, - <0x6c0f0 0x0000801f 0x00000004>, - <0x6c0f8 0x001f001f 0x00180018>, - <0x6c0fc 0x0000801f 0x00000004>, - <0x6c104 0x001f001f 0x00180018>, - <0x6c108 0x0000801f 0x00000004>, - <0x6c110 0x00000001 0x00000001>, - <0x6c114 0x0000801f 0x00000004>, - <0x6c11c 0x0000801f 0x00000004>, - <0x6c124 0x0000801f 0x00000004>, - <0x6c12c 0x0000801f 0x00000004>, - <0x6c134 0x0000801f 0x00000004>, - <0x6c13c 0xffffffff 0x01010101>, - <0x6c140 0x0000801f 0x00000004>, - <0x6c148 0x0000801f 0x00000004>, - <0x6c150 0xffffffff 0x01010101>, - <0x6c154 0x0000ffff 0x00000101>, - <0x6c158 0x0000801f 0x00000004>, - <0x6c160 0x0000801f 0x00000004>, - <0x6c168 0x0000801f 0x00000004>, - <0x6c170 0x0000801f 0x00000004>, - <0x6c178 0x0000801f 0x00000004>, - <0x6c180 0xffffffff 0x01010101>, - <0x6c184 0x0000801f 0x00000004>, - <0x6c18c 0x0000801f 0x00000004>, - <0x6c194 0x0000801f 0x00000004>, - <0x01040 0x0000000c 0x00000008>, - <0x01060 0x0001c000 0x0000c000>, - <0x01098 0x00000f00 0x00000800>, - <0x0109c 0x000fe000 0x000fe000>, - <0x01108 0x07c00000 0x04000000>, - <0x0110c 0x0000007c 0x00000010>, - <0x00e8c 0x0000007f 0x0000003c>, - <0x00e9c 0x0000007f 0x00000032>, - <0x00eac 0x0000007f 0x00000032>, - <0x00ebc 0x0000007f 0x0000005a>, - <0x01488 0x000001ff 0x00000128>, - <0x01494 0x00000100 0x00000100>, - <0x01a44 0x0000040f 0x0000040f>, - <0x01a48 0x0000040f 0x0000040f>; - apple,tunable-lane0-cio = - <0x082d8 0xf0000000 0x70000000>, - <0x082dc 0x0000000f 0x00000007>, - <0x08cf4 0x00000020 0x00000020>, - <0x077c4 0x0003ff00 0x0000fa00>, - <0x07dbc 0x00000078 0x00000030>, - <0x07dd8 0x000003f0 0x00000000>, - <0x07de8 0x00000003 0x00000003>, - <0x07dec 0x00000002 0x00000002>, - <0x07a00 0x000000f0 0x00000010>, - <0x07a08 0x00000fff 0x00000001>, - <0x07a28 0x0ff00000 0x0cf00000>, - <0x07a40 0x07ffffff 0x028154a5>, - <0x07a7c 0x20000000 0x00000000>, - <0x07a80 0x0000001f 0x00000002>, - <0x07b98 0x3f00003f 0x31000014>, - <0x07b9c 0x0003ffff 0x0000ef4b>, - <0x07ba8 0x0fc1f800 0x05005000>, - <0x07bac 0x07ffffe0 0x013f0e40>, - <0x07bbc 0x000001c7 0x00000145>, - <0x07bc8 0x000007f8 0x00000018>, - <0x08728 0x0000010f 0x0000010f>, - <0x0878c 0xfc000000 0xfc000000>, - <0x08790 0x00000001 0x00000001>, - <0x087b4 0x0e018000 0x06008000>, - <0x08708 0x40000000 0x40000000>, - <0x04c80 0x3f800000 0x00000000>, - <0x04c88 0x001fffff 0x00000000>, - <0x04fd4 0x03800000 0x02800000>, - <0x04e20 0x00fff000 0x00723000>, - <0x08980 0x00fff000 0x00723000>, - <0x085e4 0x00000004 0x00000000>, - <0x08628 0x00000ff0 0x00000660>, - <0x0862c 0x00000ff0 0x00000ea0>, - <0x08000 0x0000000a 0x00000000>, - <0x08014 0x000003ff 0x00000042>, - <0x07304 0x0000000f 0x00000006>, - <0x07334 0x01ffffff 0x001004ea>, - <0x07284 0x0000000f 0x00000006>, - <0x072cc 0x0003ffff 0x000004ea>, - <0x04d84 0x001c0000 0x00000000>, - <0x07f80 0xffffffff 0x00000148>, - <0x07f90 0x0003ff00 0x0002f700>, - <0x07fd0 0x00000100 0x00000000>, - <0x07d88 0x000000ff 0x00000041>, - <0x07da8 0xffff0000 0x22110000>, - <0x07dac 0x000000ff 0x00000044>, - <0x07dd8 0x0000c000 0x00000000>, - <0x07ddc 0x00000003 0x00000000>, - <0x07a1c 0x00000ff8 0x00000528>, - <0x07a2c 0x0003ffff 0x000140aa>, - <0x07a30 0x00001e00 0x00001000>, - <0x07a34 0x00ff0000 0x000a0000>, - <0x07b84 0x000000ff 0x00000028>, - <0x07b88 0x0000f00f 0x00007008>, - <0x07b8c 0x0000f00f 0x00006007>, - <0x07b90 0x0000f00f 0x00004005>, - <0x07bb4 0x0000703f 0x0000502d>, - <0x07bb8 0x0000703f 0x00002013>, - <0x07bbc 0x00000e00 0x00000600>, - <0x08af4 0x01fe0000 0x01540000>, - <0x08af8 0x003fc000 0x002a8000>, - <0x04e94 0x01fe0000 0x01540000>, - <0x04e98 0x003fc000 0x002a8000>; - apple,tunable-lane1-cio = - <0x112d8 0xf0000000 0x70000000>, - <0x112dc 0x0000000f 0x00000007>, - <0x11cf4 0x00000020 0x00000020>, - <0x107c4 0x0003ff00 0x0000fa00>, - <0x10dbc 0x00000078 0x00000030>, - <0x10dd8 0x000003f0 0x00000000>, - <0x10de8 0x00000003 0x00000003>, - <0x10dec 0x00000002 0x00000002>, - <0x10a00 0x000000f0 0x00000010>, - <0x10a08 0x00000fff 0x00000001>, - <0x10a28 0x0ff00000 0x0cf00000>, - <0x10a40 0x07ffffff 0x028154a5>, - <0x10a7c 0x20000000 0x00000000>, - <0x10a80 0x0000001f 0x00000002>, - <0x10b98 0x3f00003f 0x31000014>, - <0x10b9c 0x0003ffff 0x0000ef4b>, - <0x10ba8 0x0fc1f800 0x05005000>, - <0x10bac 0x07ffffe0 0x013f0e40>, - <0x10bbc 0x000001c7 0x00000145>, - <0x10bc8 0x000007f8 0x00000018>, - <0x11728 0x0000010f 0x0000010f>, - <0x1178c 0xfc000000 0xfc000000>, - <0x11790 0x00000001 0x00000001>, - <0x117b4 0x0e018000 0x06008000>, - <0x11708 0x40000000 0x40000000>, - <0x0dc80 0x3f800000 0x00000000>, - <0x0dc88 0x001fffff 0x00000000>, - <0x0dfd4 0x03800000 0x02800000>, - <0x0de20 0x00fff000 0x00723000>, - <0x11980 0x00fff000 0x00723000>, - <0x115e4 0x00000004 0x00000000>, - <0x11628 0x00000ff0 0x00000660>, - <0x1162c 0x00000ff0 0x00000ea0>, - <0x11000 0x0000000a 0x00000000>, - <0x11014 0x000003ff 0x00000042>, - <0x10304 0x0000000f 0x00000006>, - <0x10334 0x01ffffff 0x001004ea>, - <0x10284 0x0000000f 0x00000006>, - <0x102cc 0x0003ffff 0x000004ea>, - <0x0dd84 0x001c0000 0x00000000>, - <0x10f80 0xffffffff 0x00000148>, - <0x10f90 0x0003ff00 0x0002f700>, - <0x10fd0 0x00000100 0x00000000>, - <0x10d88 0x000000ff 0x00000041>, - <0x10da8 0xffff0000 0x22110000>, - <0x10dac 0x000000ff 0x00000044>, - <0x10dd8 0x0000c000 0x00000000>, - <0x10ddc 0x00000003 0x00000000>, - <0x10a1c 0x00000ff8 0x00000528>, - <0x10a2c 0x0003ffff 0x000140aa>, - <0x10a30 0x00001e00 0x00001000>, - <0x10a34 0x00ff0000 0x000a0000>, - <0x10b84 0x000000ff 0x00000028>, - <0x10b88 0x0000f00f 0x00007008>, - <0x10b8c 0x0000f00f 0x00006007>, - <0x10b90 0x0000f00f 0x00004005>, - <0x10bb4 0x0000703f 0x0000502d>, - <0x10bb8 0x0000703f 0x00002013>, - <0x10bbc 0x00000e00 0x00000600>, - <0x11af4 0x01fe0000 0x01540000>, - <0x11af8 0x003fc000 0x002a8000>, - <0x0de94 0x01fe0000 0x01540000>, - <0x0de98 0x003fc000 0x002a8000>; ports { #address-cells = <1>; @@ -970,9 +375,9 @@ /* * USB-C Back-right: ADT atc-phy3 in CIO mode, see atc2_phy for the - * layout. The tunables are the atc-phy3 groups the CIO mode - * applies, in that order: the common and PLL defaults as - * common-a, the fabric, PLL and the other common groups as + * layout. The bootloader copies the atc-phy3 groups the CIO mode + * applies, through the atcphy3 alias: the common and PLL defaults + * as common-a, the fabric, PLL and the other common groups as * common-b, and each lane's groups. */ atc3_phy: phy@413000000 { @@ -984,220 +389,6 @@ mode-switch; power-domains = <&ps_atc3_usb_aon>, <&ps_atc3_common>, <&ps_atc3_common_dp_0>, <&ps_atc3_common_dp_1>; - apple,tunable-common-a = - <0x00800 0x00fc0000 0x00fc0000>, - <0x0084c 0x000ff800 0x000ff800>, - <0x0085c 0x000000ff 0x00000080>, - <0x00860 0x007fffff 0x0052bc26>, - <0x00864 0x02c00000 0x00800000>, - <0x01614 0x0003ffc0 0x0001e5c0>, - <0x01640 0x00000007 0x00000003>, - <0x01668 0x00000ffc 0x000005f0>; - apple,tunable-common-b = - <0x6c004 0x003f003f 0x00200020>, - <0x6c00c 0x000000f1 0x000000a1>, - <0x6c010 0x0000801f 0x00000004>, - <0x6c018 0x003f003f 0x00200020>, - <0x6c020 0x000000f1 0x000000a1>, - <0x6c024 0x0000801f 0x00000004>, - <0x6c02c 0x007f007f 0x00410041>, - <0x6c034 0x000000f1 0x00000071>, - <0x6c038 0x0000801f 0x00000004>, - <0x6c040 0x0000001f 0x00000010>, - <0x6c048 0x0000801f 0x00000004>, - <0x6c050 0x007f007f 0x00450045>, - <0x6c058 0x000000f1 0x00000051>, - <0x6c05c 0x0000801f 0x00000004>, - <0x6c064 0x0000003f 0x00000020>, - <0x6c06c 0x0000801f 0x00000004>, - <0x6c074 0x00000001 0x00000001>, - <0x6c078 0x0000801f 0x00000004>, - <0x6c080 0x001f001f 0x00100010>, - <0x6c084 0x000000f1 0x00000011>, - <0x6c088 0x00000001 0x00000001>, - <0x6c08c 0x00000001 0x00000001>, - <0x6c090 0x0000801f 0x00000004>, - <0x6c098 0x001f001f 0x00100010>, - <0x6c09c 0x000000f1 0x00000011>, - <0x6c0a0 0x0000801f 0x00000004>, - <0x6c0a8 0x000000ff 0x000000a0>, - <0x6c0ac 0x0000801f 0x00000004>, - <0x6c0b4 0x0000003f 0x00000020>, - <0x6c0bc 0x0000801f 0x00000004>, - <0x6c0c4 0x0000003f 0x00000020>, - <0x6c0cc 0x0000801f 0x00000004>, - <0x6c0d4 0x0000000f 0x00000008>, - <0x6c0d8 0x0000801f 0x00000004>, - <0x6c0e0 0x001f001f 0x00180018>, - <0x6c0e4 0x0000801f 0x00000004>, - <0x6c0ec 0x001f001f 0x00180018>, - <0x6c0f0 0x0000801f 0x00000004>, - <0x6c0f8 0x001f001f 0x00180018>, - <0x6c0fc 0x0000801f 0x00000004>, - <0x6c104 0x001f001f 0x00180018>, - <0x6c108 0x0000801f 0x00000004>, - <0x6c110 0x00000001 0x00000001>, - <0x6c114 0x0000801f 0x00000004>, - <0x6c11c 0x0000801f 0x00000004>, - <0x6c124 0x0000801f 0x00000004>, - <0x6c12c 0x0000801f 0x00000004>, - <0x6c134 0x0000801f 0x00000004>, - <0x6c13c 0xffffffff 0x01010101>, - <0x6c140 0x0000801f 0x00000004>, - <0x6c148 0x0000801f 0x00000004>, - <0x6c150 0xffffffff 0x01010101>, - <0x6c154 0x0000ffff 0x00000101>, - <0x6c158 0x0000801f 0x00000004>, - <0x6c160 0x0000801f 0x00000004>, - <0x6c168 0x0000801f 0x00000004>, - <0x6c170 0x0000801f 0x00000004>, - <0x6c178 0x0000801f 0x00000004>, - <0x6c180 0xffffffff 0x01010101>, - <0x6c184 0x0000801f 0x00000004>, - <0x6c18c 0x0000801f 0x00000004>, - <0x6c194 0x0000801f 0x00000004>, - <0x01040 0x0000000c 0x00000008>, - <0x01060 0x0001c000 0x0000c000>, - <0x01098 0x00000f00 0x00000800>, - <0x0109c 0x000fe000 0x000fe000>, - <0x01108 0x07c00000 0x04000000>, - <0x0110c 0x0000007c 0x00000010>, - <0x00e8c 0x0000007f 0x0000003c>, - <0x00e9c 0x0000007f 0x00000032>, - <0x00eac 0x0000007f 0x00000032>, - <0x00ebc 0x0000007f 0x0000005a>, - <0x01488 0x000001ff 0x00000128>, - <0x01494 0x00000100 0x00000100>, - <0x01a44 0x0000040f 0x0000040f>, - <0x01a48 0x0000040f 0x0000040f>; - apple,tunable-lane0-cio = - <0x082d8 0xf0000000 0x70000000>, - <0x082dc 0x0000000f 0x00000007>, - <0x08cf4 0x00000020 0x00000020>, - <0x077c4 0x0003ff00 0x0000fa00>, - <0x07dbc 0x00000078 0x00000030>, - <0x07dd8 0x000003f0 0x00000000>, - <0x07de8 0x00000003 0x00000003>, - <0x07dec 0x00000002 0x00000002>, - <0x07a00 0x000000f0 0x00000010>, - <0x07a08 0x00000fff 0x00000001>, - <0x07a28 0x0ff00000 0x0cf00000>, - <0x07a40 0x07ffffff 0x028154a5>, - <0x07a7c 0x20000000 0x00000000>, - <0x07a80 0x0000001f 0x00000002>, - <0x07b98 0x3f00003f 0x31000014>, - <0x07b9c 0x0003ffff 0x0000ef4b>, - <0x07ba8 0x0fc1f800 0x05005000>, - <0x07bac 0x07ffffe0 0x013f0e40>, - <0x07bbc 0x000001c7 0x00000145>, - <0x07bc8 0x000007f8 0x00000018>, - <0x08728 0x0000010f 0x0000010f>, - <0x0878c 0xfc000000 0xfc000000>, - <0x08790 0x00000001 0x00000001>, - <0x087b4 0x0e018000 0x06008000>, - <0x08708 0x40000000 0x40000000>, - <0x04c80 0x3f800000 0x00000000>, - <0x04c88 0x001fffff 0x00000000>, - <0x04fd4 0x03800000 0x02800000>, - <0x04e20 0x00fff000 0x00723000>, - <0x08980 0x00fff000 0x00723000>, - <0x085e4 0x00000004 0x00000000>, - <0x08628 0x00000ff0 0x00000660>, - <0x0862c 0x00000ff0 0x00000ea0>, - <0x08000 0x0000000a 0x00000000>, - <0x08014 0x000003ff 0x00000042>, - <0x07304 0x0000000f 0x00000006>, - <0x07334 0x01ffffff 0x001004ea>, - <0x07284 0x0000000f 0x00000006>, - <0x072cc 0x0003ffff 0x000004ea>, - <0x04d84 0x001c0000 0x00000000>, - <0x07f80 0xffffffff 0x00000148>, - <0x07f90 0x0003ff00 0x0002f700>, - <0x07fd0 0x00000100 0x00000000>, - <0x07d88 0x000000ff 0x00000041>, - <0x07da8 0xffff0000 0x22110000>, - <0x07dac 0x000000ff 0x00000044>, - <0x07dd8 0x0000c000 0x00000000>, - <0x07ddc 0x00000003 0x00000000>, - <0x07a1c 0x00000ff8 0x00000528>, - <0x07a2c 0x0003ffff 0x000140aa>, - <0x07a30 0x00001e00 0x00001000>, - <0x07a34 0x00ff0000 0x000a0000>, - <0x07b84 0x000000ff 0x00000028>, - <0x07b88 0x0000f00f 0x00007008>, - <0x07b8c 0x0000f00f 0x00006007>, - <0x07b90 0x0000f00f 0x00004005>, - <0x07bb4 0x0000703f 0x0000502d>, - <0x07bb8 0x0000703f 0x00002013>, - <0x07bbc 0x00000e00 0x00000600>, - <0x08af4 0x01fe0000 0x01540000>, - <0x08af8 0x003fc000 0x002a8000>, - <0x04e94 0x01fe0000 0x01540000>, - <0x04e98 0x003fc000 0x002a8000>; - apple,tunable-lane1-cio = - <0x112d8 0xf0000000 0x70000000>, - <0x112dc 0x0000000f 0x00000007>, - <0x11cf4 0x00000020 0x00000020>, - <0x107c4 0x0003ff00 0x0000fa00>, - <0x10dbc 0x00000078 0x00000030>, - <0x10dd8 0x000003f0 0x00000000>, - <0x10de8 0x00000003 0x00000003>, - <0x10dec 0x00000002 0x00000002>, - <0x10a00 0x000000f0 0x00000010>, - <0x10a08 0x00000fff 0x00000001>, - <0x10a28 0x0ff00000 0x0cf00000>, - <0x10a40 0x07ffffff 0x028154a5>, - <0x10a7c 0x20000000 0x00000000>, - <0x10a80 0x0000001f 0x00000002>, - <0x10b98 0x3f00003f 0x31000014>, - <0x10b9c 0x0003ffff 0x0000ef4b>, - <0x10ba8 0x0fc1f800 0x05005000>, - <0x10bac 0x07ffffe0 0x013f0e40>, - <0x10bbc 0x000001c7 0x00000145>, - <0x10bc8 0x000007f8 0x00000018>, - <0x11728 0x0000010f 0x0000010f>, - <0x1178c 0xfc000000 0xfc000000>, - <0x11790 0x00000001 0x00000001>, - <0x117b4 0x0e018000 0x06008000>, - <0x11708 0x40000000 0x40000000>, - <0x0dc80 0x3f800000 0x00000000>, - <0x0dc88 0x001fffff 0x00000000>, - <0x0dfd4 0x03800000 0x02800000>, - <0x0de20 0x00fff000 0x00723000>, - <0x11980 0x00fff000 0x00723000>, - <0x115e4 0x00000004 0x00000000>, - <0x11628 0x00000ff0 0x00000660>, - <0x1162c 0x00000ff0 0x00000ea0>, - <0x11000 0x0000000a 0x00000000>, - <0x11014 0x000003ff 0x00000042>, - <0x10304 0x0000000f 0x00000006>, - <0x10334 0x01ffffff 0x001004ea>, - <0x10284 0x0000000f 0x00000006>, - <0x102cc 0x0003ffff 0x000004ea>, - <0x0dd84 0x001c0000 0x00000000>, - <0x10f80 0xffffffff 0x00000148>, - <0x10f90 0x0003ff00 0x0002f700>, - <0x10fd0 0x00000100 0x00000000>, - <0x10d88 0x000000ff 0x00000041>, - <0x10da8 0xffff0000 0x22110000>, - <0x10dac 0x000000ff 0x00000044>, - <0x10dd8 0x0000c000 0x00000000>, - <0x10ddc 0x00000003 0x00000000>, - <0x10a1c 0x00000ff8 0x00000528>, - <0x10a2c 0x0003ffff 0x000140aa>, - <0x10a30 0x00001e00 0x00001000>, - <0x10a34 0x00ff0000 0x000a0000>, - <0x10b84 0x000000ff 0x00000028>, - <0x10b88 0x0000f00f 0x00007008>, - <0x10b8c 0x0000f00f 0x00006007>, - <0x10b90 0x0000f00f 0x00004005>, - <0x10bb4 0x0000703f 0x0000502d>, - <0x10bb8 0x0000703f 0x00002013>, - <0x10bbc 0x00000e00 0x00000600>, - <0x11af4 0x01fe0000 0x01540000>, - <0x11af8 0x003fc000 0x002a8000>, - <0x0de94 0x01fe0000 0x01540000>, - <0x0de98 0x003fc000 0x002a8000>; ports { #address-cells = <1>; diff --git a/arch/arm64/boot/dts/apple/t8152-j873-usb4.dtsi b/arch/arm64/boot/dts/apple/t8152-j873-usb4.dtsi index 41083f7ebccaa..ce96f4fb0cd91 100644 --- a/arch/arm64/boot/dts/apple/t8152-j873-usb4.dtsi +++ b/arch/arm64/boot/dts/apple/t8152-j873-usb4.dtsi @@ -7,7 +7,11 @@ * after it set the port's ATC PHY to CIO mode. * * Generated from the J873g ADT (27.2 iBoot): /arm-io/acio{0,1,3}, acio-cpuN, - * dart-acioN, apciecN and dart-apciecN. + * dart-acioN, apciecN and dart-apciecN. The tunables of the routers, their + * NHIs, PCIe-C ports and DARTs, and each router's DROM, are not in this file: + * the bootloader copies them from the Mac's own ADT (acioN, apciecN, + * dart-acioN, dart-apciecN) into the nodes the usb4-N aliases name, and the + * DARTs by their address. * * Each router coprocessor's mailbox is the 0x80 window at +0x80 of its * acio-cpuN register block, with the SMC mailbox's counted FIFOs. Its @@ -18,6 +22,23 @@ #include / { + aliases { + /* aura copies the router tunables and DROMs here, the AP firmware one too. */ + usb4-0-acio = &usb4_0; + usb4-0-pcie-adapter = &usb4_0; + usb4-0-nhi = &usb4_0_nhi; + usb4-1-acio = &usb4_1; + usb4-1-pcie-adapter = &usb4_1; + usb4-1-nhi = &usb4_1_nhi; + usb4-3-acio = &usb4_3; + usb4-3-pcie-adapter = &usb4_3; + usb4-3-nhi = &usb4_3_nhi; + /* aura copies the PCIe-C tunables here. */ + usb4-0-pcie = &usb4_0_pcie; + usb4-1-pcie = &usb4_1_pcie; + usb4-3-pcie = &usb4_3_pcie; + }; + soc { cio_reset: reset-controller@300780000 { compatible = "apple,t8152-cio-reset"; @@ -129,41 +150,6 @@ lstx-gpios = <&pinctrl_aop 19 GPIO_ACTIVE_HIGH>; thunderbolt-switch; apple,pcie-tunnel = <&usb4_0_tunnel>; - apple,tunable-rc = - <0x0 0xfff0 0x5010>, - <0x2c 0x4 0x0>, - <0xac 0xffffffff 0x84638463>, - <0x4004 0x1ff01ff 0x1000100>, - <0x4008 0x801f 0x4>, - <0x4010 0x7f 0x40>, - <0x4014 0x801f 0x4>, - <0x401c 0x7f 0x40>, - <0x4024 0x801f 0x4>, - <0x402c 0x7f 0x40>, - <0x4030 0x801f 0x4>, - <0x4038 0xffffffff 0x1010101>, - <0x403c 0xffff 0x101>, - <0x4040 0x1 0x1>, - <0x4044 0xffffffff 0x1010101>, - <0x4048 0x1 0x1>, - <0x404c 0x801f 0x4>, - <0x8004 0x70007 0x40004>, - <0x8008 0x801f 0x4>, - <0x8010 0xf000f 0x80008>, - <0x8018 0x801f 0x4>, - <0x8020 0x70007 0x40004>, - <0x8028 0x801f 0x4>, - <0x8030 0x801f 0x4>, - <0x8038 0x801f 0x4>, - <0x8040 0x801f 0x4>, - <0x8048 0x801f 0x4>, - <0x8050 0x801f 0x4>, - <0x8058 0x801f 0x4>, - <0x8060 0x801f 0x4>; - apple,tunable-pcie-adapter = - <0x1008 0x6 0x6>; - apple,tunable-router-ap-fw = - <0x8 0xff2 0x482>; usb4_0_dart: iommu@a80000 { compatible = "apple,t8152-acio-dart"; @@ -175,30 +161,6 @@ interrupts = ; power-domains = <&cio_psd59>; apple,dma-range = <0x100 0x0 0x10 0x0>; - 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>, - <0x4600 0x2 0x2>; }; usb4_0_nhi: nhi@f00000 { @@ -246,112 +208,8 @@ <&usb4_0_dart 19>, <&usb4_0_dart 20>, <&usb4_0_dart 21>, <&usb4_0_dart 22>, <&usb4_0_dart 23>, <&usb4_0_dart 24>, <&usb4_0_dart 25>, <&usb4_0_dart 26>, <&usb4_0_dart 27>; - apple,thunderbolt-drom = - [db 00 00 00 00 00 00 00 00 5d 2d 12 e9 01 42 00 - 01 00 0f 00 01 00 08 81 80 02 80 00 00 00 08 82 - 90 01 80 00 00 00 03 83 20 02 84 05 85 09 01 00 - 05 86 09 01 00 02 87 05 88 09 01 00 0d 01 41 70 - 70 6c 65 20 49 6e 63 2e 00 06 02 69 4f 53 00 00]; - apple,tunable-nhi = - <0xf8004 0xff 0x80>, - <0xf8008 0x801f 0x4>, - <0xf8010 0x3f 0x20>, - <0xf8014 0x801f 0x4>, - <0xf801c 0x1f 0x10>, - <0xf8020 0x801f 0x4>, - <0xf8028 0xff 0x80>, - <0xf802c 0x801f 0x4>, - <0xf8034 0xff 0x80>, - <0xf8038 0x801f 0x4>, - <0xf8040 0x3f 0x20>, - <0xf8044 0x801f 0x4>, - <0xf804c 0x8007 0x1>, - <0xfc004 0x7 0x4>, - <0xfc008 0x801f 0x4>, - <0xfc010 0x7 0x4>, - <0xfc014 0x801f 0x4>, - <0xfc01c 0x7 0x4>, - <0xfc020 0x801f 0x4>, - <0xfc028 0x7 0x4>, - <0xfc02c 0x801f 0x4>, - <0xfc034 0x7 0x4>, - <0xfc038 0x801f 0x4>, - <0xfc040 0x7 0x4>, - <0xfc044 0x801f 0x4>, - <0xfc04c 0x8007 0x1>, - <0x4000 0x1000000f 0x10000002>, - <0x4004 0x1000000f 0x10000002>, - <0x4008 0x1000000f 0x10000002>, - <0x400c 0x1000000f 0x10000002>, - <0x4010 0x1000000f 0x10000002>, - <0x4014 0x1000000f 0x10000002>, - <0x4018 0x1000000f 0x10000002>, - <0x401c 0x1000000f 0x10000002>, - <0x4020 0x1000000f 0x10000002>, - <0x4024 0x1000000f 0x10000002>, - <0x4028 0x1000000f 0x10000002>, - <0x402c 0x1000000f 0x10000002>, - <0x4040 0x1000000f 0x10000002>, - <0x4044 0x1000000f 0x10000002>, - <0x4048 0x1000000f 0x10000002>, - <0x404c 0x1000000f 0x10000002>, - <0x4050 0x1000000f 0x10000002>, - <0x4054 0x1000000f 0x10000002>, - <0x4058 0x1000000f 0x10000002>, - <0x405c 0x1000000f 0x10000002>, - <0x4060 0x1000000f 0x10000002>, - <0x4064 0x1000000f 0x10000002>, - <0x4068 0x1000000f 0x10000002>, - <0x406c 0x1000000f 0x10000002>, - <0x4080 0x1000000f 0x10000002>, - <0x4084 0x1000000f 0x10000002>, - <0x4088 0x1000000f 0x10000002>, - <0x408c 0x1000000f 0x10000002>, - <0x4090 0x1000000f 0x10000002>, - <0x4094 0x1000000f 0x10000002>, - <0x4098 0x1000000f 0x10000002>, - <0x409c 0x1000000f 0x10000002>, - <0x40a0 0x1000000f 0x10000002>, - <0x40a4 0x1000000f 0x10000002>, - <0x40a8 0x1000000f 0x10000002>, - <0x40ac 0x1000000f 0x10000002>, - <0x40c0 0x1000000f 0x10000002>, - <0x40c4 0x1000000f 0x10000002>, - <0x40c8 0x1000000f 0x10000002>, - <0x40cc 0x1000000f 0x10000002>, - <0x40d0 0x1000000f 0x10000002>, - <0x40d4 0x1000000f 0x10000002>, - <0x40d8 0x1000000f 0x10000002>, - <0x40dc 0x1000000f 0x10000002>, - <0x40e0 0x1000000f 0x10000002>, - <0x40e4 0x1000000f 0x10000002>, - <0x40e8 0x1000000f 0x10000002>, - <0x40ec 0x1000000f 0x10000002>, - <0x4100 0x1000000f 0x10000002>, - <0x4104 0x1000000f 0x10000002>, - <0x4108 0x1000000f 0x10000002>, - <0x410c 0x1000000f 0x10000002>, - <0x4110 0x1000000f 0x10000002>, - <0x4114 0x1000000f 0x10000002>, - <0x4118 0x1000000f 0x10000002>, - <0x411c 0x1000000f 0x10000002>, - <0x4120 0x1000000f 0x10000002>, - <0x4124 0x1000000f 0x10000002>, - <0x4128 0x1000000f 0x10000002>, - <0x412c 0x1000000f 0x10000002>, - <0x4140 0x1000000f 0x10000002>, - <0x4144 0x1000000f 0x10000002>, - <0x4148 0x1000000f 0x10000002>, - <0x414c 0x1000000f 0x10000002>, - <0x4150 0x1000000f 0x10000002>, - <0x4154 0x1000000f 0x10000002>, - <0x4158 0x1000000f 0x10000002>, - <0x415c 0x1000000f 0x10000002>, - <0x4160 0x1000000f 0x10000002>, - <0x4164 0x1000000f 0x10000002>, - <0x4168 0x1000000f 0x10000002>, - <0x416c 0x1000000f 0x10000002>, - <0x43e4 0x7 0x7>; + /* Filled by the bootloader. */ + apple,thunderbolt-drom = [00]; }; ports { @@ -399,41 +257,6 @@ lstx-gpios = <&pinctrl_aop 21 GPIO_ACTIVE_HIGH>; thunderbolt-switch; apple,pcie-tunnel = <&usb4_1_tunnel>; - apple,tunable-rc = - <0x0 0xfff0 0x5010>, - <0x2c 0x4 0x0>, - <0xac 0xffffffff 0x84638463>, - <0x4004 0x1ff01ff 0x1000100>, - <0x4008 0x801f 0x4>, - <0x4010 0x7f 0x40>, - <0x4014 0x801f 0x4>, - <0x401c 0x7f 0x40>, - <0x4024 0x801f 0x4>, - <0x402c 0x7f 0x40>, - <0x4030 0x801f 0x4>, - <0x4038 0xffffffff 0x1010101>, - <0x403c 0xffff 0x101>, - <0x4040 0x1 0x1>, - <0x4044 0xffffffff 0x1010101>, - <0x4048 0x1 0x1>, - <0x404c 0x801f 0x4>, - <0x8004 0x70007 0x40004>, - <0x8008 0x801f 0x4>, - <0x8010 0xf000f 0x80008>, - <0x8018 0x801f 0x4>, - <0x8020 0x70007 0x40004>, - <0x8028 0x801f 0x4>, - <0x8030 0x801f 0x4>, - <0x8038 0x801f 0x4>, - <0x8040 0x801f 0x4>, - <0x8048 0x801f 0x4>, - <0x8050 0x801f 0x4>, - <0x8058 0x801f 0x4>, - <0x8060 0x801f 0x4>; - apple,tunable-pcie-adapter = - <0x1008 0x6 0x6>; - apple,tunable-router-ap-fw = - <0x8 0xff2 0x482>; usb4_1_dart: iommu@a80000 { compatible = "apple,t8152-acio-dart"; @@ -445,30 +268,6 @@ interrupts = ; power-domains = <&cio_psd60>; apple,dma-range = <0x100 0x0 0x10 0x0>; - 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>, - <0x4600 0x2 0x2>; }; usb4_1_nhi: nhi@f00000 { @@ -516,112 +315,8 @@ <&usb4_1_dart 19>, <&usb4_1_dart 20>, <&usb4_1_dart 21>, <&usb4_1_dart 22>, <&usb4_1_dart 23>, <&usb4_1_dart 24>, <&usb4_1_dart 25>, <&usb4_1_dart 26>, <&usb4_1_dart 27>; - apple,thunderbolt-drom = - [c8 01 00 00 00 00 00 00 00 06 7e 74 db 01 42 00 - 01 00 0f 00 01 00 08 81 81 02 81 00 00 00 08 82 - 91 01 81 00 00 00 03 83 20 02 84 05 85 09 01 00 - 05 86 09 01 00 02 87 05 88 09 01 00 0d 01 41 70 - 70 6c 65 20 49 6e 63 2e 00 06 02 69 4f 53 00 00]; - apple,tunable-nhi = - <0xf8004 0xff 0x80>, - <0xf8008 0x801f 0x4>, - <0xf8010 0x3f 0x20>, - <0xf8014 0x801f 0x4>, - <0xf801c 0x1f 0x10>, - <0xf8020 0x801f 0x4>, - <0xf8028 0xff 0x80>, - <0xf802c 0x801f 0x4>, - <0xf8034 0xff 0x80>, - <0xf8038 0x801f 0x4>, - <0xf8040 0x3f 0x20>, - <0xf8044 0x801f 0x4>, - <0xf804c 0x8007 0x1>, - <0xfc004 0x7 0x4>, - <0xfc008 0x801f 0x4>, - <0xfc010 0x7 0x4>, - <0xfc014 0x801f 0x4>, - <0xfc01c 0x7 0x4>, - <0xfc020 0x801f 0x4>, - <0xfc028 0x7 0x4>, - <0xfc02c 0x801f 0x4>, - <0xfc034 0x7 0x4>, - <0xfc038 0x801f 0x4>, - <0xfc040 0x7 0x4>, - <0xfc044 0x801f 0x4>, - <0xfc04c 0x8007 0x1>, - <0x4000 0x1000000f 0x10000002>, - <0x4004 0x1000000f 0x10000002>, - <0x4008 0x1000000f 0x10000002>, - <0x400c 0x1000000f 0x10000002>, - <0x4010 0x1000000f 0x10000002>, - <0x4014 0x1000000f 0x10000002>, - <0x4018 0x1000000f 0x10000002>, - <0x401c 0x1000000f 0x10000002>, - <0x4020 0x1000000f 0x10000002>, - <0x4024 0x1000000f 0x10000002>, - <0x4028 0x1000000f 0x10000002>, - <0x402c 0x1000000f 0x10000002>, - <0x4040 0x1000000f 0x10000002>, - <0x4044 0x1000000f 0x10000002>, - <0x4048 0x1000000f 0x10000002>, - <0x404c 0x1000000f 0x10000002>, - <0x4050 0x1000000f 0x10000002>, - <0x4054 0x1000000f 0x10000002>, - <0x4058 0x1000000f 0x10000002>, - <0x405c 0x1000000f 0x10000002>, - <0x4060 0x1000000f 0x10000002>, - <0x4064 0x1000000f 0x10000002>, - <0x4068 0x1000000f 0x10000002>, - <0x406c 0x1000000f 0x10000002>, - <0x4080 0x1000000f 0x10000002>, - <0x4084 0x1000000f 0x10000002>, - <0x4088 0x1000000f 0x10000002>, - <0x408c 0x1000000f 0x10000002>, - <0x4090 0x1000000f 0x10000002>, - <0x4094 0x1000000f 0x10000002>, - <0x4098 0x1000000f 0x10000002>, - <0x409c 0x1000000f 0x10000002>, - <0x40a0 0x1000000f 0x10000002>, - <0x40a4 0x1000000f 0x10000002>, - <0x40a8 0x1000000f 0x10000002>, - <0x40ac 0x1000000f 0x10000002>, - <0x40c0 0x1000000f 0x10000002>, - <0x40c4 0x1000000f 0x10000002>, - <0x40c8 0x1000000f 0x10000002>, - <0x40cc 0x1000000f 0x10000002>, - <0x40d0 0x1000000f 0x10000002>, - <0x40d4 0x1000000f 0x10000002>, - <0x40d8 0x1000000f 0x10000002>, - <0x40dc 0x1000000f 0x10000002>, - <0x40e0 0x1000000f 0x10000002>, - <0x40e4 0x1000000f 0x10000002>, - <0x40e8 0x1000000f 0x10000002>, - <0x40ec 0x1000000f 0x10000002>, - <0x4100 0x1000000f 0x10000002>, - <0x4104 0x1000000f 0x10000002>, - <0x4108 0x1000000f 0x10000002>, - <0x410c 0x1000000f 0x10000002>, - <0x4110 0x1000000f 0x10000002>, - <0x4114 0x1000000f 0x10000002>, - <0x4118 0x1000000f 0x10000002>, - <0x411c 0x1000000f 0x10000002>, - <0x4120 0x1000000f 0x10000002>, - <0x4124 0x1000000f 0x10000002>, - <0x4128 0x1000000f 0x10000002>, - <0x412c 0x1000000f 0x10000002>, - <0x4140 0x1000000f 0x10000002>, - <0x4144 0x1000000f 0x10000002>, - <0x4148 0x1000000f 0x10000002>, - <0x414c 0x1000000f 0x10000002>, - <0x4150 0x1000000f 0x10000002>, - <0x4154 0x1000000f 0x10000002>, - <0x4158 0x1000000f 0x10000002>, - <0x415c 0x1000000f 0x10000002>, - <0x4160 0x1000000f 0x10000002>, - <0x4164 0x1000000f 0x10000002>, - <0x4168 0x1000000f 0x10000002>, - <0x416c 0x1000000f 0x10000002>, - <0x43e4 0x7 0x7>; + /* Filled by the bootloader. */ + apple,thunderbolt-drom = [00]; }; ports { @@ -669,41 +364,6 @@ lstx-gpios = <&pinctrl_aop 25 GPIO_ACTIVE_HIGH>; thunderbolt-switch; apple,pcie-tunnel = <&usb4_3_tunnel>; - apple,tunable-rc = - <0x0 0xfff0 0x5010>, - <0x2c 0x4 0x0>, - <0xac 0xffffffff 0x84638463>, - <0x4004 0x1ff01ff 0x1000100>, - <0x4008 0x801f 0x4>, - <0x4010 0x7f 0x40>, - <0x4014 0x801f 0x4>, - <0x401c 0x7f 0x40>, - <0x4024 0x801f 0x4>, - <0x402c 0x7f 0x40>, - <0x4030 0x801f 0x4>, - <0x4038 0xffffffff 0x1010101>, - <0x403c 0xffff 0x101>, - <0x4040 0x1 0x1>, - <0x4044 0xffffffff 0x1010101>, - <0x4048 0x1 0x1>, - <0x404c 0x801f 0x4>, - <0x8004 0x70007 0x40004>, - <0x8008 0x801f 0x4>, - <0x8010 0xf000f 0x80008>, - <0x8018 0x801f 0x4>, - <0x8020 0x70007 0x40004>, - <0x8028 0x801f 0x4>, - <0x8030 0x801f 0x4>, - <0x8038 0x801f 0x4>, - <0x8040 0x801f 0x4>, - <0x8048 0x801f 0x4>, - <0x8050 0x801f 0x4>, - <0x8058 0x801f 0x4>, - <0x8060 0x801f 0x4>; - apple,tunable-pcie-adapter = - <0x1008 0x6 0x6>; - apple,tunable-router-ap-fw = - <0x8 0xff2 0x482>; usb4_3_dart: iommu@a80000 { compatible = "apple,t8152-acio-dart"; @@ -715,30 +375,6 @@ interrupts = ; power-domains = <&cio_psd62>; apple,dma-range = <0x100 0x0 0x10 0x0>; - 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>, - <0x4600 0x2 0x2>; }; usb4_3_nhi: nhi@f00000 { @@ -786,112 +422,8 @@ <&usb4_3_dart 19>, <&usb4_3_dart 20>, <&usb4_3_dart 21>, <&usb4_3_dart 22>, <&usb4_3_dart 23>, <&usb4_3_dart 24>, <&usb4_3_dart 25>, <&usb4_3_dart 26>, <&usb4_3_dart 27>; - apple,thunderbolt-drom = - [ee 03 00 00 00 00 00 00 00 4e bc d0 4b 01 3d 00 - 01 00 0f 00 01 00 08 81 83 02 83 00 00 00 08 82 - 93 01 83 00 00 00 03 83 20 02 84 05 85 09 01 00 - 05 86 09 01 00 02 87 0d 01 41 70 70 6c 65 20 49 - 6e 63 2e 00 06 02 69 4f 53 00 00 00]; - apple,tunable-nhi = - <0xf8004 0xff 0x80>, - <0xf8008 0x801f 0x4>, - <0xf8010 0x3f 0x20>, - <0xf8014 0x801f 0x4>, - <0xf801c 0x1f 0x10>, - <0xf8020 0x801f 0x4>, - <0xf8028 0xff 0x80>, - <0xf802c 0x801f 0x4>, - <0xf8034 0xff 0x80>, - <0xf8038 0x801f 0x4>, - <0xf8040 0x3f 0x20>, - <0xf8044 0x801f 0x4>, - <0xf804c 0x8007 0x1>, - <0xfc004 0x7 0x4>, - <0xfc008 0x801f 0x4>, - <0xfc010 0x7 0x4>, - <0xfc014 0x801f 0x4>, - <0xfc01c 0x7 0x4>, - <0xfc020 0x801f 0x4>, - <0xfc028 0x7 0x4>, - <0xfc02c 0x801f 0x4>, - <0xfc034 0x7 0x4>, - <0xfc038 0x801f 0x4>, - <0xfc040 0x7 0x4>, - <0xfc044 0x801f 0x4>, - <0xfc04c 0x8007 0x1>, - <0x4000 0x1000000f 0x10000002>, - <0x4004 0x1000000f 0x10000002>, - <0x4008 0x1000000f 0x10000002>, - <0x400c 0x1000000f 0x10000002>, - <0x4010 0x1000000f 0x10000002>, - <0x4014 0x1000000f 0x10000002>, - <0x4018 0x1000000f 0x10000002>, - <0x401c 0x1000000f 0x10000002>, - <0x4020 0x1000000f 0x10000002>, - <0x4024 0x1000000f 0x10000002>, - <0x4028 0x1000000f 0x10000002>, - <0x402c 0x1000000f 0x10000002>, - <0x4040 0x1000000f 0x10000002>, - <0x4044 0x1000000f 0x10000002>, - <0x4048 0x1000000f 0x10000002>, - <0x404c 0x1000000f 0x10000002>, - <0x4050 0x1000000f 0x10000002>, - <0x4054 0x1000000f 0x10000002>, - <0x4058 0x1000000f 0x10000002>, - <0x405c 0x1000000f 0x10000002>, - <0x4060 0x1000000f 0x10000002>, - <0x4064 0x1000000f 0x10000002>, - <0x4068 0x1000000f 0x10000002>, - <0x406c 0x1000000f 0x10000002>, - <0x4080 0x1000000f 0x10000002>, - <0x4084 0x1000000f 0x10000002>, - <0x4088 0x1000000f 0x10000002>, - <0x408c 0x1000000f 0x10000002>, - <0x4090 0x1000000f 0x10000002>, - <0x4094 0x1000000f 0x10000002>, - <0x4098 0x1000000f 0x10000002>, - <0x409c 0x1000000f 0x10000002>, - <0x40a0 0x1000000f 0x10000002>, - <0x40a4 0x1000000f 0x10000002>, - <0x40a8 0x1000000f 0x10000002>, - <0x40ac 0x1000000f 0x10000002>, - <0x40c0 0x1000000f 0x10000002>, - <0x40c4 0x1000000f 0x10000002>, - <0x40c8 0x1000000f 0x10000002>, - <0x40cc 0x1000000f 0x10000002>, - <0x40d0 0x1000000f 0x10000002>, - <0x40d4 0x1000000f 0x10000002>, - <0x40d8 0x1000000f 0x10000002>, - <0x40dc 0x1000000f 0x10000002>, - <0x40e0 0x1000000f 0x10000002>, - <0x40e4 0x1000000f 0x10000002>, - <0x40e8 0x1000000f 0x10000002>, - <0x40ec 0x1000000f 0x10000002>, - <0x4100 0x1000000f 0x10000002>, - <0x4104 0x1000000f 0x10000002>, - <0x4108 0x1000000f 0x10000002>, - <0x410c 0x1000000f 0x10000002>, - <0x4110 0x1000000f 0x10000002>, - <0x4114 0x1000000f 0x10000002>, - <0x4118 0x1000000f 0x10000002>, - <0x411c 0x1000000f 0x10000002>, - <0x4120 0x1000000f 0x10000002>, - <0x4124 0x1000000f 0x10000002>, - <0x4128 0x1000000f 0x10000002>, - <0x412c 0x1000000f 0x10000002>, - <0x4140 0x1000000f 0x10000002>, - <0x4144 0x1000000f 0x10000002>, - <0x4148 0x1000000f 0x10000002>, - <0x414c 0x1000000f 0x10000002>, - <0x4150 0x1000000f 0x10000002>, - <0x4154 0x1000000f 0x10000002>, - <0x4158 0x1000000f 0x10000002>, - <0x415c 0x1000000f 0x10000002>, - <0x4160 0x1000000f 0x10000002>, - <0x4164 0x1000000f 0x10000002>, - <0x4168 0x1000000f 0x10000002>, - <0x416c 0x1000000f 0x10000002>, - <0x43e4 0x7 0x7>; + /* Filled by the bootloader. */ + apple,thunderbolt-drom = [00]; }; ports { @@ -924,14 +456,6 @@ interrupts = ; power-domains = <&cio_psd86>; apple,dma-range = <0x100 0x80000000 0x0 0x7ff00000>; - apple,tunable = - <0x20c 0x80000121 0x80000121>, - <0x220 0xf0f 0xf0f>, - <0x224 0xffff 0x909>, - <0x300 0x1f31 0x1>, - <0x308 0x3ffffffc 0x10000000>, - <0x310 0x3ffffffc 0x3ffffffc>, - <0x4600 0x2 0x2>; }; usb4_0_pcie: pcie@1c50000000 { @@ -962,48 +486,6 @@ ranges = <0x43000000 0x8 0x0 0x8 0x0 0x2 0x0>, <0x2000000 0x0 0x100000 0xa 0x100000 0x0 0x3ff00000>, <0x42000000 0x0 0x40000000 0xa 0x40000000 0x0 0x40000000>; - apple,tunable-debug = - <0x1000 0x1 0x0>; - apple,tunable-fabric = - <0x4 0x3f003f 0x200020>, - <0x8 0x1 0x1>, - <0xc 0x1 0x1>, - <0x10 0x801f 0x4>, - <0x18 0x1ff 0x100>, - <0x1c 0x1 0x1>, - <0x20 0x801f 0x4>, - <0x28 0x1f 0x10>, - <0x2c 0x801f 0x4>, - <0x34 0x3f 0x20>, - <0x38 0x801f 0x4>, - <0x40 0x3f 0x20>, - <0x44 0x801f 0x4>, - <0x4c 0x10001 0x10001>, - <0x50 0x1 0x1>, - <0x54 0x1 0x1>, - <0x58 0x801f 0x4>, - <0x60 0x7f007f 0x450045>, - <0x64 0x801f 0x4>, - <0x6c 0x1f001f 0x100010>, - <0x70 0x801f 0x4>, - <0x78 0x801f 0x4>, - <0x80 0x1 0x1>, - <0x84 0x1 0x1>, - <0x88 0x801f 0x4>, - <0x90 0x1 0x1>, - <0x94 0x801f 0x4>, - <0x9c 0x1 0x1>, - <0xa0 0x801f 0x4>, - <0xa8 0x1 0x1>, - <0xac 0x1 0x1>, - <0xb0 0x801f 0x4>, - <0xb8 0x801f 0x4>, - <0xc0 0x801f 0x4>; - apple,tunable-rc = - <0x78 0x7000 0x0>, - <0x718 0x7c000 0x0>, - <0x814 0xffffffff 0x2000f060>, - <0x8bc 0x1 0x0>; usb4_0_pcie_port: pci@0,0 { device_type = "pci"; @@ -1019,9 +501,6 @@ <0 0 0 2 &usb4_0_pcie_port 0 0 0 1>, <0 0 0 3 &usb4_0_pcie_port 0 0 0 2>, <0 0 0 4 &usb4_0_pcie_port 0 0 0 3>; - apple,tunable = - <0x140 0x1 0x1>, - <0x2a0 0x7e 0xa>; }; }; }; @@ -1042,14 +521,6 @@ interrupts = ; power-domains = <&cio_psd87>; apple,dma-range = <0x100 0x80000000 0x0 0x7ff00000>; - apple,tunable = - <0x20c 0x80000121 0x80000121>, - <0x220 0xf0f 0xf0f>, - <0x224 0xffff 0x909>, - <0x300 0x1f31 0x1>, - <0x308 0x3ffffffc 0x10000000>, - <0x310 0x3ffffffc 0x3ffffffc>, - <0x4600 0x2 0x2>; }; usb4_1_pcie: pcie@1c60000000 { @@ -1080,48 +551,6 @@ ranges = <0x43000000 0xc 0x0 0xc 0x0 0x2 0x0>, <0x2000000 0x0 0x100000 0xe 0x100000 0x0 0x3ff00000>, <0x42000000 0x0 0x40000000 0xe 0x40000000 0x0 0x40000000>; - apple,tunable-debug = - <0x1000 0x1 0x0>; - apple,tunable-fabric = - <0x4 0x3f003f 0x200020>, - <0x8 0x1 0x1>, - <0xc 0x1 0x1>, - <0x10 0x801f 0x4>, - <0x18 0x1ff 0x100>, - <0x1c 0x1 0x1>, - <0x20 0x801f 0x4>, - <0x28 0x1f 0x10>, - <0x2c 0x801f 0x4>, - <0x34 0x3f 0x20>, - <0x38 0x801f 0x4>, - <0x40 0x3f 0x20>, - <0x44 0x801f 0x4>, - <0x4c 0x10001 0x10001>, - <0x50 0x1 0x1>, - <0x54 0x1 0x1>, - <0x58 0x801f 0x4>, - <0x60 0x7f007f 0x450045>, - <0x64 0x801f 0x4>, - <0x6c 0x1f001f 0x100010>, - <0x70 0x801f 0x4>, - <0x78 0x801f 0x4>, - <0x80 0x1 0x1>, - <0x84 0x1 0x1>, - <0x88 0x801f 0x4>, - <0x90 0x1 0x1>, - <0x94 0x801f 0x4>, - <0x9c 0x1 0x1>, - <0xa0 0x801f 0x4>, - <0xa8 0x1 0x1>, - <0xac 0x1 0x1>, - <0xb0 0x801f 0x4>, - <0xb8 0x801f 0x4>, - <0xc0 0x801f 0x4>; - apple,tunable-rc = - <0x78 0x7000 0x0>, - <0x718 0x7c000 0x0>, - <0x814 0xffffffff 0x2000f060>, - <0x8bc 0x1 0x0>; usb4_1_pcie_port: pci@0,0 { device_type = "pci"; @@ -1137,9 +566,6 @@ <0 0 0 2 &usb4_1_pcie_port 0 0 0 1>, <0 0 0 3 &usb4_1_pcie_port 0 0 0 2>, <0 0 0 4 &usb4_1_pcie_port 0 0 0 3>; - apple,tunable = - <0x140 0x1 0x1>, - <0x2a0 0x7e 0xa>; }; }; }; @@ -1160,14 +586,6 @@ interrupts = ; power-domains = <&cio_psd89>; apple,dma-range = <0x100 0x80000000 0x0 0x7ff00000>; - apple,tunable = - <0x20c 0x80000121 0x80000121>, - <0x220 0xf0f 0xf0f>, - <0x224 0xffff 0x909>, - <0x300 0x1f31 0x1>, - <0x308 0x3ffffffc 0x10000000>, - <0x310 0x3ffffffc 0x3ffffffc>, - <0x4600 0x2 0x2>; }; usb4_3_pcie: pcie@1c80000000 { @@ -1198,48 +616,6 @@ ranges = <0x43000000 0x14 0x0 0x14 0x0 0x2 0x0>, <0x2000000 0x0 0x100000 0x16 0x100000 0x0 0x3ff00000>, <0x42000000 0x0 0x40000000 0x16 0x40000000 0x0 0x40000000>; - apple,tunable-debug = - <0x1000 0x1 0x0>; - apple,tunable-fabric = - <0x4 0x3f003f 0x200020>, - <0x8 0x1 0x1>, - <0xc 0x1 0x1>, - <0x10 0x801f 0x4>, - <0x18 0x1ff 0x100>, - <0x1c 0x1 0x1>, - <0x20 0x801f 0x4>, - <0x28 0x1f 0x10>, - <0x2c 0x801f 0x4>, - <0x34 0x3f 0x20>, - <0x38 0x801f 0x4>, - <0x40 0x3f 0x20>, - <0x44 0x801f 0x4>, - <0x4c 0x10001 0x10001>, - <0x50 0x1 0x1>, - <0x54 0x1 0x1>, - <0x58 0x801f 0x4>, - <0x60 0x7f007f 0x450045>, - <0x64 0x801f 0x4>, - <0x6c 0x1f001f 0x100010>, - <0x70 0x801f 0x4>, - <0x78 0x801f 0x4>, - <0x80 0x1 0x1>, - <0x84 0x1 0x1>, - <0x88 0x801f 0x4>, - <0x90 0x1 0x1>, - <0x94 0x801f 0x4>, - <0x9c 0x1 0x1>, - <0xa0 0x801f 0x4>, - <0xa8 0x1 0x1>, - <0xac 0x1 0x1>, - <0xb0 0x801f 0x4>, - <0xb8 0x801f 0x4>, - <0xc0 0x801f 0x4>; - apple,tunable-rc = - <0x78 0x7000 0x0>, - <0x718 0x7c000 0x0>, - <0x814 0xffffffff 0x2000f060>, - <0x8bc 0x1 0x0>; usb4_3_pcie_port: pci@0,0 { device_type = "pci"; @@ -1255,9 +631,6 @@ <0 0 0 2 &usb4_3_pcie_port 0 0 0 1>, <0 0 0 3 &usb4_3_pcie_port 0 0 0 2>, <0 0 0 4 &usb4_3_pcie_port 0 0 0 3>; - apple,tunable = - <0x140 0x1 0x1>, - <0x2a0 0x7e 0xa>; }; }; };