blob: ca23b202b02d9df22e7bf241b11aab11f8d413ec [file] [log] [blame]
Magnus Damm0af48172011-04-29 02:36:07 +09001/*
2 * CPUIdle support code for SH-Mobile ARM
3 *
4 * Copyright (C) 2011 Magnus Damm
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10
11#include <linux/pm.h>
12#include <linux/cpuidle.h>
13#include <linux/suspend.h>
14#include <linux/module.h>
15#include <linux/err.h>
16#include <asm/system.h>
Robert Leeee807dd2012-03-20 15:22:48 -050017#include <asm/cpuidle.h>
Magnus Damm0af48172011-04-29 02:36:07 +090018#include <asm/io.h>
19
20static void shmobile_enter_wfi(void)
21{
22 cpu_do_idle();
23}
24
25void (*shmobile_cpuidle_modes[CPUIDLE_STATE_MAX])(void) = {
26 shmobile_enter_wfi, /* regular sleep mode */
27};
28
29static int shmobile_cpuidle_enter(struct cpuidle_device *dev,
Magnus Dammb73b5c42011-11-11 14:01:30 +090030 struct cpuidle_driver *drv,
31 int index)
Magnus Damm0af48172011-04-29 02:36:07 +090032{
Magnus Dammb73b5c42011-11-11 14:01:30 +090033 shmobile_cpuidle_modes[index]();
Magnus Damm0af48172011-04-29 02:36:07 +090034
Magnus Dammb73b5c42011-11-11 14:01:30 +090035 return index;
Magnus Damm0af48172011-04-29 02:36:07 +090036}
37
38static struct cpuidle_device shmobile_cpuidle_dev;
39static struct cpuidle_driver shmobile_cpuidle_driver = {
Robert Leeee807dd2012-03-20 15:22:48 -050040 .name = "shmobile_cpuidle",
41 .owner = THIS_MODULE,
42 .en_core_tk_irqen = 1,
43 .states[0] = ARM_CPUIDLE_WFI_STATE,
44 .safe_state_index = 0, /* C1 */
45 .state_count = 1,
Magnus Damm0af48172011-04-29 02:36:07 +090046};
47
Magnus Dammb73b5c42011-11-11 14:01:30 +090048void (*shmobile_cpuidle_setup)(struct cpuidle_driver *drv);
Magnus Damm0af48172011-04-29 02:36:07 +090049
50static int shmobile_cpuidle_init(void)
51{
52 struct cpuidle_device *dev = &shmobile_cpuidle_dev;
Magnus Dammb73b5c42011-11-11 14:01:30 +090053 struct cpuidle_driver *drv = &shmobile_cpuidle_driver;
Magnus Damm0af48172011-04-29 02:36:07 +090054 int i;
55
Magnus Dammb73b5c42011-11-11 14:01:30 +090056 for (i = 0; i < CPUIDLE_STATE_MAX; i++)
57 drv->states[i].enter = shmobile_cpuidle_enter;
Magnus Damm0af48172011-04-29 02:36:07 +090058
59 if (shmobile_cpuidle_setup)
Magnus Dammb73b5c42011-11-11 14:01:30 +090060 shmobile_cpuidle_setup(drv);
Magnus Damm0af48172011-04-29 02:36:07 +090061
Magnus Dammb73b5c42011-11-11 14:01:30 +090062 cpuidle_register_driver(drv);
63
64 dev->state_count = drv->state_count;
Magnus Damm0af48172011-04-29 02:36:07 +090065 cpuidle_register_device(dev);
66
67 return 0;
68}
69late_initcall(shmobile_cpuidle_init);