pm.h 5.0 KB

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