pm-s3c2416.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /* linux/arch/arm/mach-s3c2416/pm.c
  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. *
  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/device.h>
  13. #include <linux/syscore_ops.h>
  14. #include <linux/io.h>
  15. #include <asm/cacheflush.h>
  16. #include <mach/regs-s3c2443-clock.h>
  17. #include <plat/cpu.h>
  18. #include <plat/pm.h>
  19. #include "s3c2412-power.h"
  20. #ifdef CONFIG_PM_SLEEP
  21. extern void s3c2412_sleep_enter(void);
  22. static int s3c2416_cpu_suspend(unsigned long arg)
  23. {
  24. /* enable wakeup sources regardless of battery state */
  25. __raw_writel(S3C2443_PWRCFG_SLEEP, S3C2443_PWRCFG);
  26. /* set the mode as sleep, 2BED represents "Go to BED" */
  27. __raw_writel(0x2BED, S3C2443_PWRMODE);
  28. s3c2412_sleep_enter();
  29. pr_info("Failed to suspend the system\n");
  30. return 1; /* Aborting suspend */
  31. }
  32. static void s3c2416_pm_prepare(void)
  33. {
  34. /*
  35. * write the magic value u-boot uses to check for resume into
  36. * the INFORM0 register, and ensure INFORM1 is set to the
  37. * correct address to resume from.
  38. */
  39. __raw_writel(0x2BED, S3C2412_INFORM0);
  40. __raw_writel(virt_to_phys(s3c_cpu_resume), S3C2412_INFORM1);
  41. }
  42. static int s3c2416_pm_add(struct device *dev, struct subsys_interface *sif)
  43. {
  44. pm_cpu_prep = s3c2416_pm_prepare;
  45. pm_cpu_sleep = s3c2416_cpu_suspend;
  46. return 0;
  47. }
  48. static struct subsys_interface s3c2416_pm_interface = {
  49. .name = "s3c2416_pm",
  50. .subsys = &s3c2416_subsys,
  51. .add_dev = s3c2416_pm_add,
  52. };
  53. static __init int s3c2416_pm_init(void)
  54. {
  55. return subsys_interface_register(&s3c2416_pm_interface);
  56. }
  57. arch_initcall(s3c2416_pm_init);
  58. #endif
  59. static void s3c2416_pm_resume(void)
  60. {
  61. /* unset the return-from-sleep amd inform flags */
  62. __raw_writel(0x0, S3C2443_PWRMODE);
  63. __raw_writel(0x0, S3C2412_INFORM0);
  64. __raw_writel(0x0, S3C2412_INFORM1);
  65. }
  66. struct syscore_ops s3c2416_pm_syscore_ops = {
  67. .resume = s3c2416_pm_resume,
  68. };