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>
12 #include <linux/psci.h>
14 #ifdef CONFIG_ACPI_PROCESSOR_IDLE
16 #include <acpi/processor.h>
18 #define ARM64_LPI_IS_RETENTION_STATE(arch_flags) (!(arch_flags))
20 static int psci_acpi_cpu_init_idle(unsigned int cpu)
23 struct acpi_lpi_state *lpi;
24 struct acpi_processor *pr = per_cpu(processors, cpu);
26 if (unlikely(!pr || !pr->flags.has_lpi))
30 * If the PSCI cpu_suspend function hook has not been initialized
31 * idle states must not be enabled, so bail out
33 if (!psci_ops.cpu_suspend)
36 count = pr->power.count - 1;
40 for (i = 0; i < count; i++) {
43 lpi = &pr->power.lpi_states[i + 1];
45 * Only bits[31:0] represent a PSCI power_state while
46 * bits[63:32] must be 0x0 as per ARM ACPI FFH Specification
49 if (!psci_power_state_is_valid(state)) {
50 pr_warn("Invalid PSCI power state %#x\n", state);
58 int acpi_processor_ffh_lpi_probe(unsigned int cpu)
60 return psci_acpi_cpu_init_idle(cpu);
63 __cpuidle int acpi_processor_ffh_lpi_enter(struct acpi_lpi_state *lpi)
65 u32 state = lpi->address;
67 if (ARM64_LPI_IS_RETENTION_STATE(lpi->arch_flags))
68 return CPU_PM_CPU_IDLE_ENTER_RETENTION_PARAM_RCU(psci_cpu_suspend_enter,
71 return CPU_PM_CPU_IDLE_ENTER_PARAM_RCU(psci_cpu_suspend_enter,