pm-common.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * Copyright (C) 2013 Samsung Electronics Co., Ltd.
  3. * Tomasz Figa <t.figa@samsung.com>
  4. * Copyright (c) 2004 Simtec Electronics
  5. * http://armlinux.simtec.co.uk/
  6. * Written by Ben Dooks, <ben@simtec.co.uk>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #ifndef __PLAT_SAMSUNG_PM_COMMON_H
  13. #define __PLAT_SAMSUNG_PM_COMMON_H __FILE__
  14. #include <linux/irq.h>
  15. /* sleep save info */
  16. /**
  17. * struct sleep_save - save information for shared peripherals.
  18. * @reg: Pointer to the register to save.
  19. * @val: Holder for the value saved from reg.
  20. *
  21. * This describes a list of registers which is used by the pm core and
  22. * other subsystem to save and restore register values over suspend.
  23. */
  24. struct sleep_save {
  25. void __iomem *reg;
  26. unsigned long val;
  27. };
  28. #define SAVE_ITEM(x) \
  29. { .reg = (x) }
  30. /* helper functions to save/restore lists of registers. */
  31. extern void s3c_pm_do_save(struct sleep_save *ptr, int count);
  32. extern void s3c_pm_do_restore(const struct sleep_save *ptr, int count);
  33. extern void s3c_pm_do_restore_core(const struct sleep_save *ptr, int count);
  34. /* PM debug functions */
  35. /**
  36. * struct pm_uart_save - save block for core UART
  37. * @ulcon: Save value for S3C2410_ULCON
  38. * @ucon: Save value for S3C2410_UCON
  39. * @ufcon: Save value for S3C2410_UFCON
  40. * @umcon: Save value for S3C2410_UMCON
  41. * @ubrdiv: Save value for S3C2410_UBRDIV
  42. *
  43. * Save block for UART registers to be held over sleep and restored if they
  44. * are needed (say by debug).
  45. */
  46. struct pm_uart_save {
  47. u32 ulcon;
  48. u32 ucon;
  49. u32 ufcon;
  50. u32 umcon;
  51. u32 ubrdiv;
  52. u32 udivslot;
  53. };
  54. #ifdef CONFIG_SAMSUNG_PM_DEBUG
  55. /**
  56. * s3c_pm_dbg() - low level debug function for use in suspend/resume.
  57. * @msg: The message to print.
  58. *
  59. * This function is used mainly to debug the resume process before the system
  60. * can rely on printk/console output. It uses the low-level debugging output
  61. * routine printascii() to do its work.
  62. */
  63. extern void s3c_pm_dbg(const char *msg, ...);
  64. /**
  65. * s3c_pm_debug_init() - suspend/resume low level debug initialization.
  66. * @base: Virtual base of UART to use for suspend/resume debugging.
  67. *
  68. * This function needs to be called before S3C_PMDBG() can be used, to set up
  69. * UART port base address and configuration.
  70. */
  71. extern void s3c_pm_debug_init(void);
  72. #define S3C_PMDBG(fmt...) s3c_pm_dbg(fmt)
  73. extern void s3c_pm_save_uarts(void);
  74. extern void s3c_pm_restore_uarts(void);
  75. #else
  76. #define S3C_PMDBG(fmt...) pr_debug(fmt)
  77. #define s3c_pm_debug_init() do { } while (0)
  78. static inline void s3c_pm_save_uarts(void) { }
  79. static inline void s3c_pm_restore_uarts(void) { }
  80. #endif
  81. /* suspend memory checking */
  82. #ifdef CONFIG_SAMSUNG_PM_CHECK
  83. extern void s3c_pm_check_prepare(void);
  84. extern void s3c_pm_check_restore(void);
  85. extern void s3c_pm_check_cleanup(void);
  86. extern void s3c_pm_check_store(void);
  87. #else
  88. #define s3c_pm_check_prepare() do { } while (0)
  89. #define s3c_pm_check_restore() do { } while (0)
  90. #define s3c_pm_check_cleanup() do { } while (0)
  91. #define s3c_pm_check_store() do { } while (0)
  92. #endif
  93. #endif