pm.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. #include <linux/suspend.h>
  19. #include <linux/sched.h>
  20. #include <linux/proc_fs.h>
  21. #include <linux/interrupt.h>
  22. #include <linux/sysfs.h>
  23. #include <linux/module.h>
  24. #include <linux/delay.h>
  25. #include <linux/clk.h>
  26. #include <asm/io.h>
  27. #include <asm/irq.h>
  28. #include <asm/atomic.h>
  29. #include <asm/mach/time.h>
  30. #include <asm/mach/irq.h>
  31. #include <asm/mach-types.h>
  32. #include <asm/arch/irqs.h>
  33. #include <asm/arch/clock.h>
  34. #include <asm/arch/sram.h>
  35. #include <asm/arch/pm.h>
  36. static struct clk *vclk;
  37. static void (*omap2_sram_idle)(void);
  38. static void (*omap2_sram_suspend)(int dllctrl, int cpu_rev);
  39. static void (*saved_idle)(void);
  40. extern void __init pmdomain_init(void);
  41. extern void pmdomain_set_autoidle(void);
  42. static unsigned int omap24xx_sleep_save[OMAP24XX_SLEEP_SAVE_SIZE];
  43. void omap2_pm_idle(void)
  44. {
  45. local_irq_disable();
  46. local_fiq_disable();
  47. if (need_resched()) {
  48. local_fiq_enable();
  49. local_irq_enable();
  50. return;
  51. }
  52. /*
  53. * Since an interrupt may set up a timer, we don't want to
  54. * reprogram the hardware timer with interrupts enabled.
  55. * Re-enable interrupts only after returning from idle.
  56. */
  57. timer_dyn_reprogram();
  58. omap2_sram_idle();
  59. local_fiq_enable();
  60. local_irq_enable();
  61. }
  62. static int omap2_pm_prepare(void)
  63. {
  64. /* We cannot sleep in idle until we have resumed */
  65. saved_idle = pm_idle;
  66. pm_idle = NULL;
  67. return 0;
  68. }
  69. static int omap2_pm_suspend(void)
  70. {
  71. return 0;
  72. }
  73. static int omap2_pm_enter(suspend_state_t state)
  74. {
  75. int ret = 0;
  76. switch (state)
  77. {
  78. case PM_SUSPEND_STANDBY:
  79. case PM_SUSPEND_MEM:
  80. ret = omap2_pm_suspend();
  81. break;
  82. default:
  83. ret = -EINVAL;
  84. }
  85. return ret;
  86. }
  87. static void omap2_pm_finish(void)
  88. {
  89. pm_idle = saved_idle;
  90. }
  91. static struct platform_suspend_ops omap_pm_ops = {
  92. .prepare = omap2_pm_prepare,
  93. .enter = omap2_pm_enter,
  94. .finish = omap2_pm_finish,
  95. .valid = suspend_valid_only_mem,
  96. };
  97. int __init omap2_pm_init(void)
  98. {
  99. return 0;
  100. }
  101. __initcall(omap2_pm_init);