pm-s3c2412.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. // SPDX-License-Identifier: GPL-2.0
  2. //
  3. // Copyright (c) 2006 Simtec Electronics
  4. // Ben Dooks <[email protected]>
  5. //
  6. // http://armlinux.simtec.co.uk/.
  7. #include <linux/kernel.h>
  8. #include <linux/types.h>
  9. #include <linux/interrupt.h>
  10. #include <linux/list.h>
  11. #include <linux/timer.h>
  12. #include <linux/init.h>
  13. #include <linux/device.h>
  14. #include <linux/syscore_ops.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/io.h>
  17. #include <asm/cacheflush.h>
  18. #include <asm/irq.h>
  19. #include "irqs.h"
  20. #include "regs-gpio.h"
  21. #include "cpu.h"
  22. #include "pm.h"
  23. #include "wakeup-mask.h"
  24. #include "regs-dsc-s3c24xx.h"
  25. #include "s3c2412-power.h"
  26. extern void s3c2412_sleep_enter(void);
  27. static int s3c2412_cpu_suspend(unsigned long arg)
  28. {
  29. unsigned long tmp;
  30. /* set our standby method to sleep */
  31. tmp = __raw_readl(S3C2412_PWRCFG);
  32. tmp |= S3C2412_PWRCFG_STANDBYWFI_SLEEP;
  33. __raw_writel(tmp, S3C2412_PWRCFG);
  34. s3c2412_sleep_enter();
  35. pr_info("Failed to suspend the system\n");
  36. return 1; /* Aborting suspend */
  37. }
  38. /* mapping of interrupts to parts of the wakeup mask */
  39. static const struct samsung_wakeup_mask wake_irqs[] = {
  40. { .irq = IRQ_RTC, .bit = S3C2412_PWRCFG_RTC_MASKIRQ, },
  41. };
  42. static void s3c2412_pm_prepare(void)
  43. {
  44. samsung_sync_wakemask(S3C2412_PWRCFG,
  45. wake_irqs, ARRAY_SIZE(wake_irqs));
  46. }
  47. static int s3c2412_pm_add(struct device *dev, struct subsys_interface *sif)
  48. {
  49. pm_cpu_prep = s3c2412_pm_prepare;
  50. pm_cpu_sleep = s3c2412_cpu_suspend;
  51. return 0;
  52. }
  53. static struct sleep_save s3c2412_sleep[] = {
  54. SAVE_ITEM(S3C2412_DSC0),
  55. SAVE_ITEM(S3C2412_DSC1),
  56. SAVE_ITEM(S3C2413_GPJDAT),
  57. SAVE_ITEM(S3C2413_GPJCON),
  58. SAVE_ITEM(S3C2413_GPJUP),
  59. /* save the PWRCFG to get back to original sleep method */
  60. SAVE_ITEM(S3C2412_PWRCFG),
  61. /* save the sleep configuration anyway, just in case these
  62. * get damaged during wakeup */
  63. SAVE_ITEM(S3C2412_GPBSLPCON),
  64. SAVE_ITEM(S3C2412_GPCSLPCON),
  65. SAVE_ITEM(S3C2412_GPDSLPCON),
  66. SAVE_ITEM(S3C2412_GPFSLPCON),
  67. SAVE_ITEM(S3C2412_GPGSLPCON),
  68. SAVE_ITEM(S3C2412_GPHSLPCON),
  69. SAVE_ITEM(S3C2413_GPJSLPCON),
  70. };
  71. static struct subsys_interface s3c2412_pm_interface = {
  72. .name = "s3c2412_pm",
  73. .subsys = &s3c2412_subsys,
  74. .add_dev = s3c2412_pm_add,
  75. };
  76. static __init int s3c2412_pm_init(void)
  77. {
  78. return subsys_interface_register(&s3c2412_pm_interface);
  79. }
  80. arch_initcall(s3c2412_pm_init);
  81. static int s3c2412_pm_suspend(void)
  82. {
  83. s3c_pm_do_save(s3c2412_sleep, ARRAY_SIZE(s3c2412_sleep));
  84. return 0;
  85. }
  86. static void s3c2412_pm_resume(void)
  87. {
  88. unsigned long tmp;
  89. tmp = __raw_readl(S3C2412_PWRCFG);
  90. tmp &= ~S3C2412_PWRCFG_STANDBYWFI_MASK;
  91. tmp |= S3C2412_PWRCFG_STANDBYWFI_IDLE;
  92. __raw_writel(tmp, S3C2412_PWRCFG);
  93. s3c_pm_do_restore(s3c2412_sleep, ARRAY_SIZE(s3c2412_sleep));
  94. }
  95. struct syscore_ops s3c2412_pm_syscore_ops = {
  96. .suspend = s3c2412_pm_suspend,
  97. .resume = s3c2412_pm_resume,
  98. };