Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions drivers/dma/apple-sio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = {
Expand Down
19 changes: 8 additions & 11 deletions drivers/irqchip/irq-apple-aic.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
#include <linux/limits.h>
#include <linux/of_address.h>
#include <linux/slab.h>
#include <linux/soc/apple/sleep.h>
#include <linux/suspend.h>
#include <linux/syscore_ops.h>
#include <linux/irqchip/irq-apple-aic.h>
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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);
Expand Down
11 changes: 7 additions & 4 deletions drivers/mfd/macsmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
11 changes: 7 additions & 4 deletions drivers/soc/apple/rtkit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
Expand Down
14 changes: 2 additions & 12 deletions drivers/spmi/spmi-apple-controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
27 changes: 27 additions & 0 deletions include/linux/soc/apple/sleep.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <linux/compiler_types.h>
#include <linux/errno.h>
#include <linux/kconfig.h>
#include <linux/of.h>
#include <linux/types.h>

struct device;
Expand Down Expand Up @@ -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. */
Expand Down
Loading