pm.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /* linux/arch/arm/mach-s3c2410/pm.c
  2. *
  3. * Copyright (c) 2006 Simtec Electronics
  4. * Ben Dooks <ben@simtec.co.uk>
  5. *
  6. * S3C2410 (and compatible) Power Manager (Suspend-To-RAM) support
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. */
  22. #include <linux/init.h>
  23. #include <linux/suspend.h>
  24. #include <linux/errno.h>
  25. #include <linux/time.h>
  26. #include <linux/sysdev.h>
  27. #include <asm/hardware.h>
  28. #include <asm/io.h>
  29. #include <asm/mach-types.h>
  30. #include <asm/arch/regs-gpio.h>
  31. #include <asm/arch/regs-s3c6410-clock.h>
  32. #include <asm/arch/regs-rtc.h>
  33. #include <asm/plat-s3c24xx/cpu.h>
  34. #include <asm/plat-s3c24xx/pm.h>
  35. #ifdef CONFIG_S3C2410_PM_DEBUG
  36. extern void pm_dbg(const char *fmt, ...);
  37. #define DBG(fmt...) pm_dbg(fmt)
  38. #else
  39. #define DBG(fmt...) printk(KERN_DEBUG fmt)
  40. #endif
  41. static void s3c6400_cpu_suspend(void)
  42. {
  43. unsigned long tmp;
  44. /* issue the standby signal into the pm unit. Note, we
  45. * issue a write-buffer drain just in case */
  46. tmp = 0;
  47. asm("b 1f\n\t"
  48. ".align 5\n\t"
  49. "1:\n\t"
  50. "mcr p15, 0, %0, c7, c10, 5\n\t"
  51. "mcr p15, 0, %0, c7, c10, 4\n\t"
  52. "mcr p15, 0, %0, c7, c0, 4" :: "r" (tmp));
  53. /* we should never get past here */
  54. panic("sleep resumed to originator?");
  55. }
  56. static void s3c6400_pm_prepare(void)
  57. {
  58. }
  59. static int s3c6400_pm_add(struct sys_device *sysdev)
  60. {
  61. pm_cpu_prep = s3c6400_pm_prepare;
  62. pm_cpu_sleep = s3c6400_cpu_suspend;
  63. return 0;
  64. }
  65. static struct sleep_save s3c6400_sleep[] = {
  66. };
  67. static int s3c6400_pm_suspend(struct sys_device *dev, pm_message_t state)
  68. {
  69. s3c2410_pm_do_save(s3c6400_sleep, ARRAY_SIZE(s3c6400_sleep));
  70. return 0;
  71. }
  72. static int s3c6400_pm_resume(struct sys_device *dev)
  73. {
  74. unsigned long tmp;
  75. #if 0
  76. tmp = __raw_readl(S3C_PWR_CFG);
  77. tmp &= ~(0x60<<0);
  78. tmp |= (0x1<<5);
  79. __raw_writel(tmp, S3C_PWR_CFG);
  80. #endif
  81. s3c2410_pm_do_restore(s3c6400_sleep, ARRAY_SIZE(s3c6400_sleep));
  82. return 0;
  83. }
  84. static struct sysdev_driver s3c6400_pm_driver = {
  85. .add = s3c6400_pm_add,
  86. .suspend = s3c6400_pm_suspend,
  87. .resume = s3c6400_pm_resume,
  88. };
  89. static __init int s3c6400_pm_init(void)
  90. {
  91. return sysdev_driver_register(&s3c6400_sysclass, &s3c6400_pm_driver);
  92. }
  93. arch_initcall(s3c6400_pm_init);