pm.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /* linux/include/asm-arm/plat-s3c24xx/pm.h
  2. *
  3. * Copyright (c) 2004 Simtec Electronics
  4. * http://armlinux.simtec.co.uk/
  5. * Written by Ben Dooks, <ben@simtec.co.uk>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. /* s3c_pm_init
  12. *
  13. * called from board at initialisation time to setup the power
  14. * management
  15. */
  16. #ifdef CONFIG_PM
  17. extern __init int s3c_pm_init(void);
  18. #else
  19. static inline int s3c_pm_init(void)
  20. {
  21. return 0;
  22. }
  23. #endif
  24. /* configuration for the IRQ mask over sleep */
  25. extern unsigned long s3c_irqwake_intmask;
  26. extern unsigned long s3c_irqwake_eintmask;
  27. /* IRQ masks for IRQs allowed to go to sleep (see irq.c) */
  28. extern unsigned long s3c_irqwake_intallow;
  29. extern unsigned long s3c_irqwake_eintallow;
  30. /* per-cpu sleep functions */
  31. extern void (*pm_cpu_prep)(void);
  32. extern void (*pm_cpu_sleep)(void);
  33. /* Flags for PM Control */
  34. extern unsigned long s3c_pm_flags;
  35. extern unsigned char pm_uart_udivslot; /* true to save UART UDIVSLOT */
  36. /* from sleep.S */
  37. extern int s3c_cpu_save(unsigned long *saveblk);
  38. extern void s3c_cpu_resume(void);
  39. extern void s3c2410_cpu_suspend(void);
  40. extern unsigned long s3c_sleep_save_phys;
  41. /* sleep save info */
  42. /**
  43. * struct sleep_save - save information for shared peripherals.
  44. * @reg: Pointer to the register to save.
  45. * @val: Holder for the value saved from reg.
  46. *
  47. * This describes a list of registers which is used by the pm core and
  48. * other subsystem to save and restore register values over suspend.
  49. */
  50. struct sleep_save {
  51. void __iomem *reg;
  52. unsigned long val;
  53. };
  54. #define SAVE_ITEM(x) \
  55. { .reg = (x) }
  56. /**
  57. * struct pm_uart_save - save block for core UART
  58. * @ulcon: Save value for S3C2410_ULCON
  59. * @ucon: Save value for S3C2410_UCON
  60. * @ufcon: Save value for S3C2410_UFCON
  61. * @umcon: Save value for S3C2410_UMCON
  62. * @ubrdiv: Save value for S3C2410_UBRDIV
  63. *
  64. * Save block for UART registers to be held over sleep and restored if they
  65. * are needed (say by debug).
  66. */
  67. struct pm_uart_save {
  68. u32 ulcon;
  69. u32 ucon;
  70. u32 ufcon;
  71. u32 umcon;
  72. u32 ubrdiv;
  73. u32 udivslot;
  74. };
  75. /* helper functions to save/restore lists of registers. */
  76. extern void s3c_pm_do_save(struct sleep_save *ptr, int count);
  77. extern void s3c_pm_do_restore(struct sleep_save *ptr, int count);
  78. extern void s3c_pm_do_restore_core(struct sleep_save *ptr, int count);
  79. #ifdef CONFIG_PM
  80. extern int s3c_irqext_wake(unsigned int irqno, unsigned int state);
  81. extern int s3c24xx_irq_suspend(struct sys_device *dev, pm_message_t state);
  82. extern int s3c24xx_irq_resume(struct sys_device *dev);
  83. #else
  84. #define s3c_irqext_wake NULL
  85. #define s3c24xx_irq_suspend NULL
  86. #define s3c24xx_irq_resume NULL
  87. #endif
  88. /* PM debug functions */
  89. #ifdef CONFIG_S3C2410_PM_DEBUG
  90. /**
  91. * s3c_pm_dbg() - low level debug function for use in suspend/resume.
  92. * @msg: The message to print.
  93. *
  94. * This function is used mainly to debug the resume process before the system
  95. * can rely on printk/console output. It uses the low-level debugging output
  96. * routine printascii() to do its work.
  97. */
  98. extern void s3c_pm_dbg(const char *msg, ...);
  99. #define S3C_PMDBG(fmt...) s3c_pm_dbg(fmt)
  100. #else
  101. #define S3C_PMDBG(fmt...) printk(KERN_DEBUG fmt)
  102. #endif
  103. #ifdef CONFIG_S3C_PM_DEBUG_LED_SMDK
  104. /**
  105. * s3c_pm_debug_smdkled() - Debug PM suspend/resume via SMDK Board LEDs
  106. * @set: set bits for the state of the LEDs
  107. * @clear: clear bits for the state of the LEDs.
  108. */
  109. extern void s3c_pm_debug_smdkled(u32 set, u32 clear);
  110. #else
  111. static inline void s3c_pm_debug_smdkled(u32 set, u32 clear) { }
  112. #endif /* CONFIG_S3C_PM_DEBUG_LED_SMDK */
  113. /* suspend memory checking */
  114. #ifdef CONFIG_S3C2410_PM_CHECK
  115. extern void s3c_pm_check_prepare(void);
  116. extern void s3c_pm_check_restore(void);
  117. extern void s3c_pm_check_cleanup(void);
  118. extern void s3c_pm_check_store(void);
  119. #else
  120. #define s3c_pm_check_prepare() do { } while(0)
  121. #define s3c_pm_check_restore() do { } while(0)
  122. #define s3c_pm_check_cleanup() do { } while(0)
  123. #define s3c_pm_check_store() do { } while(0)
  124. #endif
  125. /**
  126. * s3c_pm_configure_extint() - ensure pins are correctly set for IRQ
  127. *
  128. * Setup all the necessary GPIO pins for waking the system on external
  129. * interrupt.
  130. */
  131. extern void s3c_pm_configure_extint(void);
  132. /**
  133. * s3c_pm_restore_gpios() - restore the state of the gpios after sleep.
  134. *
  135. * Restore the state of the GPIO pins after sleep, which may involve ensuring
  136. * that we do not glitch the state of the pins from that the bootloader's
  137. * resume code has done.
  138. */
  139. extern void s3c_pm_restore_gpios(void);
  140. /**
  141. * s3c_pm_save_gpios() - save the state of the GPIOs for restoring after sleep.
  142. *
  143. * Save the GPIO states for resotration on resume. See s3c_pm_restore_gpios().
  144. */
  145. extern void s3c_pm_save_gpios(void);
  146. /**
  147. * s3c_pm_cb_flushcache - callback for assembly code
  148. *
  149. * Callback to issue flush_cache_all() as this call is
  150. * not a directly callable object.
  151. */
  152. extern void s3c_pm_cb_flushcache(void);
  153. extern void s3c_pm_save_core(void);
  154. extern void s3c_pm_restore_core(void);