diff options
Diffstat (limited to 'arch/arm/mach-tegra/cpuidle-tegra20.c')
-rw-r--r-- | arch/arm/mach-tegra/cpuidle-tegra20.c | 72 |
1 files changed, 21 insertions, 51 deletions
diff --git a/arch/arm/mach-tegra/cpuidle-tegra20.c b/arch/arm/mach-tegra/cpuidle-tegra20.c index 825ced4f7a40..590ec25855dd 100644 --- a/arch/arm/mach-tegra/cpuidle-tegra20.c +++ b/arch/arm/mach-tegra/cpuidle-tegra20.c | |||
@@ -43,32 +43,33 @@ static atomic_t abort_barrier; | |||
43 | static int tegra20_idle_lp2_coupled(struct cpuidle_device *dev, | 43 | static int tegra20_idle_lp2_coupled(struct cpuidle_device *dev, |
44 | struct cpuidle_driver *drv, | 44 | struct cpuidle_driver *drv, |
45 | int index); | 45 | int index); |
46 | #define TEGRA20_MAX_STATES 2 | ||
47 | #else | ||
48 | #define TEGRA20_MAX_STATES 1 | ||
46 | #endif | 49 | #endif |
47 | 50 | ||
48 | static struct cpuidle_state tegra_idle_states[] = { | ||
49 | [0] = ARM_CPUIDLE_WFI_STATE_PWR(600), | ||
50 | #ifdef CONFIG_PM_SLEEP | ||
51 | [1] = { | ||
52 | .enter = tegra20_idle_lp2_coupled, | ||
53 | .exit_latency = 5000, | ||
54 | .target_residency = 10000, | ||
55 | .power_usage = 0, | ||
56 | .flags = CPUIDLE_FLAG_TIME_VALID | | ||
57 | CPUIDLE_FLAG_COUPLED, | ||
58 | .name = "powered-down", | ||
59 | .desc = "CPU power gated", | ||
60 | }, | ||
61 | #endif | ||
62 | }; | ||
63 | |||
64 | static struct cpuidle_driver tegra_idle_driver = { | 51 | static struct cpuidle_driver tegra_idle_driver = { |
65 | .name = "tegra_idle", | 52 | .name = "tegra_idle", |
66 | .owner = THIS_MODULE, | 53 | .owner = THIS_MODULE, |
67 | .en_core_tk_irqen = 1, | 54 | .states = { |
55 | ARM_CPUIDLE_WFI_STATE_PWR(600), | ||
56 | #ifdef CONFIG_PM_SLEEP | ||
57 | { | ||
58 | .enter = tegra20_idle_lp2_coupled, | ||
59 | .exit_latency = 5000, | ||
60 | .target_residency = 10000, | ||
61 | .power_usage = 0, | ||
62 | .flags = CPUIDLE_FLAG_TIME_VALID | | ||
63 | CPUIDLE_FLAG_COUPLED, | ||
64 | .name = "powered-down", | ||
65 | .desc = "CPU power gated", | ||
66 | }, | ||
67 | #endif | ||
68 | }, | ||
69 | .state_count = TEGRA20_MAX_STATES, | ||
70 | .safe_state_index = 0, | ||
68 | }; | 71 | }; |
69 | 72 | ||
70 | static DEFINE_PER_CPU(struct cpuidle_device, tegra_idle_device); | ||
71 | |||
72 | #ifdef CONFIG_PM_SLEEP | 73 | #ifdef CONFIG_PM_SLEEP |
73 | #ifdef CONFIG_SMP | 74 | #ifdef CONFIG_SMP |
74 | static void __iomem *pmc = IO_ADDRESS(TEGRA_PMC_BASE); | 75 | static void __iomem *pmc = IO_ADDRESS(TEGRA_PMC_BASE); |
@@ -217,39 +218,8 @@ static int tegra20_idle_lp2_coupled(struct cpuidle_device *dev, | |||
217 | 218 | ||
218 | int __init tegra20_cpuidle_init(void) | 219 | int __init tegra20_cpuidle_init(void) |
219 | { | 220 | { |
220 | int ret; | ||
221 | unsigned int cpu; | ||
222 | struct cpuidle_device *dev; | ||
223 | struct cpuidle_driver *drv = &tegra_idle_driver; | ||
224 | |||
225 | #ifdef CONFIG_PM_SLEEP | 221 | #ifdef CONFIG_PM_SLEEP |
226 | tegra_tear_down_cpu = tegra20_tear_down_cpu; | 222 | tegra_tear_down_cpu = tegra20_tear_down_cpu; |
227 | #endif | 223 | #endif |
228 | 224 | return cpuidle_register(&tegra_idle_driver, cpu_possible_mask); | |
229 | drv->state_count = ARRAY_SIZE(tegra_idle_states); | ||
230 | memcpy(drv->states, tegra_idle_states, | ||
231 | drv->state_count * sizeof(drv->states[0])); | ||
232 | |||
233 | ret = cpuidle_register_driver(&tegra_idle_driver); | ||
234 | if (ret) { | ||
235 | pr_err("CPUidle driver registration failed\n"); | ||
236 | return ret; | ||
237 | } | ||
238 | |||
239 | for_each_possible_cpu(cpu) { | ||
240 | dev = &per_cpu(tegra_idle_device, cpu); | ||
241 | dev->cpu = cpu; | ||
242 | #ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED | ||
243 | dev->coupled_cpus = *cpu_possible_mask; | ||
244 | #endif | ||
245 | |||
246 | dev->state_count = drv->state_count; | ||
247 | ret = cpuidle_register_device(dev); | ||
248 | if (ret) { | ||
249 | pr_err("CPU%u: CPUidle device registration failed\n", | ||
250 | cpu); | ||
251 | return ret; | ||
252 | } | ||
253 | } | ||
254 | return 0; | ||
255 | } | 225 | } |