Lorenzo Pieralisi | d64f84f | 2014-07-17 10:30:07 +0100 | [diff] [blame] | 1 | /* |
| 2 | * ARM64 CPU idle arch support |
| 3 | * |
| 4 | * Copyright (C) 2014 ARM Ltd. |
| 5 | * Author: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> |
| 6 | * |
| 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. |
| 10 | */ |
| 11 | |
Sudeep Holla | 5a611ed | 2016-07-19 18:52:58 +0100 | [diff] [blame] | 12 | #include <linux/acpi.h> |
| 13 | #include <linux/cpuidle.h> |
| 14 | #include <linux/cpu_pm.h> |
Lorenzo Pieralisi | d64f84f | 2014-07-17 10:30:07 +0100 | [diff] [blame] | 15 | #include <linux/of.h> |
| 16 | #include <linux/of_device.h> |
| 17 | |
| 18 | #include <asm/cpuidle.h> |
| 19 | #include <asm/cpu_ops.h> |
| 20 | |
Sudeep Holla | ce3ad71 | 2016-07-19 18:52:55 +0100 | [diff] [blame] | 21 | int arm_cpuidle_init(unsigned int cpu) |
Lorenzo Pieralisi | d64f84f | 2014-07-17 10:30:07 +0100 | [diff] [blame] | 22 | { |
| 23 | int ret = -EOPNOTSUPP; |
Lorenzo Pieralisi | d64f84f | 2014-07-17 10:30:07 +0100 | [diff] [blame] | 24 | |
Jisheng Zhang | b5fda7e | 2016-03-25 11:08:55 +0800 | [diff] [blame] | 25 | if (cpu_ops[cpu] && cpu_ops[cpu]->cpu_suspend && |
| 26 | cpu_ops[cpu]->cpu_init_idle) |
Lorenzo Pieralisi | 819a882 | 2015-05-13 14:12:46 +0100 | [diff] [blame] | 27 | ret = cpu_ops[cpu]->cpu_init_idle(cpu); |
Lorenzo Pieralisi | d64f84f | 2014-07-17 10:30:07 +0100 | [diff] [blame] | 28 | |
Lorenzo Pieralisi | d64f84f | 2014-07-17 10:30:07 +0100 | [diff] [blame] | 29 | return ret; |
| 30 | } |
Lorenzo Pieralisi | af3cfdb | 2015-01-26 18:33:44 +0000 | [diff] [blame] | 31 | |
| 32 | /** |
Geert Uytterhoeven | 0e4c0e6 | 2017-02-17 15:25:08 +0100 | [diff] [blame] | 33 | * arm_cpuidle_suspend() - function to enter a low-power idle state |
Lorenzo Pieralisi | af3cfdb | 2015-01-26 18:33:44 +0000 | [diff] [blame] | 34 | * @arg: argument to pass to CPU suspend operations |
| 35 | * |
| 36 | * Return: 0 on success, -EOPNOTSUPP if CPU suspend hook not initialized, CPU |
| 37 | * operations back-end error code otherwise. |
| 38 | */ |
Sudeep Holla | af391b1 | 2015-06-18 15:41:32 +0100 | [diff] [blame] | 39 | int arm_cpuidle_suspend(int index) |
Lorenzo Pieralisi | af3cfdb | 2015-01-26 18:33:44 +0000 | [diff] [blame] | 40 | { |
| 41 | int cpu = smp_processor_id(); |
| 42 | |
Sudeep Holla | af391b1 | 2015-06-18 15:41:32 +0100 | [diff] [blame] | 43 | return cpu_ops[cpu]->cpu_suspend(index); |
Lorenzo Pieralisi | af3cfdb | 2015-01-26 18:33:44 +0000 | [diff] [blame] | 44 | } |
Sudeep Holla | 5a611ed | 2016-07-19 18:52:58 +0100 | [diff] [blame] | 45 | |
| 46 | #ifdef CONFIG_ACPI |
| 47 | |
| 48 | #include <acpi/processor.h> |
| 49 | |
| 50 | int acpi_processor_ffh_lpi_probe(unsigned int cpu) |
| 51 | { |
| 52 | return arm_cpuidle_init(cpu); |
| 53 | } |
| 54 | |
| 55 | int acpi_processor_ffh_lpi_enter(struct acpi_lpi_state *lpi) |
| 56 | { |
| 57 | return CPU_PM_CPU_IDLE_ENTER(arm_cpuidle_suspend, lpi->index); |
| 58 | } |
| 59 | #endif |