From c57bde2634d87779b75c227adaf07e0b9cc6d550 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Thu, 19 Nov 2026 23:28:19 +1100 Subject: [PATCH 1/6] soc: apple: sleep: say whether the device tree describes a sleep Several drivers select their T6050 (M5 Pro and Max) deep-sleep handling with a list of boards, the ones the sleep has run on (J714s, J716c). What those boards have in common is in the device tree: an available sleep-controller node, compatible "apple,t6050-sleep". No other board in the tree has one; a board gains it with its sleep description. Add apple_sleep_described(compatible), true when an available node with that compatible exists, and apple_t6050_sleep_described() for "apple,t6050-sleep". Both are static inline and independent of CONFIG_APPLE_SOC_SLEEP, as the board checks they replace are. Signed-off-by: Ryan Murray --- include/linux/soc/apple/sleep.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/include/linux/soc/apple/sleep.h b/include/linux/soc/apple/sleep.h index cec1e88452676..25ad980bec878 100644 --- a/include/linux/soc/apple/sleep.h +++ b/include/linux/soc/apple/sleep.h @@ -9,6 +9,7 @@ #include #include #include +#include #include struct device; @@ -36,6 +37,32 @@ struct apple_sleep_smc_saved_ops { int (*pmvc)(void *data); }; +/* + * Whether the device tree describes a deep sleep with the sleep controller @compatible: an + * available node with that compatible. The per-device handling that belongs to such a sleep + * (what a block keeps or puts back across it, the steps it takes for it) is selected by this, + * not by the boards the sleep has run on, so a board gains it with its sleep description. + * It tells what the hardware description has, independent of CONFIG_APPLE_SOC_SLEEP. + */ +static inline bool apple_sleep_described(const char *compatible) +{ + struct device_node *np; + + for_each_compatible_node(np, NULL, compatible) { + if (of_device_is_available(np)) { + of_node_put(np); + return true; + } + } + return false; +} + +/* The T6050's (M5 Pro and Max) deep sleep, apple,t6050-sleep. */ +static inline bool apple_t6050_sleep_described(void) +{ + return apple_sleep_described("apple,t6050-sleep"); +} + #if IS_ENABLED(CONFIG_APPLE_SOC_SLEEP) const struct apple_sleep_smc_policy *apple_sleep_smc_policy(void); /* J813 experiment: send the final SMC notice after the peer idle handshakes. */ From d8de53df510df45540a8af7a1cf25e2a5f129892 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Thu, 19 Nov 2026 23:28:31 +1100 Subject: [PATCH 2/6] irqchip/apple-aic: set up the T6050 sleep save by the sleep description The AIC3 save and restore over a T6050 deep sleep were registered on the J714s and the J716c, by board name. The reason is the sleep: its last steps mask every interrupt and acknowledge events by hand, so the controller's configuration has to be saved and put back around it. Register them where the device tree describes that sleep (apple,t6050-sleep). In the tree today that is the J714s and the J716c only, the boards the list named, so nothing changes; another board gets them with its sleep description. Fixes: 55b73f1388ed ("irqchip/apple-aic: keep the T6050 controller over a J716c deep sleep too") Signed-off-by: Ryan Murray --- drivers/irqchip/irq-apple-aic.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/irqchip/irq-apple-aic.c b/drivers/irqchip/irq-apple-aic.c index 0a9aeced27721..70aa543c18a2e 100644 --- a/drivers/irqchip/irq-apple-aic.c +++ b/drivers/irqchip/irq-apple-aic.c @@ -56,6 +56,7 @@ #include #include #include +#include #include #include #include @@ -286,8 +287,8 @@ struct aic_info { bool siq_cfg_routing; /* A firmware-driven suspend powers the controller down: aic_syscore_ops keep it. */ bool fw_suspend; - /* If set, fw_suspend holds on these boards only */ - const char *const *fw_suspend_boards; + /* If set, fw_suspend holds only where this sleep controller is described */ + const char *fw_suspend_sleep; }; static const struct aic_info aic1_info __initconst = { @@ -336,20 +337,16 @@ static const struct aic_info aic3_info __initconst = { /* * The M5 Pro's sleep: the last steps mask every interrupt and acknowledge events by hand. The - * save and restore are set up on the boards with a T6050 sleep, the J714s and the J716c; - * another T6050 board is as one without them. + * save and restore are set up where the device tree describes that sleep (apple,t6050-sleep); + * a T6050 board without it is as one without them. */ -static const char *const aic3_t6050_sleep_boards[] __initconst = { - "apple,j714s", "apple,j716c", NULL -}; - static const struct aic_info aic3_t6050_info __initconst = { .version = 3, .irq_cfg = AIC3_IRQ_CFG, .fast_ipi = true, .local_fast_ipi = true, .fw_suspend = true, - .fw_suspend_boards = aic3_t6050_sleep_boards, + .fw_suspend_sleep = "apple,t6050-sleep", }; static const struct aic_info aic3_t8140_info __initconst = { @@ -1280,8 +1277,8 @@ static struct syscore aic_syscore = { static void __init aic_sleep_init(struct aic_irq_chip *irqc) { if (!irqc->info.fw_suspend || - (irqc->info.fw_suspend_boards && - !of_machine_compatible_match(irqc->info.fw_suspend_boards))) + (irqc->info.fw_suspend_sleep && + !apple_sleep_described(irqc->info.fw_suspend_sleep))) return; aic_sleep.irq_cfg = kcalloc(irqc->nr_die * irqc->nr_irq, sizeof(u32), GFP_KERNEL); From bdc27e657864fbf510df37dbc094d562cef6f847 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Thu, 19 Nov 2026 23:28:37 +1100 Subject: [PATCH 3/6] spmi: apple: recover a failed exchange on every generation 4 controller After a failed exchange a generation 4 controller drains its reply FIFO (a late reply, or a stray word read in a reply's place) before the next command, so no old reply can answer a new command. This was enabled on the J714s, J716c, J813 and J815 by board name, because their deep sleep writes the PMU on the same queue. Every other generation 4 machine refused all later commands after one failed exchange, until reboot. The drain is the controller's FIFO behaviour, not a property of the board, and the J815 already shows it is not tied to a sleep description (it has none in the tree). Do it on every generation 4 controller ("apple,t8142-spmi", the T6050 and T8142 machines). On a machine where no exchange fails nothing changes. The machines that gain it (J714c, J716s, J775c, J775d, J873s, K114c, K114s, K116c, K116s, J704) behave differently only after a failed exchange: they wait one command timeout and read out at most 64 words, and keep the failure if the FIFO does not empty, instead of failing every later command. Fixes: e6b75c3cfd5b ("spmi: apple: J714s: recover from a failed exchange on a generation 4 controller") Signed-off-by: Ryan Murray --- drivers/spmi/spmi-apple-controller.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/drivers/spmi/spmi-apple-controller.c b/drivers/spmi/spmi-apple-controller.c index c5f8829cfeb45..25ddd443e085b 100644 --- a/drivers/spmi/spmi-apple-controller.c +++ b/drivers/spmi/spmi-apple-controller.c @@ -235,23 +235,13 @@ static int apple_spmi_wait_rx_not_empty(struct spmi_controller *ctrl) * late, or the stray one that was read in a reply's place, is read out instead: the bus gets a * command's whole timeout to finish, then the reply FIFO is read until it is empty. Nothing of * an old exchange can then answer a new command. A FIFO that does not empty keeps the failure. - * On the J714s, J716c, J813 and J815, whose deep sleep writes the PMU on this queue. - * Other generation 4 machines keep refusing later commands after a failed exchange. + * This is the controller's own FIFO behaviour, so it holds on every generation 4 controller; + * it matters most where a deep sleep also writes the PMU on this queue. */ -static bool apple_spmi_gen4_recovers(void) -{ - return of_machine_is_compatible("apple,j714s") || - of_machine_is_compatible("apple,j716c") || - of_machine_is_compatible("apple,j813") || - of_machine_is_compatible("apple,j815"); -} - static int apple_spmi_gen4_recover(struct spmi_controller *ctrl, struct apple_spmi *spmi) { unsigned int i; - if (!apple_spmi_gen4_recovers()) - return -EIO; usleep_range(REG_POLL_TIMEOUT_US, 2 * REG_POLL_TIMEOUT_US); for (i = 0; i < SPMI_GEN4_REPLY_DRAIN_MAX; i++) { if (readl(spmi->regs + spmi->hw->status) & spmi->hw->rx_empty) { From 324d292ed894b0959879780fa448394e09994355 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Thu, 19 Nov 2026 23:28:44 +1100 Subject: [PATCH 4/6] mfd: macsmc: select the T6050 saved-context path by the sleep description The SMC's saved-context transport for the T6050 firmware sleep was set up on a machine that is "apple,t6050" and "apple,j714s" or "apple,j716c". It belongs to the sleep, so set it up for an "apple,t6050-smc" where the device tree describes that sleep (apple,t6050-sleep): the J714s and the J716c in the tree today, so nothing changes. The J714s wake-reason table stays keyed on the board: it is that board's SMC numbering (its SD reader and keyboard bits), board data rather than a capability. Fixes: 30f95ffef4b5 ("mfd: macsmc: the T6050 saved-context path on the J716c") Signed-off-by: Ryan Murray --- drivers/mfd/macsmc.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/mfd/macsmc.c b/drivers/mfd/macsmc.c index 5204c960ebe9d..60fe88f6819c2 100644 --- a/drivers/mfd/macsmc.c +++ b/drivers/mfd/macsmc.c @@ -646,10 +646,13 @@ static int apple_smc_probe(struct platform_device *pdev) mutex_init(&smc->mutex); spin_lock_init(&smc->lock); smc->dev = &pdev->dev; - smc->saved_enabled = of_machine_is_compatible("apple,t6050") && - (of_machine_is_compatible("apple,j714s") || - of_machine_is_compatible("apple,j716c")) && - of_device_is_compatible(dev->of_node, "apple,t6050-smc"); + /* The T6050 firmware sleep's saved context: where that sleep is described. */ + smc->saved_enabled = of_device_is_compatible(dev->of_node, "apple,t6050-smc") && + apple_t6050_sleep_described(); + /* + * Board data, not a capability: the J714s's SMC numbers its wake reasons with its own SD + * reader and keyboard bits. Another board keeps the generic table until its own is read. + */ if (smc->saved_enabled && of_machine_is_compatible("apple,j714s")) smc->wake_reasons = apple_smc_j714s_wake_reasons; /* J813's late notice needs the bounded, IRQ-independent transport too. */ From f5d802932f4423d4632df96761e362651a4495ca Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Thu, 19 Nov 2026 23:28:54 +1100 Subject: [PATCH 5/6] dmaengine: apple-sio: take the T6050 description by the sleep description The T6050 SIO description (stopped by the sleep's commit, channel words from the DT) was in force on the J714s only, and the node was taken by its generic compatible elsewhere. Its commit stop belongs to the T6050 sleep, so use it where the device tree describes that sleep (apple,t6050-sleep). Today the SIO only probes on the J714s: every T6050 tree ships the node disabled, and the boot loader enables it through the "sio" alias, which only the J714s has. The J716c, the one other board with the sleep described, has the same split SIO description, disabled and without the alias. So nothing changes on any board. Fixes: ed190a0eaa60 ("dma: apple-sio, soc: apple: T6050 SIO, AOP and AOP2 for the sleep") Signed-off-by: Ryan Murray --- drivers/dma/apple-sio.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/dma/apple-sio.c b/drivers/dma/apple-sio.c index d4d954708a8d2..99e8e3a641b33 100644 --- a/drivers/dma/apple-sio.c +++ b/drivers/dma/apple-sio.c @@ -697,12 +697,13 @@ static const struct sio_hw_data sio_hw_t6050 = { }; /* - * The T6050 description is in force on the board it has run on. On another T6050 board the - * node is taken as before: by its generic compatible. + * The T6050 description has the SIO stopped by the sleep's commit (commit_stop), so it is in + * force where the device tree describes that sleep (apple,t6050-sleep). On a T6050 board + * without it the node is taken as before: by its generic compatible. */ static bool sio_t6050_board(void) { - return of_machine_is_compatible("apple,j714s"); + return apple_t6050_sleep_described(); } static const struct of_device_id sio_of_match[] = { From 49a2916f451d473413a7201997749d4a586056fc Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Thu, 19 Nov 2026 23:29:01 +1100 Subject: [PATCH 6/6] soc: apple: rtkit: acknowledge the PMP v2 CoreAnalytics event wherever it runs The T6050 PMP v2 firmware sends an all-zero CoreAnalytics event on its auxiliary buffer endpoint some minutes after it starts. On the J714s it is acknowledged; on every other board the driver logs "refused auxiliary buffer request" and leaves the firmware without an answer. The event is part of the firmware's protocol, not of the board, so acknowledge it wherever "apple,t6050-pmp-v2" runs. This changes behaviour on the other boards whose tree enables the PMP (J714c and K116s): that one exact message gets the zero acknowledgement instead of the refusal. Every other word on the endpoint is handled as before. Fixes: 6a9d6bf8bc57 ("soc: apple: rtkit: J714s: acknowledge the PMP's CoreAnalytics event") Signed-off-by: Ryan Murray --- drivers/soc/apple/rtkit.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/soc/apple/rtkit.c b/drivers/soc/apple/rtkit.c index 22a7fad956426..a6cd51a72c784 100644 --- a/drivers/soc/apple/rtkit.c +++ b/drivers/soc/apple/rtkit.c @@ -1420,8 +1420,8 @@ static void apple_rtkit_oslog_rx(struct apple_rtkit *rtk, u64 msg) /* Registry-v2 firmware requests one 8 KiB auxiliary buffer at endpoint 7. * Identical requests reuse the session buffer; changed geometry is refused. - * On the J714s the same endpoint also carries a CoreAnalytics event with every - * field zero, some minutes after the PMP has started; it is acknowledged with + * The same endpoint also carries a CoreAnalytics event with every field zero, + * some minutes after the PMP has started (seen on the J714s); it is acknowledged with * an event acknowledgement whose fields are zero too, as the CoreAnalytics * endpoint of other coprocessors acknowledges an event * (apple_rtkit_coreanalytics_rx()). Any other message is refused as before. @@ -2273,8 +2273,11 @@ static struct apple_rtkit *__apple_rtkit_init(struct device *dev, void *cookie, goto free_rtk; rtk->pmp_registry_v2 = of_device_is_compatible(dev->of_node, "apple,t6050-pmp-v2"); - rtk->pmp_ca_event_ack = rtk->pmp_registry_v2 && - of_machine_is_compatible("apple,j714s"); + /* + * The PMP v2 firmware's all-zero CoreAnalytics event on its buffer endpoint is part of + * that firmware's protocol, so it is answered wherever the PMP v2 runs. + */ + rtk->pmp_ca_event_ack = rtk->pmp_registry_v2; init_completion(&rtk->epmap_completion); init_completion(&rtk->coreanalytics_completion);