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