blob: 9e050268cde4d237ab850a532b38c22cdb37c694 [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>
Robert Leeee807dd2012-03-20 15:22:48 -050016#include <asm/cpuidle.h>
Magnus Damm0af48172011-04-29 02:36:07 +090017#include <asm/io.h>
18
Rafael J. Wysocki5b411472012-08-15 20:58:19 +020019int shmobile_enter_wfi(struct cpuidle_device *dev, struct cpuidle_driver *drv,
20 int index)
Magnus Damm0af48172011-04-29 02:36:07 +090021{
22 cpu_do_idle();
Rafael J. Wysocki5b411472012-08-15 20:58:19 +020023 return 0;
Magnus Damm0af48172011-04-29 02:36:07 +090024}
25
26static struct cpuidle_device shmobile_cpuidle_dev;
Rafael J. Wysocki5b411472012-08-15 20:58:19 +020027static struct cpuidle_driver shmobile_cpuidle_default_driver = {
Robert Leeee807dd2012-03-20 15:22:48 -050028 .name = "shmobile_cpuidle",
29 .owner = THIS_MODULE,
30 .en_core_tk_irqen = 1,
31 .states[0] = ARM_CPUIDLE_WFI_STATE,
Rafael J. Wysocki5b411472012-08-15 20:58:19 +020032 .states[0].enter = shmobile_enter_wfi,
Robert Leeee807dd2012-03-20 15:22:48 -050033 .safe_state_index = 0, /* C1 */
34 .state_count = 1,
Magnus Damm0af48172011-04-29 02:36:07 +090035};
36
Rafael J. Wysocki5b411472012-08-15 20:58:19 +020037static struct cpuidle_driver *cpuidle_drv = &shmobile_cpuidle_default_driver;
38
39void shmobile_cpuidle_set_driver(struct cpuidle_driver *drv)
40{
41 cpuidle_drv = drv;
42}
Magnus Damm0af48172011-04-29 02:36:07 +090043
Shawn Guo21cc1b72012-04-26 21:58:41 +080044int shmobile_cpuidle_init(void)
Magnus Damm0af48172011-04-29 02:36:07 +090045{
46 struct cpuidle_device *dev = &shmobile_cpuidle_dev;
Magnus Damm0af48172011-04-29 02:36:07 +090047
Rafael J. Wysocki5b411472012-08-15 20:58:19 +020048 cpuidle_register_driver(cpuidle_drv);
Magnus Damm0af48172011-04-29 02:36:07 +090049
Rafael J. Wysocki5b411472012-08-15 20:58:19 +020050 dev->state_count = cpuidle_drv->state_count;
Magnus Damm0af48172011-04-29 02:36:07 +090051 cpuidle_register_device(dev);
52
53 return 0;
54}