1 // SPDX-License-Identifier: GPL-2.0-only
3 * ARM64 CPU idle arch support
5 * Copyright (C) 2014 ARM Ltd.
6 * Author: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
9 #include <linux/acpi.h>
10 #include <linux/cpuidle.h>
11 #include <linux/cpu_pm.h>
13 #include <linux/of_device.h>
15 #include <asm/cpuidle.h>
16 #include <asm/cpu_ops.h>
18 int arm_cpuidle_init(unsigned int cpu
)
20 int ret
= -EOPNOTSUPP
;
22 if (cpu_ops
[cpu
] && cpu_ops
[cpu
]->cpu_suspend
&&
23 cpu_ops
[cpu
]->cpu_init_idle
)
24 ret
= cpu_ops
[cpu
]->cpu_init_idle(cpu
);
30 * arm_cpuidle_suspend() - function to enter a low-power idle state
31 * @arg: argument to pass to CPU suspend operations
33 * Return: 0 on success, -EOPNOTSUPP if CPU suspend hook not initialized, CPU
34 * operations back-end error code otherwise.
36 int arm_cpuidle_suspend(int index
)
38 int cpu
= smp_processor_id();
40 return cpu_ops
[cpu
]->cpu_suspend(index
);
45 #include <acpi/processor.h>
47 #define ARM64_LPI_IS_RETENTION_STATE(arch_flags) (!(arch_flags))
49 int acpi_processor_ffh_lpi_probe(unsigned int cpu
)
51 return arm_cpuidle_init(cpu
);
54 int acpi_processor_ffh_lpi_enter(struct acpi_lpi_state
*lpi
)
56 if (ARM64_LPI_IS_RETENTION_STATE(lpi
->arch_flags
))
57 return CPU_PM_CPU_IDLE_ENTER_RETENTION(arm_cpuidle_suspend
,
60 return CPU_PM_CPU_IDLE_ENTER(arm_cpuidle_suspend
, lpi
->index
);