pm.c 2.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/*
 * 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.
 */

19
#include <linux/suspend.h>
20 21 22 23 24
#include <linux/sched.h>
#include <linux/proc_fs.h>
#include <linux/interrupt.h>
#include <linux/sysfs.h>
#include <linux/module.h>
25
#include <linux/delay.h>
26
#include <linux/clk.h>
27
#include <linux/io.h>
28 29 30 31 32 33

#include <asm/irq.h>
#include <asm/atomic.h>
#include <asm/mach/time.h>
#include <asm/mach/irq.h>

34 35 36 37
#include <mach/irqs.h>
#include <mach/clock.h>
#include <mach/sram.h>
#include <mach/pm.h>
38 39 40 41 42 43

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);

44 45 46 47 48
extern void __init pmdomain_init(void);
extern void pmdomain_set_autoidle(void);

static unsigned int omap24xx_sleep_save[OMAP24XX_SLEEP_SAVE_SIZE];

49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
void omap2_pm_idle(void)
{
	local_irq_disable();
	local_fiq_disable();
	if (need_resched()) {
		local_fiq_enable();
		local_irq_enable();
		return;
	}

	omap2_sram_idle();
	local_fiq_enable();
	local_irq_enable();
}

64
static int omap2_pm_prepare(void)
65 66 67 68
{
	/* We cannot sleep in idle until we have resumed */
	saved_idle = pm_idle;
	pm_idle = NULL;
69
	return 0;
70 71
}

72 73 74 75 76
static int omap2_pm_suspend(void)
{
	return 0;
}

77 78
static int omap2_pm_enter(suspend_state_t state)
{
79 80
	int ret = 0;

81 82 83 84
	switch (state)
	{
	case PM_SUSPEND_STANDBY:
	case PM_SUSPEND_MEM:
85
		ret = omap2_pm_suspend();
86 87
		break;
	default:
88
		ret = -EINVAL;
89 90
	}

91
	return ret;
92 93
}

94
static void omap2_pm_finish(void)
95 96 97 98
{
	pm_idle = saved_idle;
}

99
static struct platform_suspend_ops omap_pm_ops = {
100 101 102
	.prepare	= omap2_pm_prepare,
	.enter		= omap2_pm_enter,
	.finish		= omap2_pm_finish,
103
	.valid		= suspend_valid_only_mem,
104 105
};

106
static int __init omap2_pm_init(void)
107 108 109 110 111
{
	return 0;
}

__initcall(omap2_pm_init);