2006-04-02 20:46:25 +04:00
|
|
|
/*
|
|
|
|
* linux/arch/arm/mach-omap2/pm.c
|
|
|
|
*
|
|
|
|
* OMAP2 Power Management Routines
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 Nokia Corporation
|
|
|
|
* Tony Lindgren <tony@atomide.com>
|
|
|
|
*
|
|
|
|
* Copyright (C) 2005 Texas Instruments, Inc.
|
|
|
|
* Richard Woodruff <r-woodruff2@ti.com>
|
|
|
|
*
|
|
|
|
* Based on pm.c for omap1
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*/
|
|
|
|
|
2007-10-18 14:04:39 +04:00
|
|
|
#include <linux/suspend.h>
|
2006-04-02 20:46:25 +04:00
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/proc_fs.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/sysfs.h>
|
|
|
|
#include <linux/module.h>
|
2006-06-27 03:16:18 +04:00
|
|
|
#include <linux/delay.h>
|
2008-03-18 11:59:00 +03:00
|
|
|
#include <linux/clk.h>
|
2006-04-02 20:46:25 +04:00
|
|
|
|
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/irq.h>
|
|
|
|
#include <asm/atomic.h>
|
|
|
|
#include <asm/mach/time.h>
|
|
|
|
#include <asm/mach/irq.h>
|
|
|
|
#include <asm/mach-types.h>
|
|
|
|
|
|
|
|
#include <asm/arch/irqs.h>
|
|
|
|
#include <asm/arch/clock.h>
|
|
|
|
#include <asm/arch/sram.h>
|
|
|
|
#include <asm/arch/pm.h>
|
|
|
|
|
|
|
|
static struct clk *vclk;
|
|
|
|
static void (*omap2_sram_idle)(void);
|
|
|
|
static void (*omap2_sram_suspend)(int dllctrl, int cpu_rev);
|
|
|
|
static void (*saved_idle)(void);
|
|
|
|
|
2006-06-27 03:16:18 +04:00
|
|
|
extern void __init pmdomain_init(void);
|
|
|
|
extern void pmdomain_set_autoidle(void);
|
|
|
|
|
|
|
|
static unsigned int omap24xx_sleep_save[OMAP24XX_SLEEP_SAVE_SIZE];
|
|
|
|
|
2006-04-02 20:46:25 +04:00
|
|
|
void omap2_pm_idle(void)
|
|
|
|
{
|
|
|
|
local_irq_disable();
|
|
|
|
local_fiq_disable();
|
|
|
|
if (need_resched()) {
|
|
|
|
local_fiq_enable();
|
|
|
|
local_irq_enable();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Since an interrupt may set up a timer, we don't want to
|
|
|
|
* reprogram the hardware timer with interrupts enabled.
|
|
|
|
* Re-enable interrupts only after returning from idle.
|
|
|
|
*/
|
|
|
|
timer_dyn_reprogram();
|
|
|
|
|
|
|
|
omap2_sram_idle();
|
|
|
|
local_fiq_enable();
|
|
|
|
local_irq_enable();
|
|
|
|
}
|
|
|
|
|
2007-10-18 14:04:41 +04:00
|
|
|
static int omap2_pm_prepare(void)
|
2006-04-02 20:46:25 +04:00
|
|
|
{
|
|
|
|
/* We cannot sleep in idle until we have resumed */
|
|
|
|
saved_idle = pm_idle;
|
|
|
|
pm_idle = NULL;
|
2007-10-18 14:04:41 +04:00
|
|
|
return 0;
|
2006-04-02 20:46:25 +04:00
|
|
|
}
|
|
|
|
|
2006-06-27 03:16:18 +04:00
|
|
|
static int omap2_pm_suspend(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-04-02 20:46:25 +04:00
|
|
|
static int omap2_pm_enter(suspend_state_t state)
|
|
|
|
{
|
2006-06-27 03:16:18 +04:00
|
|
|
int ret = 0;
|
|
|
|
|
2006-04-02 20:46:25 +04:00
|
|
|
switch (state)
|
|
|
|
{
|
|
|
|
case PM_SUSPEND_STANDBY:
|
|
|
|
case PM_SUSPEND_MEM:
|
2006-06-27 03:16:18 +04:00
|
|
|
ret = omap2_pm_suspend();
|
2006-04-02 20:46:25 +04:00
|
|
|
break;
|
|
|
|
default:
|
2006-06-27 03:16:18 +04:00
|
|
|
ret = -EINVAL;
|
2006-04-02 20:46:25 +04:00
|
|
|
}
|
|
|
|
|
2006-06-27 03:16:18 +04:00
|
|
|
return ret;
|
2006-04-02 20:46:25 +04:00
|
|
|
}
|
|
|
|
|
2007-10-18 14:04:41 +04:00
|
|
|
static void omap2_pm_finish(void)
|
2006-04-02 20:46:25 +04:00
|
|
|
{
|
|
|
|
pm_idle = saved_idle;
|
|
|
|
}
|
|
|
|
|
2007-10-18 14:04:40 +04:00
|
|
|
static struct platform_suspend_ops omap_pm_ops = {
|
2006-04-02 20:46:25 +04:00
|
|
|
.prepare = omap2_pm_prepare,
|
|
|
|
.enter = omap2_pm_enter,
|
|
|
|
.finish = omap2_pm_finish,
|
2007-10-18 14:04:40 +04:00
|
|
|
.valid = suspend_valid_only_mem,
|
2006-04-02 20:46:25 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
int __init omap2_pm_init(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
__initcall(omap2_pm_init);
|