pm.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. omap2_sram_idle();
  53. local_fiq_enable();
  54. local_irq_enable();
  55. }
  56. static int omap2_pm_prepare(void)
  57. {
  58. /* We cannot sleep in idle until we have resumed */
  59. saved_idle = pm_idle;
  60. pm_idle = NULL;
  61. return 0;
  62. }
  63. static int omap2_pm_suspend(void)
  64. {
  65. return 0;
  66. }
  67. static int omap2_pm_enter(suspend_state_t state)
  68. {
  69. int ret = 0;
  70. switch (state)
  71. {
  72. case PM_SUSPEND_STANDBY:
  73. case PM_SUSPEND_MEM:
  74. ret = omap2_pm_suspend();
  75. break;
  76. default:
  77. ret = -EINVAL;
  78. }
  79. return ret;
  80. }
  81. static void omap2_pm_finish(void)
  82. {
  83. pm_idle = saved_idle;
  84. }
  85. static struct platform_suspend_ops omap_pm_ops = {
  86. .prepare = omap2_pm_prepare,
  87. .enter = omap2_pm_enter,
  88. .finish = omap2_pm_finish,
  89. .valid = suspend_valid_only_mem,
  90. };
  91. int __init omap2_pm_init(void)
  92. {
  93. return 0;
  94. }
  95. __initcall(omap2_pm_init);