blob: 4e0b07c7963c89230c0f8d4709a990cce10bc4da [file] [log] [blame]
Peter De Schrijver22b8b852012-01-26 18:22:03 +02001/*
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>
Peter De Schrijver22b8b852012-01-26 18:22:03 +020026#include <linux/cpuidle.h>
Peter De Schrijver22b8b852012-01-26 18:22:03 +020027
Joseph Lod5db9a42012-10-08 18:24:16 +080028#include <asm/cpuidle.h>
Peter De Schrijver22b8b852012-01-26 18:22:03 +020029
30struct cpuidle_driver tegra_idle_driver = {
31 .name = "tegra_idle",
32 .owner = THIS_MODULE,
Joseph Lod5db9a42012-10-08 18:24:16 +080033 .en_core_tk_irqen = 1,
Peter De Schrijver22b8b852012-01-26 18:22:03 +020034 .state_count = 1,
35 .states = {
Joseph Lod5db9a42012-10-08 18:24:16 +080036 [0] = ARM_CPUIDLE_WFI_STATE_PWR(600),
Peter De Schrijver22b8b852012-01-26 18:22:03 +020037 },
38};
39
40static DEFINE_PER_CPU(struct cpuidle_device, tegra_idle_device);
41
Peter De Schrijver22b8b852012-01-26 18:22:03 +020042static 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}
69device_initcall(tegra_cpuidle_init);