2011-04-28 17:36:07 +00:00
|
|
|
/*
|
|
|
|
* CPUIdle support code for SH-Mobile ARM
|
|
|
|
*
|
|
|
|
* Copyright (C) 2011 Magnus Damm
|
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
|
|
* License. See the file "COPYING" in the main directory of this archive
|
|
|
|
* for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/pm.h>
|
|
|
|
#include <linux/cpuidle.h>
|
|
|
|
#include <linux/suspend.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/err.h>
|
2012-03-20 20:22:48 +00:00
|
|
|
#include <asm/cpuidle.h>
|
2011-04-28 17:36:07 +00:00
|
|
|
#include <asm/io.h>
|
|
|
|
|
2012-08-15 18:58:19 +00:00
|
|
|
int shmobile_enter_wfi(struct cpuidle_device *dev, struct cpuidle_driver *drv,
|
|
|
|
int index)
|
2011-04-28 17:36:07 +00:00
|
|
|
{
|
|
|
|
cpu_do_idle();
|
2012-08-15 18:58:19 +00:00
|
|
|
return 0;
|
2011-04-28 17:36:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct cpuidle_device shmobile_cpuidle_dev;
|
2012-08-15 18:58:19 +00:00
|
|
|
static struct cpuidle_driver shmobile_cpuidle_default_driver = {
|
2012-03-20 20:22:48 +00:00
|
|
|
.name = "shmobile_cpuidle",
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.en_core_tk_irqen = 1,
|
|
|
|
.states[0] = ARM_CPUIDLE_WFI_STATE,
|
2012-08-15 18:58:19 +00:00
|
|
|
.states[0].enter = shmobile_enter_wfi,
|
2012-03-20 20:22:48 +00:00
|
|
|
.safe_state_index = 0, /* C1 */
|
|
|
|
.state_count = 1,
|
2011-04-28 17:36:07 +00:00
|
|
|
};
|
|
|
|
|
2012-08-15 18:58:19 +00:00
|
|
|
static struct cpuidle_driver *cpuidle_drv = &shmobile_cpuidle_default_driver;
|
|
|
|
|
|
|
|
void shmobile_cpuidle_set_driver(struct cpuidle_driver *drv)
|
|
|
|
{
|
|
|
|
cpuidle_drv = drv;
|
|
|
|
}
|
2011-04-28 17:36:07 +00:00
|
|
|
|
2012-04-26 13:58:41 +00:00
|
|
|
int shmobile_cpuidle_init(void)
|
2011-04-28 17:36:07 +00:00
|
|
|
{
|
|
|
|
struct cpuidle_device *dev = &shmobile_cpuidle_dev;
|
2011-11-11 05:01:30 +00:00
|
|
|
|
2012-08-15 18:58:19 +00:00
|
|
|
cpuidle_register_driver(cpuidle_drv);
|
2011-04-28 17:36:07 +00:00
|
|
|
|
2012-08-15 18:58:19 +00:00
|
|
|
dev->state_count = cpuidle_drv->state_count;
|
2011-04-28 17:36:07 +00:00
|
|
|
cpuidle_register_device(dev);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|