pm.h 5.0 KB

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