pm.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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/sysdev.h>
  13. #include <linux/io.h>
  14. #include <asm/cacheflush.h>
  15. #include <mach/regs-power.h>
  16. #include <mach/regs-s3c2443-clock.h>
  17. #include <plat/cpu.h>
  18. #include <plat/pm.h>
  19. extern void s3c2412_sleep_enter(void);
  20. static void s3c2416_cpu_suspend(void)
  21. {
  22. flush_cache_all();
  23. /* enable wakeup sources regardless of battery state */
  24. __raw_writel(S3C2443_PWRCFG_SLEEP, S3C2443_PWRCFG);
  25. /* set the mode as sleep, 2BED represents "Go to BED" */
  26. __raw_writel(0x2BED, S3C2443_PWRMODE);
  27. s3c2412_sleep_enter();
  28. }
  29. static void s3c2416_pm_prepare(void)
  30. {
  31. /*
  32. * write the magic value u-boot uses to check for resume into
  33. * the INFORM0 register, and ensure INFORM1 is set to the
  34. * correct address to resume from.
  35. */
  36. __raw_writel(0x2BED, S3C2412_INFORM0);
  37. __raw_writel(virt_to_phys(s3c_cpu_resume), S3C2412_INFORM1);
  38. }
  39. static int s3c2416_pm_add(struct sys_device *sysdev)
  40. {
  41. pm_cpu_prep = s3c2416_pm_prepare;
  42. pm_cpu_sleep = s3c2416_cpu_suspend;
  43. return 0;
  44. }
  45. static int s3c2416_pm_suspend(struct sys_device *dev, pm_message_t state)
  46. {
  47. return 0;
  48. }
  49. static int s3c2416_pm_resume(struct sys_device *dev)
  50. {
  51. /* unset the return-from-sleep amd inform flags */
  52. __raw_writel(0x0, S3C2443_PWRMODE);
  53. __raw_writel(0x0, S3C2412_INFORM0);
  54. __raw_writel(0x0, S3C2412_INFORM1);
  55. return 0;
  56. }
  57. static struct sysdev_driver s3c2416_pm_driver = {
  58. .add = s3c2416_pm_add,
  59. .suspend = s3c2416_pm_suspend,
  60. .resume = s3c2416_pm_resume,
  61. };
  62. static __init int s3c2416_pm_init(void)
  63. {
  64. return sysdev_driver_register(&s3c2416_sysclass, &s3c2416_pm_driver);
  65. }
  66. arch_initcall(s3c2416_pm_init);