pm-s3c2416.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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-power.h>
  17. #include <mach/regs-s3c2443-clock.h>
  18. #include <plat/cpu.h>
  19. #include <plat/pm.h>
  20. extern void s3c2412_sleep_enter(void);
  21. static int s3c2416_cpu_suspend(unsigned long arg)
  22. {
  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. panic("sleep resumed to originator?");
  29. }
  30. static void s3c2416_pm_prepare(void)
  31. {
  32. /*
  33. * write the magic value u-boot uses to check for resume into
  34. * the INFORM0 register, and ensure INFORM1 is set to the
  35. * correct address to resume from.
  36. */
  37. __raw_writel(0x2BED, S3C2412_INFORM0);
  38. __raw_writel(virt_to_phys(s3c_cpu_resume), S3C2412_INFORM1);
  39. }
  40. static int s3c2416_pm_add(struct device *dev, struct subsys_interface *sif)
  41. {
  42. pm_cpu_prep = s3c2416_pm_prepare;
  43. pm_cpu_sleep = s3c2416_cpu_suspend;
  44. return 0;
  45. }
  46. static struct subsys_interface s3c2416_pm_interface = {
  47. .name = "s3c2416_pm",
  48. .subsys = &s3c2416_subsys,
  49. .add_dev = s3c2416_pm_add,
  50. };
  51. static __init int s3c2416_pm_init(void)
  52. {
  53. return subsys_interface_register(&s3c2416_pm_interface);
  54. }
  55. arch_initcall(s3c2416_pm_init);
  56. static void s3c2416_pm_resume(void)
  57. {
  58. /* unset the return-from-sleep amd inform flags */
  59. __raw_writel(0x0, S3C2443_PWRMODE);
  60. __raw_writel(0x0, S3C2412_INFORM0);
  61. __raw_writel(0x0, S3C2412_INFORM1);
  62. }
  63. struct syscore_ops s3c2416_pm_syscore_ops = {
  64. .resume = s3c2416_pm_resume,
  65. };