pm-core.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. #include <mach/regs-gpio.h>
  15. static inline void s3c_pm_debug_init_uart(void)
  16. {
  17. u32 tmp = __raw_readl(S3C_PCLK_GATE);
  18. /* As a note, since the S3C64XX UARTs generally have multiple
  19. * clock sources, we simply enable PCLK at the moment and hope
  20. * that the resume settings for the UART are suitable for the
  21. * use with PCLK.
  22. */
  23. tmp |= S3C_CLKCON_PCLK_UART0;
  24. tmp |= S3C_CLKCON_PCLK_UART1;
  25. tmp |= S3C_CLKCON_PCLK_UART2;
  26. tmp |= S3C_CLKCON_PCLK_UART3;
  27. __raw_writel(tmp, S3C_PCLK_GATE);
  28. udelay(10);
  29. }
  30. static inline void s3c_pm_arch_prepare_irqs(void)
  31. {
  32. /* VIC should have already been taken care of */
  33. /* clear any pending EINT0 interrupts */
  34. __raw_writel(__raw_readl(S3C64XX_EINT0PEND), S3C64XX_EINT0PEND);
  35. }
  36. static inline void s3c_pm_arch_stop_clocks(void)
  37. {
  38. }
  39. static inline void s3c_pm_arch_show_resume_irqs(void)
  40. {
  41. }
  42. /* make these defines, we currently do not have any need to change
  43. * the IRQ wake controls depending on the CPU we are running on */
  44. #define s3c_irqwake_eintallow ((1 << 28) - 1)
  45. #define s3c_irqwake_intallow (0)
  46. static inline void s3c_pm_arch_update_uart(void __iomem *regs,
  47. struct pm_uart_save *save)
  48. {
  49. u32 ucon = __raw_readl(regs + S3C2410_UCON);
  50. u32 ucon_clk = ucon & S3C6400_UCON_CLKMASK;
  51. u32 save_clk = save->ucon & S3C6400_UCON_CLKMASK;
  52. u32 new_ucon;
  53. u32 delta;
  54. /* S3C64XX UART blocks only support level interrupts, so ensure that
  55. * when we restore unused UART blocks we force the level interrupt
  56. * settigs. */
  57. save->ucon |= S3C2410_UCON_TXILEVEL | S3C2410_UCON_RXILEVEL;
  58. /* We have a constraint on changing the clock type of the UART
  59. * between UCLKx and PCLK, so ensure that when we restore UCON
  60. * that the CLK field is correctly modified if the bootloader
  61. * has changed anything.
  62. */
  63. if (ucon_clk != save_clk) {
  64. new_ucon = save->ucon;
  65. delta = ucon_clk ^ save_clk;
  66. /* change from UCLKx => wrong PCLK,
  67. * either UCLK can be tested for by a bit-test
  68. * with UCLK0 */
  69. if (ucon_clk & S3C6400_UCON_UCLK0 &&
  70. !(save_clk & S3C6400_UCON_UCLK0) &&
  71. delta & S3C6400_UCON_PCLK2) {
  72. new_ucon &= ~S3C6400_UCON_UCLK0;
  73. } else if (delta == S3C6400_UCON_PCLK2) {
  74. /* as an precaution, don't change from
  75. * PCLK2 => PCLK or vice-versa */
  76. new_ucon ^= S3C6400_UCON_PCLK2;
  77. }
  78. S3C_PMDBG("ucon change %04x => %04x (save=%04x)\n",
  79. ucon, new_ucon, save->ucon);
  80. save->ucon = new_ucon;
  81. }
  82. }