]> Pileus Git - ~andy/linux/blob - arch/arm/mach-tegra/cpuidle.c
4e0b07c7963c89230c0f8d4709a990cce10bc4da
[~andy/linux] / arch / arm / mach-tegra / cpuidle.c
1 /*
2  * arch/arm/mach-tegra/cpuidle.c
3  *
4  * CPU idle driver for Tegra CPUs
5  *
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>
10  *
11  * Rework for 3.3 by Peter De Schrijver <pdeschrijver@nvidia.com>
12  *
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.
17  *
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
21  * more details.
22  */
23
24 #include <linux/kernel.h>
25 #include <linux/module.h>
26 #include <linux/cpuidle.h>
27
28 #include <asm/cpuidle.h>
29
30 struct cpuidle_driver tegra_idle_driver = {
31         .name = "tegra_idle",
32         .owner = THIS_MODULE,
33         .en_core_tk_irqen = 1,
34         .state_count = 1,
35         .states = {
36                 [0] = ARM_CPUIDLE_WFI_STATE_PWR(600),
37         },
38 };
39
40 static DEFINE_PER_CPU(struct cpuidle_device, tegra_idle_device);
41
42 static int __init tegra_cpuidle_init(void)
43 {
44         int ret;
45         unsigned int cpu;
46         struct cpuidle_device *dev;
47         struct cpuidle_driver *drv = &tegra_idle_driver;
48
49         ret = cpuidle_register_driver(&tegra_idle_driver);
50         if (ret) {
51                 pr_err("CPUidle driver registration failed\n");
52                 return ret;
53         }
54
55         for_each_possible_cpu(cpu) {
56                 dev = &per_cpu(tegra_idle_device, cpu);
57                 dev->cpu = cpu;
58
59                 dev->state_count = drv->state_count;
60                 ret = cpuidle_register_device(dev);
61                 if (ret) {
62                         pr_err("CPU%u: CPUidle device registration failed\n",
63                                 cpu);
64                         return ret;
65                 }
66         }
67         return 0;
68 }
69 device_initcall(tegra_cpuidle_init);