pm.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /* linux/arch/arm/mach-s3c2412/pm.c
  2. *
  3. * Copyright (c) 2006 Simtec Electronics
  4. * Ben Dooks <ben@simtec.co.uk>
  5. *
  6. * http://armlinux.simtec.co.uk/.
  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 version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #include <linux/kernel.h>
  13. #include <linux/types.h>
  14. #include <linux/interrupt.h>
  15. #include <linux/list.h>
  16. #include <linux/timer.h>
  17. #include <linux/init.h>
  18. #include <linux/sysdev.h>
  19. #include <linux/platform_device.h>
  20. #include <asm/hardware.h>
  21. #include <asm/io.h>
  22. #include <asm/irq.h>
  23. #include <asm/arch/regs-power.h>
  24. #include <asm/arch/regs-gpioj.h>
  25. #include <asm/arch/regs-gpio.h>
  26. #include <asm/arch/regs-dsc.h>
  27. #include <asm/plat-s3c24xx/cpu.h>
  28. #include <asm/plat-s3c24xx/pm.h>
  29. #include <asm/plat-s3c24xx/s3c2412.h>
  30. static void s3c2412_cpu_suspend(void)
  31. {
  32. unsigned long tmp;
  33. /* set our standby method to sleep */
  34. tmp = __raw_readl(S3C2412_PWRCFG);
  35. tmp |= S3C2412_PWRCFG_STANDBYWFI_SLEEP;
  36. __raw_writel(tmp, S3C2412_PWRCFG);
  37. /* issue the standby signal into the pm unit. Note, we
  38. * issue a write-buffer drain just in case */
  39. tmp = 0;
  40. asm("b 1f\n\t"
  41. ".align 5\n\t"
  42. "1:\n\t"
  43. "mcr p15, 0, %0, c7, c10, 4\n\t"
  44. "mcr p15, 0, %0, c7, c0, 4" :: "r" (tmp));
  45. /* we should never get past here */
  46. panic("sleep resumed to originator?");
  47. }
  48. static void s3c2412_pm_prepare(void)
  49. {
  50. }
  51. static int s3c2412_pm_add(struct sys_device *sysdev)
  52. {
  53. pm_cpu_prep = s3c2412_pm_prepare;
  54. pm_cpu_sleep = s3c2412_cpu_suspend;
  55. return 0;
  56. }
  57. static struct sleep_save s3c2412_sleep[] = {
  58. SAVE_ITEM(S3C2412_DSC0),
  59. SAVE_ITEM(S3C2412_DSC1),
  60. SAVE_ITEM(S3C2413_GPJDAT),
  61. SAVE_ITEM(S3C2413_GPJCON),
  62. SAVE_ITEM(S3C2413_GPJUP),
  63. /* save the PWRCFG to get back to original sleep method */
  64. SAVE_ITEM(S3C2412_PWRCFG),
  65. /* save the sleep configuration anyway, just in case these
  66. * get damaged during wakeup */
  67. SAVE_ITEM(S3C2412_GPBSLPCON),
  68. SAVE_ITEM(S3C2412_GPCSLPCON),
  69. SAVE_ITEM(S3C2412_GPDSLPCON),
  70. SAVE_ITEM(S3C2412_GPESLPCON),
  71. SAVE_ITEM(S3C2412_GPFSLPCON),
  72. SAVE_ITEM(S3C2412_GPGSLPCON),
  73. SAVE_ITEM(S3C2412_GPHSLPCON),
  74. SAVE_ITEM(S3C2413_GPJSLPCON),
  75. };
  76. static int s3c2412_pm_suspend(struct sys_device *dev, pm_message_t state)
  77. {
  78. s3c2410_pm_do_save(s3c2412_sleep, ARRAY_SIZE(s3c2412_sleep));
  79. return 0;
  80. }
  81. static int s3c2412_pm_resume(struct sys_device *dev)
  82. {
  83. unsigned long tmp;
  84. tmp = __raw_readl(S3C2412_PWRCFG);
  85. tmp &= ~S3C2412_PWRCFG_STANDBYWFI_MASK;
  86. tmp |= S3C2412_PWRCFG_STANDBYWFI_IDLE;
  87. __raw_writel(tmp, S3C2412_PWRCFG);
  88. s3c2410_pm_do_restore(s3c2412_sleep, ARRAY_SIZE(s3c2412_sleep));
  89. return 0;
  90. }
  91. static struct sysdev_driver s3c2412_pm_driver = {
  92. .add = s3c2412_pm_add,
  93. .suspend = s3c2412_pm_suspend,
  94. .resume = s3c2412_pm_resume,
  95. };
  96. static __init int s3c2412_pm_init(void)
  97. {
  98. return sysdev_driver_register(&s3c2412_sysclass, &s3c2412_pm_driver);
  99. }
  100. arch_initcall(s3c2412_pm_init);