pm-core.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /* linux/arch/arm/mach-s3c64xx/include/mach/pm-core.h
  2. *
  3. * Copyright 2008 Openmoko, Inc.
  4. * Copyright 2008 Simtec Electronics
  5. * Ben Dooks <ben@simtec.co.uk>
  6. * http://armlinux.simtec.co.uk/
  7. *
  8. * S3C64XX - PM core support for arch/arm/plat-s3c/pm.c
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. */
  14. #ifndef __MACH_S3C64XX_PM_CORE_H
  15. #define __MACH_S3C64XX_PM_CORE_H __FILE__
  16. #include <linux/serial_s3c.h>
  17. #include <linux/delay.h>
  18. #include <mach/regs-gpio.h>
  19. #include <mach/regs-clock.h>
  20. #include <mach/map.h>
  21. static inline void s3c_pm_debug_init_uart(void)
  22. {
  23. u32 tmp = __raw_readl(S3C_PCLK_GATE);
  24. /* As a note, since the S3C64XX UARTs generally have multiple
  25. * clock sources, we simply enable PCLK at the moment and hope
  26. * that the resume settings for the UART are suitable for the
  27. * use with PCLK.
  28. */
  29. tmp |= S3C_CLKCON_PCLK_UART0;
  30. tmp |= S3C_CLKCON_PCLK_UART1;
  31. tmp |= S3C_CLKCON_PCLK_UART2;
  32. tmp |= S3C_CLKCON_PCLK_UART3;
  33. __raw_writel(tmp, S3C_PCLK_GATE);
  34. udelay(10);
  35. }
  36. static inline void s3c_pm_arch_prepare_irqs(void)
  37. {
  38. /* VIC should have already been taken care of */
  39. /* clear any pending EINT0 interrupts */
  40. __raw_writel(__raw_readl(S3C64XX_EINT0PEND), S3C64XX_EINT0PEND);
  41. }
  42. static inline void s3c_pm_arch_stop_clocks(void)
  43. {
  44. }
  45. static inline void s3c_pm_arch_show_resume_irqs(void)
  46. {
  47. }
  48. /* make these defines, we currently do not have any need to change
  49. * the IRQ wake controls depending on the CPU we are running on */
  50. #ifdef CONFIG_PM_SLEEP
  51. #define s3c_irqwake_eintallow ((1 << 28) - 1)
  52. #define s3c_irqwake_intallow (~0)
  53. #else
  54. #define s3c_irqwake_eintallow 0
  55. #define s3c_irqwake_intallow 0
  56. #endif
  57. static inline void s3c_pm_arch_update_uart(void __iomem *regs,
  58. struct pm_uart_save *save)
  59. {
  60. u32 ucon = __raw_readl(regs + S3C2410_UCON);
  61. u32 ucon_clk = ucon & S3C6400_UCON_CLKMASK;
  62. u32 save_clk = save->ucon & S3C6400_UCON_CLKMASK;
  63. u32 new_ucon;
  64. u32 delta;
  65. /* S3C64XX UART blocks only support level interrupts, so ensure that
  66. * when we restore unused UART blocks we force the level interrupt
  67. * settigs. */
  68. save->ucon |= S3C2410_UCON_TXILEVEL | S3C2410_UCON_RXILEVEL;
  69. /* We have a constraint on changing the clock type of the UART
  70. * between UCLKx and PCLK, so ensure that when we restore UCON
  71. * that the CLK field is correctly modified if the bootloader
  72. * has changed anything.
  73. */
  74. if (ucon_clk != save_clk) {
  75. new_ucon = save->ucon;
  76. delta = ucon_clk ^ save_clk;
  77. /* change from UCLKx => wrong PCLK,
  78. * either UCLK can be tested for by a bit-test
  79. * with UCLK0 */
  80. if (ucon_clk & S3C6400_UCON_UCLK0 &&
  81. !(save_clk & S3C6400_UCON_UCLK0) &&
  82. delta & S3C6400_UCON_PCLK2) {
  83. new_ucon &= ~S3C6400_UCON_UCLK0;
  84. } else if (delta == S3C6400_UCON_PCLK2) {
  85. /* as an precaution, don't change from
  86. * PCLK2 => PCLK or vice-versa */
  87. new_ucon ^= S3C6400_UCON_PCLK2;
  88. }
  89. S3C_PMDBG("ucon change %04x => %04x (save=%04x)\n",
  90. ucon, new_ucon, save->ucon);
  91. save->ucon = new_ucon;
  92. }
  93. }
  94. static inline void s3c_pm_restored_gpios(void)
  95. {
  96. /* ensure sleep mode has been cleared from the system */
  97. __raw_writel(0, S3C64XX_SLPEN);
  98. }
  99. static inline void samsung_pm_saved_gpios(void)
  100. {
  101. /* turn on the sleep mode and keep it there, as it seems that during
  102. * suspend the xCON registers get re-set and thus you can end up with
  103. * problems between going to sleep and resuming.
  104. */
  105. __raw_writel(S3C64XX_SLPEN_USE_xSLP, S3C64XX_SLPEN);
  106. }
  107. #endif /* __MACH_S3C64XX_PM_CORE_H */