pm-s3c2412.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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/device.h>
  19. #include <linux/syscore_ops.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/io.h>
  22. #include <asm/cacheflush.h>
  23. #include <asm/irq.h>
  24. #include <mach/hardware.h>
  25. #include <mach/regs-gpio.h>
  26. #include <plat/cpu.h>
  27. #include <plat/pm.h>
  28. #include <plat/wakeup-mask.h>
  29. #include "regs-dsc.h"
  30. #include "s3c2412-power.h"
  31. extern void s3c2412_sleep_enter(void);
  32. static int s3c2412_cpu_suspend(unsigned long arg)
  33. {
  34. unsigned long tmp;
  35. /* set our standby method to sleep */
  36. tmp = __raw_readl(S3C2412_PWRCFG);
  37. tmp |= S3C2412_PWRCFG_STANDBYWFI_SLEEP;
  38. __raw_writel(tmp, S3C2412_PWRCFG);
  39. s3c2412_sleep_enter();
  40. pr_info("Failed to suspend the system\n");
  41. return 1; /* Aborting suspend */
  42. }
  43. /* mapping of interrupts to parts of the wakeup mask */
  44. static struct samsung_wakeup_mask wake_irqs[] = {
  45. { .irq = IRQ_RTC, .bit = S3C2412_PWRCFG_RTC_MASKIRQ, },
  46. };
  47. static void s3c2412_pm_prepare(void)
  48. {
  49. samsung_sync_wakemask(S3C2412_PWRCFG,
  50. wake_irqs, ARRAY_SIZE(wake_irqs));
  51. }
  52. static int s3c2412_pm_add(struct device *dev, struct subsys_interface *sif)
  53. {
  54. pm_cpu_prep = s3c2412_pm_prepare;
  55. pm_cpu_sleep = s3c2412_cpu_suspend;
  56. return 0;
  57. }
  58. static struct sleep_save s3c2412_sleep[] = {
  59. SAVE_ITEM(S3C2412_DSC0),
  60. SAVE_ITEM(S3C2412_DSC1),
  61. SAVE_ITEM(S3C2413_GPJDAT),
  62. SAVE_ITEM(S3C2413_GPJCON),
  63. SAVE_ITEM(S3C2413_GPJUP),
  64. /* save the PWRCFG to get back to original sleep method */
  65. SAVE_ITEM(S3C2412_PWRCFG),
  66. /* save the sleep configuration anyway, just in case these
  67. * get damaged during wakeup */
  68. SAVE_ITEM(S3C2412_GPBSLPCON),
  69. SAVE_ITEM(S3C2412_GPCSLPCON),
  70. SAVE_ITEM(S3C2412_GPDSLPCON),
  71. SAVE_ITEM(S3C2412_GPFSLPCON),
  72. SAVE_ITEM(S3C2412_GPGSLPCON),
  73. SAVE_ITEM(S3C2412_GPHSLPCON),
  74. SAVE_ITEM(S3C2413_GPJSLPCON),
  75. };
  76. static struct subsys_interface s3c2412_pm_interface = {
  77. .name = "s3c2412_pm",
  78. .subsys = &s3c2412_subsys,
  79. .add_dev = s3c2412_pm_add,
  80. };
  81. static __init int s3c2412_pm_init(void)
  82. {
  83. return subsys_interface_register(&s3c2412_pm_interface);
  84. }
  85. arch_initcall(s3c2412_pm_init);
  86. static int s3c2412_pm_suspend(void)
  87. {
  88. s3c_pm_do_save(s3c2412_sleep, ARRAY_SIZE(s3c2412_sleep));
  89. return 0;
  90. }
  91. static void s3c2412_pm_resume(void)
  92. {
  93. unsigned long tmp;
  94. tmp = __raw_readl(S3C2412_PWRCFG);
  95. tmp &= ~S3C2412_PWRCFG_STANDBYWFI_MASK;
  96. tmp |= S3C2412_PWRCFG_STANDBYWFI_IDLE;
  97. __raw_writel(tmp, S3C2412_PWRCFG);
  98. s3c_pm_do_restore(s3c2412_sleep, ARRAY_SIZE(s3c2412_sleep));
  99. }
  100. struct syscore_ops s3c2412_pm_syscore_ops = {
  101. .suspend = s3c2412_pm_suspend,
  102. .resume = s3c2412_pm_resume,
  103. };