Merge tag 'locks-v3.16-2' of git://git.samba.org/jlayton/linux
[linux/fpc-iii.git] / arch / arm / mach-tegra / cpuidle-tegra114.c
blobb5fb7c110c64314f2e9b11c218b760d6e9d9e09c
1 /*
2 * Copyright (c) 2013, NVIDIA Corporation. All rights reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #include <linux/kernel.h>
18 #include <linux/module.h>
19 #include <linux/cpuidle.h>
20 #include <linux/cpu_pm.h>
21 #include <linux/clockchips.h>
22 #include <asm/firmware.h>
24 #include <asm/cpuidle.h>
25 #include <asm/suspend.h>
26 #include <asm/smp_plat.h>
28 #include "pm.h"
29 #include "sleep.h"
31 #ifdef CONFIG_PM_SLEEP
32 #define TEGRA114_MAX_STATES 2
33 #else
34 #define TEGRA114_MAX_STATES 1
35 #endif
37 #ifdef CONFIG_PM_SLEEP
38 static int tegra114_idle_power_down(struct cpuidle_device *dev,
39 struct cpuidle_driver *drv,
40 int index)
42 local_fiq_disable();
44 tegra_set_cpu_in_lp2();
45 cpu_pm_enter();
47 clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER, &dev->cpu);
49 call_firmware_op(prepare_idle);
51 /* Do suspend by ourselves if the firmware does not implement it */
52 if (call_firmware_op(do_idle) == -ENOSYS)
53 cpu_suspend(0, tegra30_sleep_cpu_secondary_finish);
55 clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, &dev->cpu);
57 cpu_pm_exit();
58 tegra_clear_cpu_in_lp2();
60 local_fiq_enable();
62 return index;
64 #endif
66 static struct cpuidle_driver tegra_idle_driver = {
67 .name = "tegra_idle",
68 .owner = THIS_MODULE,
69 .state_count = TEGRA114_MAX_STATES,
70 .states = {
71 [0] = ARM_CPUIDLE_WFI_STATE_PWR(600),
72 #ifdef CONFIG_PM_SLEEP
73 [1] = {
74 .enter = tegra114_idle_power_down,
75 .exit_latency = 500,
76 .target_residency = 1000,
77 .power_usage = 0,
78 .flags = CPUIDLE_FLAG_TIME_VALID,
79 .name = "powered-down",
80 .desc = "CPU power gated",
82 #endif
86 int __init tegra114_cpuidle_init(void)
88 return cpuidle_register(&tegra_idle_driver, NULL);