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[] = { 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); 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. */ 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); 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) { 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. */