Linux 4.18.10
[linux/fpc-iii.git] / arch / arm64 / kernel / cpuidle.c
blobf2d13810daa8fc28449be12138e398a14275fc9a
1 /*
2 * ARM64 CPU idle arch support
4 * Copyright (C) 2014 ARM Ltd.
5 * Author: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
12 #include <linux/acpi.h>
13 #include <linux/cpuidle.h>
14 #include <linux/cpu_pm.h>
15 #include <linux/of.h>
16 #include <linux/of_device.h>
18 #include <asm/cpuidle.h>
19 #include <asm/cpu_ops.h>
21 int arm_cpuidle_init(unsigned int cpu)
23 int ret = -EOPNOTSUPP;
25 if (cpu_ops[cpu] && cpu_ops[cpu]->cpu_suspend &&
26 cpu_ops[cpu]->cpu_init_idle)
27 ret = cpu_ops[cpu]->cpu_init_idle(cpu);
29 return ret;
32 /**
33 * arm_cpuidle_suspend() - function to enter a low-power idle state
34 * @arg: argument to pass to CPU suspend operations
36 * Return: 0 on success, -EOPNOTSUPP if CPU suspend hook not initialized, CPU
37 * operations back-end error code otherwise.
39 int arm_cpuidle_suspend(int index)
41 int cpu = smp_processor_id();
43 return cpu_ops[cpu]->cpu_suspend(index);
46 #ifdef CONFIG_ACPI
48 #include <acpi/processor.h>
50 #define ARM64_LPI_IS_RETENTION_STATE(arch_flags) (!(arch_flags))
52 int acpi_processor_ffh_lpi_probe(unsigned int cpu)
54 return arm_cpuidle_init(cpu);
57 int acpi_processor_ffh_lpi_enter(struct acpi_lpi_state *lpi)
59 if (ARM64_LPI_IS_RETENTION_STATE(lpi->arch_flags))
60 return CPU_PM_CPU_IDLE_ENTER_RETENTION(arm_cpuidle_suspend,
61 lpi->index);
62 else
63 return CPU_PM_CPU_IDLE_ENTER(arm_cpuidle_suspend, lpi->index);
65 #endif