1 /* 2 * linux/arch/arm/mach-omap2/pm.c 3 * 4 * OMAP2 Power Management Routines 5 * 6 * Copyright (C) 2006 Nokia Corporation 7 * Tony Lindgren <tony@atomide.com> 8 * 9 * Copyright (C) 2005 Texas Instruments, Inc. 10 * Richard Woodruff <r-woodruff2@ti.com> 11 * 12 * Based on pm.c for omap1 13 * 14 * This program is free software; you can redistribute it and/or modify 15 * it under the terms of the GNU General Public License version 2 as 16 * published by the Free Software Foundation. 17 */ 18 19 #include <linux/suspend.h> 20 #include <linux/sched.h> 21 #include <linux/proc_fs.h> 22 #include <linux/interrupt.h> 23 #include <linux/sysfs.h> 24 #include <linux/module.h> 25 #include <linux/delay.h> 26 #include <linux/clk.h> 27 28 #include <asm/io.h> 29 #include <asm/irq.h> 30 #include <asm/atomic.h> 31 #include <asm/mach/time.h> 32 #include <asm/mach/irq.h> 33 #include <asm/mach-types.h> 34 35 #include <asm/arch/irqs.h> 36 #include <asm/arch/clock.h> 37 #include <asm/arch/sram.h> 38 #include <asm/arch/pm.h> 39 40 static struct clk *vclk; 41 static void (*omap2_sram_idle)(void); 42 static void (*omap2_sram_suspend)(int dllctrl, int cpu_rev); 43 static void (*saved_idle)(void); 44 45 extern void __init pmdomain_init(void); 46 extern void pmdomain_set_autoidle(void); 47 48 static unsigned int omap24xx_sleep_save[OMAP24XX_SLEEP_SAVE_SIZE]; 49 50 void omap2_pm_idle(void) 51 { 52 local_irq_disable(); 53 local_fiq_disable(); 54 if (need_resched()) { 55 local_fiq_enable(); 56 local_irq_enable(); 57 return; 58 } 59 60 omap2_sram_idle(); 61 local_fiq_enable(); 62 local_irq_enable(); 63 } 64 65 static int omap2_pm_prepare(void) 66 { 67 /* We cannot sleep in idle until we have resumed */ 68 saved_idle = pm_idle; 69 pm_idle = NULL; 70 return 0; 71 } 72 73 static int omap2_pm_suspend(void) 74 { 75 return 0; 76 } 77 78 static int omap2_pm_enter(suspend_state_t state) 79 { 80 int ret = 0; 81 82 switch (state) 83 { 84 case PM_SUSPEND_STANDBY: 85 case PM_SUSPEND_MEM: 86 ret = omap2_pm_suspend(); 87 break; 88 default: 89 ret = -EINVAL; 90 } 91 92 return ret; 93 } 94 95 static void omap2_pm_finish(void) 96 { 97 pm_idle = saved_idle; 98 } 99 100 static struct platform_suspend_ops omap_pm_ops = { 101 .prepare = omap2_pm_prepare, 102 .enter = omap2_pm_enter, 103 .finish = omap2_pm_finish, 104 .valid = suspend_valid_only_mem, 105 }; 106 107 int __init omap2_pm_init(void) 108 { 109 return 0; 110 } 111 112 __initcall(omap2_pm_init); 113