pm-s3c2416.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // SPDX-License-Identifier: GPL-2.0
  2. //
  3. // Copyright (c) 2010 Samsung Electronics Co., Ltd.
  4. // http://www.samsung.com
  5. //
  6. // S3C2416 - PM support (Based on Ben Dooks' S3C2412 PM support)
  7. #include <linux/device.h>
  8. #include <linux/syscore_ops.h>
  9. #include <linux/io.h>
  10. #include <asm/cacheflush.h>
  11. #include "regs-s3c2443-clock.h"
  12. #include "cpu.h"
  13. #include "pm.h"
  14. #include "s3c2412-power.h"
  15. #ifdef CONFIG_PM_SLEEP
  16. extern void s3c2412_sleep_enter(void);
  17. static int s3c2416_cpu_suspend(unsigned long arg)
  18. {
  19. /* enable wakeup sources regardless of battery state */
  20. __raw_writel(S3C2443_PWRCFG_SLEEP, S3C2443_PWRCFG);
  21. /* set the mode as sleep, 2BED represents "Go to BED" */
  22. __raw_writel(0x2BED, S3C2443_PWRMODE);
  23. s3c2412_sleep_enter();
  24. pr_info("Failed to suspend the system\n");
  25. return 1; /* Aborting suspend */
  26. }
  27. static void s3c2416_pm_prepare(void)
  28. {
  29. /*
  30. * write the magic value u-boot uses to check for resume into
  31. * the INFORM0 register, and ensure INFORM1 is set to the
  32. * correct address to resume from.
  33. */
  34. __raw_writel(0x2BED, S3C2412_INFORM0);
  35. __raw_writel(__pa_symbol(s3c_cpu_resume), S3C2412_INFORM1);
  36. }
  37. static int s3c2416_pm_add(struct device *dev, struct subsys_interface *sif)
  38. {
  39. pm_cpu_prep = s3c2416_pm_prepare;
  40. pm_cpu_sleep = s3c2416_cpu_suspend;
  41. return 0;
  42. }
  43. static struct subsys_interface s3c2416_pm_interface = {
  44. .name = "s3c2416_pm",
  45. .subsys = &s3c2416_subsys,
  46. .add_dev = s3c2416_pm_add,
  47. };
  48. static __init int s3c2416_pm_init(void)
  49. {
  50. return subsys_interface_register(&s3c2416_pm_interface);
  51. }
  52. arch_initcall(s3c2416_pm_init);
  53. #endif
  54. static void s3c2416_pm_resume(void)
  55. {
  56. /* unset the return-from-sleep amd inform flags */
  57. __raw_writel(0x0, S3C2443_PWRMODE);
  58. __raw_writel(0x0, S3C2412_INFORM0);
  59. __raw_writel(0x0, S3C2412_INFORM1);
  60. }
  61. struct syscore_ops s3c2416_pm_syscore_ops = {
  62. .resume = s3c2416_pm_resume,
  63. };