2 * arch/arm/mach-tegra/cpuidle.c
4 * CPU idle driver for Tegra CPUs
6 * Copyright (c) 2010-2012, NVIDIA Corporation.
7 * Copyright (c) 2011 Google, Inc.
8 * Author: Colin Cross <ccross@android.com>
9 * Gary King <gking@nvidia.com>
11 * Rework for 3.3 by Peter De Schrijver <pdeschrijver@nvidia.com>
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful, but WITHOUT
19 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
24 #include <linux/kernel.h>
25 #include <linux/module.h>
26 #include <linux/cpu.h>
27 #include <linux/cpuidle.h>
28 #include <linux/hrtimer.h>
30 #include <asm/proc-fns.h>
32 static int tegra_idle_enter_lp3(struct cpuidle_device *dev,
33 struct cpuidle_driver *drv, int index);
35 struct cpuidle_driver tegra_idle_driver = {
41 .enter = tegra_idle_enter_lp3,
43 .target_residency = 10,
45 .flags = CPUIDLE_FLAG_TIME_VALID,
47 .desc = "CPU flow-controlled",
52 static DEFINE_PER_CPU(struct cpuidle_device, tegra_idle_device);
54 static int tegra_idle_enter_lp3(struct cpuidle_device *dev,
55 struct cpuidle_driver *drv, int index)
67 exit = ktime_sub(ktime_get(), enter);
68 us = ktime_to_us(exit);
73 dev->last_residency = us;
78 static int __init tegra_cpuidle_init(void)
82 struct cpuidle_device *dev;
83 struct cpuidle_driver *drv = &tegra_idle_driver;
85 ret = cpuidle_register_driver(&tegra_idle_driver);
87 pr_err("CPUidle driver registration failed\n");
91 for_each_possible_cpu(cpu) {
92 dev = &per_cpu(tegra_idle_device, cpu);
95 dev->state_count = drv->state_count;
96 ret = cpuidle_register_device(dev);
98 pr_err("CPU%u: CPUidle device registration failed\n",
105 device_initcall(tegra_cpuidle_init);