Merge tag 'for-linus-20190706' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / arch / arm64 / kernel / cpuidle.c
blobd1048173fd8a1bdcf77b607def93b4d629dae71c
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * ARM64 CPU idle arch support
5 * Copyright (C) 2014 ARM Ltd.
6 * Author: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
7 */
9 #include <linux/acpi.h>
10 #include <linux/cpuidle.h>
11 #include <linux/cpu_pm.h>
12 #include <linux/of.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);
26 return ret;
29 /**
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);
43 #ifdef CONFIG_ACPI
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,
58 lpi->index);
59 else
60 return CPU_PM_CPU_IDLE_ENTER(arm_cpuidle_suspend, lpi->index);
62 #endif