pm-s3c2410.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. /* linux/arch/arm/mach-s3c2410/pm.c
  2. *
  3. * Copyright (c) 2006 Simtec Electronics
  4. * Ben Dooks <ben@simtec.co.uk>
  5. *
  6. * S3C2410 (and compatible) Power Manager (Suspend-To-RAM) 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 as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. */
  22. #include <linux/init.h>
  23. #include <linux/suspend.h>
  24. #include <linux/errno.h>
  25. #include <linux/time.h>
  26. #include <linux/device.h>
  27. #include <linux/syscore_ops.h>
  28. #include <linux/gpio.h>
  29. #include <linux/io.h>
  30. #include <asm/mach-types.h>
  31. #include <mach/hardware.h>
  32. #include <mach/regs-gpio.h>
  33. #include <mach/gpio-samsung.h>
  34. #include <plat/gpio-cfg.h>
  35. #include <plat/cpu.h>
  36. #include <plat/pm.h>
  37. #include "h1940.h"
  38. static void s3c2410_pm_prepare(void)
  39. {
  40. /* ensure at least GSTATUS3 has the resume address */
  41. __raw_writel(virt_to_phys(s3c_cpu_resume), S3C2410_GSTATUS3);
  42. S3C_PMDBG("GSTATUS3 0x%08x\n", __raw_readl(S3C2410_GSTATUS3));
  43. S3C_PMDBG("GSTATUS4 0x%08x\n", __raw_readl(S3C2410_GSTATUS4));
  44. if (machine_is_h1940()) {
  45. void *base = phys_to_virt(H1940_SUSPEND_CHECK);
  46. unsigned long ptr;
  47. unsigned long calc = 0;
  48. /* generate check for the bootloader to check on resume */
  49. for (ptr = 0; ptr < 0x40000; ptr += 0x400)
  50. calc += __raw_readl(base+ptr);
  51. __raw_writel(calc, phys_to_virt(H1940_SUSPEND_CHECKSUM));
  52. }
  53. /* RX3715 and RX1950 use similar to H1940 code and the
  54. * same offsets for resume and checksum pointers */
  55. if (machine_is_rx3715() || machine_is_rx1950()) {
  56. void *base = phys_to_virt(H1940_SUSPEND_CHECK);
  57. unsigned long ptr;
  58. unsigned long calc = 0;
  59. /* generate check for the bootloader to check on resume */
  60. for (ptr = 0; ptr < 0x40000; ptr += 0x4)
  61. calc += __raw_readl(base+ptr);
  62. __raw_writel(calc, phys_to_virt(H1940_SUSPEND_CHECKSUM));
  63. }
  64. if (machine_is_aml_m5900()) {
  65. gpio_request_one(S3C2410_GPF(2), GPIOF_OUT_INIT_HIGH, NULL);
  66. gpio_free(S3C2410_GPF(2));
  67. }
  68. if (machine_is_rx1950()) {
  69. /* According to S3C2442 user's manual, page 7-17,
  70. * when the system is operating in NAND boot mode,
  71. * the hardware pin configuration - EINT[23:21] –
  72. * must be set as input for starting up after
  73. * wakeup from sleep mode
  74. */
  75. s3c_gpio_cfgpin(S3C2410_GPG(13), S3C2410_GPIO_INPUT);
  76. s3c_gpio_cfgpin(S3C2410_GPG(14), S3C2410_GPIO_INPUT);
  77. s3c_gpio_cfgpin(S3C2410_GPG(15), S3C2410_GPIO_INPUT);
  78. }
  79. }
  80. static void s3c2410_pm_resume(void)
  81. {
  82. unsigned long tmp;
  83. /* unset the return-from-sleep flag, to ensure reset */
  84. tmp = __raw_readl(S3C2410_GSTATUS2);
  85. tmp &= S3C2410_GSTATUS2_OFFRESET;
  86. __raw_writel(tmp, S3C2410_GSTATUS2);
  87. if (machine_is_aml_m5900()) {
  88. gpio_request_one(S3C2410_GPF(2), GPIOF_OUT_INIT_LOW, NULL);
  89. gpio_free(S3C2410_GPF(2));
  90. }
  91. }
  92. struct syscore_ops s3c2410_pm_syscore_ops = {
  93. .resume = s3c2410_pm_resume,
  94. };
  95. static int s3c2410_pm_add(struct device *dev, struct subsys_interface *sif)
  96. {
  97. pm_cpu_prep = s3c2410_pm_prepare;
  98. pm_cpu_sleep = s3c2410_cpu_suspend;
  99. return 0;
  100. }
  101. #if defined(CONFIG_CPU_S3C2410)
  102. static struct subsys_interface s3c2410_pm_interface = {
  103. .name = "s3c2410_pm",
  104. .subsys = &s3c2410_subsys,
  105. .add_dev = s3c2410_pm_add,
  106. };
  107. /* register ourselves */
  108. static int __init s3c2410_pm_drvinit(void)
  109. {
  110. return subsys_interface_register(&s3c2410_pm_interface);
  111. }
  112. arch_initcall(s3c2410_pm_drvinit);
  113. static struct subsys_interface s3c2410a_pm_interface = {
  114. .name = "s3c2410a_pm",
  115. .subsys = &s3c2410a_subsys,
  116. .add_dev = s3c2410_pm_add,
  117. };
  118. static int __init s3c2410a_pm_drvinit(void)
  119. {
  120. return subsys_interface_register(&s3c2410a_pm_interface);
  121. }
  122. arch_initcall(s3c2410a_pm_drvinit);
  123. #endif
  124. #if defined(CONFIG_CPU_S3C2440)
  125. static struct subsys_interface s3c2440_pm_interface = {
  126. .name = "s3c2440_pm",
  127. .subsys = &s3c2440_subsys,
  128. .add_dev = s3c2410_pm_add,
  129. };
  130. static int __init s3c2440_pm_drvinit(void)
  131. {
  132. return subsys_interface_register(&s3c2440_pm_interface);
  133. }
  134. arch_initcall(s3c2440_pm_drvinit);
  135. #endif
  136. #if defined(CONFIG_CPU_S3C2442)
  137. static struct subsys_interface s3c2442_pm_interface = {
  138. .name = "s3c2442_pm",
  139. .subsys = &s3c2442_subsys,
  140. .add_dev = s3c2410_pm_add,
  141. };
  142. static int __init s3c2442_pm_drvinit(void)
  143. {
  144. return subsys_interface_register(&s3c2442_pm_interface);
  145. }
  146. arch_initcall(s3c2442_pm_drvinit);
  147. #endif