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
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 <asm/firmware.h>
18 #include <linux/tick.h>
19 #include <linux/cpuidle.h>
20 #include <linux/cpu_pm.h>
21 #include <linux/kernel.h>
22 #include <linux/module.h>
24 #include <asm/cpuidle.h>
25 #include <asm/smp_plat.h>
26 #include <asm/suspend.h>
33 #ifdef CONFIG_PM_SLEEP
34 #define TEGRA114_MAX_STATES 2
36 #define TEGRA114_MAX_STATES 1
39 #ifdef CONFIG_PM_SLEEP
40 static int tegra114_idle_power_down(struct cpuidle_device
*dev
,
41 struct cpuidle_driver
*drv
,
46 tegra_set_cpu_in_lp2();
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
, 0) == -ENOSYS
)
53 cpu_suspend(0, tegra30_sleep_cpu_secondary_finish
);
56 tegra_clear_cpu_in_lp2();
63 static void tegra114_idle_enter_freeze(struct cpuidle_device
*dev
,
64 struct cpuidle_driver
*drv
,
67 tegra114_idle_power_down(dev
, drv
, index
);
71 static struct cpuidle_driver tegra_idle_driver
= {
74 .state_count
= TEGRA114_MAX_STATES
,
76 [0] = ARM_CPUIDLE_WFI_STATE_PWR(600),
77 #ifdef CONFIG_PM_SLEEP
79 .enter
= tegra114_idle_power_down
,
80 .enter_freeze
= tegra114_idle_enter_freeze
,
82 .target_residency
= 1000,
83 .flags
= CPUIDLE_FLAG_TIMER_STOP
,
85 .name
= "powered-down",
86 .desc
= "CPU power gated",
92 int __init
tegra114_cpuidle_init(void)
94 if (!psci_smp_available())
95 return cpuidle_register(&tegra_idle_driver
, NULL
);