pm.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 <linux/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 <mach/irqs.h>
  32. #include <mach/clock.h>
  33. #include <mach/sram.h>
  34. #include <mach/pm.h>
  35. static struct clk *vclk;
  36. static void (*omap2_sram_idle)(void);
  37. static void (*omap2_sram_suspend)(int dllctrl, int cpu_rev);
  38. static void (*saved_idle)(void);
  39. extern void __init pmdomain_init(void);
  40. extern void pmdomain_set_autoidle(void);
  41. static unsigned int omap24xx_sleep_save[OMAP24XX_SLEEP_SAVE_SIZE];
  42. void omap2_pm_idle(void)
  43. {
  44. local_irq_disable();
  45. local_fiq_disable();
  46. if (need_resched()) {
  47. local_fiq_enable();
  48. local_irq_enable();
  49. return;
  50. }
  51. omap2_sram_idle();
  52. local_fiq_enable();
  53. local_irq_enable();
  54. }
  55. static int omap2_pm_prepare(void)
  56. {
  57. /* We cannot sleep in idle until we have resumed */
  58. saved_idle = pm_idle;
  59. pm_idle = NULL;
  60. return 0;
  61. }
  62. static int omap2_pm_suspend(void)
  63. {
  64. return 0;
  65. }
  66. static int omap2_pm_enter(suspend_state_t state)
  67. {
  68. int ret = 0;
  69. switch (state)
  70. {
  71. case PM_SUSPEND_STANDBY:
  72. case PM_SUSPEND_MEM:
  73. ret = omap2_pm_suspend();
  74. break;
  75. default:
  76. ret = -EINVAL;
  77. }
  78. return ret;
  79. }
  80. static void omap2_pm_finish(void)
  81. {
  82. pm_idle = saved_idle;
  83. }
  84. static struct platform_suspend_ops omap_pm_ops = {
  85. .prepare = omap2_pm_prepare,
  86. .enter = omap2_pm_enter,
  87. .finish = omap2_pm_finish,
  88. .valid = suspend_valid_only_mem,
  89. };
  90. static int __init omap2_pm_init(void)
  91. {
  92. return 0;
  93. }
  94. __initcall(omap2_pm_init);